Other Parts Discussed in Thread: BLE-STACK
CC2642R with SDK 3.10.00.53
function to require to update connection parameters as below:
static void SimplePeripheral_processParamUpdate(uint16_t connHandle,
uint16_t desiredMinInterval,
uint16_t desiredMaxInterval,
uint16_t desiredSlaveLatency,
uint16_t desiredConnTimeout)
{
gapUpdateLinkParamReq_t req;
uint8_t connIndex;
req.connectionHandle = connHandle;
req.connLatency = desiredSlaveLatency;
req.connTimeout = desiredConnTimeout;
req.intervalMin = desiredMinInterval;
req.intervalMax = desiredMaxInterval;
connIndex = SimplePeripheral_getConnIndex(connHandle);
SIMPLEPERIPHERAL_ASSERT(connIndex < MAX_NUM_BLE_CONNS);
Clock_Struct* pUpdateClock = connList[connIndex].pUpdateClock;
if( pUpdateClock != NULL ){
// Deconstruct the clock object
Clock_destruct(connList[connIndex].pUpdateClock);
// Free clock struct
ICall_free(connList[connIndex].pUpdateClock);
connList[connIndex].pUpdateClock = NULL;
}
// Send parameter update
bStatus_t status = GAP_UpdateLinkParamReq(&req);
#ifdef STATUS_PRINT
char printdata[40]={0};
sprintf(printdata, "\r\ncParaReq %d %d %d %d %d %d", req.intervalMin,req.intervalMax,req.connLatency,req.connTimeout,connIndex,status);
PRINT_STATUS((uint8_t*)printdata, strlen(printdata));
#endif
// If there is an ongoing update, queue this for when the udpate completes
if (status == bleAlreadyInRequestedMode)
{
// spConnHandleEntry_t *connHandleEntry = ICall_malloc(sizeof(spConnHandleEntry_t));
// if (connHandleEntry)
// {
// connHandleEntry->connHandle = connHandle;
//
// List_put(¶mUpdateList, (List_Elem *)&connHandleEntry);
// }
}
}
Event in static void SimplePeripheral_processGapMessage(gapEventHdr_t *pMsg)
case GAP_LINK_PARAM_UPDATE_EVENT:
{
gapLinkUpdateEvent_t *pPkt = (gapLinkUpdateEvent_t *)pMsg;
// Get the address from the connection handle
linkDBInfo_t linkInfo;
linkDB_GetInfo(pPkt->connectionHandle, &linkInfo);
if(pPkt->status == SUCCESS)
{
connection_info.latency = linkInfo.connLatency;
connection_info.connTimeout = linkInfo.connTimeout;
connection_info.connInterval = linkInfo.connInterval;
#ifdef STATUS_PRINT
char printdata[40]={0};
sprintf(printdata, "\r\ncParaupdate %d %d %d", connection_info.connInterval, connection_info.latency, connection_info.connTimeout);
PRINT_STATUS((uint8_t*)printdata, strlen(printdata));
#endif
}
else
{
#ifdef STATUS_PRINT
//print status
PRINT_STATUS("\r\nParaupdate fail", 17);
#endif
}
if the parameters are different, function GAP_UpdateLinkParamReq() will return 0(success) and will trigger GAP_LINK_PARAM_UPDATE_EVENT
but if the parameters is the same as previous one, function GAP_UpdateLinkParamReq() will return 0(success), but no GAP_LINK_PARAM_UPDATE_EVENT,
then again to update parameters, function GAP_UpdateLinkParamReq() will return 17(bleAlreadyInRequestedMode), no GAP_LINK_PARAM_UPDATE_EVENT,
then any requirement to update, function GAP_UpdateLinkParamReq() will always return 17(bleAlreadyInRequestedMode), no GAP_LINK_PARAM_UPDATE_EVENT.
Disconnect and re-connect can recover it, but it doesn't make sense.
BTW, in initiate I changed the timeout to the minimum with GAP_SetParamValue(GAP_PARAM_CONN_PARAM_TIMEOUT, 1), or the GAP_UpdateLinkParamReq() will be failed if too often.
the debug log as below: