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);