Duo BLE Central writeValue example


I am running the BLE Central example and need to writeValue to the connected peripheral.

The value I need to write is 0x9100
The tx characteristic on the peripheral is

here is the code snippet… I am attempting to use.
uint8_t data[]= {0x91,0x00};
ble.writeValue(device.connected_handle, device.service.chars[0].chars.value_handle, 20, data);

The following is some Serial.print’s for the device.connected_handle and device.service.chars[0].char.value_handle.
characteristic start handle: D
characteristic value handle: E
characteristic end_handle: E
characteristic properties: C
characteristic uuid16: 0
characteristic uuid128 : 99 FA 0 2 33 8A 10 24 8A 49 0 9C 2 15 F7 8A

The following is from the reference manual.
// The connection handle can be obtained in the connected callback function
static uint16_t conn_handle;
// The characteristic value attribute handle can be obtained in the characteristic discovered callback function
static uint16_t char_value_handle;
static uint8_t data[20] = { … };
ble.writeValue(conn_handle, char_value_handle, 20, data);

Not sure what the issue is? It appears I am following the guidelines, any suggestions?


Have you tested our SimpleBLECentral & SimpleBLEPeripheral for Duo?


Yes, notice in my first sentence “I am running the BLE Central example and need to writeValue to the connected peripheral.”

Neither Simple examples actually use the writeValue. I am asking for an example where BLECentral connects to a BLEPeripheral and uses the ble.writeValue(conn_handle, char_value_handle, 20, data) function. The example needs to have the BLECentral running on the RedBear Duo, and the Peripheral may be some other device, perhaps iPhone, Android, or nRF52 Bluefruit LE.


Typically, the mobile phone act as a BLE Central device and the device act as a BLE Peripheral.

When Central wants to send data, it will just write directly to a Peripheral’s “write” characteristic. On the other hand, BLE Peripheral will “notify” or “indicate” to BLE Central before it send data over.

gattReadCallback does use ble.writeValue to send out data in the SimpleBLECentral sketch.