This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Periodic advertisement when APP_ADV_DURATION expires

Hi,

I am using ble_app_uart example for peripheral device and it will be powered by a 3.7 V battery. I need to use battery as long as possible. So I decided to make peripheral device advertise periodically.

Since I need to use app_timer, System ON sleep mode works for me. I know that device doesn't advertise when APP_ADV_DURATION expires (assume it is not 0).  I tried to restart advertise after APP_ADV_DURATION which triggers BLE_ADV_EVT_IDLE event. Also I disabled sleep_mode_enter() function in BLE_ADV_EVT_IDLE since it will put device in System OFF sleep mode.

My timeout handler is like this:

static void single_shot_timer_handler(void * p_context)
{
 uint32_t err_code;
 
 err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST); 
 APP_ERROR_CHECK(err_code);
}



And I wanted to start timer in BLE_ADV_EVT_IDLE event like this:

switch (ble_adv_evt)
    {
        case BLE_ADV_EVT_FAST:
            NRF_LOG_INFO("adv fast");
            err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
            APP_ERROR_CHECK(err_code);
            break;
        case BLE_ADV_EVT_IDLE:
            NRF_LOG_INFO("idle");                        
            err_code = app_timer_start(m_single_shot_timer_id, APP_TIMER_TICKS(20000), NULL);
            APP_ERROR_CHECK(err_code);
            //sleep_mode_enter();
            break;

I just wanted to advertise for 10 seconds and make it sleep for 20 seconds. I expected timer to start 20 seconds after BLE_ADV_EVT_IDLE. However, device advertises all the time. I mean when APP_ADV_DURATION expires, it doesn't stop advertising.

By the way APP_ADV_DURATION macro is 1000. And I use SDK 16

Could you please help me about it ? I will be very appreciated if you give me a suggestion.

Best Regards

Parents
  • OpenCircuit said:
    1. You said that the average current during sleep is about 6 uA. Sometimes the current is around 9 uA - 15 uA momentarily. What does cause that ?

    Did you measure this yourself? It could be a short wakeup to handle some event. I did not dig into your application to see what you have running apart from the UART.

    OpenCircuit said:
    2. Is this average 5 uA current normal during sleep ? I mean that can this be more reduced ?

    Some expected sleep currents are given in the PS, but you may have a higher current if you have additional peripherals running. If the logger module is running, this may also consume additional current. There are many posts about reducing current here on DevZone, please try searching older posts/blogs.

  • Yes, I measured myself. It is regular ble_app_uart example and I use timer. I just wondered how these momentarily current values appeared during sleep. But it is okay if they do not have a significant effect for power consumption.

    I searched through devzone and I found out that setting NRF_LOG_ENABLED to 0 reduces current. It reduced current value from 6 uA to 4.3 uA during idle. I guess 4.3 uA is acceptable.

Reply Children
No Data
Related