![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
websocket
Dependencies: ESP8266Interface2 WebSocketClient mbed-dev mbed
Fork of ESP8266_WebSockets_HelloWorld by
main.cpp
00001 #include "mbed.h" 00002 #include "ESP8266Interface.h" 00003 #include "TCPSocketConnection.h" 00004 #include "TCPSocketServer.h" 00005 #include "Websocket.h" 00006 00007 00008 00009 ESP8266Interface wifi(PTD3,PTD2,PTD11,"demossid","password",115200); // TX,RX,Reset,SSID,Password,Baud 00010 00011 int main() { 00012 wifi.init(); //Reset 00013 wifi.connect(); //Use DHCP 00014 printf("IP Address is %s\n", wifi.getIPAddress()); 00015 00016 Websocket ws("ws://192.168.1.20:8888/ws"); 00017 00018 //Check for successful socket connection 00019 if(!ws.connect()) 00020 ws.close(); 00021 else{ 00022 char str[100]; 00023 00024 for(int i=0; i<0x7fffffff; ++i) { 00025 // string with a message 00026 sprintf(str, "%d WebSocket Hello World over wifi", i); 00027 printf("send: %s\n",str); 00028 ws.send(str); 00029 00030 // clear the buffer and wait a sec... 00031 memset(str, 0, 100); 00032 //wait(0.5f); 00033 00034 // websocket server should echo whatever we sent it 00035 if (ws.read(str)) { 00036 printf("rcv'd: %s\n", str); 00037 } 00038 } 00039 } 00040 ws.close(); 00041 00042 while(true) {} 00043 } 00044
Generated on Fri Aug 12 2022 06:49:37 by
![doxygen](doxygen.png)