librairie nopn objet

Revision:
0:87b461d3fda2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 23 20:13:29 2022 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include "sim800l-c.h"
+
+
+
+// Blinking rate in milliseconds
+#define BLINKING_RATE_MS 500
+RawSerial pc(USBTX,USBRX);
+Ticker PostSms;
+bool envoi30s;
+void post()
+{
+    envoi30s = true;
+}
+int main()
+{
+    envoi30s = false;
+    pc.baud(921600);
+    pc.printf("Bonjour\r\n");
+    pc.printf("Patientez init sim800l : ");
+    if (sim800linit(115200)) pc.printf("ok.\r\n");
+    else pc.printf("Erreur.\r\n");
+    pc.printf("Efface all SMS : ");
+    if (sim800lsmsclearall()) pc.printf("ok.\r\n");
+    else pc.printf("Erreur.\r\n");
+    pc.printf("Envoi Sms : ");
+    if (sim800lsendsms("+33xxxxxxxxx","Test Sms")) pc.printf("ok;\r\n");
+    else pc.printf("erreur;\r\n");
+    // Initialise the digital pin LED1 as an output
+    DigitalOut led(LED1);
+    PostSms.attach(&post,30);
+    while (true) {
+        //      led = !led;
+        //      thread_sleep_for(BLINKING_RATE_MS);
+        if (envoi30s) {
+            pc.printf("Envoi sms 30s : ");
+            if (sim800lsendsms("+33xxxxxxxxx","30s")) pc.printf("ok.\r\n");
+            else pc.printf("erreur.\r\n");
+            envoi30s = false;
+        }
+        if (sim800lsmsready()) {
+            led = 1;
+            pc.printf("Recois SMS, index : %d\r\n",sim800lIndexSmsRecu());
+            sim800lreadsms(sim800lIndexSmsRecu());
+            pc.printf("Texte sms recu --- \r\n%s\r\n",sim800lreadtextesms());
+            pc.printf("Reponse SMS : ");
+            if (sim800lsendsms("+33xxxxxxxxx",sim800lreadtextesms())) pc.printf("ok.\r\n");
+            else pc.printf("erreur.\r\n");
+            led = 0;
+        }
+    }
+}