liaison bluetooth entre gros robot -> panneau ou gros robot -> petit robot

Fork of liaison_Bluetooth by j d

LiaisonBluetooth.h

Committer:
duperoux_j
Date:
2018-04-11
Revision:
3:46a9b9c1e1c0
Parent:
1:ea044def4e89
Child:
5:be0c602be047

File content as of revision 3:46a9b9c1e1c0:

#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