bad

Dependencies:   mbed USBDevice

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GSMTest2PICO.cpp Source File

GSMTest2PICO.cpp

00001 #include "mbed.h"
00002 #include "USBSerial.h"
00003 //#include "string.h"
00004 
00005 // Blinking rate in milliseconds
00006 #define BLINKING_RATE_MS                                                    500
00007 #define CTRL_Z              26      //Attach at the end of this message string
00008 
00009 // Virtual serial port over USB
00010 USBSerial microUSB;
00011 Serial SIM800L(P0_1, P0_0); //tx, rx
00012 // Serial pc(USBTX, USBRX);
00013 char buf[40];
00014 char buf1[40];
00015 long GSMBAUD = 9600;
00016 // long PCBAUD  = 9600;
00017 
00018 int main()
00019 {
00020     // Initialise the digital pin LED1 as an output
00021     //DigitalOut led(LED1);
00022 
00023     SIM800L.baud(GSMBAUD);
00024     //microUSB.scanf("%s", buf);    
00025     SIM800L.puts("AT\r\n");
00026     SIM800L.scanf("%s", buf);
00027     SIM800L.scanf("%s", buf1);
00028     microUSB.printf("%s" , buf);
00029     microUSB.printf("%s\n", buf1);
00030     
00031     SIM800L.puts("AT+CMGF=1\r\n");
00032     SIM800L.scanf("%s", buf);
00033     SIM800L.scanf("%s", buf1);
00034     microUSB.printf("%s" , buf);
00035     microUSB.printf("%s\n", buf1);
00036     
00037     SIM800L.puts("AT+CMGS=\"17039739276\"\r\n");
00038     
00039     wait(0.1f);
00040 
00041     SIM800L.printf("This is the automatted program SMS from SIM800L. :D %c\r\n", CTRL_Z);
00042     
00043     SIM800L.scanf("%s", buf);
00044     SIM800L.scanf("%s", buf1);
00045     microUSB.printf("%s" , buf);
00046     microUSB.printf("%s\n", buf1);
00047     
00048     wait(1);
00049 
00050     //pc.printf("Yike");
00051     SIM800L.puts("AT+CMGF=0\r\n");
00052     SIM800L.scanf("%s", buf);
00053     SIM800L.scanf("%s", buf1);
00054     microUSB.printf("%s" , buf);
00055     microUSB.printf("%s\n", buf1);
00056         //led = !led;
00057 //        pc.printf("regular serial communication works!");
00058         //microUSB.printf("you typed: %s\r\n",buf);
00059         //microUSB.printf("\x1B[2J");  //clear terminal program screen
00060 //        while (SIM800L.readable()){
00061 //               microUSB.printf("%c", microUSB.putc((SIM800L.getc())));
00062 //        
00063 }
00064