is there a way pass a service/characteristic uuid as a variable ?

Dear support

I am developing a generic client, after connection and service discovery,  there are usually a few characteristics with different uuids are found, I need to choose which characteristic to work on by its uuid, and pass the uuid as a parameter, I noticed in examples they are all passed by macro like BT_UUID_BAS etc. is it possible I define a variable like struct bt_uuid* my_uuid and pass it around like my_uuid = BT_UUID_BAS; ?

I tried and it doesn't work me, I wonder what is the solution.

Thank you!

Ping 

Parents
  • Hi, Vidar

    Further to my question, I wonder whether there is ever a need to let the upper level host know the UUIDs of the service/characteristic discovered by central SDP? As the central is designed to be generic for any peripherals, and upper level application has no knowledge of the services, I wonder whether just provide handle values and properties is enough for the host to do full data exchange.

    Thank you!

    Ping

  • Hi Ping,

    Technically, the host does not have to know the UUID to write or subscribe to notifications from a characteristic. But I'm not sure what it is going to send/receive if it does not know what kind of characteristic it is? Is the gateway meant to be able interface with any peripheral device? Please keep in mind that peripherals will often include undocumented proprietary services with custom UUIDs.

    PingISTL said:
    the protocols are internal to a specific peripheral and I need to know this before I send data to read/write, is that right?

    Usually you will be able to write and read the characteristics, but if you connect to an arbitrary peripheral you would not necessary know how to interface with it.

    Regards,

    Vidar

  • Hi, Vidar

    Thank you for clarification.

    Yes, the gateway is meant to be working with any peripheral device, there is another upper level server is meant to know the protocols and pass the data to gateway and then gateway pass it to BLE module. Before this Gateway report full DB that BLE finds. For a particular characteristics , I am thinking of report it starting handle(when UUID =0x2803), so upper app knows the handle value and do a read, then able to know the characteristic UUID, value handle to read/write or notify depend on properties.  For standard UUIDs listed in Bluetooth 16-bit UUID Number Document,  hopefully server knows the protocol, for  proprietary services with custom UUIDs, it is upper level server's job to find how to interact with it as gateway doesn't know.

    Thank you again for your support - your suggestion on handles are very helpful! 

    Ping 

  • Hi Ping,

    Thank you. I agree, for your implementation I think it will make sense to report all the UUIDs along with their attribute handles to host after the service discovery is completed. This way the host can decide which characteristic(s) it wants to interface with. It is kind of similar to how the nRF Connect Bluetooth Low Energy app works.

Reply Children
No Data
Related