Simple data send /receive via BLE (Redbear Duo)


#1

I am trying to implement a simple circuit where mobile user sends 0 or 1 to Red Bear duo via BLE. This is very simple with standard Bluetooth but the BLE examples in github for Redbear Duo do not have such functionality and all empty inside loop(). I tried adding the code below in loop but code fails to compile so can not test on device

Using SimpleChat.ino example

....

....    

void loop() {
    
     if(ble.readValue() == '1')
     {
        Serial.println("LED on");
        digitalWrite(ledPin, HIGH);    
     }
    
     if(ble.readValue() == '0')
     {
        Serial.println("LED off");
        digitalWrite(ledPin, LOW);    
     }
    
}

#2

Hi @danmally,

The SimpleChat is an example of BLE Peripheral. For BLE Peripheral, it usually acts as a GATT Server. So you can not call the GATT Client APIs in this example. To handle the data that is sent from mobile App, please refer to this APIs: https://github.com/redbear/Duo/blob/master/docs/programming_reference_manual.md#ondatawritecallback.

Best regards,
guohui