Envoi d'un SMS via frdm

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
maxlh23
Date:
Mon Apr 18 15:03:06 2016 +0000
Commit message:
Envoi d'un simple SMS via le microcontrolleur frdm

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
diff -r 000000000000 -r 5ec65dc8f772 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 18 15:03:06 2016 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include <string>
+ 
+Serial pc(USBTX, USBRX); // pc comunication
+Serial SIM900(D1, D0);   //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("+33669345069");
+SIM900.putc('"');
+SIM900.printf("\r");
+wait_ms(1000);
+SIM900.printf("Essai2"); // texte à placer dans le message
+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);
+ 
+sendSMS();  // SEND SMS
+ wait_ms(100);
+ 
+}
+ 
\ No newline at end of file
diff -r 000000000000 -r 5ec65dc8f772 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 18 15:03:06 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/c0f6e94411f5
\ No newline at end of file