New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
didUpdateValueForCharacteristic event failing #275
Comments
searching for the error message I guess you are trying to implement it on Android, right? It should show you:
(source) with false as |
@m1ga Thank you for the above information. I ran a build with We cloned the centralManager.js and peripheralChannel.js files from the example and nothing much is changed on them. Here's where the error occurs on the peripheralChannel.js appcelerator.ble/example/peripheralChannel.js Line 215 in ff1591f
The BLE chip(peripheral) that we are connecting to only has a notify property on its characteristic, so maybe calling appcelerator.ble/example/peripheralChannel.js Line 388 in ff1591f
|
have a look at this code: cmgr.addEventListener('didDiscoverPeripheral', function(e) {
cmgr.connectPeripheral({
peripheral: e.peripheral,
options: {
[BLE.CONNECT_PERIPHERAL_OPTIONS_KEY_NOTIFY_ON_CONNECTION]: true,
[BLE.CONNECT_PERIPHERAL_OPTIONS_KEY_NOTIFY_ON_DISCONNECTION]: true
}
});
});
cmgr.addEventListener('didConnectPeripheral', function(e) {
peripheral = e.peripheral;
peripheral.addEventListener('didDiscoverServices', function(e) {
var services = e.source.services;
services.forEach(function(service) {
if (service.uuid.toUpperCase() == 'DEVICE_UUID') {
e.source.discoverCharacteristics({
characteristics: [],
service: service
});
}
});
peripheral.addEventListener('didDiscoverCharacteristics', function(e) {
var peripheral = e.peripheral;
var characteristics = e.service.characteristics;
characteristics.forEach(function(characteristic) {
function _didUpdateValueForCharacteristic(e) {}
function _didReadValue(e) {}
if (characteristic.uuid == 'CHAR_UUID') {
global.charactersticObject = characteristic;
peripheral.subscribeToCharacteristic({
characteristic: characteristic,
descriptorUUID: BLE.CBUUID_CLIENT_CHARACTERISTIC_CONFIGURATION_STRING,
descriptorValue: BLE.ENABLE_NOTIFICATION_VALUE
});
peripheral.readValueForCharacteristic(characteristic);
peripheral.addEventListener('didReadValueForCharacteristic', _didReadValue);
peripheral.addEventListener('didUpdateValueForCharacteristic', _didUpdateValueForCharacteristic);
}
});
});
peripheral.addEventListener('didUpdateValueForCharacteristic', function(e) {});
peripheral.discoverServices();
});
});
cmgr.startScan(); I had that in an example file. That should be the correct flow |
We are working on a BLE app that acts as a Central and connects to a chip(peripheral). The peripheral contains a service and a characteristic and the characteristic contains a notify property. After calling
peripheral.subscribeToCharacteristic()
andperipheral.readValueForCharacteristic()
methods, it subscribes successfully with thedidUpdateNotificationStateForCharacteristics
event, however errors out on thedidUpdateValueForCharacteristic
event. The error message is:257: failed to initiate reading characteristic for peripheral name
The text was updated successfully, but these errors were encountered: