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

Radio Notification Context

Hello,

I have a problem using the radio notifications. I use the softdevice V. 15.3.0.

I would like to have an interrupt every time I send an advertisement, which I can achieve using:

ble_radio_notification_init( 2, NRF_RADIO_NOTIFICATION_DISTANCE_800US, interrupt_func)

While this is working fine on its own, the interrupt is not only triggered by advertisements, but also from radio activities coming from a scanner which is running simultaneously. Is there a way to find out if the interrupt was triggered by advertisement or the scanner? Also if I could just get an interrupt when advertising this would be fine.

Best Regards,

Lukas

Edit: Wrong naming, mistaken advertisement and notification.

Parents
  • Hi.

    The function that you're referring to is apart of the radio notifications API, which will notify the application every time the radio is in use. The S112 softdevice will produce a BLE_GATTS_EVT_HVN_TX_COMPLETE event every time a BLE notification is sent. You can implement the event in the switch case in the gatt handler in your project.

     
    best regards
    Jared 
  • Hey,

    Thanks for your help. Since I know it should work for S132 I tried but could not make it work.

    I initialize the following modules

    void init(void)
    	nrf_pwr_mgmt_init();
    	ble_stack_init();
    	gap_params_init();
    	nrf_ble_gatt_init(&m_gatt, NULL);
    	advertising_init();
    	scan_init();
    }

    The ble_evt_handler looks as follows


    void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context)
    {
    	NRF_LOG_INFO("%d", p_ble_evt->header.evt_id);
    	NRF_LOG_PROCESS();
    }

    When I run it I can see the advertisements are sent using my phone, also I get only 29 in the logs which corresponds to the scan report. Unfortunately I do not get any other evt_ids in the handler, e.g. BLE_GATTS_EVT_HVN_TX_COMPLETE does not appear.

    I was trying to follow the example: ble_peripheral/experimental/ble_app_hids_keyboard_pairing_nfc, where BLE_GATTS_EVT_HVN_TX_COMPLETE is used.

    best regards,

    Lukas

  • Sorry I do not get what you mean by "enable notifcations". Could you please elaborate?

    Edit: If i understand correctly you mean

    ble_radio_notification_init(2, NRF_RADIO_NOTIFICATION_DISTANCE_2680US, NULL);

    which I did indeed initialize.

  • Hey,

    After reading the post you sent me I think there was a misunderstanding. I would like to get an interrupt when sending an advertisement, not when sending a notification. I've mistaken the two terms, sorry for that. 

    So the actual question I had was if I can get an interrupt after an advertisement. And I could already do this with 

    ble_radio_notification_init(2, NRF_RADIO_NOTIFICATION_DISTANCE_2680US, interrupt_fun);

    But this interrupt also fires when doing a scan. So is there a way to only do this after advertising and not when performing a scan?

    Sorry for my mistake. 

  • Hi,

    Oh well, I see.. The thing with using radio notifications is that it's totally agnostic over what happens on the higher layer, it only cares if the radio is Active or not. There isn't a specific event that is generated when the nRF are advertising. You can always do this indirectly by setting a flag once you've started advertising in the application, but it won't necessarily be precise as the Softdevice has to schedule the task i.e put in the queue and execute it. But it will in most cases work fine Slight smile

    regards

    Jared

Reply
  • Hi,

    Oh well, I see.. The thing with using radio notifications is that it's totally agnostic over what happens on the higher layer, it only cares if the radio is Active or not. There isn't a specific event that is generated when the nRF are advertising. You can always do this indirectly by setting a flag once you've started advertising in the application, but it won't necessarily be precise as the Softdevice has to schedule the task i.e put in the queue and execute it. But it will in most cases work fine Slight smile

    regards

    Jared

Children
Related