jhuh
Bluetooth_HC05_LE_TRAME.cpp
- Committer:
- aure
- Date:
- 2017-03-19
- Revision:
- 4:f597583e8b55
- Parent:
- 3:8fd068b00d9c
File content as of revision 4:f597583e8b55:
#include "Bluetooth_HC05_LE_TRAME.h" //#define BAUDS 38400 #define BAUDS 9600 //constante bauds 9600 #define nb_caractere_max 10 #define TX p13 #define RX p14 Serial seriale(TX,RX,MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); Bluetooth_HC05_LE_TRAME::Bluetooth_HC05_LE_TRAME() { seriale.baud(BAUDS); seriale.format(8,SerialBase::None,1); this->flush='t'; this->resetBuffer(); } Bluetooth_HC05_LE_TRAME::~Bluetooth_HC05_LE_TRAME() { } void Bluetooth_HC05_LE_TRAME::envoyer(char* envoi) { seriale.puts(envoi); wait(1); } void Bluetooth_HC05_LE_TRAME::recevoir() //1 ere tentative { //char* recu=NULL; int i=0; int compteur=0; char buffer[20]; ///////////////////////////////////////////////OK rematrre apres if(seriale.readable()) { for(i=0;i<longueur_trame;i++) { buffer[compteur]=seriale.getc(); // this->buf[i]=buffer[i]; //rajouter // this->buf[i]=seriale.getc(); // compteur++; } } char buffer_copie[compteur]; for(i=0;i<compteur;i++) { //buffer_copie[i]=buffer[i]; this->buf[i]=buffer[i]; } //recu=buffer; //strcpy(recu,buffer_copie); // this->resetBuffer(); // char*recu=&buffer_copie[0]; // return(recu); } ///////////////////////////////// void Bluetooth_HC05_LE_TRAME::resetBuffer() { char flu; while(seriale.readable()) { flu = seriale.getc(); } } int Bluetooth_HC05_LE_TRAME::donneesRecue() { int ok=0; if(seriale.readable()) ok=1; return ok; } char* Bluetooth_HC05_LE_TRAME::getBuf() { return(this->buf); } int Bluetooth_HC05_LE_TRAME::getLongueurTrame() { return(longueur_trame); }