Open focussing opened 7 years ago
You have to add the event listener on the latest peripheral you get
centralManager.addEventListener('didConnectPeripheral', function(e) {
console.log('\ndidConnectPeripheral');
console.log(e);
console.log(e.peripheral);
centralManager.stopScan();
connectedPeripheral = e.peripheral;
connectedPeripheral.addEventListener('didDiscoverServices', function(e) {
console.log('\ndidDiscoverServices');
console.log(e);
console.log(e.peripheral);
console.log(e.peripheral.services);
var peripheral = e.peripheral;
peripheral.addEventListener('didDiscoverCharacteristicsForService', function(e) {
console.log('didDiscoverCharacteristicsForService');
console.log(e);
});
peripheral.services.forEach(function(service) {
peripheral.discoverCharacteristicsForService({ service: service });
});
});
connectedPeripheral.discoverServices();
});
I am doing that, please take a look at https://github.com/hansemannn/titanium-bluetooth/issues/23
I updated that issue today.
I am struggling to implement the following
Next I want to get the UUIDs from the services, and subscribe to let's say one of them My code so far: