see http://mbed.org/users/okini3939/notebook/wattmeter-shield-on-mbed/
Fork of GSwifi_xively by
Diff: GSwifiInterface/GSwifiInterface.cpp
- Revision:
- 4:9a2415f2ab07
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GSwifiInterface/GSwifiInterface.cpp Wed Nov 27 08:18:45 2013 +0000 @@ -0,0 +1,59 @@ +/* Copyright (C) 2013 gsfan, MIT License + * port to the GainSpan Wi-FI module GS1011 + */ + +#include "GSwifiInterface.h" + +GSwifiInterface::GSwifiInterface( PinName tx, PinName rx, PinName cts, PinName rts, PinName reset, PinName alarm, int baud) : + GSwifi(tx, rx, cts, rts, reset, alarm, baud) +{ +} + +int GSwifiInterface::init(const char* name) +{ + return setAddress(name); +} + +int GSwifiInterface::init(const char* ip, const char* netmask, const char* gateway, const char* name) +{ + return setAddress(ip, netmask, gateway, name); +} + +int GSwifiInterface::connect(Security sec, const char* ssid, const char* phrase, WiFiMode mode) +{ + setSsid(sec, ssid, phrase); + switch (mode) { + case WM_INFRASTRUCTURE: + return join(); + case WM_ADHOCK: + return adhock(); + case WM_LIMITEDAP: + return limitedap(); + } + return -1; +} + +int GSwifiInterface::disconnect() +{ + return GSwifi::dissociate(); +} + +char * GSwifiInterface::getMACAddress() +{ + return _state.mac; +} + +char * GSwifiInterface::getIPAddress() +{ + return _state.ip; +} + +char * GSwifiInterface::getGateway() +{ + return _state.gateway; +} + +char * GSwifiInterface::getNetworkMask() +{ + return _state.netmask; +}