How to advertise with specific 128bit uuid by pc-ble-driver-py?

Hi,

I have met a problem that I try to advertise nRF52840 dongle in pc-ble-driver-py. However, connection is not built from this command:

BASE_UUID = [0x6E, 0x40, 0x00, 0x01, 0xB5, 0xA3, 0xF3, 0x93,
                                 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E]
adv_data = BLEAdvData(service_128bit_uuid_complete=BASE_UUID)

The uuid is uart over ble which is used in nRFConnect desktop. And we can connect through this application.

I wonder to know how to advertise with specific 128bit uuid by pc-ble-driver-py. Thank you!

  • I find that this code can not change the complete list of 128-bit service uuids. Is there any function which can change the uuid of the advertising device?

  • Hi Sigurd,

    This function self.adapter.driver.ble_vs_uuid_add still doesn't work. Maybe the difference is that I use nRF52840 as slave by adveristing it. 

    class HRCollector(BLEDriverObserver, BLEAdapterObserver):
        def __init__(self, adapter):
            super(HRCollector, self).__init__()
            self.adapter = adapter
            self.conn_q = Queue()
            self.adapter.observer_register(self)
            self.adapter.driver.observer_register(self)
            self.adapter.default_mtu = 250
            from pc_ble_driver_py.ble_driver import BLEUUIDBase
            self.nus_base = BLEUUIDBase([
                0x6e, 0x40, 0x00, 0x00, 0xb5, 0xa3, 0xf3, 0x93, 0xe0, 0xa9, 0xe5, 0x0e, 0x24, 0xdc, 0xca, 0x9e
            ])
    
        def open(self):
    
            self.adapter.driver.open()
            if config.__conn_ic_id__.upper() == "NRF51":
                self.adapter.driver.ble_enable(
                    BLEEnableParams(
                        vs_uuid_count=1,
                        service_changed=0,
                        periph_conn_count=0,
                        central_conn_count=1,
                        central_sec_count=0,
                    )
                )
            elif config.__conn_ic_id__.upper() == "NRF52":
    
                gatt_cfg = BLEConfigConnGatt()
                gatt_cfg.att_mtu = self.adapter.default_mtu
                gatt_cfg.tag = CFG_TAG
                self.adapter.driver.ble_cfg_set(BLEConfig.conn_gatt, gatt_cfg)
    
                self.adapter.driver.ble_enable()
                self.adapter.driver.ble_vs_uuid_add(self.nus_base)
            from pc_ble_driver_py.ble_driver import BLEUUIDBase
            # BASE_UUID = [0x6E, 0x40, 0x00, 0x01, 0xB5, 0xA3, 0xF3, 0x93,
            #                          0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E]
            # adv_data = BLEAdvData(service_128bit_uuid_complete=BASE_UUID)
            adv_data = BLEAdvData(complete_local_name="pc_ble_driver_py")
            self.adapter.driver.ble_gap_adv_data_set(adv_data)
    
            self.adapter.driver.ble_gap_adv_start()
            scan_duration = 60
            try:
                new_conn = self.conn_q.get(timeout=scan_duration)
                self.adapter.enable_notification(
                    new_conn, BLEUUID(Uart_Tx_uuid), uart_tx_handle
                )
                return new_conn
            except Empty:
                print(f"No heart rate collector advertising with name {TARGET_DEV_NAME} found.")
                return None
            # return None
    
        def close(self):
            self.adapter.driver.close()
    
        def on_gap_evt_connected(
            self, ble_driver, conn_handle, peer_addr, role, conn_params
        ):
            print("New connection: {}".format(conn_handle))
            self.conn_q.put(conn_handle)
    
    

  • zhaoyuan said:
    This function self.adapter.driver.ble_vs_uuid_add still doesn't work.

    What do you mean by "doesn't work"? Are you getting any errors?

  • Hi,

    I don't get any error. But the uuid has not changed, which can be seen in complete list of 128-bit service uuids.

Related