liaison bluetooth entre gros robot -> panneau ou gros robot -> petit robot
Fork of liaison_Bluetooth by
Diff: LiaisonBluetooth.h
- Revision:
- 1:ea044def4e89
- Parent:
- 0:f39d89bfe442
- Child:
- 3:46a9b9c1e1c0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LiaisonBluetooth.h Wed Apr 11 12:33:54 2018 +0000 @@ -0,0 +1,40 @@ +#ifndef LIAISON_BLUETOOTH_PANNEAU_GROSROB +#define LIAISON_BLUETOOTH_PANNEAU_GROSROB + +#define MARQUEUR_DEBUT_TRAME 0x2 +#define MARQUEUR_FIN_TRAME 0x4 + +#define PAQUET_IDENTIFIANT_RAFRAICHIRSCORE 0x30 //utilisé par le gros robot vers panneau domotique +#define PAQUET_IDENTIFIANT_FINMATCH 0x31 //utilisé par le gros robot vers panneau domotique +#define PAQUET_IDENTIFIANT_AJOUTERSCORE 0x32 //utilisé par le petit robot vers gros robot + +#include <stdlib.h> +#include <string.h> +#include "mbed.h" + +typedef struct { + int identifiant; + char *data; +} PaquetDomotique; + +class LiaisonBluetooth { + private: + Serial m_bluetooth; + DigitalIn m_state; + + public: + LiaisonBluetooth(Serial bluetooth, DigitalIn state); + + bool paquet_en_attente(); + PaquetDomotique *lire(); + + void envoyer(char idenfitiant, int longueur_data, char *data); +}; + +PaquetDomotique *creer_paquetdomotique(int identifiant, char *data); +void detruire_paquetdomotique(PaquetDomotique *paquet); + +char *convertir_int_en_4char(int integer); +int convertir_4char_en_int(char *data); + +#endif