Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "platform/mbed_thread.h" 00003 #include "sim800l-c.h" 00004 00005 00006 00007 // Blinking rate in milliseconds 00008 #define BLINKING_RATE_MS 500 00009 RawSerial pc(USBTX,USBRX); 00010 Ticker PostSms; 00011 bool envoi30s; 00012 void post() 00013 { 00014 envoi30s = true; 00015 } 00016 int main() 00017 { 00018 envoi30s = false; 00019 pc.baud(921600); 00020 pc.printf("Bonjour\r\n"); 00021 pc.printf("Patientez init sim800l : "); 00022 if (sim800linit(115200)) pc.printf("ok.\r\n"); 00023 else pc.printf("Erreur.\r\n"); 00024 pc.printf("Efface all SMS : "); 00025 if (sim800lsmsclearall()) pc.printf("ok.\r\n"); 00026 else pc.printf("Erreur.\r\n"); 00027 pc.printf("Envoi Sms : "); 00028 if (sim800lsendsms("+33xxxxxxxxx","Test Sms")) pc.printf("ok;\r\n"); 00029 else pc.printf("erreur;\r\n"); 00030 // Initialise the digital pin LED1 as an output 00031 DigitalOut led(LED1); 00032 PostSms.attach(&post,30); 00033 while (true) { 00034 // led = !led; 00035 // thread_sleep_for(BLINKING_RATE_MS); 00036 if (envoi30s) { 00037 pc.printf("Envoi sms 30s : "); 00038 if (sim800lsendsms("+33xxxxxxxxx","30s")) pc.printf("ok.\r\n"); 00039 else pc.printf("erreur.\r\n"); 00040 envoi30s = false; 00041 } 00042 if (sim800lsmsready()) { 00043 led = 1; 00044 pc.printf("Recois SMS, index : %d\r\n",sim800lIndexSmsRecu()); 00045 sim800lreadsms(sim800lIndexSmsRecu()); 00046 pc.printf("Texte sms recu --- \r\n%s\r\n",sim800lreadtextesms()); 00047 pc.printf("Reponse SMS : "); 00048 if (sim800lsendsms("+33xxxxxxxxx",sim800lreadtextesms())) pc.printf("ok.\r\n"); 00049 else pc.printf("erreur.\r\n"); 00050 led = 0; 00051 } 00052 } 00053 }
Generated on Fri Jul 22 2022 18:13:47 by
1.7.2