wifly/socket interface for wifly modules
Dependents: PROJET_MATTHIEU_2019 PROJET_MATTHIEU_2019
Diff: WiflyInterface.cpp
- Revision:
- 11:b912f91e3212
- Parent:
- 7:a92dbed32890
- Child:
- 12:5ffaed1456c8
diff -r 81445de1fe27 -r b912f91e3212 WiflyInterface.cpp --- a/WiflyInterface.cpp Thu Aug 23 16:03:52 2012 +0000 +++ b/WiflyInterface.cpp Fri Aug 24 13:07:01 2012 +0000 @@ -1,40 +1,50 @@ #include "WiflyInterface.h" -WiflyInterface::WiflyInterface(PinName tx, PinName rx, PinName reset, PinName tcp_status, const char * ssid, const char * phrase, Security sec) : - Wifly(tx, rx, reset, tcp_status, ssid, phrase, sec) {ip_set = false;} - -int WiflyInterface::init() { - dhcp = true; +WiflyInterface::WiflyInterface( PinName tx, PinName rx, PinName reset, PinName tcp_status, + const char * ssid, const char * phrase, Security sec) : + Wifly(tx, rx, reset, tcp_status, ssid, phrase, sec) +{ + ip_set = false; +} + +int WiflyInterface::init() +{ + state.dhcp = true; reset(); return 0; } -int WiflyInterface::init(const char* ip, const char* mask, const char* gateway) { - dhcp = false; +int WiflyInterface::init(const char* ip, const char* mask, const char* gateway) +{ + state.dhcp = false; this->ip = ip; strcpy(ip_string, ip); ip_set = true; this->netmask = mask; this->gateway = gateway; - reset(); + return 0; } -int WiflyInterface::connect() { +int WiflyInterface::connect() +{ return join(); } -int WiflyInterface::disconnect() { - return leave(); +int WiflyInterface::disconnect() +{ + return disconnect(); } -char * WiflyInterface::getIPAddress() { +char * WiflyInterface::getIPAddress() +{ char * match = 0; if (!ip_set) { if (!sendCommand("get ip a\r", NULL, ip_string)) return NULL; exit(); + flush(); match = strstr(ip_string, "<"); if (match != NULL) { *match = '\0';