Hi,
I am using SimpleLink CC13xx_CC26xx SDK 6.40.00.13 with the CC2642R.
My application is advertising with a 2s interval in both legacy and long range modes (i.e. code PHY) and I need to update sensor data in the advertising data every 2s.
The advertising parameters are as follows:
GapAdv_params_t advParamsLegacy = { .eventProps = GAP_ADV_PROP_CONNECTABLE | GAP_ADV_PROP_LEGACY | GAP_ADV_PROP_SCANNABLE, .primIntMin = DEFAULT_ADVERTISING_INTERVAL, .primIntMax = DEFAULT_ADVERTISING_INTERVAL, .primChanMap = GAP_ADV_CHAN_ALL, .peerAddrType = PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID, .peerAddr = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, .filterPolicy = GAP_ADV_WL_POLICY_ANY_REQ, .txPower = GAP_ADV_TX_POWER_NO_PREFERENCE, .primPhy = GAP_ADV_PRIM_PHY_1_MBPS, .secPhy = GAP_ADV_SEC_PHY_1_MBPS, .sid = 0 }; GapAdv_params_t advParamsLongRange = { .eventProps = GAP_ADV_PROP_CONNECTABLE, .primIntMin = DEFAULT_ADVERTISING_INTERVAL, .primIntMax = DEFAULT_ADVERTISING_INTERVAL, .primChanMap = GAP_ADV_CHAN_ALL, .peerAddrType = PEER_ADDRTYPE_PUBLIC_OR_PUBLIC_ID, .peerAddr = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa }, .filterPolicy = GAP_ADV_WL_POLICY_ANY_REQ, .txPower = GAP_ADV_TX_POWER_NO_PREFERENCE, .primPhy = GAP_ADV_PRIM_PHY_CODED_S2, .secPhy = GAP_ADV_SEC_PHY_CODED_S8, .sid = 1 };
After creating the two advertising sets I am enabling several events as follows:
status = GapAdv_setEventMask(advHandleLegacy, GAP_ADV_EVT_MASK_START_AFTER_ENABLE | GAP_ADV_EVT_MASK_END_AFTER_DISABLE | GAP_ADV_EVT_MASK_SET_TERMINATED | GAP_ADV_EVT_MASK_START); status = GapAdv_setEventMask(advHandleLongRange, GAP_ADV_EVT_MASK_START_AFTER_ENABLE | GAP_ADV_EVT_MASK_END_AFTER_DISABLE | GAP_ADV_EVT_MASK_SET_TERMINATED | GAP_ADV_EVT_MASK_START);
And then in the event handler (which is handled in the thread, same as in the simple_peripheral example) when there is a GAP_EVT_ADV_START event I update the advertising data for the handle passed into the event handler:
ret = GapAdv_prepareLoadByHandle(handle, GAP_ADV_FREE_OPTION_DONT_FREE); CHECK_RETURN_CODE(ret); Advertising_Update(buffer, fixed_point_press, fixed_point_temp, battery); ret = GapAdv_loadByHandle(handle, GAP_ADV_DATA_TYPE_ADV, buf_len, buffer); CHECK_RETURN_CODE(ret);
(Advertising_Update() updates a few bytes in the buffer and 'buffer' points to the advertising data that matches the handle and advertising set).
This does not work properly and the second advertising set stops advertising. Sometimes it works for several advertisements and then the second advertising set stops and sometimes it stops after only one or two advertisements. The first advertisement set (legacy mode) seems to always keep advertising, but the long range (extended advertising with coded PHY) always stops after a while.
But if I remove the calls to GapAdv_prepareLoadByHandle() and GapAdv_loadByHandle() when updating the advertising data then it seems to work OK.
The manuals recommend using GapAdv_prepareLoadByHandle() and GapAdv_loadByHandle(), so what's going wrong here? It seems like GapAdv_prepareLoadByHandle() when called for one advertising set is affecting the other advertising set.
regards,
Charles