SIM800L works with AT command on CoolTerm.
Dependencies: mbed BufferedSerial SoftSerial
GSMTest1.cpp
- Committer:
- kchhouk
- Date:
- 2020-01-31
- Revision:
- 0:b98b6cf2edfe
File content as of revision 0:b98b6cf2edfe:
#include "mbed.h" #include "BufferedSerial.h" #include <string> //Works with AT Command Serial pc(USBTX, USBRX); Serial SIM800L(P3_1, P3_0); DigitalOut led1(LED1); DigitalOut led2(LED2); char *phone = "\"17039739276\""; //char str[2]; long GSMBAUD = 9600; long PCBAUD = 9600; int main(){ pc.baud(PCBAUD); SIM800L.baud(GSMBAUD); /* SIM800L.puts("AT"); SIM800L.puts("\r\n"); //wait(0.1f); SIM800L.puts("AT+CMGF=1"); SIM800L.puts("\r\n"); //wait(0.1f); SIM800L.puts("AT+CMGS=\"17039739276\""); SIM800L.puts("\r\n"); //wait(0.1f); SIM800L.printf("Testing SMS from KC."); //SIM800L.puts("\r\n"); //wait(0.1f); //wait_ms(500); */ while(1){ while(pc.readable()){ SIM800L.putc(pc.getc()); //SIM800L.printf("%c", SIM800L.putc(pc.getc())); //SIM800L.puts("\r\n"); } wait(0.1f); while(SIM800L.readable()){ //pc.putc(SIM800L.getc()); pc.printf("%c", pc.putc(SIM800L.getc())); } //wait(0.1f); } }