liaison bluetooth entre gros robot -> panneau ou gros robot -> petit robot
Fork of liaison_Bluetooth by
LiaisonBluetooth.h@7:543d5548dbb9, 2018-04-13 (annotated)
- Committer:
- duperoux_j
- Date:
- Fri Apr 13 13:00:25 2018 +0000
- Revision:
- 7:543d5548dbb9
- Parent:
- 5:be0c602be047
- Child:
- 14:7118ea22e01f
debug test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duperoux_j | 0:f39d89bfe442 | 1 | #ifndef LIAISON_BLUETOOTH_PANNEAU_GROSROB |
duperoux_j | 0:f39d89bfe442 | 2 | #define LIAISON_BLUETOOTH_PANNEAU_GROSROB |
duperoux_j | 0:f39d89bfe442 | 3 | |
duperoux_j | 5:be0c602be047 | 4 | #define MARQUEUR_DEBUT_TRAME '\x02' |
duperoux_j | 5:be0c602be047 | 5 | #define MARQUEUR_FIN_TRAME '\x04' |
duperoux_j | 0:f39d89bfe442 | 6 | |
duperoux_j | 0:f39d89bfe442 | 7 | #define PAQUET_IDENTIFIANT_RAFRAICHIRSCORE 0x30 //utilisé par le gros robot vers panneau domotique |
duperoux_j | 0:f39d89bfe442 | 8 | #define PAQUET_IDENTIFIANT_FINMATCH 0x31 //utilisé par le gros robot vers panneau domotique |
duperoux_j | 0:f39d89bfe442 | 9 | #define PAQUET_IDENTIFIANT_AJOUTERSCORE 0x32 //utilisé par le petit robot vers gros robot |
duperoux_j | 0:f39d89bfe442 | 10 | |
duperoux_j | 0:f39d89bfe442 | 11 | #include <stdlib.h> |
duperoux_j | 0:f39d89bfe442 | 12 | #include <string.h> |
duperoux_j | 5:be0c602be047 | 13 | #include <math.h> |
duperoux_j | 0:f39d89bfe442 | 14 | #include "mbed.h" |
duperoux_j | 0:f39d89bfe442 | 15 | |
duperoux_j | 0:f39d89bfe442 | 16 | typedef struct { |
duperoux_j | 0:f39d89bfe442 | 17 | int identifiant; |
duperoux_j | 5:be0c602be047 | 18 | unsigned int longueur; |
duperoux_j | 0:f39d89bfe442 | 19 | char *data; |
duperoux_j | 0:f39d89bfe442 | 20 | } PaquetDomotique; |
duperoux_j | 0:f39d89bfe442 | 21 | |
duperoux_j | 5:be0c602be047 | 22 | class LiaisonBluetooth |
duperoux_j | 5:be0c602be047 | 23 | { |
duperoux_j | 5:be0c602be047 | 24 | private: |
duperoux_j | 7:543d5548dbb9 | 25 | Serial *m_bluetooth, *m_pc; |
duperoux_j | 5:be0c602be047 | 26 | bool m_state; |
duperoux_j | 5:be0c602be047 | 27 | |
duperoux_j | 5:be0c602be047 | 28 | public: |
duperoux_j | 7:543d5548dbb9 | 29 | LiaisonBluetooth(Serial *bluetooth, Serial *pc); |
duperoux_j | 5:be0c602be047 | 30 | |
duperoux_j | 5:be0c602be047 | 31 | bool paquet_en_attente(); |
duperoux_j | 5:be0c602be047 | 32 | PaquetDomotique *lire(); |
duperoux_j | 5:be0c602be047 | 33 | |
duperoux_j | 5:be0c602be047 | 34 | void envoyer(char idenfitiant, int longueur_data, char *data); |
duperoux_j | 0:f39d89bfe442 | 35 | }; |
duperoux_j | 0:f39d89bfe442 | 36 | |
duperoux_j | 5:be0c602be047 | 37 | PaquetDomotique *creer_paquetdomotique(int identifiant, unsigned int longueur_data, char *data); |
duperoux_j | 0:f39d89bfe442 | 38 | void detruire_paquetdomotique(PaquetDomotique *paquet); |
duperoux_j | 0:f39d89bfe442 | 39 | |
duperoux_j | 5:be0c602be047 | 40 | char *convertir_int_en_4char(unsigned int integer); |
duperoux_j | 5:be0c602be047 | 41 | unsigned int convertir_4char_en_int(char *data); |
duperoux_j | 0:f39d89bfe442 | 42 | |
duperoux_j | 0:f39d89bfe442 | 43 | #endif |