emw3162 driver
Fork of emw3162-driver-mbed-os-5 by
Diff: EMW3162Interface.cpp
- Revision:
- 5:a8a6cb7e1128
- Parent:
- 3:a6f80a95b039
- Child:
- 6:80cdb5076d18
--- a/EMW3162Interface.cpp Thu Feb 16 18:10:28 2017 +0000 +++ b/EMW3162Interface.cpp Thu Feb 16 18:14:15 2017 +0000 @@ -36,11 +36,6 @@ int EMW3162Interface::connect() { - return 0; -} -int EMW3162Interface::connect(const char *ssid, const char *pass, nsapi_security_t security, - uint8_t channel) -{ _esp.setTimeout(EMW3162_CONNECT_TIMEOUT); if (!_esp.startup()) { @@ -51,7 +46,7 @@ return NSAPI_ERROR_DHCP_FAILURE; } - if (!_esp.connect(ssid, pass)) { + if (!_esp.connect(ap_ssid, ap_pass)) { return NSAPI_ERROR_NO_CONNECTION; } @@ -59,11 +54,29 @@ return NSAPI_ERROR_DHCP_FAILURE; } - return NSAPI_ERROR_OK; + return 0; +} +int EMW3162Interface::connect(const char *ssid, const char *pass, nsapi_security_t security, + uint8_t channel) +{ + if (channel != 0) { + return NSAPI_ERROR_UNSUPPORTED; + } + + set_credentials(ssid, pass, security); + return connect(); } int EMW3162Interface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security) { + memset(ap_ssid, 0, sizeof(ap_ssid)); + strncpy(ap_ssid, ssid, sizeof(ap_ssid)); + + memset(ap_pass, 0, sizeof(ap_pass)); + strncpy(ap_pass, pass, sizeof(ap_pass)); + + ap_sec = security; + return 0; }