This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to get bonding information using an index according to bonded count value

Hi,

I am implementing to assign the directed advertising mode on peripheral device.

So, after pairing a central device with undirected connectable mode at the first time,the peer device’s address is stored to non-volatile area of peripheral device.

And then, at the next advertising timing, the peripheral device should be assigned to the directed connectable mode with the peer device’s address when the bonding count is more than 0.

So, the GAPBondMgr_GetParameter(GAPBOND_BOND_COUNT, &bond_count); is enough to get the bonding count.

And then, I want to make it continue to loop with the bonded address, at this time, public address.

For example, if the bonding count is 2, up to 7, I need to read the bonding information(address, and so on) with an index number and assign the address as directed address.

For that, I need to use gapBondMgrGetPublicAddr(idx, remoteBdAddr);. This API is enough for use right now.

but, this API is not available for me to use from Application side as the static function API exists in stack side.

As I understand, I need to utilize the ICall message or GAPRole_SetParameter() API to get something from Stack side.

Actually, I didn’t understand yet fully how to add my own protocols, let me know how to add or if you have a reference code for that.

Please refer to my code below.

Thank in advance,

Ji Won

 

   if (events & START_ADVERTISING_EVT)

    {

      events &= ~START_ADVERTISING_EVT;

     

      if (gapRole_AdvEnabled || gapRole_AdvNonConnEnabled)

      {

        gapAdvertisingParams_t params;

 

        // Setup advertisement parameters

        if (gapRole_AdvNonConnEnabled)

        {

          // Only advertise non-connectable undirected.

          params.eventType = GAP_ADTYPE_ADV_NONCONN_IND;

        }

        else

        {

          uint8 bond_count;

          uint8 advDirectType;

          static uint8 idx = 0;

          uint8 remoteBdAddr[B_ADDR_LEN] = { 0x00, };

 

          // check for an existing bond, value of zero indicates no stored bonds in NV

          GAPBondMgr_GetParameter(GAPBOND_BOND_COUNT, &bond_count);

          if (bond_count)

          {

            Log_info1("bonded count: %d ", bond_count);

 

            gapBondMgrGetPublicAddr(idx, remoteBdAddr);  

            advDirectType = GAP_ADTYPE_ADV_HDC_DIRECT_IND;

    GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8), &advDirectType);

    GAPRole_SetParameter(GAPROLE_ADV_DIRECT_ADDR, sizeof(remoteBdAddr), remoteBdAddr);            

     idx++;

             idx %= bond_count;

          }

          params.eventType = gapRole_AdvEventType;

 

          GAPRole_SetParameter(GAPROLE_ADV_EVENT_TYPE, sizeof(uint8), &advDirectType);

          params.initiatorAddrType = gapRole_AdvDirectType;

 

          GAPRole_SetParameter(GAPROLE_ADV_DIRECT_ADDR, sizeof(remoteBdAddr), remoteBdAddr);

          VOID memcpy(params.initiatorAddr, gapRole_AdvDirectAddr, B_ADDR_LEN);

 

          char *cstr_peerAddress = Util_convertBdAddr2Str(gapRole_AdvDirectAddr);

          Log_info1("initiator address is: \x1b[32m%s\x1b[0m", (IArg)cstr_peerAddress);

  • On my understanding about ICall mechanism, for application side to use the gapBondMgrGetPublicAddr() API on stack side,
    I need to define and add the DISPATCH_GAP_BOND_PUBLIC_ADDR like DISPATCH_GAP_BOND_RESOLVE_ADDR in bleDispatch.h of application side.

    And then, I have to add the related function API to call GAPBondMgr_GetPublicAddr() into both ICallBleAPI.c of application side and bleDispatch.c of stack side.
    The related function API would be based on a case of processDispGAPProfile() API.
    At this point, the newly added DISPATCH_GAP_BOND_PUBLIC_ADDR should be used.
    Right?

    BR,
    Ji Won
  • Hi Ji Won,

    To re-iterate, you would like to setup a peripheral device to do directed advertising. In order to do directed advertising, you need your device's address as well as the initiator's address. You plan to use the GAPBondMgr to get the initiator's address.

    Instead of adding your own API to do this, I recommend caching these addresses at the application layer (possibly with LRU if you plan to connect to many centrals) and then use this to set you adv data.
  • Hi Sean,

    Thanks for your comments.
    Anyway, I made it possible after adding my own API on ICall dispatch related parts. So, for now, there is no problem.
    But, what is LRU and what means the 'caching these addresses'?

    Thanks in advance,
    Ji Won