setup program for esp8266 using the KL25Z mbed.

Dependencies:   mbed

Fork of ESP8266-configuration-mbed-LPC1768 by jim hamblen

Files at this revision

API Documentation at this revision

Comitter:
cstevens
Date:
Fri Jun 03 09:30:15 2016 +0000
Parent:
5:9f46b8cdd469
Commit message:
esp_setup - adapted for KL25z by chris stevens 2016

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 9f46b8cdd469 -r 6261d6c51f5c main.cpp
--- a/main.cpp	Fri Aug 28 01:21:15 2015 +0000
+++ b/main.cpp	Fri Jun 03 09:30:15 2016 +0000
@@ -1,16 +1,17 @@
 #include "mbed.h"
-
+//https://developer.mbed.org/users/4180_1/notebook/using-the-esp8266-with-the-mbed-lpc1768/
+//modified to run on KL25Z using serial port at PTA2,PTA1 (tx,rx) and PTD4 as RST pin
 Serial pc(USBTX, USBRX);
-Serial esp(p28, p27); // tx, rx
-DigitalOut reset(p26);
+Serial esp(PTA2,PTA1); // tx, rx
+DigitalOut reset(PTD4);
 Timer t;
 
 int  count,ended,timeout;
 char buf[1024];
 char snd[255];
 
-char ssid[32] = "mySSID";     // enter WiFi router ssid inside the quotes
-char pwd [32] = "myPASSWORD"; // enter WiFi router password inside the quotes
+char ssid[32] = "TALKTALK-E88A77";     // enter WiFi router ssid inside the quotes
+char pwd [32] = "BTJFPYFJ"; // enter WiFi router password inside the quotes
 
 void SendCMD(),getreply(),ESPconfig(),ESPsetbaudrate();
 
@@ -18,7 +19,7 @@
 int main()
 {
     reset=0; //hardware reset for 8266
-    pc.baud(115200);  // set what you want here depending on your terminal program speed
+    //pc.baud(115200);  // set what you want here depending on your terminal program speed
     pc.printf("\f\n\r-------------ESP8266 Hardware Reset-------------\n\r");
     wait(0.5);
     reset=1;
@@ -40,14 +41,14 @@
         SendCMD();
         timeout=15;
         getreply();
-        pc.printf(buf);
+        pc.printf("       buf  = ##start %s                 ..##end\n",buf);
         wait(2);
         pc.printf("\n---------- Get IP and MAC ----------\r\n");
         strcpy(snd, "AT+CIFSR\r\n");
         SendCMD();
         timeout=10;
         getreply();
-        pc.printf(buf);
+        pc.printf("       buf  = ##start %s                 ..##end\n",buf);
         wait(2);
     }
 
@@ -82,7 +83,7 @@
     SendCMD();
     timeout=5;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(2);
 
@@ -91,7 +92,7 @@
     SendCMD();
     timeout=4;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(3);
 
@@ -101,7 +102,7 @@
     SendCMD();
     timeout=4;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(2);
 
@@ -111,7 +112,7 @@
     SendCMD();
     timeout=4;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(2);
 
@@ -120,7 +121,7 @@
     SendCMD();
     timeout=15;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(2);
 
@@ -134,7 +135,7 @@
     SendCMD();
     timeout=10;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(5);
 
@@ -143,7 +144,7 @@
     SendCMD();
     timeout=3;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     wait(1);
 
@@ -152,7 +153,7 @@
     SendCMD();
     timeout=5;
     getreply();
-    pc.printf(buf);
+    pc.printf("       buf  = ##start %s                 ..##end\n",buf);
 
     pc.printf("\n\n\n  If you get a valid (non zero) IP, ESP8266 has been set up.\r\n");
     pc.printf("  Run this if you want to reconfig the ESP8266 at any time.\r\n");
@@ -167,9 +168,9 @@
 
 void getreply()
 {
-    memset(buf, '\0', sizeof(buf));
-    t.start();
-    ended=0;
+    memset(buf, '\0', sizeof(buf)); // this zeros the array
+    t.start(); //  start a timer
+    ended=0; 
     count=0;
     while(!ended) {
         if(esp.readable()) {
diff -r 9f46b8cdd469 -r 6261d6c51f5c mbed.bld
--- a/mbed.bld	Fri Aug 28 01:21:15 2015 +0000
+++ b/mbed.bld	Fri Jun 03 09:30:15 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file