The driver for the ESP8266 WiFi module

Dependents:   Robot Wi-fi

Fork of esp8266-driver by ESP8266

Files at this revision

API Documentation at this revision

Comitter:
williampeers
Date:
Thu Jul 27 03:25:51 2017 +0000
Parent:
1:0fb2335eff0c
Child:
3:639bd6868cf9
Commit message:
Sender working with reconnect if AGV or control resets, but not wifi

Changed in this revision

ESP8266/ESP8266.h Show annotated file Show diff for this revision Revisions of this file
ESP8266Interface.cpp Show annotated file Show diff for this revision Revisions of this file
ESP8266Interface.h Show annotated file Show diff for this revision Revisions of this file
--- a/ESP8266/ESP8266.h	Wed Jul 26 12:01:42 2017 +0000
+++ b/ESP8266/ESP8266.h	Thu Jul 27 03:25:51 2017 +0000
@@ -191,9 +191,10 @@
         attach(Callback<void()>(obj, method));
     }
 
+    ATParser _parser;
+    
 private:
     BufferedSerial _serial;
-    ATParser _parser;
 
     struct packet {
         struct packet *next;
--- a/ESP8266Interface.cpp	Wed Jul 26 12:01:42 2017 +0000
+++ b/ESP8266Interface.cpp	Thu Jul 27 03:25:51 2017 +0000
@@ -33,6 +33,16 @@
     _esp.attach(this, &ESP8266Interface::event);
 }
 
+int ESP8266Interface::testWifi() {
+    int ret;
+    ret = _esp.isConnected();
+    //ret = _esp._parser.send("AT+CWJAP?") && _esp._parser.recv("+CWJAP:\"denver\"");
+    //_esp._parser.flush();
+    return(ret);
+}
+
+
+
 int ESP8266Interface::connect(const char *ssid, const char *pass, nsapi_security_t security,
                                         uint8_t channel)
 {
--- a/ESP8266Interface.h	Wed Jul 26 12:01:42 2017 +0000
+++ b/ESP8266Interface.h	Thu Jul 27 03:25:51 2017 +0000
@@ -36,12 +36,17 @@
      */
     ESP8266Interface(PinName tx, PinName rx, bool debug = false);
 
+    
+    
+    int testWifi();
+
     /** Start the interface
      *
      *  Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
      *  If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
      *
      *  @return         0 on success, negative error code on failure
+     
      */
     virtual int connect();
 
@@ -254,11 +259,11 @@
     {
         return this;
     }
-
+    
 private:
-    ESP8266 _esp;
     bool _ids[ESP8266_SOCKET_COUNT];
 
+    ESP8266 _esp;
     char ap_ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
     nsapi_security_t ap_sec;
     uint8_t ap_ch;