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
main.cpp
- Committer:
- yi
- Date:
- 2015-02-15
- Revision:
- 1:e821c773d5f0
- Parent:
- 0:998e2e00df0c
- Child:
- 4:99a67256b765
File content as of revision 1:e821c773d5f0:
#include "mbed.h"
#include "SNIC_WifiInterface.h"
#include "HTTPServer.h"
/**
* Wifi AP parameter
*/
/* Set this */
//#define WIFI_SSID ""
//#define WIFI_SECUTIRY_KEY ""
/*
#define WIFI_SSID "2ndguests"
#define WIFI_SECUTIRY_KEY "Sepkddi0077"
#define WIFI_SECURITY_TYPE e_SEC_WPA2_AES
*/
//#define WIFI_SSID "Team3_4"
#define WIFI_SSID "Team11_12"
#define WIFI_SECUTIRY_KEY "123456789"
#define WIFI_SECURITY_TYPE e_SEC_WPA2_AES
//#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 IP_ADDRESS "192.168.100.44"
#define NET_MASK "255.255.255.0"
#define DEFAULT_GATEWAY "192.168.0.1"
#define PORT_NUMBER 80
#define _DEBUG
Serial pc(USBTX, USBRX); // This is required when defined "_DEBUG"
/** Wi-Fi SNIC UART Interface*/
//C_SNIC_WifiInterface mSNICwifi( p13, p14, p12, p11, p20 );
C_SNIC_WifiInterface mSNICwifi( p9, p10, NC, NC, p30 );
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();
}
