Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NySNICInterface mbed-rtos mbed
Fork of RESTServer_team4 by
Diff: main.cpp
- Revision:
- 0:998e2e00df0c
- Child:
- 1:e821c773d5f0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Feb 10 12:15:47 2015 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+#include "SNIC_WifiInterface.h"
+#include "HTTPServer.h"
+
+/**
+ * Wifi AP parameter
+ */
+
+/* Set this */
+#define WIFI_SSID ""
+#define WIFI_SECUTIRY_KEY ""
+//#define WIFI_SECURITY_TYPE e_SEC_OPEN
+//#define WIFI_SECURITY_TYPE e_SEC_WEP
+//#define WIFI_SECURITY_TYPE e_SEC_WPA_TKIP
+#define WIFI_SECURITY_TYPE e_SEC_WPA2_AES
+//#define WIFI_SECURITY_TYPE e_SEC_WPA2_MIXED
+//#define WIFI_SECURITY_TYPE e_SEC_WPA_AES
+
+
+#define IP_ADDRESS "192.168.0.44"
+#define NET_MASK "255.255.255.0"
+#define DEFAULT_GATEWAY "192.168.0.1"
+#define PORT_NUMBER 80
+
+
+Serial pc(USBTX, USBRX); // This is required when defined "_DEBUG"
+/** Wi-Fi SNIC UART Interface*/
+C_SNIC_WifiInterface mSNICwifi( p13, p14, p12, p11, p20 );
+
+
+
+
+void wifi_connect()
+{
+ // Initialize Wi-Fi interface
+ if(mSNICwifi.init()!=0){
+ printf("Wi-Fi initial failed\r\n");
+ mbed_die();
+ }
+ wait(0.5);
+
+ if(mSNICwifi.disconnect()!= 0 )
+ {
+ printf("on the disconnect state\r\n");
+ mbed_die();
+ }
+ wait(0.3);
+
+ // Connect to AP
+ if(mSNICwifi.connect( WIFI_SSID,strlen(WIFI_SSID),
+ WIFI_SECURITY_TYPE,
+ WIFI_SECUTIRY_KEY,
+ strlen(WIFI_SECUTIRY_KEY))!=0)
+ {
+ printf("Connect AP is failed\r\n");
+ mbed_die();
+ }
+ wait(0.5);
+
+ int retIp = mSNICwifi.setIPConfig(false, IP_ADDRESS, NET_MASK, DEFAULT_GATEWAY);
+}
+
+
+int main()
+{
+ // for debug
+ pc.baud( 115200 );
+
+ wifi_connect();
+
+ HTTPServer srv;
+
+ pc.printf("server init.\r\n");
+ srv.init(PORT_NUMBER);
+
+ srv.add_request_handler("GET", new GetRequestHandler());
+ srv.add_request_handler("DELETE", new DeleteRequestHandler());
+ srv.add_request_handler("POST", new PostRequestHandler());
+
+ wait(1);
+ pc.printf("server running.\r\n");
+ srv.run();
+}
