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.
Diff: Bluetooth_HC05_LE_TRAME.cpp
- Revision:
- 1:7cc085e87bb0
- Parent:
- 0:092ac281a013
- Child:
- 2:7d02a128e1e3
--- a/Bluetooth_HC05_LE_TRAME.cpp Wed Mar 15 10:43:27 2017 +0000
+++ b/Bluetooth_HC05_LE_TRAME.cpp Fri Mar 17 18:14:59 2017 +0000
@@ -1,6 +1,5 @@
#include "Bluetooth_HC05_LE_TRAME.h"
-#include "mbed.h"
-#include "m3pi.h"
+
//#define BAUDS 38400
#define BAUDS 9600 //constante bauds 9600
@@ -8,7 +7,7 @@
#define TX p13
#define RX p14
-m3pi mmm;
+
Serial seriale(TX,RX,MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
@@ -19,7 +18,7 @@
seriale.baud(BAUDS);
seriale.format(8,SerialBase::None,1);
this->flush='t';
- this->resetBuffer();
+ this->resetBuffer();
}
Bluetooth_HC05_LE_TRAME::~Bluetooth_HC05_LE_TRAME()
@@ -34,11 +33,11 @@
wait(1);
}
-char* Bluetooth_HC05_LE_TRAME::recevoir(int longueur) //1 ere tentative
+char Bluetooth_HC05_LE_TRAME::recevoir(int longueur) //1 ere tentative
{
- char* recu=NULL;
+ //char* recu=NULL;
- if (seriale.readable()) {
+
int i=0;
@@ -46,13 +45,13 @@
char buffer[20];
///////////////////////////////////////////////OK rematrre apres
- while(seriale.readable()==1)
+ if(seriale.readable())
{
- for(i=0;i<longueur;i++)
- {
+ // for(i=0;i<longueur;i++)
+ // {
buffer[compteur]=seriale.getc();
compteur++;
- }
+ // }
}
char buffer_copie[compteur];
@@ -62,28 +61,36 @@
//recu=buffer;
- strcpy(recu,buffer_copie);
+ //strcpy(recu,buffer_copie);
- }
- else
- {
- recu="0";
- }
- this->resetBuffer();
+
+ // this->resetBuffer();
+ // char*recu=&buffer_copie[0];
+ char recu= buffer_copie[0];
return(recu);
}
+
/////////////////////////////////
void Bluetooth_HC05_LE_TRAME::resetBuffer()
{
+ char flu;
while(seriale.readable())
{
- this->flush = seriale.getc();
+ flu = seriale.getc();
}
}
+
+int Bluetooth_HC05_LE_TRAME::donneesRecue()
+{
+ int ok=0;
+ if(seriale.readable())
+ ok=1;
+ return ok;
+}