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

Fork of liaison_Bluetooth by j d

Revision:
9:f69c70d1bd2d
Parent:
8:4b5a472a8f94
--- a/LiaisonBluetooth.cpp	Fri Apr 13 13:04:27 2018 +0000
+++ b/LiaisonBluetooth.cpp	Fri Apr 13 13:14:50 2018 +0000
@@ -32,15 +32,12 @@
     
     wait_ms(10);
     
-    if (m_bluetooth->readable() && m_state) {
-        identifiant = m_bluetooth->getc();
-    } else { m_pc->printf("error identifiant %d\n", identifiant); return NULL; }
-
+    identifiant = m_bluetooth->getc();
+    m_pc->printf("identifiant %x\n", identifiant);
+    
     char buffer_longueur_paquet[4];
     for (int i = 0 ; i < 4 ; i++) {
-        if (m_bluetooth->readable() && m_state) {
-            buffer_longueur_paquet[i] = m_bluetooth->getc();
-        } else { m_pc->printf("error buffer_longueur_paquet %d\n", i); return NULL; }
+        buffer_longueur_paquet[i] = m_bluetooth->getc();
     }
     unsigned short longueur_paquet = atoi(buffer_longueur_paquet);
     
@@ -51,7 +48,7 @@
     char buffer_data[longueur_paquet];
     int index = 0;
     while (index < longueur_paquet) {
-        if (m_bluetooth->readable() && m_state) {
+        if (m_bluetooth->readable() && m_state) { //wtf readable() not always working ?! removed almost all
             char c = m_bluetooth->getc();
             
             m_pc->printf("%x\n", c);
@@ -75,7 +72,7 @@
     m_bluetooth->putc(idenfitiant);
 
     //char *longueur_buffer = convertir_int_en_4char(longueur_data);
-    char str[4]; 
+    char str[4] = {0, 0, 0, 0}; 
     sprintf(str,"%d", longueur_data);
     for (int i = 0 ; i < 4 ; i++) {
         m_bluetooth->putc(str[i]);