Hello World program for NNN50 SoftAP mode
Dependencies: NNN50_WIFI_API
This is a SoftAP example for Delta DFCM-NNN50 platform. In order to test with this example, user first need to open TCP Client port (use port 1030 in this example) on a PC or mobile with Socket test tool (download RealTerm' for PC, and Socket X for iOS or anymore socket test tool program available) When this example is running, the module will run as SoftAP with TCP Server. A PC or mobile can then connect to the SoftAP and connect to Server port. Once Server port is connected, user can send out the test message and expected to receive the reversed test message reply by Delta DFCM-NNN50. For more information on the usage of regular TCP and UDP Sockets, the mbed handbook can be found here
Revision 2:74cba40b8b64, committed 2017-04-17
- Comitter:
- tsungta
- Date:
- Mon Apr 17 15:58:54 2017 +0000
- Parent:
- 1:797e84377dc1
- Commit message:
- This revision is based on mbed-os (mbedOS 5) with an application bug (panic when remote endpoint close the socket) correction ; NNN50_WIFI_API need to update to 22:5b38592 at least; Add mbed_app.json for correct setting; Add.mbedignore (may not shown)
Changed in this revision
diff -r 797e84377dc1 -r 74cba40b8b64 .mbedignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.mbedignore Mon Apr 17 15:58:54 2017 +0000 @@ -0,0 +1,1 @@ +mbed-os/features/netsocket/
diff -r 797e84377dc1 -r 74cba40b8b64 NNN50_WIFI_API.lib --- a/NNN50_WIFI_API.lib Sun Apr 02 03:03:57 2017 +0000 +++ b/NNN50_WIFI_API.lib Mon Apr 17 15:58:54 2017 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/Delta/code/NNN50_WIFI_API/#eb59b255b9e3 +http://developer.mbed.org/teams/Delta/code/NNN50_WIFI_API/#5b38592bc0e6
diff -r 797e84377dc1 -r 74cba40b8b64 main.cpp --- a/main.cpp Sun Apr 02 03:03:57 2017 +0000 +++ b/main.cpp Mon Apr 17 15:58:54 2017 +0000 @@ -2,8 +2,6 @@ #include "EthernetInterface.h" #include "WIFIDevice.h" -Serial uart(p17, p16);//for NNN50 - WIFIDevice wifi; EthernetInterface eth; @@ -14,27 +12,29 @@ eth.init(); //Default AP mode setting: ip = 192.168.1.1 / security = WEP / channel no. = 1, refer to WIFIDevice.h for detail if(wifi.enableAccessPoint("NNN50_AP", "0123456789") != 0) - uart.printf("enableAccessPoint return error!...\n"); + printf("enableAccessPoint return error!...\n"); TCPSocketServer server; - server.bind(ECHO_SERVER_PORT); - server.listen(); while (true) { - uart.printf("Wait for new connection...\n"); + printf("Wait for new connection...\n"); TCPSocketConnection client; + server.bind(ECHO_SERVER_PORT); + server.listen(); server.accept(client); client.set_blocking(false, 10000); // Timeout after 10s - uart.printf("Connection from: %s\n", client.get_address()); + printf("Connection from: %s\n", client.get_address()); char buffer[256]; while (true) { int n = client.receive(buffer, sizeof(buffer)); - if (n <= 0) break; //disconnect with client if no tcp packet is received within blocking period. - + if (n <= 0) {//disconnect with client if no tcp packet is received within blocking period or remote endpoint close the socket. + server.close(); + break; + } // print received message to terminal buffer[n] = '\0'; - uart.printf("Received message from Client :'%s'\n",buffer); + printf("Received message from Client :'%s'\n",buffer); // reverse the message char temp; @@ -45,7 +45,7 @@ } // print reversed message to terminal - uart.printf("Sending message to Client: '%s'\n",buffer); + printf("Sending message to Client: '%s'\n",buffer); // Echo received message back to client client.send_all(buffer, n);
diff -r 797e84377dc1 -r 74cba40b8b64 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Mon Apr 17 15:58:54 2017 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#50b3418e45484ebf442b88cd935a2d5355402d7d
diff -r 797e84377dc1 -r 74cba40b8b64 mbed.bld --- a/mbed.bld Sun Apr 02 03:03:57 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb \ No newline at end of file
diff -r 797e84377dc1 -r 74cba40b8b64 mbed_app.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_app.json Mon Apr 17 15:58:54 2017 +0000 @@ -0,0 +1,17 @@ +{ + "config": { + "lf_clock_rc_calib_timer_interval": { + "value": 16, + "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL" + }, + "lf_clock_rc_calib_mode_config": { + "value": 0, + "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG" + }, + "uart_hwfc": { + "help": "Value: 1 for enable, 0 for disable", + "value": 0, + "macro_name": "MBED_CONF_NORDIC_UART_HWFC" + } + } +} \ No newline at end of file