bad

Dependencies:   mbed USBDevice

Committer:
kchhouk
Date:
Fri Feb 21 20:35:47 2020 +0000
Revision:
0:5c1655777e38
not working

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kchhouk 0:5c1655777e38 1 #include "mbed.h"
kchhouk 0:5c1655777e38 2 #include "USBSerial.h"
kchhouk 0:5c1655777e38 3 //#include "string.h"
kchhouk 0:5c1655777e38 4
kchhouk 0:5c1655777e38 5 // Blinking rate in milliseconds
kchhouk 0:5c1655777e38 6 #define BLINKING_RATE_MS 500
kchhouk 0:5c1655777e38 7 #define CTRL_Z 26 //Attach at the end of this message string
kchhouk 0:5c1655777e38 8
kchhouk 0:5c1655777e38 9 // Virtual serial port over USB
kchhouk 0:5c1655777e38 10 USBSerial microUSB;
kchhouk 0:5c1655777e38 11 Serial SIM800L(P0_1, P0_0); //tx, rx
kchhouk 0:5c1655777e38 12 // Serial pc(USBTX, USBRX);
kchhouk 0:5c1655777e38 13 char buf[40];
kchhouk 0:5c1655777e38 14 char buf1[40];
kchhouk 0:5c1655777e38 15 long GSMBAUD = 9600;
kchhouk 0:5c1655777e38 16 // long PCBAUD = 9600;
kchhouk 0:5c1655777e38 17
kchhouk 0:5c1655777e38 18 int main()
kchhouk 0:5c1655777e38 19 {
kchhouk 0:5c1655777e38 20 // Initialise the digital pin LED1 as an output
kchhouk 0:5c1655777e38 21 //DigitalOut led(LED1);
kchhouk 0:5c1655777e38 22
kchhouk 0:5c1655777e38 23 SIM800L.baud(GSMBAUD);
kchhouk 0:5c1655777e38 24 //microUSB.scanf("%s", buf);
kchhouk 0:5c1655777e38 25 SIM800L.puts("AT\r\n");
kchhouk 0:5c1655777e38 26 SIM800L.scanf("%s", buf);
kchhouk 0:5c1655777e38 27 SIM800L.scanf("%s", buf1);
kchhouk 0:5c1655777e38 28 microUSB.printf("%s" , buf);
kchhouk 0:5c1655777e38 29 microUSB.printf("%s\n", buf1);
kchhouk 0:5c1655777e38 30
kchhouk 0:5c1655777e38 31 SIM800L.puts("AT+CMGF=1\r\n");
kchhouk 0:5c1655777e38 32 SIM800L.scanf("%s", buf);
kchhouk 0:5c1655777e38 33 SIM800L.scanf("%s", buf1);
kchhouk 0:5c1655777e38 34 microUSB.printf("%s" , buf);
kchhouk 0:5c1655777e38 35 microUSB.printf("%s\n", buf1);
kchhouk 0:5c1655777e38 36
kchhouk 0:5c1655777e38 37 SIM800L.puts("AT+CMGS=\"17039739276\"\r\n");
kchhouk 0:5c1655777e38 38
kchhouk 0:5c1655777e38 39 wait(0.1f);
kchhouk 0:5c1655777e38 40
kchhouk 0:5c1655777e38 41 SIM800L.printf("This is the automatted program SMS from SIM800L. :D %c\r\n", CTRL_Z);
kchhouk 0:5c1655777e38 42
kchhouk 0:5c1655777e38 43 SIM800L.scanf("%s", buf);
kchhouk 0:5c1655777e38 44 SIM800L.scanf("%s", buf1);
kchhouk 0:5c1655777e38 45 microUSB.printf("%s" , buf);
kchhouk 0:5c1655777e38 46 microUSB.printf("%s\n", buf1);
kchhouk 0:5c1655777e38 47
kchhouk 0:5c1655777e38 48 wait(1);
kchhouk 0:5c1655777e38 49
kchhouk 0:5c1655777e38 50 //pc.printf("Yike");
kchhouk 0:5c1655777e38 51 SIM800L.puts("AT+CMGF=0\r\n");
kchhouk 0:5c1655777e38 52 SIM800L.scanf("%s", buf);
kchhouk 0:5c1655777e38 53 SIM800L.scanf("%s", buf1);
kchhouk 0:5c1655777e38 54 microUSB.printf("%s" , buf);
kchhouk 0:5c1655777e38 55 microUSB.printf("%s\n", buf1);
kchhouk 0:5c1655777e38 56 //led = !led;
kchhouk 0:5c1655777e38 57 // pc.printf("regular serial communication works!");
kchhouk 0:5c1655777e38 58 //microUSB.printf("you typed: %s\r\n",buf);
kchhouk 0:5c1655777e38 59 //microUSB.printf("\x1B[2J"); //clear terminal program screen
kchhouk 0:5c1655777e38 60 // while (SIM800L.readable()){
kchhouk 0:5c1655777e38 61 // microUSB.printf("%c", microUSB.putc((SIM800L.getc())));
kchhouk 0:5c1655777e38 62 //
kchhouk 0:5c1655777e38 63 }
kchhouk 0:5c1655777e38 64