void StartServers() { server.listen(80); server.addPath("/", onIndex); server.setDefaultHandler(onFile); // Web Sockets configuration server.enableWebSockets(true); server.commandProcessing(true,"command"); server.setWebSocketConnectionHandler(wsConnected); server.setWebSocketMessageHandler(wsMessageReceived); server.setWebSocketBinaryHandler(wsBinaryReceived); server.setWebSocketDisconnectionHandler(wsDisconnected); Serial.println("\r\n=== WEB SERVER STARTED ==="); Serial.println(WifiStation.getIP()); Serial.println("==============================\r\n"); // Start FTP server ftp.listen(21); ftp.addUser("me", "123"); // FTP account Serial.println("\r\n=== FTP SERVER STARTED ==="); Serial.println("==============================\r\n"); telnet.listen(23); telnet.enableDebug(true); Serial.println("\r\n=== TelnetServer SERVER STARTED ==="); Serial.println("==============================\r\n"); }
/** * Start a new thread for an interactive terminal with a client. * Close the data socket once terminated. */ void * TelnetServer::threadFunction(void * threadArg) { struct threadArgStruct * params = (struct threadArgStruct *)threadArg; TelnetServer* obj = (TelnetServer*) params->objectPtr; int dataSocket = (int) params->dataSocket; obj->startTelnetTerminal(dataSocket); }
int main( int argc, char *argv[] ) { TelnetServer server; DefaultHandler handler; server.start( 2000 ); server.setPromt( "> " ); server.setDefaultHandler( &handler ); while( 1 ) { sleep( 10 ); } return 0; }
/* * start http and telnet server * telnet can be used to configure cammera settings * unsing ArdCammCommand handler */ void StartServers() { server.listen(80); server.addPath("/", onIndex); server.addPath("/cam/set", onCamSetup); server.addPath("/cam/capture", onCapture); // server.addPath("/stream", onStream); server.addPath("/favicon.ico", onFavicon); server.setDefaultHandler(onFile); Serial.println("\r\n=== WEB SERVER STARTED ==="); Serial.println(WifiStation.getIP()); Serial.println("==============================\r\n"); telnet.listen(23); telnet.enableDebug(true); Serial.println("\r\n=== TelnetServer SERVER STARTED ==="); Serial.println("==============================\r\n"); }
void startServers() { tcpServer.listen(8023); Serial.println("\r\n=== TCP SERVER Port 8023 STARTED ==="); Serial.println(WifiStation.getIP()); Serial.println("==============================\r\n"); telnetServer.listen(23); Serial.println("\r\n=== Telnet SERVER Port 23 STARTED ==="); Serial.println(WifiStation.getIP()); Serial.println("==============================\r\n"); commandHandler.registerCommand(CommandDelegate("application","This command is defined by the application\r\n","testGroup", applicationCommand)); }
void init() { Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.systemDebugOutput(true); // Enable debug output to serial Serial.commandProcessing(true); WifiStation.enable(true); WifiStation.config(WIFI_SSID, WIFI_PWD); WifiAccessPoint.enable(false); // Run our method when station was connected to AP WifiStation.waitConnection(connectOk, 30, connectFail); Debug.setDebug(Serial); Debug.initCommand(); Debug.start(); Debug.printf("This is the debug output\r\n"); telnetServer.setDebug(true);/* is default but here to show possibility */ commandHandler.registerCommand(CommandDelegate("appheap","Usage appheap on/off/now for heapdisplay\r\n","testGroup", appheapCommand)); memoryTimer.initializeMs(250,checkHeap).start(); }
// Will be called when WiFi station was connected to AP void connectOk() { NtpSming = new ntpClientSming(); Serial.println("I'm CONNECTED"); Serial.print("My IP: "); Serial.println(WifiStation.getIP().toString()); Serial.print("My gate: "); Serial.println(WifiStation.getNetworkGateway().toString()); telnetServer.listen(23); commandHandler.registerCommand(CommandDelegate("info","Info from ESP via Telnet\r\n","testGroup", EspInfoCommand)); commandHandler.registerCommand(CommandDelegate("reset","Software reset via Telnet\r\n","testGroup", ResetCommand)); test_spiffs(); // Start send data loop procTimer.initializeMs(60 * 1000, sendData).start(true); // every 60 seconds resetTimer.initializeMs(240 * 1000, resetData).start(true); // every 240 seconds if errors }