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

SDk12 ble_app_hrs_rscs_relay has no BLE_ADV_EVT_IDLE in on_adv_evt

Hi I use ble_app_hrs_rscs_relay example with sdk12 and when the APP_ADV_TIMEOUT_IN_SECONDS is reach the nrf52 stop advertising but the on_adv_evt has no BLE_ADV_EVT_IDLE flag coming.

I do ble_advertising_start only now. Do I need call sd_ble_gap_scan_start on the same time with this example.

Thanks

  • FormerMember
    0 FormerMember

    Yes, in BLE_ADV_EVT_IDLE, calling ble_advertising_start() is all you need to do to start advertising.

    Note: If you don't want advertising to time out, the advertising timeout can be set to '0'.

  • Hi Kristin, Sorry I means I did calling

        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    

    and it did timeout because it has no any ble advertising but the on_adv_evt has no BLE_ADV_EVT_IDLE occur.

    of course I just need keep ble advertising until the Phone scan and connect. I will set the timeout to 0. but why the on_adv_evt has no BLE_ADV_EVT_IDLE occur.

    Thank you.

  • FormerMember
    0 FormerMember in reply to Vincent

    Did you add BLE_ADV_EVT_IDLE to on_adv_evt(..), but BLE_ADV_EVT_IDLE never occurs?

  • static void adv_start(void) { ret_code_t err_code; uint32_t count;

    //check if there are no flash operations in progress
    err_code = fs_queued_op_count_get(&count);
    APP_ERROR_CHECK(err_code);
    
    if (count == 0)
    {
        // Start advertising.
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    }
    	else
    	{
    		  NRF_LOG_INFO("flash operations in progress\r\n");
    	}
    

    }

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    

    { switch (ble_adv_evt) { case BLE_ADV_EVT_FAST: NRF_LOG_INFO("Fast Advertising\r\n"); break;//BLE_ADV_EVT_FAST

        case BLE_ADV_EVT_IDLE:
    				  NRF_LOG_INFO("Advertising Idle\r\n");
            //adv_start();
    			break;//BLE_ADV_EVT_IDLE
    
        default:
            // No implementation needed.
            break;
    }
    

    }

    I only add the printf and I was thought when the on_adv_evt got the BLE_ADV_EVT_IDLE then I scan again. The timeout time I set it is 30 second and it did stop advertising but I dont see the printf and mcu did not advertising again.

    Thanks

  • FormerMember
    0 FormerMember in reply to Vincent

    Which version of the SDK do you use? When I test ble_app_gls from SDK 12.1.0 and enables fast advertising then timeout, it works ( the application hits BLE_ADV_EVT_IDLE).

    How do you configure fast advertising?

Related