Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
wadh4587
Date:
Thu Jun 16 15:44:49 2016 +0000
Parent:
10:f7a48cc24892
Commit message:
WIFI server startup

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f7a48cc24892 -r a84a248f779f main.cpp
--- a/main.cpp	Wed Jun 15 14:47:19 2016 +0000
+++ b/main.cpp	Thu Jun 16 15:44:49 2016 +0000
@@ -1,21 +1,19 @@
 /* Simpler prog based on the serial passthrough code to enable a command line driven test of esp8266
 * wifi modules.
-* NB this uses the mbed sleep() command to form a low power system but on some MCUs this is a problem
-* this works fine on an lpc1768 but not as yet on the KL25Z
 */
 #include "mbed.h"
 
 Serial pc(USBTX, USBRX); // serial terminal for the pc connection
 Serial dev(PTE0,PTE1);  // for KL25Z... asuming one can't use the PTA1 version which is the stdio
 DigitalOut led1(LED1); // twp leds
-DigitalOut led4(LED2); // to allow visual check of bidirectional comms
+DigitalOut led2(LED2); // to allow visual check of bidirectional comms
 DigitalOut rst(PTD7); // single digital pin to drive the esp8266 reset line
 
 // subroutine to run anytime a serial interrupt arrives from the device
 // this basically passes everything thatthe device produces on to the pc terminal screen
+
 void dev_recv()
 {
-    led1 = !led1;
     while(dev.readable()) {
         pc.putc(dev.getc());
         wait_us(1);
@@ -28,7 +26,6 @@
 void pc_recv()
 {
     char c;
-    led4 = !led4;
     while(pc.readable()) {
         c = pc.getc();
         dev.putc(c);
@@ -44,20 +41,27 @@
 {
     pc.baud(115200);
     dev.baud(115200);
-    rst=0;
+    rst = 0;
     wait(1);
     rst = 1; // send the esp8266 reset
     wait(1);
+    
+    led1 = 0, led2 = 1;         //Red LED indicates startup in progress
 
     pc.attach(&pc_recv, Serial::RxIrq); // attach the two interrupt services
     dev.attach(&dev_recv, Serial::RxIrq);
-    pc.printf("ok off we go....\n\r");
-//    wait(10);
-//    pc.printf("AT+RST\n\r");
-//    wait(20);
-//        pc.printf("AT+CWJAP="CWMWIFI","CWM2016TT""\n\r);
+    dev.printf("AT+RST\r\n");
+    wait(10);
+    dev.printf("AT+CWJAP=\"BTHub3-WXWX\",\"fdd6f7c682\"\r\n");
+    wait(10);
+    dev.printf("AT+CIPMUX=1\r\n");
+    wait(2);
+    dev.printf("AT+CIPSERVER=1,333\r\n");
+    wait(2);
 
-    while(1) {
-//        (i++)%10; // THIS USED TO BE A SLEEP COMMAND BUT IT WAS CAUSING SOME TROUBLE.
+    led1 = 1, led2 = 0;     //Green LED indicates startup complete
+
+    while(1) {          //Main code goes here
+
     }
 }
\ No newline at end of file