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

Integration of Bond Management Service in GATT Server Profile

Hi ,
I would want to establish a GATT Server application as well as integrate Bond Management Service from glucose example (ble_app_gls) in examples folder of SDK15.3.0_59ac345 into my GATT Server Application. How to integrate this service into GATT Server application. What are the dependencies which I need to take care of while integrating this service.

Parents
  • Hi,

    You can refer to Merging two BLE examples together for information on how to merge BLE examples/services. This does not handle BMS specifically, but that should be OK. I suggest you take the BMS Example and merge that into your application (I don't know why you mentionned ble_app_gls, as this does not include the BMS service).

  • Einar ,

    That was a typo from my side . There is device information service in ble_app_gls . I want to merge that into my application. Can you tell me which is the correct example for GATT Server Application ? I have been using ble_app_gatts_c . Is it right ?

  • Hi,

    You can set SEC_PARAM_BOND to 0 in the main.c of the BMS example (in that case there will still be pairing, but no bonding). However, it is a bit strange... How can it make sense to include the BMS if you don't want to use bonding?

    Update: it just came to me that you did not intend to use BMS, I just forget every time I read the title of this case Slight smile  Obviously in that case you should start with the GLS example (if you are sure GLS is what you need?) instead of the BMS example. This also includes DIS, so the earlier posts are still valid. And you can disable bonding here by setting SEC_PARAM_BOND to 0, as mentionned before.

    Note that the GLS characteristics require security, so it will not work without being paired. Do you intend to remove pairing as well? If so, you can do that (stript out all peer manager related code), but you also have to update the security modes for the characteristics. In practice, replace all instances of SEC_JUST_WORKS with SEC_OPEN in the main.c of the example.

  • You can set SEC_PARAM_BOND to 0 in the main.c of the BMS example (in that case there will still be pairing, but no bonding)

    I am getting an error after doing this ! The code gets redirected to NRF_BREAKPOINT_COND .

    Is there any other parameter that I need to change ?

    I want bond management service just to have read/write characteristic access. 

  • Hi,

    Jaydev Borkar said:
    Is there any other parameter that I need to change ?

    I can see that an error has been detected, but not what error. Please build the debug target (Select "Debug" in the dropdown menue in the upper left part of the screen when not in debug mode). If you also enable logging, you will get a log printed when there is an error. If not, inspect p_info etc. to see what error you got where. It will tell you which file, at which line you got which error code.

    Jaydev Borkar said:
    I want bond management service just to have read/write characteristic access. 

    I don't understand. Why do you want BMS when you are not using bonding? The whole purpose of BMS is to manage bonds, but there will not be any if you don't support bonding. 

  • I can see that an error has been detected, but not what error. Please build the debug target (Select "Debug" in the dropdown menue in the upper left part of the screen when not in debug mode). If you also enable logging, you will get a log printed when there is an error. If not, inspect p_info etc. to see what error you got where. It will tell you which file, at which line you got which error code.

    I enabled logging using PUTTY . I get error 7. NRF_ERROR_INVALID_PARAM. I have put in many log details in each of the functions .. Please check the below screenshot .

    I don't understand. Why do you want BMS when you are not using bonding? The whole purpose of BMS is to manage bonds, but there will not be any if you don't support bonding.

    BMS was used in our previous implementation just to have read and write characteristic access. We could have used any other service . But we ended up taking BMS .  So I wanted to replicate the same in new project . 

  • Hi,

    Jaydev Borkar said:

    I enabled logging using PUTTY . I get error 7. NRF_ERROR_INVALID_PARAM. I have put in many log details in each of the functions .. Please check the below screenshot .

    I see. The error code is typically returned from a function call and then detected by an APP_ERROR_CHECK(), which is on line 735 in your modified BMS example. Which function returns this error code? When you know the function and the error code you can start to check what would cause that function to return the specific error code. Often it will be quite obvious, but sometimes it requires a bit more digging.

Reply
  • Hi,

    Jaydev Borkar said:

    I enabled logging using PUTTY . I get error 7. NRF_ERROR_INVALID_PARAM. I have put in many log details in each of the functions .. Please check the below screenshot .

    I see. The error code is typically returned from a function call and then detected by an APP_ERROR_CHECK(), which is on line 735 in your modified BMS example. Which function returns this error code? When you know the function and the error code you can start to check what would cause that function to return the specific error code. Often it will be quite obvious, but sometimes it requires a bit more digging.

Children
  • It is  err_code = pm_sec_params_set(&sec_param); function is showing the error . This error is reflected only if I change #define SEC_PARAM_BOND from 1 to 0. 

  • Hi,

    Ah, that makes sense. I forgot that you also need to change the key distribution configuration to disable it, since that only makes sense when bonding. So you should look for this part in peer_manager_init():

        sec_param.kdist_own.enc  = 1;
        sec_param.kdist_own.id   = 1;
        sec_param.kdist_peer.enc = 1;
        sec_param.kdist_peer.id  = 1;

    and replace it with this:

        sec_param.kdist_own.enc  = 0;
        sec_param.kdist_own.id   = 0;
        sec_param.kdist_peer.enc = 0;
        sec_param.kdist_peer.id  = 0;

    With this change, the nRF will still support pairing, but not bonding. If you don't want pairing support either, you should remove the peer manager. If that is your desire in tead, you can test by just comment out the call to peer_manager_init() in main() and pm_handler_secure_on_connection() in ble_evt_handler(), both in your main.c file.

Related