This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issues with characteristic values using the pc-ble-driver-py library

Hello!

I am doing some development with pc-ble-driver-py and ran in to some unexpected behaviours when reading characteristics. I have been modifying the nus_collector.py script that was given as an example on this post. I am also using a PCA10028 to scan for devices.

Firstly, when scanning for devices, they last few characters for some devices are missing or corrupted. For example, when receiving the advertising name of a device with the name of "TestDev", the received name is captured as follows:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
TesÝgSt -> [84, 101, 115, 221, 103, 83, 116]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
TesÝÝÝ -> [84, 101, 115, 221, 221, 221, 0]
TesÝÝÝ -> [84, 101, 115, 221, 221, 221, 0]
TesÝwar -> [84, 101, 115, 221, 119, 97, 114]
TesÝÝÝ5 -> [84, 101, 115, 221, 221, 221, 53]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
TesÝÝÝI -> [84, 101, 115, 221, 221, 221, 73]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
TesÝÝÝÝ -> [84, 101, 115, 221, 221, 221, 221]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

where the expected output should be:

Fullscreen
1
TestDev -> [84, 101, 115, 116, 68, 101, 118]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Upon using nRF Connect (either PC or mobile versions), the correct device name is displayed:

   

This end of device name string corruption does not just happen for this particular device - I have tested scanning other devices where I see a similar behaviour with differing amounts of corruption (e.g. some devices only have 1 character that is corrupted at the end of the string). However, not all of the devices I have scanned display the corruption; some devices have their advertising names being received correctly.



Secondly, when receiving heart rate notifications from a connected device, the data is tens of thousands of values in length. Is there any documentation on how to convert this data so it can be interpreted in beats per minute (bpm)? Note: the heart rate is correctly displayed on nRF Connect (both PC and mobile).

Here is the modified nus_collector.py script that I have been using to test:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import sys
import time
import queue
import logging
from enum import Enum
from functools import wraps
CONN_IC_ID = 'NRF51'
from pc_ble_driver_py import config
config.__conn_ic_id__ = CONN_IC_ID
from pc_ble_driver_py.ble_driver import BLEUUID, BLEUUIDBase, BLEDriverObserver, BLEDriver, BLEEnableParams, BLEAdvData, BLEGapTimeoutSrc
from pc_ble_driver_py.ble_adapter import BLEAdapterObserver, BLEAdapter
TARGET_DEV_NAME = "TestDev"
TARGET_DEV_MAC_ADDRESS = 'DEA01D552902'
CONNECTIONS = 1
def init(conn_ic_id):
global nrf_sd_ble_api_ver
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any help with either of these issues would be greatly appreciated!

Regards,

Scott