BLE abstraction for DISS - can't change security level

I’m using the BLE abstraction layer to add the Device Information Service Server (ble_diss.c). After calling the DISS_Initialize(), the BLE stack eventually calls DISS_ProfileTaskAddCmd() to add the service. This function calls GAPM_ProfileTaskAddCmd() with a hard-coded security level set to PERM(SVC_AUTH, ENABLE)`.

I’d like to disable the authorization, but I don’t see any way to change this - is there a GAPM function call to change a service’s authorization after it has been added? If there isn’t, how can I override the DISS_ProfileTaskAddCmd(), or do I have to re-implement the ble_diss.c code?

@mbianchi

The ble_diss.c code is in the SDK. If you includes it by reference into your project then if you makes changes it will change for all other applications that also include it by reference.

So to answer the question of:

“do I have to re-implement the ble_diss.c code?”

The answer is no, copy it local to the project then make the modification to the permission as desired.

Thank you for using our community forum!

Thanks @martin.bela - but I was hoping this was not the answer. This seems like an oversight in the stack API. Why wouldn’t there be a GAP command to change the service authorization after it has been set? I don’t like the idea of copying SDK code and making local modifications - that just become a possible maintenance burden when upgrading SDKs.

@mbianchi

Turns out there is a way. You can use GATTM_SVC_SET_PERMISSION_REQ and read it back by GATTM_SVC_GET_PERMISSION_REQ.

@martin.bela

Thanks for finding that! I have implemented that request in my message handler for GAPM_PROFILE_ADDED_IND which is generated by a call to DISS_Initialize(). I am now able to read all the DISS characteristics without having first paired.

1 Like