- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Scenario:
Design is to detect probe. If no probe absent, enter Sleep/Low Power Mode for 6 seconds and repeat
If probe is present, then Enable BLE Timer for 1sec.
On first entry to 1 sec timer call back. Abort Low Pwer mode.
Measure probe, enable ADVertisement and wait for pairign etc.
Issue: We do not get registered even call back for BLECM_APP_EVT_LINK_UP alone
But all other event callback (BLECM_APP_EVT_LINK_UP and BLECM_APP_EVT_ADV_TIMEOUT ) are called back properly.
Note: Tried executing without calling
bleprofile_enteringDiscLowPowerMode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP); and
bleprofile_abortingDiscLowPowerMode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP);
in code
Then, in this case all 3 registered app event are called.
--------------------------------------------------------------------------------------------------------------
Code:
On create()
{
.................
bleprofile_Init(bleprofile_p_cfg);
bleprofile_GPIOInit(bleprofile_gpio_p_cfg);
.
.......
// register connection up and connection down handler.
bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_DOWN, cookp_connection_down);
bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_UP, cookp_connection_up);
bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, cookp_advertisement_stopped);
.............
// Low powe mode initialize
devlpm_init();
devlpm_registerForLowPowerQueries(cookp_lpm_queriable, 0);
bleprofile_enteringDiscLowPowerMode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP);
}
UINT32 cookp_lpm_queriable(LowPowerModePollType type, UINT32 context)
{
if(!cp_lp_abort){
if(cookp_probe_chk()){
ble_trace0("LPQ No");
cookp_reg_timer();
return 0;
}
else {
ble_trace0("LPQ yes");
return 1000000 * 6;
}
}
return 0;
}
void timer_cb()
{
if(!cp_lp_abort){ /* if probe detected on wake up */
cp_lp_abort = TRUE;
bleprofile_abortingDiscLowPowerMode(DEV_LPM_DISC_LOW_POWER_MODES_SLEEP);
}
..................
}
const BLE_PROFILE_CFG cookp_cfg =
{
/*.fine_timer_interval =*/ 500, //COOKP_FINE_TIMER, // ms Note: tried with and without Fine timer , same result
/*.default_adv =*/ HIGH_UNDIRECTED_DISCOVERABLE,
/*.button_adv_toggle =*/ 0, // pairing button make adv toggle (if 1) or always on (if 0)
/*.high_undirect_adv_interval =*/ 32, // slots
/*.low_undirect_adv_interval =*/ 1024, // slots
/*.high_undirect_adv_duration =*/ 10, // seconds
/*.low_undirect_adv_duration =*/ 20, // seconds
/*.high_direct_adv_interval =*/ 0, // seconds
/*.low_direct_adv_interval =*/ 0, // seconds
/*.high_direct_adv_duration =*/ 0, // seconds
/*.low_direct_adv_duration =*/ 0, // seconds
/*.local_name =*/ COOKP_DEVICE_NAME, // [LOCAL_NAME_LEN_MAX];
/*.cod =*/ BIT16_TO_8(COOKP_DEVICE_APPEARENCE),0x00, // [COD_LEN];
/*.ver =*/ "1.00", // [VERSION_LEN];
/*.encr_required =*/ 0, //(SECURITY_ENABLED | SECURITY_REQUEST), // data encrypted and device sends security request on every connection
/*.disc_required =*/ 0, // if 1, disconnection after confirmation
/*.test_enable =*/ 0, // TEST MODE is enabled when 1
/*.tx_power_level =*/ 0x04, // dbm
/*.con_idle_timeout =*/ 0, // second 0-> no timeout
/*.powersave_timeout =*/ 0, // second 0-> no timeout
/*.hdl =*/ {COOKP_MAIN_CHAR_HANDLE, 0x00, 0x00, 0x00, 0x00}, // [HANDLE_NUM_MAX];
/*.serv =*/ {COOKP_MAIN_SERVICE_UUID, 0x00, 0x00, 0x00, 0x00},
/*.cha =*/ {COOKP_MAIN_CHAR_UUID, 0x00, 0x00, 0x00, 0x00},
/*.findme_locator_enable =*/ 0, // if 1 Find me locator is enable
/*.findme_alert_level =*/ 0, // alert level of find me
/*.client_grouptype_enable =*/ 0, // if 1 grouptype read can be used
/*.linkloss_button_enable =*/ 0, // if 1 linkloss button is enable
/*.pathloss_check_interval =*/ 0, // second
/*.alert_interval =*/ 0, // interval of alert
/*.high_alert_num =*/ 0, // number of alert for each interval
/*.mild_alert_num =*/ 0, // number of alert for each interval
/*.status_led_enable =*/ 0, // if 1 status LED is enable
/*.status_led_interval =*/ 0, // second
/*.status_led_con_blink =*/ 0, // blink num of connection
/*.status_led_dir_adv_blink =*/ 0, // blink num of dir adv
/*.status_led_un_adv_blink =*/ 0, // blink num of undir adv
/*.led_on_ms =*/ 0, // led blink on duration in ms
/*.led_off_ms =*/ 0, // led blink off duration in ms
/*.buz_on_ms =*/ 0, // buzzer on duration in ms
/*.button_power_timeout =*/ 0, // seconds
/*.button_client_timeout =*/ 0, // seconds
/*.button_discover_timeout =*/ 0, // seconds
/*.button_filter_timeout =*/ 0, // seconds
#ifdef BLE_UART_LOOPBACK_TRACE
/*.button_uart_timeout =*/ 15, // seconds
#endif
};
- Labels:
-
Sleep Modes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After the connection up/down handlers, include the following:
bleprofile_regAppEvtHandler(BLECM_APP_EVT_ENTERING_HIDOFF,(BLECM_NO_PARAM_FUNC)cookp_enter_hidoff);
bleprofile_regAppEvtHandler(BLECM_APP_EVT_ABORTING_HIDOFF,(BLECM_NO_PARAM_FUNC)cookp_abort_hidoff);
Then,
void cookp_enter_hidoff(void)
{
// Do nothing
}
void cookp_abort_hidoff(void)
{
// Do nothing
}
Let me know if it helps.