NNN40 change mode from AP to STA by HTTP server

Dependencies:   WIFI_API_32kRAM mbed

How to use Demo code

  • Step1: Prepare a router, and set the SSID and Password as follow
  1. SSID: "SSID"
  2. Password: "0123456789"
  • Step2: Burn demo code to NNN40 module.

You can drag and drop the sample code to NNN40 module.

  • Step3: Login module from Http server (192.168.2.1) by PC.

You can set SSID and password by browser. After clicking "confirm" button, the module will change mode from AP to STA, get IP from router

  • DEMO video:
Revision:
11:f57e9de44f6f
Parent:
9:a9bf63017854
Child:
12:eca9b56155c7
--- a/main.cpp	Thu Jul 18 10:10:14 2013 +0000
+++ b/main.cpp	Wed Sep 16 02:43:42 2015 +0000
@@ -7,8 +7,12 @@
 #include "RequestHandler.h"
 #include "RPCType.h"
 
+#include "WIFIDevice.h"
+
 #define SERVER_PORT 80
 
+WIFIDevice wifi;
+
 HTTPServer create_simple_server()
 {    
     HTTPServer srv;
@@ -30,12 +34,15 @@
     RPCType::instance().register_types();    
 
     EthernetInterface eth;
+    //wifi.setNetwork("GainSpan_JS", "Delta9999", 0);
+    //wifi.setNetwork("TP-LINK_2.4G_TTWU", "0972753720", 0);
+    wifi.setAccessPoint("NNN40_TTWU", "0123456789", SECURITY_WPA2_TKIP_PSK, 2);      
     if(eth.init())
     {
         printf("Error while initializing the ethernet interface.\n");
         return -1;
     }
-    if(eth.connect())
+    if(eth.connect(60000))
     {
         printf("Error while starting the ethernet interface.\n");
         return -1;