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

How to get full uuids in pc-ble-driver-py?

I'm using python code based on the heart_rate_collector.py example in pc-ble-driver-py to scan for devices and connect to a peripheral device. 

This all works fine, except that when I try to enable notifications on a particular (known to exist) characteristic, that produces an exception NordicSemiException('CCCD not found').

I'd like to look at the UUIDs that are actually found during discovery of the device in question and compare them with the UUID I'm passing to see why the CCCD is not found.

How do I access the *full* UUIDs in python code?

I wrote the following code (inserted in the connect_and_discover() function):

self.adapter.service_discovery(new_conn)
for s in self.adapter.db_conns[0L].services:
    print "Service UUID=", s.uuid, s.uuid.value
    for c in s.chars:
        print "  Char UUID=", c.uuid, c.uuid.value
        for d in c.descs:
            print "     Desc UUID=", d.uuid, d.uuid.value

This produces:

New connection: 0
Service UUID= 0x1800 6144
  Char UUID= 0x2A00 10752
     Desc UUID= 0x2A00 10752
  Char UUID= 0x2A01 10753
     Desc UUID= 0x2A01 10753
  Char UUID= 0x2A04 10756
     Desc UUID= 0x2A04 10756
Service UUID= 0x1801 6145
Service UUID= 0x00 (Standard.unknown) Standard.unknown
  Char UUID= 0x00 (Standard.unknown) Standard.unknown
     Desc UUID= 0x2A00 10752
     Desc UUID= 0x2902 (Standard.cccd) Standard.cccd
  Char UUID= 0x00 (Standard.unknown) Standard.unknown
     Desc UUID= 0x2902 (Standard.cccd) Standard.cccd

The enumeration works fine (these are the right number of services etc) but the UUIDs all print as 0x00.   I'd like to show the UUIDs either as byte arrays or formatted the way UUIDs usually are.

I think it would be great if there was a python example that connects to a device and displays all the discovery information.

P.S. My environment is Ubuntu 16.04LTS, pc-ble-driver-py v0.11.4 (installed from pip) and nRD51 DK.

Parents Reply
  • ilw, thank you!   I did try ble_vs_uuid_add() and that did work.  My BASE_UUID bytes were reversed though (probably why notification wasn't working either), I had to reorder them and then it worked okay.

    For the Nordic guys: 

    1. Why is ble_vs_uuid_add necessary? Can't the driver code work with all the UUIDs actually present/discovered, not just the ones it knows?  and

    2. How does pc-ble-driver-js do this?  Clearly the nRF Connect desktop app doesn't have this limitation as it works fine with any UUIDs, and that runs on top of pc-ble-driver-js.

Children
No Data
Related