Sim800L loib obj sms

Committer:
schnf30
Date:
Sat Apr 30 20:07:22 2022 +0000
Revision:
1:2e6fa015734c
Parent:
0:5c39ec4eaaa1
VERS

Who changed what in which revision?

UserRevisionLine numberNew contents of line
schnf30 0:5c39ec4eaaa1 1 #ifndef _sim800l_
schnf30 0:5c39ec4eaaa1 2 #define _sim800l_
schnf30 0:5c39ec4eaaa1 3 #include "mbed.h"
schnf30 0:5c39ec4eaaa1 4
schnf30 0:5c39ec4eaaa1 5 #define maxdata 1000
schnf30 0:5c39ec4eaaa1 6 #define timeoutdefaut 1
schnf30 0:5c39ec4eaaa1 7 #define timeoutsendsms 60
schnf30 0:5c39ec4eaaa1 8 #define timeoutreadsms 5
schnf30 0:5c39ec4eaaa1 9 #define timewaitCallready 10
schnf30 0:5c39ec4eaaa1 10 #define timewaitSmsready 60
schnf30 0:5c39ec4eaaa1 11 #define timewaitSmsallclear 25
schnf30 0:5c39ec4eaaa1 12 #define timewaitCCID 2
schnf30 0:5c39ec4eaaa1 13
schnf30 0:5c39ec4eaaa1 14 extern RawSerial pc;
schnf30 0:5c39ec4eaaa1 15
schnf30 0:5c39ec4eaaa1 16 class Sim800l
schnf30 0:5c39ec4eaaa1 17 {
schnf30 0:5c39ec4eaaa1 18 public:
schnf30 0:5c39ec4eaaa1 19 /*
schnf30 0:5c39ec4eaaa1 20 * Constructor
schnf30 0:5c39ec4eaaa1 21 *
schnf30 0:5c39ec4eaaa1 22 * @param tx mbed pin to use for tx line of Serial interface
schnf30 0:5c39ec4eaaa1 23 * @param rx mbed pin to use for rx line of Serial interface
schnf30 0:5c39ec4eaaa1 24 * @param reset reset pin of the wifi module ()
schnf30 0:5c39ec4eaaa1 25 */
schnf30 0:5c39ec4eaaa1 26 Sim800l(PinName tx, PinName rx, PinName resetpin, int baudrate=9600);
schnf30 0:5c39ec4eaaa1 27 bool init();
schnf30 0:5c39ec4eaaa1 28 bool smsready(void);
schnf30 0:5c39ec4eaaa1 29 bool sendsms(const char *phonenumber,const char *data);
schnf30 0:5c39ec4eaaa1 30 bool readsms(int index);
schnf30 0:5c39ec4eaaa1 31 bool smsclearall(void);
schnf30 0:5c39ec4eaaa1 32 int IndexSmsRecu(void);
schnf30 0:5c39ec4eaaa1 33 char *readtextesms();
schnf30 0:5c39ec4eaaa1 34
schnf30 0:5c39ec4eaaa1 35 protected:
schnf30 0:5c39ec4eaaa1 36 RawSerial serial;
schnf30 0:5c39ec4eaaa1 37 DigitalOut reset;
schnf30 1:2e6fa015734c 38 char *_DataTmp; // tableau de donnees pour stocker pendant reception
schnf30 1:2e6fa015734c 39 char *_Data; // tableau de donnees lorsque toutes les donnees sont recues
schnf30 1:2e6fa015734c 40 char *_DataSms; // tableau de donnees lorsque toutes les donnees sont recues
schnf30 1:2e6fa015734c 41 char *_Phrase; // pour convertir en phrase avant envoi
schnf30 0:5c39ec4eaaa1 42 /*
schnf30 0:5c39ec4eaaa1 43 char _DataTmp[maxdata + 1]; // tableau de donnees pour stocker pendant reception
schnf30 0:5c39ec4eaaa1 44 char _Data[maxdata + 1]; // tableau de donnees lorsque toutes les donnees sont recues
schnf30 0:5c39ec4eaaa1 45 char _DataSms[maxdata + 1]; // tableau de donnees lorsque toutes les donnees sont recues
schnf30 0:5c39ec4eaaa1 46 char _Phrase[maxdata + 1]; // pour convertir en phrase avant envoi
schnf30 0:5c39ec4eaaa1 47 */
schnf30 0:5c39ec4eaaa1 48 volatile int _DataPtr = 0; // position de stockage de la prochaine donnee a recevoir
schnf30 0:5c39ec4eaaa1 49 volatile bool _DataReady = false;
schnf30 0:5c39ec4eaaa1 50 volatile bool _SmsReady = false;
schnf30 0:5c39ec4eaaa1 51 volatile int _IndexSms;
schnf30 0:5c39ec4eaaa1 52 Timeout _timeout; // permet deviter blocage en attente
schnf30 0:5c39ec4eaaa1 53 volatile bool FinTimeOut;
schnf30 0:5c39ec4eaaa1 54 bool dataready(void);
schnf30 0:5c39ec4eaaa1 55 char * read(void);
schnf30 0:5c39ec4eaaa1 56 void receive();
schnf30 0:5c39ec4eaaa1 57 void Ftimeout();
schnf30 0:5c39ec4eaaa1 58 void SetTimeout(float delay);
schnf30 0:5c39ec4eaaa1 59 // attente r eponse dans *reponse
schnf30 0:5c39ec4eaaa1 60 bool waitreponse(const char *reponse,float timeout);
schnf30 0:5c39ec4eaaa1 61 // envoi commande et attend reponse
schnf30 0:5c39ec4eaaa1 62 bool writecmdandwaitreponse(const char *data, const char *reponse,float timeout);
schnf30 0:5c39ec4eaaa1 63 // attente r eponse dans *reponse
schnf30 0:5c39ec4eaaa1 64 bool waitsmsreponse(const char *reponse,float timeout);
schnf30 0:5c39ec4eaaa1 65 };
schnf30 0:5c39ec4eaaa1 66 #endif