emw3162 driver

Fork of emw3162-driver-mbed-os-5 by Maggie Mei

Files at this revision

API Documentation at this revision

Comitter:
sarahmarshy
Date:
Thu Feb 16 19:26:33 2017 +0000
Parent:
6:80cdb5076d18
Commit message:
Change references to _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	Thu Feb 16 19:24:40 2017 +0000
+++ b/EMW3162Interface.cpp	Thu Feb 16 19:26:33 2017 +0000
@@ -26,31 +26,31 @@
 
 // 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()
 {
-    _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(ap_ssid, ap_pass)) {
+    if (!_emw.connect(ap_ssid, ap_pass)) {
         return NSAPI_ERROR_NO_CONNECTION;
     }
 
-    if (!_esp.getIPAddress()) {
+    if (!_emw.getIPAddress()) {
         return NSAPI_ERROR_DHCP_FAILURE;
     }
 
@@ -87,9 +87,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;
     }
 
@@ -98,12 +98,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();
 }
 
 const char *EMW3162Interface::get_gateway()
@@ -167,9 +167,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;
     }
 
@@ -191,10 +191,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;
     }
@@ -211,9 +211,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;
     }
  
@@ -223,9 +223,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	Thu Feb 16 19:24:40 2017 +0000
+++ b/EMW3162Interface.h	Thu Feb 16 19:26:33 2017 +0000
@@ -231,7 +231,7 @@
     }
     
 private:
-    EMW3162 _esp;
+    EMW3162 _emw;
     bool _ids[EMW3162_SOCKET_COUNT];
 
     char ap_ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */