Krisna Chhouk
/
GSMProgramAutomation
GSM Automation using Sim800L
GSMProgramAutomation.cpp
- Committer:
- kchhouk
- Date:
- 2020-02-01
- Revision:
- 0:c9d0008613d6
File content as of revision 0:c9d0008613d6:
#include "mbed.h" #define CTRL_Z 26 //Attach at the end of this message string Serial pc(USBTX, USBRX); Serial SIM800L(P3_1, P3_0); DigitalOut led1(LED1); char phone[14] = "\"17039739276\""; char buf[40]; char buf1[40]; long GSMBAUD = 9600; long PCBAUD = 9600; int main(){ pc.baud(PCBAUD); SIM800L.baud(GSMBAUD); //wait(0.1f); SIM800L.puts("AT\r\n"); SIM800L.scanf("%s", buf); SIM800L.scanf("%s", buf1); pc.printf("%s\n", buf); pc.printf("%s\n", buf1); //wait(0.01f); SIM800L.puts("AT+CMGF=1\r\n"); SIM800L.scanf("%s", buf); SIM800L.scanf("%s", buf1); pc.printf("%s\n", buf); pc.printf("%s\n", buf1); //wait(0.01f); SIM800L.puts("AT+CMGS=\"17039739276\"\r\n"); //SIM800L.puts("\r\n"); // SIM800L.scanf("%s", buf); // SIM800L.scanf("%s", buf1); // pc.printf("%s\n", buf); // pc.printf("%s\n", buf1); wait(0.1f); SIM800L.printf("This is the automatted program SMS from SIM800L. :D %c\r\n", CTRL_Z); //wait(4); //SIM800L.puts("26\r\n"); //wait(0.1f); SIM800L.scanf("%s", buf); SIM800L.scanf("%s", buf1); pc.printf("%s\n", buf); pc.printf("%s\n", buf1); wait(1); //pc.printf("Yike"); SIM800L.puts("AT+CMGF=0\r\n"); SIM800L.scanf("%s", buf); SIM800L.scanf("%s", buf1); pc.printf("%s\n", buf); pc.printf("%s\n", buf1); }