tushar bhanarkar
/
gsm_SET
SIM900A
main.cpp
- Committer:
- tusharbhanarkar
- Date:
- 2017-04-18
- Revision:
- 0:f07c569c074c
File content as of revision 0:f07c569c074c:
#include "mbed.h" #include <string> Serial pc(USBTX, USBRX); // pc comunication Serial SIM900(p13, p14); //tx, rx SIM 900 string result; char x; void clearString() { result.clear(); } void callback_rx() { while (SIM900.readable()) { x = SIM900.getc(); result += x; pc.putc(x); // print the answer from SIM900 } } void sendSMS() { clearString(); SIM900.printf("AT+CMGF=1\r\n"); //at command for send sms wait_ms(1000); clearString(); wait_ms(1000); SIM900.printf("AT+CMGS="); SIM900.putc('"'); SIM900.printf("+919405204727"); SIM900.putc('"'); SIM900.printf("\r"); SIM900.printf("\n"); wait_ms(1000); SIM900.printf("test1"); wait_ms(1000); SIM900.putc(0x1A); wait_ms(5000); } int main() { pc.printf("\r\n GSM 900 TEST\n"); SIM900.attach(&callback_rx); SIM900.baud(9600); // wait_ms(100); while(1) { wait_ms(10); sendSMS(); // SEND SMS wait_ms(100); } }