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

Device getting restart after advertising_start() function

Hi, I am using following code inside for(;;) in main function

if(diff == 30) 	
    advertising_stop();
else if(diff == 60)
    advertising_start();

Following are the advertising_start and advertising_stop function

static void advertising_start(void) {
    uint32_t err_code;

    err_code = sd_ble_gap_adv_start(&m_adv_params);
    APP_ERROR_CHECK(err_code);

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
   APP_ERROR_CHECK(err_code);
}

static void advertising_stop(void) { 	
   uint32_t err_code;
   err_code = sd_ble_gap_adv_stop(); 	
   APP_ERROR_CHECK(err_code);

   err_code = bsp_indication_set(BSP_INDICATE_IDLE); 	
   APP_ERROR_CHECK(err_code); 
}

advertising_stop(); works properly when diff(time difference) reaches 30. but when diff reaches 60 and advertising_start() is called then device gets reset. What may be the reason behind this?

I am new to development framework, please guide me on this issue.

Parents
  • I am using following code, Are parameters correct?

    static void advertising_start(void){
     uint32_t err_code;
     ble_gap_adv_params_t m_adv_params;
     memset(&m_adv_params, 0, sizeof(m_adv_params));
     m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
     m_adv_params.p_peer_addr = NULL;
     m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
     m_adv_params.p_whitelist = NULL;
     m_adv_params.interval    = 0;
     m_adv_params.timeout     = 0;
     m_adv_params.channel_mask.ch_37_off = 0;
     m_adv_params.channel_mask.ch_38_off = 0;
     m_adv_params.channel_mask.ch_39_off = 0;
    
     err_code = sd_ble_gap_adv_start(&m_adv_params);
     printf("\n error = %d",err_code);
    //APP_ERROR_CHECK(err_code);
     err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
     printf("\n error = %d",err_code);
     APP_ERROR_CHECK(err_code);
    }
    

    still err_code coming AS 7

Reply
  • I am using following code, Are parameters correct?

    static void advertising_start(void){
     uint32_t err_code;
     ble_gap_adv_params_t m_adv_params;
     memset(&m_adv_params, 0, sizeof(m_adv_params));
     m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
     m_adv_params.p_peer_addr = NULL;
     m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
     m_adv_params.p_whitelist = NULL;
     m_adv_params.interval    = 0;
     m_adv_params.timeout     = 0;
     m_adv_params.channel_mask.ch_37_off = 0;
     m_adv_params.channel_mask.ch_38_off = 0;
     m_adv_params.channel_mask.ch_39_off = 0;
    
     err_code = sd_ble_gap_adv_start(&m_adv_params);
     printf("\n error = %d",err_code);
    //APP_ERROR_CHECK(err_code);
     err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
     printf("\n error = %d",err_code);
     APP_ERROR_CHECK(err_code);
    }
    

    still err_code coming AS 7

Children
No Data
Related