Changeset 179 for rtos_arduino/trunk
- Timestamp:
- Mar 28, 2016, 2:24:53 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
rtos_arduino/trunk/examples/WifiEcho/rca_app.cpp
r146 r179 1 1 #include "rca.h" 2 2 3 #define SSID "" 4 #define PASSWORD "" 3 //#define SSID "0024_MYNET" 4 //#define PASSWORD "yf-19_yf-21_plus" 5 6 //#define SSID "RX501NC_0B8C" 7 //#define PASSWORD "50229567" 8 9 #define SSID "ERTL_GLOBAL" 10 #define PASSWORD "ertl__toppers" 5 11 6 12 #define AP_SSID "M0_AP" 7 13 #define AP_PASSWORD "none" 14 15 #define WMODE_STATION 8 16 9 17 #include "ESP8266.h" … … 13 21 void setup() 14 22 { 23 int ret; 24 15 25 Serial.println("Web Server Task : Start!"); 16 26 17 wifi.begin(Serial5, 115200); 18 27 ret = wifi.begin(Serial5, 115200); 28 29 if(ret == 1) { 30 Serial.print("Cannot communicate with ESP8266."); 31 while(1); 32 } else if(ret == 2) { 33 Serial.println("FW Version mismatch."); 34 Serial.print("FW Version:"); 35 Serial.println(wifi.getVersion().c_str()); 36 Serial.print("Supported FW Version:"); 37 Serial.println(ESP8266_SUPPORT_VERSION); 38 while(1); 39 } else { 40 Serial.print("begin ok\r\n"); 41 } 42 19 43 Serial.print("FW Version:"); 20 44 Serial.println(wifi.getVersion().c_str()); 21 45 22 #if 146 #ifdef WMODE_STATION 23 47 if (wifi.setOprToStation()) { 24 48 Serial.print("to station ok\r\n"); … … 34 58 Serial.print("Join AP failure\r\n"); 35 59 } 36 #else 60 #else /* !WMODE_STATION */ 37 61 if (wifi.setOprToSoftAP()) { 38 62 Serial.print("to softap ok\r\n"); 39 63 } else { 40 64 Serial.print("to softap err\r\n"); 41 } 42 65 } 43 66 if(wifi.setSoftAPParam(AP_SSID, AP_PASSWORD, 7, 0)){ 44 67 Serial.print("Set SoftAP success\r\n"); … … 49 72 Serial.print("Set SoftAP failure\r\n"); 50 73 } 51 #endif 74 #endif /* WMODE_STATION */ 75 52 76 if (wifi.enableMUX()) { 53 77 Serial.print("multiple ok\r\n"); … … 55 79 Serial.print("multiple err\r\n"); 56 80 } 57 81 58 82 if (wifi.startTCPServer(80)) { 59 83 Serial.print("start tcp server ok\r\n"); … … 67 91 Serial.print("set tcp server timout err\r\n"); 68 92 } 69 93 70 94 Serial.print("setup end\r\n"); 71 95 } 72 96 97 uint8_t mux_id_ptn; 73 98 74 99 void loop() … … 76 101 uint8_t mux_id; 77 102 uint8_t buffer[128] = {0}; 78 uint32_t len = wifi.recv(&mux_id, buffer, sizeof(buffer)); 103 uint8_t pre_mux_id_ptn; 104 uint32_t len 105 106 pre_mux_id_ptn = mux_id_ptn; 107 108 if(!wifi.getMuxCStatus(&mux_id_ptn)) { 109 Serial.println("isConnected(&mux_id_ptn) : Error!"); 110 while(1); 111 } 79 112 80 if(len == 0) { 113 if (pre_mux_id_ptn != mux_id_ptn) { 114 Serial.print("Connection Status changed! : 0x"); 115 Serial.println(mux_id_ptn, HEX); 116 } 117 118 if(!wifi.isDataAvailable()) { 81 119 return; 82 120 } 121 122 if((len = wifi.recv(&mux_id, buffer, sizeof(buffer))) == 0) { 123 return; 124 } 125 126 String cmd = (char*)buffer; 83 127 84 Serial.println("Web Server Task : Recive Request"); 85 86 String cmd = (char*)buffer; 87 88 wifi.send(mux_id, cmd); 128 Serial.print("Web Server Task : Recive Request from mux : "); 129 Serial.println(mux_id); 130 Serial.print("Web Server Task : Recive len : "); 131 Serial.println(len); 132 Serial.print("Web Server Task : Recive Data : "); 133 Serial.println(cmd); 134 135 if(!wifi.send(mux_id, cmd)) { 136 Serial.println("send(mux_id, cmd) : Error!"); 137 while(1); 138 } 139 89 140 wifi.releaseTCP(mux_id); 90 141 }
Note:
See TracChangeset
for help on using the changeset viewer.