
TCPEchoServer for Murata Type-YD WiFi module
Dependencies: PowerControl SNICInterface mbed-rtos mbed
Fork of TCPEchoServer by
mbed 上で動作する TCPEchoServer です(ムラタ製 TypeYDモジュール使用)。
ターミナルを接続して実行すると、割り当てられたIPアドレスが表示されます。 対向機から実行する Python スクリプトは、こちら です(IPアドレスを書き換えて使用して下さい)。
Revision 7:27b297e209a6, committed 2015-01-23
- Comitter:
- MACRUM
- Date:
- Fri Jan 23 10:15:33 2015 +0000
- Parent:
- 6:5dae237341f7
- Child:
- 8:6e121d9ce02b
- Commit message:
- Initial release
Changed in this revision
--- a/EthernetInterface.lib Tue Jun 04 16:07:06 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/EthernetInterface/ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PowerControl.lib Fri Jan 23 10:15:33 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JST2011/code/PowerControl/#d0fa2aeb02a4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SNICInterface_mod.lib Fri Jan 23 10:15:33 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/MACRUM/code/SNICInterface_mod/#62ba69ff80d2
--- a/main.cpp Tue Jun 04 16:07:06 2013 +0100 +++ b/main.cpp Fri Jan 23 10:15:33 2015 +0000 @@ -1,22 +1,55 @@ #include "mbed.h" -#include "EthernetInterface.h" +#include "SNIC_WifiInterface.h" +#include "TCPSocketServer.h" + +#if defined(TARGET_LPC1768) +#include "PowerControl/EthernetPowerControl.h" +#endif #define ECHO_SERVER_PORT 7 +#define DEMO_AP_SSID "SSID" +#define DEMO_AP_SECURITY_TYPE e_SEC_WPA2_AES +#define DEMO_AP_SECUTIRY_KEY "PASSWORD" + +C_SNIC_WifiInterface wifi( p9, p10, NC, NC, p30 ); + int main (void) { - EthernetInterface eth; - eth.init(); //Use DHCP - eth.connect(); - printf("IP Address is %s\n", eth.getIPAddress()); +#if defined(TARGET_LPC1768) + PHY_PowerDown(); +#endif + + wifi.init(); //Use DHCP + + wait(0.5); + int s = wifi.disconnect(); + if( s != 0 ) + { + return -1; + } + + wait(0.3); + // Connect AP + wifi.connect( DEMO_AP_SSID + , strlen(DEMO_AP_SSID) + , DEMO_AP_SECURITY_TYPE + , DEMO_AP_SECUTIRY_KEY + , strlen(DEMO_AP_SECUTIRY_KEY) ); + wait(0.5); + + wifi.setIPConfig( true ); + wait(0.5); + + printf("IP Address is %s\n", wifi.getIPAddress()); TCPSocketServer server; server.bind(ECHO_SERVER_PORT); - server.listen(); - + server.listen(); + while (true) { printf("\nWait for new connection...\n"); TCPSocketConnection client; - server.accept(client); + server.accept(&client); client.set_blocking(false, 1500); // Timeout after (1.5)s printf("Connection from: %s\n", client.get_address());
--- a/mbed-rtos.lib Tue Jun 04 16:07:06 2013 +0100 +++ b/mbed-rtos.lib Fri Jan 23 10:15:33 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed-rtos/#444020d511f5
--- a/mbed.bld Tue Jun 04 16:07:06 2013 +0100 +++ b/mbed.bld Fri Jan 23 10:15:33 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/ \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file