initial

Dependencies:   ATParser mbed

Committer:
youngs2
Date:
Thu Apr 05 14:50:44 2018 +0000
Revision:
1:1c928ac1083f
Parent:
0:d382db2d4a0f
Child:
2:cc9dffa51350
initial #2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
youngs2 0:d382db2d4a0f 1 #include "mbed.h"
youngs2 0:d382db2d4a0f 2 #include "ATParser.h"
youngs2 0:d382db2d4a0f 3
youngs2 1:1c928ac1083f 4 BufferedSerial pc(SERIAL_TX, SERIAL_RX);
youngs2 1:1c928ac1083f 5 BufferedSerial device(PA_9, PA_10); // tx, rx
youngs2 0:d382db2d4a0f 6 DigitalOut myled(LED1);
youngs2 0:d382db2d4a0f 7
youngs2 1:1c928ac1083f 8 int main()
youngs2 0:d382db2d4a0f 9 {
youngs2 1:1c928ac1083f 10 pc.baud(115200);
youngs2 1:1c928ac1083f 11 device.baud(115200);
youngs2 1:1c928ac1083f 12 pc.printf("Hola\n\r");
youngs2 1:1c928ac1083f 13 ATParser at = ATParser(device, "\n\r", 256, 2000, false);
youngs2 1:1c928ac1083f 14 if(at.send("AT") && at.recv("\n\r"))
youngs2 1:1c928ac1083f 15 {
youngs2 1:1c928ac1083f 16 pc.printf("Bueno#1\n\r");
youngs2 1:1c928ac1083f 17 myled = !myled;
youngs2 1:1c928ac1083f 18 }
youngs2 1:1c928ac1083f 19 else
youngs2 1:1c928ac1083f 20 pc.printf("Nope#1\n\r");
youngs2 1:1c928ac1083f 21 if(at.send("AT+NI=1,MTCDT-19400691")
youngs2 1:1c928ac1083f 22 && at.recv("Set Network Name: MTCDT-19400691")
youngs2 1:1c928ac1083f 23 /*&& at.recv("\n\r")*/
youngs2 1:1c928ac1083f 24 && at.recv("OK"))
youngs2 1:1c928ac1083f 25 pc.printf("Bueno#2\n\r");
youngs2 1:1c928ac1083f 26 else
youngs2 1:1c928ac1083f 27 pc.printf("Nope#2\n\r");
youngs2 1:1c928ac1083f 28 while(1);
youngs2 0:d382db2d4a0f 29 }
youngs2 0:d382db2d4a0f 30
youngs2 1:1c928ac1083f 31 /*
youngs2 1:1c928ac1083f 32 memset(address, 0, 100);
youngs2 1:1c928ac1083f 33 len = at.read(address, 100)
youngs2 1:1c928ac1083f 34 for(i = 0; i < len; i++)
youngs2 1:1c928ac1083f 35 {
youngs2 1:1c928ac1083f 36 if(!address[i]);
youngs2 1:1c928ac1083f 37 else if(address[i] >= '0') printf("%c\n\r",address[i]);
youngs2 1:1c928ac1083f 38 else if(address[i]=='\n') printf("\\n\n\r", address[i]);
youngs2 1:1c928ac1083f 39 else if(address[i]=='\r') printf("\\r\n\r", address[i]);
youngs2 0:d382db2d4a0f 40 }
youngs2 1:1c928ac1083f 41 */