Quang Anh Le
/
SMS
n.n
Revision 0:5fa883d73460, committed 2019-08-05
- Comitter:
- QuangAnhLe
- Date:
- Mon Aug 05 17:47:50 2019 +0000
- Commit message:
- 1. Commit
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Aug 05 17:47:50 2019 +0000 @@ -0,0 +1,61 @@ +#include "mbed.h" +#include <string> + +Serial pc(PA_2,PA_3); // pc comunication +Serial SIM900(PA_9, PA_10); //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"); //at command for send sms + wait_ms(1000); +clearString(); +wait_ms(1000); +SIM900.printf("AT+CMGS="); +SIM900.putc('"'); +SIM900.printf("+4917645651571"); +SIM900.putc('"'); +SIM900.printf("\r"); +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); + + + +wait_ms(10); +sendSMS(); // SEND SMS + wait_ms(100); + + + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Aug 05 17:47:50 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file