device is already connected and discovered, but somehow the monitorCharacteristicForDevice callback not firing at all and im just stuck without response. I'm currently using react-native 0.73.9 with react-native-ble-plx 3.5.0
manager.startDeviceScan(null, null, (error, device) => {
if (error) {
// Handle error (scanning will be stopped automatically)
setState({
isSyncing: false,
});
return;
}
console.log(device?.name);
// Check if it is a device you are looking for based on advertisement data
// or other criteria.
if (device && device.name && device.name.includes("WeLock")) {
// Stop scanning as it's not necessary if you are scanning for one device.
console.log("found welock device", device.name);
manager.stopDeviceScan();
manager
.connectToDevice(device.id)
.then((device) => {
console.log("device connected", device);
return device.discoverAllServicesAndCharacteristics();
})
.then((device) => {
console.log("monitor...", device.id);
// Once connected, read the specific characteristic value
manager.monitorCharacteristicForDevice(
device.id,
SERVICE_UUID,
NOTIFY_CHARACTER,
(err, characteristic) => {
console.log({ err, characteristic });
}
);
Prerequisites
Question
device is already connected and discovered, but somehow the monitorCharacteristicForDevice callback not firing at all and im just stuck without response. I'm currently using react-native 0.73.9 with react-native-ble-plx 3.5.0
Is there anything that I did wrong? thank you in advance
Question related code
manager.startDeviceScan(null, null, (error, device) => { if (error) { // Handle error (scanning will be stopped automatically) setState({ isSyncing: false, }); return; } console.log(device?.name); // Check if it is a device you are looking for based on advertisement data // or other criteria. if (device && device.name && device.name.includes("WeLock")) { // Stop scanning as it's not necessary if you are scanning for one device. console.log("found welock device", device.name); manager.stopDeviceScan(); manager .connectToDevice(device.id) .then((device) => { console.log("device connected", device); return device.discoverAllServicesAndCharacteristics(); }) .then((device) => { console.log("monitor...", device.id); // Once connected, read the specific characteristic value manager.monitorCharacteristicForDevice( device.id, SERVICE_UUID, NOTIFY_CHARACTER, (err, characteristic) => { console.log({ err, characteristic }); } );