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

pc-ble-driver-py and service discovery

Hi,

We are using a self-developed python script to connect to nRF52840 in our products. The product contains many custom 128-bit services and characteristics (30+). These are for all production test purposes static, and it is quite tedious to do service discovery (which by the way takes 15seconds with pc-ble-driver-py and only 2-3seconds on a mobile phone). Is there any way to "fool" the driver/adapter to use pre-assigned handles/uuid pairs?

Best regards,

Geir Strand

Parents
  • Hi Geir, 

    You can take a look at UART central example and UART peripheral example. Is it what you are looking for?

    The central application will scan and connect to peripheral devices that advertise with a specific UUID in its advertisement report, that is NUS UUID in this case.

    -Amanda H.

  • Hi Amanda,

    I don't think this is relevant. I am talking about pc-ble-driver-py and service discovery there. The product under test with nRF52840 is already developed with 30+ characteristics. I want to speed up discovery or use a static handle/UUID combo so that the test station doesn't have to wait 15 seconds for service discovery.

  • Hi, 

    Sorry for the misunderstand. 

    You do not have to perform service discovery if you know the services in advance and know that they will never change. This is briefly described in this thread

    -Amanda H.

  • hi Amanda,

    I have tried to understand what I need to do to just scan for my services/characteristics, but I did not fully understand it from the thread you linked to.

    Is the suggestion to just add the base uuids with ble_vs_uuid_add?

    I have tried to just add the service uuid's I'm interested in, but the code does not recognize the uuids as base uuids...

  • Hi Geir, 

    Sorry for the delay. I got further information from my colleague.

    There are two things you can do:

    • Make the service discovery faster. We suspect that you are using too long a connection interval. If you still want low power consumption, you can do the short connection interval at the beginning and change to the longer connection interval later on.
    • Don’t do service discovery at all. This is what you are thinking of. To do that you need to know the handle of the characteristic. The handle is important. It’s different from the UUID. What the service_discovery() does is to discover the UUID and match the handle of each UUID (We think there is a problem if there are more than 1 service/characteristic with the same UUID with this library).
      The handle is not exposed to the application via the API inside ble_adapter.py. To do anything, for example, enable_notification() or write_cmd(), the input from application is UUID not handle.
      If you know the handle, you should use self.driver.ble_gattc_write() to do the write directly and the input of the function is the handle. not the UUID.
      So basically, you need to look into ble_adapter.py and see how we call the self.driver.* command and do the same in your application.

    -Amanda H.

Reply
  • Hi Geir, 

    Sorry for the delay. I got further information from my colleague.

    There are two things you can do:

    • Make the service discovery faster. We suspect that you are using too long a connection interval. If you still want low power consumption, you can do the short connection interval at the beginning and change to the longer connection interval later on.
    • Don’t do service discovery at all. This is what you are thinking of. To do that you need to know the handle of the characteristic. The handle is important. It’s different from the UUID. What the service_discovery() does is to discover the UUID and match the handle of each UUID (We think there is a problem if there are more than 1 service/characteristic with the same UUID with this library).
      The handle is not exposed to the application via the API inside ble_adapter.py. To do anything, for example, enable_notification() or write_cmd(), the input from application is UUID not handle.
      If you know the handle, you should use self.driver.ble_gattc_write() to do the write directly and the input of the function is the handle. not the UUID.
      So basically, you need to look into ble_adapter.py and see how we call the self.driver.* command and do the same in your application.

    -Amanda H.

Children
Related