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

periodic advertising and sleep mode

link text from this link i want to advertise for 10 second then i want to stop advertise for 20 second then again advertise for 10 second. i want this continuously. for that i have defined timer

static void timers1_init(void)
{
    uint32_t err_code;

    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);

    // Create timers.
    err_code = app_timer_create(&abc,
                               APP_TIMER_MODE_SINGLE_SHOT,
                                timeout_handler);

//APP_TIMER_MODE_SINGLE_SHOT-The timer will expire only once.
//APP_TIMER_MODE_REPEATED-The timer will restart each time it expires.

    APP_ERROR_CHECK(err_code);
}

static void application_timers_start(void)
{
    uint32_t err_code;

    // Start application timers.
    err_code = app_timer_start(abc, INTERVAL, NULL);
    APP_ERROR_CHECK(err_code);
}


static void timeout_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
	sd_ble_gap_adv_stop ();
	//power_manage();
    
}
Parents
  • i have edited code for first timer i define period for two timers

    #define INTERVAL     APP_TIMER_TICKS(10000, APP_TIMER_PRESCALER) 
    #define INTERVAL1     APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER)
    

    created second timer

    APP_TIMER_DEF(abc1);
    
    static void timeout_handler1(void * p_context)
    {
    	uint32_t err_code;
        UNUSED_PARAMETER(p_context);
    	advertising_start();
    	//err_code=sd_ble_gap_adv_start(BLE_ADV_MODE_FAST);
    //	 err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    	//power_manage();
        
    }
    
Reply
  • i have edited code for first timer i define period for two timers

    #define INTERVAL     APP_TIMER_TICKS(10000, APP_TIMER_PRESCALER) 
    #define INTERVAL1     APP_TIMER_TICKS(20000, APP_TIMER_PRESCALER)
    

    created second timer

    APP_TIMER_DEF(abc1);
    
    static void timeout_handler1(void * p_context)
    {
    	uint32_t err_code;
        UNUSED_PARAMETER(p_context);
    	advertising_start();
    	//err_code=sd_ble_gap_adv_start(BLE_ADV_MODE_FAST);
    //	 err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
    	//power_manage();
        
    }
    
Children
No Data
Related