Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Bluetooth_HC05_LE_TRAME.cpp
- Committer:
- aure
- Date:
- 2017-03-18
- Revision:
- 2:7d02a128e1e3
- Parent:
- 1:7cc085e87bb0
- Child:
- 3:8fd068b00d9c
File content as of revision 2:7d02a128e1e3:
#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<4;i++)
{
buffer[compteur]=seriale.getc();
compteur++;
}
}
/* char buffer_copie[compteur];
for(i=0;i<compteur;i++)
{
buffer_copie[i]=buffer[i];
}*/
for(i=0;i<compteur;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);
}