WiFi test

Dependencies:   mbed

Fork of SerialPassthroughcjsESP8266 by chris stevens

Files at this revision

API Documentation at this revision

Comitter:
danlock10y
Date:
Thu Jun 09 14:49:00 2016 +0000
Parent:
9:b1344ca3497d
Commit message:
WiFi test crap

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b1344ca3497d -r 56ca30af7a7b main.cpp
--- a/main.cpp	Wed Jun 08 10:07:11 2016 +0000
+++ b/main.cpp	Thu Jun 09 14:49:00 2016 +0000
@@ -6,11 +6,11 @@
 #include "mbed.h"
 
 RawSerial  pc(USBTX, USBRX); // serial terminal for the pc connection
-//RawSerial dev(PTE0,PTE1);  // for KL25Z... asuming one can't use the PTA1 version which is the stdio
-RawSerial  dev(p28,p27); // serial uart for connecting to the esp8266 tx,rx NB mbed tx must connect ot esp rx and vice versa
+RawSerial dev(PTE0,PTE1);  // for KL25Z... asuming one can't use the PTA1 version which is the stdio
+//RawSerial  dev(p28,p27); // serial uart for connecting to the esp8266 tx,rx NB mbed tx must connect ot esp rx and vice versa
 DigitalOut led1(LED1); // twp leds  
 DigitalOut led4(LED4); // to allow visual check of bidirectional comms
-DigitalOut rst(p26); // single digital pin to drive the esp8266 reset line
+DigitalOut rst(PTD1); // 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
@@ -33,7 +33,7 @@
     while(pc.readable()) {
         c=pc.getc();
         dev.putc(c);
-        //pc.putc(c); // echo back
+        pc.putc(c); // echo back
         if(c==13) {dev.putc(10); // send the linefeed to complement the carriage return generated by return key on the pc
         pc.putc(10);
             }
@@ -53,9 +53,39 @@
 
     pc.attach(&pc_recv, Serial::RxIrq); // attach the two interrupt services
     dev.attach(&dev_recv, Serial::RxIrq);
+        
+int i=0;
+    wait(5);
+    pc.printf("Send rst\r\n");
+    dev.printf("AT+RST\r\n");
     
+    wait(2);
+    pc.printf("Set mode\r\n");
+    dev.printf("AT+CWMODE=1\r\n");
+    
+    wait(2);
+    pc.printf("\r\n Login\r\n");
+    dev.printf("AT+CWJAP=\"CWMWIFI\",\"CWM2016TT\"\r\n");
     
-int i=0;
+    wait(10);
+    pc.printf("\r\n Find IP\r\n");
+    dev.printf("AT+CIFSR\r\n");
+    
+    wait(5);
+    pc.printf("\r\n MUX\r\n");
+    dev.printf("AT+CIPMUX=1\r\n");
+    
+    wait(2);
+    pc.printf("\r\n Open connection\r\n");
+    dev.printf("AT+CIPSTART=0,\"TCP\",\"192.168.1.6\",5050\r\n");
+    
+    wait(2);
+    pc.printf("\r\n Send Message\r\n");
+    dev.printf("AT+CIPSEND=0,14\r\n");
+ wait(2);
+    pc.printf("\r\n Send the Message\r\n");
+    dev.printf("Hello cruel!\r\n");
+    
     while(1) {
         
        (i++)%10; // THIS USED TO BE A SLEEP COMMAND BUT IT WAS CAUSING SOME TROUBLE.