@@ -1215,15 +1215,20 @@ void dmExtAdvActHciEnableCmpl(hciEvt_t *pEvent)
1215
1215
dmEvt_t dmMsg ;
1216
1216
1217
1217
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 */
1219
1220
1220
1221
for ( i = 0 ; i < DM_NUM_ADV_SETS ; i ++ )
1221
1222
{
1222
1223
switch (dmAdvCb .advState [i ])
1223
1224
{
1224
1225
case DM_ADV_STATE_STOPPING :
1225
1226
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 ;
1226
1230
dmMsg .advSetStop .advHandle = i ;
1231
+
1227
1232
advType = dmAdvCb .advType [i ];
1228
1233
1229
1234
if (dmMsg .hdr .status == HCI_SUCCESS )
@@ -1243,10 +1248,24 @@ void dmExtAdvActHciEnableCmpl(hciEvt_t *pEvent)
1243
1248
/* if not connectable directed advertising */
1244
1249
if ((advType != DM_ADV_NONE ) && !DM_ADV_CONN_DIRECTED (advType ))
1245
1250
{
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 );
1247
1254
}
1248
1255
break ;
1249
1256
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
+ {
1250
1269
case DM_ADV_STATE_STARTING :
1251
1270
case DM_ADV_STATE_STARTING_DIRECTED :
1252
1271
dmMsg .advSetStart .advHandle [dmMsg .advSetStart .numSets ++ ] = i ;
0 commit comments