pc-ble-driver-py is assigning one service / characteristics uuid_type=3

I'm running into an odd problem...  I'm using a nRF52832 development kit and pc-ble-driver-py to write tests against our custom services and characteristics, and I just hit a problem that I cannot figure out. 

For some reason, 1 service and its characteristics are getting their uuid type set to 3, but the maximum value the uuid type can be is 2. 

I'm basing the BLE interaction from the heart_rate_collector.py example.  This is the function that looks an advertiser with the specified MAC address, connects to it (if found), and discovers the services and characteristics.

    def connect_and_discover(self, mac_addr):
        self.mac_addr = mac_addr
        scan_duration = 5
        params = BLEGapScanParams(interval_ms=200, window_ms=150, timeout_s=scan_duration)

        self.adapter.driver.ble_gap_scan_start(scan_params=params)

        try:
            self.conn_handle = self.conn_q.get(timeout=scan_duration)
            print('starting discovery')
            self.adapter.service_discovery(self.conn_handle)
            
            self.services = self.adapter.db_conns[self.conn_handle].services

            return self.conn_handle
        except Empty:
            print(f"No advertiser with addr {mac_addr} found.")
            return None

I set a breakpoint after the call to self.adapter.service_discovery(self.conn_handle), and drilled into the list of services in the db_conns list.  The very last service and all of its characteristics have the base.type set to 3.

Why would the softdevice set the type to a value other than 0, 1, or 2?

Parents
  • Hello,

    The BLE_UUID_TYPE_VENDOR_BEGIN (0x2) marks the start index for the vendor UUID storage in the Softdevice, and it will get incremented every time you register a new one through the BLEUUIDBase() -> sd_ble_uuid_vs_add() function. In other words, a 'type' value above 0x2 is really a reference to a particular base uuid in the Softdevice's UUID buffer.

    From the Softdevice API documentation:

    Add a Vendor Specific base UUID.

    This call enables the application to add a Vendor Specific base UUID to the BLE stack's table, for later use with all other modules and APIs. This then allows the application to use the shorter, 24-bit ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The type field in the ble_uuid_t structure is an index (relative to BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the UUID field in the same structure contains the 2 bytes at indexes 12 and 13. The number of possible 128-bit UUIDs available to the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.

    Hope this helps!

    Best regards,

    Vidar

Reply
  • Hello,

    The BLE_UUID_TYPE_VENDOR_BEGIN (0x2) marks the start index for the vendor UUID storage in the Softdevice, and it will get incremented every time you register a new one through the BLEUUIDBase() -> sd_ble_uuid_vs_add() function. In other words, a 'type' value above 0x2 is really a reference to a particular base uuid in the Softdevice's UUID buffer.

    From the Softdevice API documentation:

    Add a Vendor Specific base UUID.

    This call enables the application to add a Vendor Specific base UUID to the BLE stack's table, for later use with all other modules and APIs. This then allows the application to use the shorter, 24-bit ble_uuid_t format when dealing with both 16-bit and 128-bit UUIDs without having to check for lengths and having split code paths. This is accomplished by extending the grouping mechanism that the Bluetooth SIG standard base UUID uses for all other 128-bit UUIDs. The type field in the ble_uuid_t structure is an index (relative to BLE_UUID_TYPE_VENDOR_BEGIN) to the table populated by multiple calls to this function, and the UUID field in the same structure contains the 2 bytes at indexes 12 and 13. The number of possible 128-bit UUIDs available to the application is therefore the number of Vendor Specific UUIDs added with the help of this function times 65536, although restricted to modifying bytes 12 and 13 for each of the entries in the supplied array.

    Hope this helps!

    Best regards,

    Vidar

Children
No Data
Related