ESP8266 test with W7500. You can monitor UART Tx/RX of ESP8266.
Dependencies: ESP8266Interface
Fork of ESP8266_Test by
main.cpp
00001 #include "mbed.h" 00002 #include "ESP8266Interface.h" 00003 #include "TCPSocketConnection.h" 00004 00005 00006 RawSerial pc(USBTX, USBRX); // tx, rx 00007 00008 DigitalOut led1(LED1); 00009 DigitalOut led2(LED2); 00010 00011 const char* TEST_SERVER_ADDRESS = "192.168.3.64"; 00012 const int TEST_SERVER_PORT = 8000; 00013 00014 ESP8266Interface wifi(D1, D0, D2, "WizFiDemoAP","12345678",115200); // tx, rx 00015 00016 00017 // For monitoring data from ESP8266 00018 Timeout timer_buffer_debug; 00019 CircBuffer<char> buffer_ESP8266_recv(1024); 00020 00021 void print_buffer_ESP8266() 00022 { 00023 char c=0; 00024 while ( buffer_ESP8266_recv.available() ) { 00025 buffer_ESP8266_recv.dequeue(&c); 00026 pc.putc(c); 00027 } 00028 timer_buffer_debug.attach(&print_buffer_ESP8266, 0.1); 00029 } 00030 00031 00032 int main() 00033 { 00034 // LED Blink 00035 for (int i=0; i<5; i++) { 00036 led1 = 1; 00037 wait(0.1); 00038 led1 = 0; 00039 wait(0.1); 00040 } 00041 00042 pc.baud(115200); 00043 pc.printf("\r\nWIZwiki-W7500 with ESP8266 Test. \r\n"); 00044 00045 timer_buffer_debug.attach(&print_buffer_ESP8266, 0.5); 00046 00047 bool result; 00048 wifi.init(); 00049 result = wifi.connect(); 00050 if ( !result ) { 00051 pc.printf("wifi.connect error\r\n"); 00052 return 0; 00053 } 00054 00055 TCPSocketConnection socket; 00056 while (socket.connect(TEST_SERVER_ADDRESS, TEST_SERVER_PORT) < 0) { 00057 pc.printf("Unable to connect to (%s) on port (%d)\n", TEST_SERVER_ADDRESS, TEST_SERVER_PORT); 00058 wait(1); 00059 } 00060 00061 char hello[] = "Hello World\r\n"; 00062 socket.send_all(hello, sizeof(hello) - 1); 00063 socket.close(); 00064 00065 while(true) {} 00066 }
Generated on Fri Jul 15 2022 04:58:58 by 1.7.2