Other Parts Discussed in Thread: CC2650
I'm having trouble tracing through the HeartRate example's stateChangeEvt() code. I try to set a breakpoint at line 845, but the break point keeps moving to line 852
static void HeartRate_stateChangeEvt(gaprole_States_t newState)
{
// If no change to the GAP Role state has occurred
if (gapProfileState == newState)
{
return;
}
// If connected
if (newState == GAPROLE_CONNECTED)
{
// Get connection handle.
GAPRole_GetParameter(GAPROLE_CONNHANDLE, &gapConnHandle);
PINCC26XX_setOutputValue(Board_LED1, 0);
}
// If disconnected
else if (gapProfileState == GAPROLE_CONNECTED &&
newState != GAPROLE_CONNECTED)
{
// Stop periodic measurement of heart rate.
Util_stopClock(&measPerClock);
if (newState == GAPROLE_WAITING_AFTER_TIMEOUT)
{
// Link loss timeout-- use fast advertising
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_FAST_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_FAST_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_MIN, DEFAULT_FAST_ADV_DURATION);
}
else
{
// Else use slow advertising
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_SLOW_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_SLOW_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_MIN, DEFAULT_SLOW_ADV_DURATION);
}
// Enable advertising.
HeartRate_toggleAdvertising();
}
// If advertising stopped
else if (gapProfileState == GAPROLE_ADVERTISING &&
newState == GAPROLE_WAITING)
{
// If advertising stopped by user
if (advCancelled)
{
// Disable advertising.
advCancelled = FALSE;
}
// Else if fast advertising switch to slow
else if (GAP_GetParamValue(TGAP_GEN_DISC_ADV_INT_MIN) == DEFAULT_FAST_ADV_INTERVAL)
{
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MIN, DEFAULT_SLOW_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_INT_MAX, DEFAULT_SLOW_ADV_INTERVAL);
GAP_SetParamValue(TGAP_GEN_DISC_ADV_MIN, DEFAULT_SLOW_ADV_DURATION);
// Enable advertising.
HeartRate_toggleAdvertising();
}
Furthermore, the else if at line 829 is entered, but then jumps to line 866. Then toggleAdvertising() is called, but even though the CC2650 isn't advertising since the device was just in a connection and is now disconnected, the advState is still TRUE and advertising doesn't start (it is turned off). This doesn't seem correct. Why are all these seemingly weird behaviors occurring? Shouldn't advertising automatically stop when the peripheral is connected to a central?