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:
Committer:
feb11
Date:
Wed Jul 17 11:07:06 2013 +0000
Revision:
3:fb0a778f2480
Parent:
0:9e4bcb10b3e3
Child:
9:a9bf63017854
Interactive server by default

Who changed what in which revision?

UserRevisionLine numberNew contents of line
feb11 0:9e4bcb10b3e3 1 #include "mbed.h"
feb11 0:9e4bcb10b3e3 2 #include "EthernetInterface.h"
feb11 0:9e4bcb10b3e3 3 #include "mbed_rpc.h"
feb11 0:9e4bcb10b3e3 4 #include "RPCCommand.h"
feb11 0:9e4bcb10b3e3 5 #include "HTTPServer.h"
feb11 0:9e4bcb10b3e3 6 #include "Formatter.h"
feb11 0:9e4bcb10b3e3 7 #include "RequestHandler.h"
feb11 0:9e4bcb10b3e3 8 #include "RPCType.h"
feb11 0:9e4bcb10b3e3 9
feb11 0:9e4bcb10b3e3 10 #define SERVER_PORT 80
feb11 0:9e4bcb10b3e3 11
feb11 0:9e4bcb10b3e3 12 HTTPServer create_simple_server()
feb11 0:9e4bcb10b3e3 13 {
feb11 0:9e4bcb10b3e3 14 HTTPServer srv;
feb11 0:9e4bcb10b3e3 15 srv.add_request_handler("DELETE", new DeleteRequestHandler());
feb11 0:9e4bcb10b3e3 16 srv.add_request_handler("GET", new GetRequestHandler());
feb11 0:9e4bcb10b3e3 17 srv.add_request_handler("PUT", new PutRequestHandler());
feb11 0:9e4bcb10b3e3 18 return srv;
feb11 0:9e4bcb10b3e3 19 }
feb11 0:9e4bcb10b3e3 20
feb11 0:9e4bcb10b3e3 21 HTTPServer create_interactive_server()
feb11 0:9e4bcb10b3e3 22 {
feb11 0:9e4bcb10b3e3 23 HTTPServer srv(new InteractiveHTMLFormatter());
feb11 0:9e4bcb10b3e3 24 srv.add_request_handler("GET", new ComplexRequestHandler());
feb11 0:9e4bcb10b3e3 25 return srv;
feb11 0:9e4bcb10b3e3 26 }
feb11 0:9e4bcb10b3e3 27
feb11 0:9e4bcb10b3e3 28 int main(void)
feb11 0:9e4bcb10b3e3 29 {
feb11 0:9e4bcb10b3e3 30 RPCType::instance().register_types();
feb11 0:9e4bcb10b3e3 31
feb11 0:9e4bcb10b3e3 32 EthernetInterface eth;
feb11 0:9e4bcb10b3e3 33 eth.init();
feb11 0:9e4bcb10b3e3 34 eth.connect();
feb11 0:9e4bcb10b3e3 35 printf("IP Address is %s\n", eth.getIPAddress());
feb11 0:9e4bcb10b3e3 36
feb11 3:fb0a778f2480 37 HTTPServer srv = create_interactive_server();
feb11 0:9e4bcb10b3e3 38
feb11 0:9e4bcb10b3e3 39 if(!srv.init(SERVER_PORT))
feb11 0:9e4bcb10b3e3 40 {
feb11 0:9e4bcb10b3e3 41 printf("Error while initializing the server\n");
feb11 0:9e4bcb10b3e3 42 eth.disconnect();
feb11 0:9e4bcb10b3e3 43 return -1;
feb11 0:9e4bcb10b3e3 44 }
feb11 0:9e4bcb10b3e3 45
feb11 0:9e4bcb10b3e3 46 srv.run();
feb11 0:9e4bcb10b3e3 47
feb11 0:9e4bcb10b3e3 48 return 0;
feb11 0:9e4bcb10b3e3 49 }
feb11 0:9e4bcb10b3e3 50