Hello Team,
I am trying to develop an app with BLE example as the base and modifying it.
Hardware setup:
PC - Windows 10, nRF Connect launcher v3.6.1, BLE example app, nRF52840 Dongle connected to PC
Peripheral - A small device with a sensor and a nRF52840 SoC transmitting sensor data
After I connect my device as shown in the picture below. the services are discovered and shown automatically.
When I click on a service , it expands and shows the characteristics normally after being connected.
I tried to do this manually via the clicking on UI, as I wanted to discover the characteristics of a service to start using it.
I have tried writing functions to extract characteristics and descriptors in the modified BLE app.
Below is a function to extract Characteristics
extractChar(service, uuid) { const { device, deviceDetails } = this.props; const { instanceId } = device; let retval; if (service) { const deviceDetail = deviceDetails.devices.get(instanceId); if (!deviceDetail.discoveringChildren) { const chars = service.get('children'); if (chars) { chars.forEach(char => { if (char.uuid === uuid) { retval = char; }// if (char.uuid === uuid) }); }// if (chars) }// if (!deviceDetail.discoveringChildren) }// if (service) return retval; }
Below is a function to extract descriptors
extractDescriptor(char, uuid) {
const { device, deviceDetails } = this.props;
const { instanceId } = device;
let retval;
if (char) {
const deviceDetail = deviceDetails.devices.get(instanceId);
if (!deviceDetail.discoveringChildren) {
const descs = char.get('children');
if (descs) {
descs.forEach(desc => {
if (desc.uuid === uuid) {
retval = desc;
}// if (desc.uuid === uuid)
});
}// if (descs)
}// if (!deviceDetail.discoveringChildren)
}// if (char)
return retval;
}
I have written 4 custom services and they are call using the functions above in an identical way for all the services.
While the above functions do work, but for some reason they always only expand one service and the rest of the services using the same method have 'children' : undefined.
I have tried several times and using several methods. The first custom service expands and the rest are stuck in an endless loop as shown below. They never load and are stuck as such.
Can anyone help or suggest what might be wrong or if there is any other way for me to expand the characteristics and descriptors for my custom services ?
Thanks and regards,
Avi