Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GSMTest2PICO.cpp
- Committer:
- kchhouk
- Date:
- 2020-02-21
- Revision:
- 0:5c1655777e38
File content as of revision 0:5c1655777e38:
#include "mbed.h"
#include "USBSerial.h"
//#include "string.h"
// Blinking rate in milliseconds
#define BLINKING_RATE_MS 500
#define CTRL_Z 26 //Attach at the end of this message string
// Virtual serial port over USB
USBSerial microUSB;
Serial SIM800L(P0_1, P0_0); //tx, rx
// Serial pc(USBTX, USBRX);
char buf[40];
char buf1[40];
long GSMBAUD = 9600;
// long PCBAUD = 9600;
int main()
{
// Initialise the digital pin LED1 as an output
//DigitalOut led(LED1);
SIM800L.baud(GSMBAUD);
//microUSB.scanf("%s", buf);
SIM800L.puts("AT\r\n");
SIM800L.scanf("%s", buf);
SIM800L.scanf("%s", buf1);
microUSB.printf("%s" , buf);
microUSB.printf("%s\n", buf1);
SIM800L.puts("AT+CMGF=1\r\n");
SIM800L.scanf("%s", buf);
SIM800L.scanf("%s", buf1);
microUSB.printf("%s" , buf);
microUSB.printf("%s\n", buf1);
SIM800L.puts("AT+CMGS=\"17039739276\"\r\n");
wait(0.1f);
SIM800L.printf("This is the automatted program SMS from SIM800L. :D %c\r\n", CTRL_Z);
SIM800L.scanf("%s", buf);
SIM800L.scanf("%s", buf1);
microUSB.printf("%s" , buf);
microUSB.printf("%s\n", buf1);
wait(1);
//pc.printf("Yike");
SIM800L.puts("AT+CMGF=0\r\n");
SIM800L.scanf("%s", buf);
SIM800L.scanf("%s", buf1);
microUSB.printf("%s" , buf);
microUSB.printf("%s\n", buf1);
//led = !led;
// pc.printf("regular serial communication works!");
//microUSB.printf("you typed: %s\r\n",buf);
//microUSB.printf("\x1B[2J"); //clear terminal program screen
// while (SIM800L.readable()){
// microUSB.printf("%c", microUSB.putc((SIM800L.getc())));
//
}