n.n

Dependencies:   mbed

Revision:
0:5fa883d73460
diff -r 000000000000 -r 5fa883d73460 main.cpp
--- /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);
+ 
+
+ 
+}