|
@@ -26,17 +26,10 @@ void connectOk();
|
|
|
void connectFail();
|
|
|
void showTime();
|
|
|
|
|
|
-// UDP server
|
|
|
-void onReceive(UdpConnection& connection, char *data, int size, IPAddress remoteIP, uint16_t remotePort); // Declaration
|
|
|
-const uint16_t EchoPort = 777;
|
|
|
-UdpConnection udp(onReceive);
|
|
|
-
|
|
|
// NTP Client
|
|
|
void onNtpReceive(NtpClient& client, time_t timestamp);
|
|
|
NtpClient ntpClient ("ntps1-0.cs.tu-berlin.de", 300, onNtpReceive);
|
|
|
|
|
|
-// FTP Server;
|
|
|
-FTPServer ftp;
|
|
|
|
|
|
void init()
|
|
|
{
|
|
@@ -190,16 +183,6 @@ void process()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void startFTP()
|
|
|
-{
|
|
|
- // Start FTP server
|
|
|
- ftp.listen(21);
|
|
|
- ftp.addUser("user", "resu"); // FTP account
|
|
|
- // You can also use special FTP comand: "fsformat" for clearing file system (for example from TotalCMD)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
void connectOk()
|
|
|
{
|
|
|
WifiAccessPoint.enable(false);
|
|
@@ -207,10 +190,6 @@ void connectOk()
|
|
|
Serial.println(WifiStation.getIP().toString());
|
|
|
|
|
|
startWebServer();
|
|
|
-
|
|
|
- startFTP();
|
|
|
-
|
|
|
- udp.listen(EchoPort);
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -239,27 +218,3 @@ void onNtpReceive(NtpClient& client, time_t timestamp) {
|
|
|
NTPLastUpdate = SystemClock.now();
|
|
|
Serial.println("*** Time synchronized OK! ***"); // DEBUG
|
|
|
}
|
|
|
-
|
|
|
-/*
|
|
|
- * UDP Server
|
|
|
- */
|
|
|
-void onReceive(UdpConnection& connection, char *data, int size, IPAddress remoteIP, uint16_t remotePort)
|
|
|
-{
|
|
|
- debugf("UDP Sever callback from %s:%d, %d bytes", remoteIP.toString().c_str(), remotePort, size);
|
|
|
-
|
|
|
- // We implement string mode server for example
|
|
|
- Serial.print(">\t");
|
|
|
- Serial.print(data);
|
|
|
-
|
|
|
- if (data == "get_sensors")
|
|
|
- {
|
|
|
- String text = String("Temperature: ") + String(SensorT, 2) + String("\rHumidity: ") + String(SensorH, 2) + String("\r");
|
|
|
- udp.sendStringTo(remoteIP, EchoPort, text);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- // Send echo to remote sender
|
|
|
- String text = String("echo: ") + data;
|
|
|
- udp.sendStringTo(remoteIP, EchoPort, text);
|
|
|
- }
|
|
|
-}
|