EMW3162 driver for NSAPI
Fork of emw3162-driver by
Revision 3:a1d89edf0749, committed 2017-04-06
- Comitter:
- Maggie17
- Date:
- Thu Apr 06 02:58:04 2017 +0000
- Parent:
- 2:fb6251306b21
- Commit message:
- change _esp to _emw
Changed in this revision
EMW3162Interface.cpp | Show annotated file Show diff for this revision Revisions of this file |
EMW3162Interface.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/EMW3162Interface.cpp Mon Nov 14 02:30:49 2016 +0000 +++ b/EMW3162Interface.cpp Thu Apr 06 02:58:04 2017 +0000 @@ -26,12 +26,12 @@ // EMW3162Interface implementation EMW3162Interface::EMW3162Interface(PinName tx, PinName rx, bool debug) - : _esp(tx, rx, debug) + : _emw(tx, rx, debug) { memset(_ids, 0, sizeof(_ids)); memset(_cbs, 0, sizeof(_cbs)); - _esp.attach(this, &EMW3162Interface::event); + _emw.attach(this, &EMW3162Interface::event); } int EMW3162Interface::connect( @@ -39,21 +39,21 @@ const char *pass, nsapi_security_t security) { - _esp.setTimeout(EMW3162_CONNECT_TIMEOUT); + _emw.setTimeout(EMW3162_CONNECT_TIMEOUT); - if (!_esp.startup()) { + if (!_emw.startup()) { return NSAPI_ERROR_DEVICE_ERROR; } - if (!_esp.dhcp(true)) { + if (!_emw.dhcp(true)) { return NSAPI_ERROR_DHCP_FAILURE; } - if (!_esp.connect(ssid, pass)) { + if (!_emw.connect(ssid, pass)) { return NSAPI_ERROR_NO_CONNECTION; } - if (!_esp.getIPAddress()) { + if (!_emw.getIPAddress()) { return NSAPI_ERROR_DHCP_FAILURE; } @@ -62,9 +62,9 @@ int EMW3162Interface::disconnect() { - _esp.setTimeout(EMW3162_MISC_TIMEOUT); + _emw.setTimeout(EMW3162_MISC_TIMEOUT); - if (!_esp.disconnect()) { + if (!_emw.disconnect()) { return NSAPI_ERROR_DEVICE_ERROR; } @@ -73,12 +73,12 @@ const char* EMW3162Interface::get_ip_address() { - return _esp.getIPAddress(); + return _emw.getIPAddress(); } const char* EMW3162Interface::get_mac_address() { - return _esp.getMACAddress(); + return _emw.getMACAddress(); } struct EMW3162_socket { @@ -122,9 +122,9 @@ { struct EMW3162_socket *socket = (struct EMW3162_socket *)handle; int err = 0; - _esp.setTimeout(EMW3162_MISC_TIMEOUT); + _emw.setTimeout(EMW3162_MISC_TIMEOUT); - if (!_esp.close(socket->socketId)) { + if (!_emw.close(socket->socketId)) { err = NSAPI_ERROR_DEVICE_ERROR; } @@ -146,10 +146,10 @@ int EMW3162Interface::socket_connect(void *handle, const SocketAddress &addr) { struct EMW3162_socket *socket = (struct EMW3162_socket *)handle; - _esp.setTimeout(EMW3162_MISC_TIMEOUT); + _emw.setTimeout(EMW3162_MISC_TIMEOUT); const char *proto = (socket->proto == NSAPI_UDP) ? "UNICAST" : "CLIENT"; - socket -> socketId = _esp.open(proto, socket->id, addr.get_ip_address(), addr.get_port()); + socket -> socketId = _emw.open(proto, socket->id, addr.get_ip_address(), addr.get_port()); if (!(socket -> socketId)) { return NSAPI_ERROR_DEVICE_ERROR; } @@ -166,9 +166,9 @@ int EMW3162Interface::socket_send(void *handle, const void *data, unsigned size) { struct EMW3162_socket *socket = (struct EMW3162_socket *)handle; - _esp.setTimeout(EMW3162_SEND_TIMEOUT); + _emw.setTimeout(EMW3162_SEND_TIMEOUT); - if (!_esp.send(socket->socketId, data, size)) { + if (!_emw.send(socket->socketId, data, size)) { return NSAPI_ERROR_DEVICE_ERROR; } @@ -178,9 +178,9 @@ int EMW3162Interface::socket_recv(void *handle, void *data, unsigned size) { struct EMW3162_socket *socket = (struct EMW3162_socket *)handle; - _esp.setTimeout(EMW3162_RECV_TIMEOUT); + _emw.setTimeout(EMW3162_RECV_TIMEOUT); - int32_t recv = _esp.recv(socket->socketId, data, size); + int32_t recv = _emw.recv(socket->socketId, data, size); if (recv < 0) { return NSAPI_ERROR_WOULD_BLOCK; }
--- a/EMW3162Interface.h Mon Nov 14 02:30:49 2016 +0000 +++ b/EMW3162Interface.h Thu Apr 06 02:58:04 2017 +0000 @@ -176,7 +176,7 @@ } private: - EMW3162 _esp; + EMW3162 _emw; bool _ids[EMW3162_SOCKET_COUNT]; void event();