Dynamically define characteristics for a service

Hi -

Is there a simple way to dynamically enable characteristics within a given service profile for a GATT server?  For example, we are using the Fitness Machine Service (FTM). If our product knows at runtime that's it's configured as a rower, we want to only allow the Rower Data characteristic to be discoverable.  If it's configured as a bike, we want to only allow the Indoor Bike Data characteristic to be discoverable.

I realize this can be accomplished by defining two different ftm_services (i.e. ftm_service_rower and ftm_service_bike) then using the bt_gatt_service_register() to select the appropriate implementation, however, this would quickly get resource intensive if there were numerous combinations which could occur at runtime.

Could all possible characteristics be defined then selectively disabled, preventing them from being discovered by a client?

Thanks,

Parents
  • Hi

    Since services are defined with the BT_GATT_SERVICE_DEFINE that are set in one specific section during build time, I don't think so. But we found this Zephyr issue where someone is discussing something similar. 

    The easiest way to do this I would think is to add everything and have a specific custom characteristic saying what machine the device is at the moment. I think it would be a lot of extra work (for something that might not work) to try adding this in RAM like you describe.

    Best regards,

    Simon

Reply
  • Hi

    Since services are defined with the BT_GATT_SERVICE_DEFINE that are set in one specific section during build time, I don't think so. But we found this Zephyr issue where someone is discussing something similar. 

    The easiest way to do this I would think is to add everything and have a specific custom characteristic saying what machine the device is at the moment. I think it would be a lot of extra work (for something that might not work) to try adding this in RAM like you describe.

    Best regards,

    Simon

Children
No Data
Related