This question has been asked but there is not workable solution to it. Therefore, I need to ask it again:
I am developing my own application based on the Keyfob-demo project. It is expected that the keyfob (peripheral) is supposed to measure the RSSI between the master and itself after a given period of sampling time. During the sampling time, the keyfob should go into sleep ( power mode 1 is sufficient but if it can go into the power mode 2, it would be better). I have the following codes for the rssi sampling section ( it was in a event handling process. The flag value for this event is KFD_RSSI_READ_EVT_T):
.....
rssi_sampling_counter = 0; uint16 simpleBLEConnHandle; //halSleep(10); GAPRole_GetParameter(GAPROLE_CONNHANDLE,&simpleBLEConnHandle); HCI_ReadRssiCmd(simpleBLEConnHandle ); #if defined ( POWER_SAVING ) osal_pwrmgr_device( PWRMGR_BATTERY ); #endif osal_stop_timerEx( keyfobapp_TaskID, KFD_START_DEVICE_EVT); osal_stop_timerEx( keyfobapp_TaskID,KFD_BATTERY_CHECK_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_ACCEL_READ_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_TOGGLE_BUZZER_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_ADV_IN_CONNECTION_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_PERIODIC_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_RSSI_READ_EVT_T); osal_stop_timerEx( keyfobapp_TaskID, KFD_BUTTON_EVT); halSleep(10); osal_start_timerEx(keyfobapp_TaskID,KFD_RSSI_READ_EVT_T, rssi_sampling_period);
I have tried to terminate all the timer evenst in the keyfob demo application layer except the rssi sampling one before it goes into sleep. However, there is still some peaks showing up in every 200 - 300 ms according to the oscilloscope graph. I read the past threads on this issue and some users suggested that the keyfob can only go to sleep where there is no active tasks on-hold. But in my case, the RSSI sampling timer cannot be stopped, right? Otherwise, how can the keyfob knows when to measure the rssi value? So does it mean the keyfob can never go into the power mode 1 in my case? I am deperately looking for help on this issue. Please advise and I will appreciate any constructive response to my urgent request. Thanks.
additionally, I have turned on the POWER_SAVING macro in the compiling environment to enable the power saving functions. But it still cannot enter the power mode 1. Please advise.
Hi,
Br,
Igor
question 1 - it depends on what the master set. It is changed in the test. Currently, it is 10 seconds.
question 2 - I have commented that line. I still get those peaks at the period of 100 ms.
I wonder if there is anything running underneath about the rssi sampling for those peaks on the oscilloscope?
I use the following macro to force the node into the power mode 2. However, it will make the connection drop:
In hal_sleep.h:
#define HAL_SLEEP_SET_POWER_MODE( mode ) \ st( SLEEPCMD &= ~PMODE; \ SLEEPCMD |= (mode); \ while (!(STLOAD & LDRDY)); \ { \ halSetSleepMode(); \ } \ )#else // HAL_SLEEP_DEBUG_POWER_MODE// Debug: Don't set power mode, just block until sleep timer interrupt.#define HAL_SLEEP_SET_POWER_MODE( mode ) \ st( while( halSleepInt == FALSE ); \ halSleepInt = FALSE; \ )#endif // !HAL_SLEEP_DEBUG_POWER_MODE
Then in the function - static void peripheralStateNotificationCB( gaprole_States_t newState )
static void peripheralStateNotificationCB( gaprole_States_t newState )
{
..... if ( gapProfileState != newState ) { switch( newState )
case GAPROLE_STARTED:
....
case GAPROLE_CONNECTED:
#if defined ( POWER_SAVING ) osal_pwrmgr_device( PWRMGR_BATTERY ); osal_pwrmgr_powerconserve(); #endif // ProxReporter_SetParameter(PP_FLIGHT_MODE_NOTIFICATION,sizeof(uint8), &flight_mode_enabled); osal_stop_timerEx( keyfobapp_TaskID, KFD_START_DEVICE_EVT); osal_stop_timerEx( keyfobapp_TaskID,KFD_BATTERY_CHECK_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_ACCEL_READ_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_TOGGLE_BUZZER_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_ADV_IN_CONNECTION_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_PERIODIC_EVT); osal_stop_timerEx( keyfobapp_TaskID, KFD_RSSI_READ_EVT_T); osal_stop_timerEx( keyfobapp_TaskID, KFD_BUTTON_EVT); /* if (gapProfileState ==GAPROLE_CONNECTED) { halSleep(100); GAPRole_TerminateConnection(); // putchar ('t'); } */ halSleep(1000); HAL_SLEEP_SET_POWER_MODE( HAL_SLEEP_TIMER );
osal_start_timerEx(keyfobapp_TaskID,KFD_RSSI_READ_EVT_T, rssi_sampling);
}
My question is simple - Please advise whether the bluetooth connection can be held or not when the keyfob (slave) goes to the power mode 2???
If yes, please advise why the connection is broken. If no, please advise how to get the button press interrupt (on the keyfob) to trigger the reconnection. Thanks.
Please advise... I need the power mode 2 workable urgently. The TI staff asked me to post my question on the TI forum but actually no TI staff is answering it???