Skip to content

Commit 7b94f25

Browse files
fix CORDIO not handling all adv set stop events
1 parent c4585b9 commit 7b94f25

File tree

1 file changed

+21
-2
lines changed
  • connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm

1 file changed

+21
-2
lines changed

connectivity/FEATURE_BLE/libraries/cordio_stack/ble-host/sources/stack/dm/dm_adv_ae.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,15 +1215,20 @@ void dmExtAdvActHciEnableCmpl(hciEvt_t *pEvent)
12151215
dmEvt_t dmMsg;
12161216

12171217
memcpy(&dmMsg, &pEvent->hdr, sizeof(wsfMsgHdr_t));
1218-
dmMsg.advSetStart.numSets = 0;
1218+
1219+
/* we have to handle stopping and starting separately as it uses the same message memory */
12191220

12201221
for ( i= 0; i < DM_NUM_ADV_SETS; i++)
12211222
{
12221223
switch(dmAdvCb.advState[i])
12231224
{
12241225
case DM_ADV_STATE_STOPPING:
12251226
case DM_ADV_STATE_STOPPING_DIRECTED:
1227+
/* prepare the message for callback */
1228+
dmMsg.advSetStop.handle = DM_ADV_HCI_HANDLE_NONE;
1229+
dmMsg.advSetStop.status = dmMsg.hdr.status;
12261230
dmMsg.advSetStop.advHandle = i;
1231+
12271232
advType = dmAdvCb.advType[i];
12281233

12291234
if (dmMsg.hdr.status == HCI_SUCCESS)
@@ -1243,10 +1248,24 @@ void dmExtAdvActHciEnableCmpl(hciEvt_t *pEvent)
12431248
/* if not connectable directed advertising */
12441249
if ((advType != DM_ADV_NONE) && !DM_ADV_CONN_DIRECTED(advType))
12451250
{
1246-
cbackEvent = DM_ADV_SET_STOP_IND;
1251+
/* we have to dispatch callbacks one by one as msg only has space for one set of parameters */
1252+
dmMsg.hdr.event = DM_ADV_SET_STOP_IND;
1253+
(*dmCb.cback)((dmEvt_t *) &dmMsg);
12471254
}
12481255
break;
12491256

1257+
default:
1258+
break;
1259+
}
1260+
}
1261+
1262+
/* safe to write as message is only used by starting, removing and clearing does not send a message */
1263+
dmMsg.advSetStart.numSets = 0;
1264+
1265+
for ( i= 0; i < DM_NUM_ADV_SETS; i++)
1266+
{
1267+
switch(dmAdvCb.advState[i])
1268+
{
12501269
case DM_ADV_STATE_STARTING:
12511270
case DM_ADV_STATE_STARTING_DIRECTED:
12521271
dmMsg.advSetStart.advHandle[dmMsg.advSetStart.numSets++] = i;

0 commit comments

Comments
 (0)