[ nRF52833 ] How to set Non-Connectable Advertizing using Advertising Library / Module

Hello,

In my experimentation to update advertising data during runtime, I am following the example @ 

 How to update advertising data dynamically using BLE Advertising library 

It is using the ble_advertising.h library module 

However I would like to set this advertising to non-connectable, non-scannable and non directed mode similar to 

static ble_gap_adv_params_t m_adv_params;  

m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;

However, the data structure used for the advertising module 

ble_advertising_init_t init;

does not provide any provision to set the non connectable mode. 

May be the init.advdata.flags could be set ?  But does it have the values that I can set to non-connectable

Very similar question has already been asked previously but still open

 How to set non-connectable mode in BLE 

 

Can you please guide here ?

Thanks,

Abhi Ash

Parents
  • Hi Abhi, 
    For doing non-connectable advertising, it's suggested to use the softdevice APIs directly, similar to what in the ble_app_beacon example. You can configure advertising using sd_ble_gap_adv_set_configure() and start advertising using sd_ble_gap_adv_start(). 

    If you want to use the ble_advertising library, you would need to modify the library to support non-connectable mode. 

  • Hi Hung Bui,

    My requirement is to update the contents of beacon (non-connectable) dynamically and how can we implement this using only softdevice APIs ( i.e. without using the advertising library )?

    "If you want to use the ble_advertising library, you would need to modify the library to support non-connectable mode. "

    How is this possible for a normal user ?  Some are SV calls. Is it ok to modify the ble_advdata_t  ?  i.e. allow more values to the .flags ? Currently it uses values from ble_gap.h 

    #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
    #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
    #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
    #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
    #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
    #define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */
    #define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */

    Thanks,

    Abhi Ash

  • Hello,

    In ble_advertising.c,  I have added the line below in both ble_advertising_init() and ble_advertising_start() functions however I still see the adverizement type as ADV_IND 

     p_advertising->adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;

    Can you please guide regarding where exactly the change needs to be made to make the advertising non connectable ?

    Thanks,

    Regards

    Abhi Ash

  • Hi AbhiAsh, 
    You would need to change it in set_adv_mode_fast(), set_adv_mode_slow() as well. 
    But I don't see the point of modifying it if you only want to do beaconing. Unless you want to support both switching between connectable and non-connectable.
    Have you looked at the beacon example we have ? 

  • Hi Hung,

    Thanks for your response.

    My requirement is just sending out advertisements in non-connectable mode only. Connectable would be never needed.

    I have tried and used the beacon example however it directly uses the gap API and not the advertising library.
    I need to dynamically change the beacon contents.

    I inserted the line below in both fast and slow adv init functions
    p_adv_params->properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;

    However, sniffing the packet using the nRF Sniffer, the PDU Type is still shown as ADV_IND.
    and when I observe in the nRFConnect Android App, I can see the CONNECT option besides.

    May be something is still missing or going wrong

    Thanks
    Abhishek

  • Please attach your code where you do the modification. 

    I don't see a problem modifying the beacon example to stop advertising, update the advertising content and continue advertising. 

  • I reviewed my code once more.

    I was setting it at the beginning of the function and it was getting overwritten.

    It should be like given below

    // p_advertising->adv_params.properties.type =                BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    p_adv_params->properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;

    It works now and shows ADV_NONCONN_IND

    Thanks again,

    Abhi Ash

Reply
  • I reviewed my code once more.

    I was setting it at the beginning of the function and it was getting overwritten.

    It should be like given below

    // p_advertising->adv_params.properties.type =                BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;
    p_adv_params->properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;

    It works now and shows ADV_NONCONN_IND

    Thanks again,

    Abhi Ash

Children
No Data
Related