sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
462 stars 179 forks source link

Unable to WriteWIthoutResponse to BLECharacteristic from Central #123

Closed cbolgiano closed 7 years ago

cbolgiano commented 7 years ago

I am unable to write to a local BLECharacteristic in my BLEPeripheral from central. I tried using the BLEWritten event but I never end up in the body of the bound function. Good news though is that I am able to connect successfully to the device from central and handle the connects and disconnects using the BLEConnected and BLEDisconnected events no problem. I figure I am missing something at the fundamental level or misunderstanding how to use this library. I attached the source code of my central which is a cordova android application using https://github.com/don/cordova-plugin-ble-central for my central. The hardware for the peripheral that I am using is: https://tinycircuits.com/collections/all/products/tinyscreenplus and https://tinycircuits.com/collections/all/products/bluetooth-low-energy-nordic-tinyshield. I have been able to write to the peripheral successfully using your UART example using the same setup but I would like to use GATT instead. Please help if you have time. I have been stuck for almost 3 weeks. src.zip

"

sandeepmistry commented 7 years ago

@cbolgiano please see: https://github.com/sandeepmistry/arduino-BLEPeripheral/blob/master/API.md#contructor

I think you are just missing the BLEWriteWithoutResponse, so change:

BLECharacteristic timeCharacteristic = BLECharacteristic("CCC2", BLERead | BLEWrite, 20);

to

BLECharacteristic timeCharacteristic = BLECharacteristic("CCC2", BLERead | BLEWrite | BLEWriteWithoutResponse, 20);