Krisna Chhouk
/
GSMProgramAutomation
GSM Automation using Sim800L
Diff: GSMProgramAutomation.cpp
- Revision:
- 0:c9d0008613d6
diff -r 000000000000 -r c9d0008613d6 GSMProgramAutomation.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GSMProgramAutomation.cpp Sat Feb 01 17:53:46 2020 +0000 @@ -0,0 +1,65 @@ +#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); +} +