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

Parents
  • 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.

Reply
  • 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.

Children
  • 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?

  • Hi The whole Information like below: SDK: nRF5_SDK_12.1.0_0d23e2a Example Code: ble_app_hrs_rscs_relay MCU: nRF52832 on PCA10040 Board SD: 132 The Modify parts:

    static void adv_scan_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 scanning for peripherals and initiate connection to devices which
        // advertise Heart Rate or Running speed and cadence UUIDs.
        //scan_start();
    
        // Turn on the LED to signal scanning.
        LEDS_ON(CENTRAL_SCANNING_LED);
    
        // Start advertising.
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    }
    

    }

    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_RC,            \
                                 .rc_ctiv       = 16,                                \
                                 .rc_temp_ctiv  = 0,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}
    

    That are parts of example code I modify. and I set the

    #define APP_ADV_TIMEOUT_IN_SECONDS       20
    

    and the nRF52 stop advertising after 20 second but the on_adv_evt has no BLE_ADV_EVT_IDLE flag trigger.

    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"); LEDS_ON(PERIPHERAL_ADVERTISING_LED); break;//BLE_ADV_EVT_FAST

        case BLE_ADV_EVT_IDLE:
        {
    				  NRF_LOG_INFO("BLE_ADV_EVT_IDLE\r\n");
            ret_code_t err_code;
            err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
            APP_ERROR_CHECK(err_code);
        } break;//BLE_ADV_EVT_IDLE
    
        default:
            // No implementation needed.
            break;
    }
    

    }

  • FormerMember
    0 FormerMember in reply to Vincent

    Okay, I see. Do you have added (registered) on_adv_evt (..) as the event handler in ble_advertising_init(..)?

Related