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

BLE DEVICE_NAME not showing

Hi,

I am facing problem while developing code for the application.

I am working on the "ble_app_uart" example code to develop my one of the application, But after making some custom changes into the code it stops showing the "DEVICE_NAME" in nRF Connect Nordic application.

I have added some of the code from the "Beacon" project to advertise the company and devices type & all.

Here after adding all these line of code into the "ble_app_uart" from the "Beacon" project it stop showing the DEVICE_NAME in the application. I don't know why is it so.

Can you please guide to resolve this error.

For more I am sharing code which i have used for advertising:

#define DEVICE_NAME                     "SSLBL" 

#define APP_ADV_INTERVAL 64 /**< The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms). */
#define APP_ADV_TIMEOUT_IN_SECONDS 60 /**< The advertising timeout (in units of seconds). */


#define MIN_CONN_INTERVAL MSEC_TO_UNITS(20, UNIT_1_25_MS) /**< Minimum acceptable connection interval (20 ms), Connection interval uses 1.25 ms units. */
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(75, UNIT_1_25_MS) /**< Maximum acceptable connection interval (75 ms), Connection interval uses 1.25 ms units. */
#define SLAVE_LATENCY 0 /**< Slave latency. */
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds), Supervision Timeout uses 10 ms units. */
#define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER) /**< Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(30000, APP_TIMER_PRESCALER) /**< Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT 3 /**< Number of attempts before giving up the connection parameter negotiation. */

#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */


#define APP_TAG_INFO_LENGTH 0x17 /**< Total length of information advertised by the TAG. */
#define APP_ADV_DATA_LENGTH 0x16 /**< Length of manufacturer specific data in the advertisement. */
#define APP_COMPANY_IDENTIFIER 0x02A1 /**< Company identifier for ASA. as per www.bluetooth.org. */
#define APP_FM_VER 0x02, 0x03 /**< Firmware Version */
#define APP_HW_VER 0x04, 0x05 /**< Hardware Version */

static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
ble_adv_modes_config_t options;

uint8_t flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

ble_advdata_manuf_data_t manuf_specific_data;

manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;


// Build advertising data struct to pass into @ref ble_advertising_init.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.include_appearance = false;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;

memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
scanrsp.uuids_complete.p_uuids = m_adv_uuids;

manuf_specific_data.data.p_data = (uint8_t *) m_tag_info;
manuf_specific_data.data.size = APP_TAG_INFO_LENGTH;

// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));

advdata.name_type = BLE_ADVDATA_FULL_NAME;
advdata.flags = flags;
advdata.p_manuf_specific_data = &manuf_specific_data;

err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);

// Initialize advertising parameters (used when starting advertising).
memset(&m_adv_params, 0, sizeof(m_adv_params));

memset(&options, 0, sizeof(options));
options.ble_adv_fast_enabled = true;
options.ble_adv_fast_interval = APP_ADV_INTERVAL;
options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS;


err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);
}

And also I am sharing the screenshot of my application more clarification.

Parents
  • Please check in ble_app_uart example where the DEVICE_NAME is being used in the main.c, You will then understand how to set the advertising data to contain the device name. Right now I do not see anywhere in your code where you use DEVICE_NAME.

  • Hi Susheel, 

    I have seen that DEVICE_NAME in my project it shows in the "GAP_INIT()" function.

    I have all set for the device name. As I mentioned that I have used "ble_app_uart" and in which I have added small portion of the "beacon" project only to advertise the manufacture data to it custom for my application.

    But after all in the end I am Not getting device while broadcasting & watching it into the nrf application.

    And I want to display the DEVICE_NAME with Company identifier, Hardware, Firmware version in advertise data packet.

    Here I am sharing my main.c code for your reference.

    Thanks

  • in advertising_init() function you have explicitly asked not to include the advertising device name.

    comment it out like below

    //    // Build and set advertising data.
    //    memset(&advdata, 0, sizeof(advdata));
    
    //    advdata.name_type             = BLE_ADVDATA_NO_NAME;
    //    advdata.flags                 = flags;
    //    advdata.p_manuf_specific_data = &manuf_specific_data;
    
    //    err_code = ble_advdata_set(&advdata, NULL);
    //    APP_ERROR_CHECK(err_code);

  • Hi Susheel, 

    Thanks for your answer and answer work out for me it starts advertising.

    But in addition of it I want to advertise the manufacturer specific data too. Like company name, Firmware & Hardware version with it.

    So that we can get the Device_Name, Company_Name, Hardware & Firmware version details within the advertising packet.

    Looking forward for your valuable guidelines ....

    Regards

    Sachin 

  • then you add manufacture data in advertising packet and the device name in the scan response or vice versa.

  • Code("my code" in above) available, I have added the manufacturer details to it, but after it stop advertising the Device_Name at the time of broadcasting.

    I have added those manufacturer details to it to do the same. But after your reply I have commented those lines to make the code advertising.

    So, Is there any way to add the those details or any lines which I have to add into the code to advertise the manufacturer data.

    Thanks 

  • Then instead of BLE_ADVDATA_NO_NAME you need to put BLE_ADVDATA_FULL_NAME.   use below and try it out.

    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        ble_advdata_t scanrsp;
    	  ble_adv_modes_config_t options;
    
    		uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    
    	  ble_advdata_manuf_data_t manuf_specific_data;
    
    		manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    	
    		
    		// Build advertising data struct to pass into @ref ble_advertising_init.
        memset(&advdata, 0, sizeof(advdata));
        advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance = false;
        advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        scanrsp.uuids_complete.p_uuids  = m_adv_uuids;
    
    		manuf_specific_data.data.p_data = (uint8_t *) m_tag_info;
        manuf_specific_data.data.size   = APP_TAG_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type             = BLE_ADVDATA_FULL_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        
    
        memset(&options, 0, sizeof(options));
        options.ble_adv_fast_enabled  = true;
        options.ble_adv_fast_interval = APP_ADV_INTERVAL;
        options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
        	
    		err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
        APP_ERROR_CHECK(err_code);
    	
    }
    

    Make sure that you actually have space in the adv packet + scan response data to send "device_name+manufacture data+uuids list. It sounds to me that you might not have that much space

    You will most likely get an error NRF_ERROR_DATA_SIZE in ble_advertising_init. You need to calculate the available space in packets and organise the data to be sent accordingly.

Reply
  • Then instead of BLE_ADVDATA_NO_NAME you need to put BLE_ADVDATA_FULL_NAME.   use below and try it out.

    static void advertising_init(void)
    {
        uint32_t      err_code;
        ble_advdata_t advdata;
        ble_advdata_t scanrsp;
    	  ble_adv_modes_config_t options;
    
    		uint8_t       flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;
    
    	  ble_advdata_manuf_data_t manuf_specific_data;
    
    		manuf_specific_data.company_identifier = APP_COMPANY_IDENTIFIER;
    	
    		
    		// Build advertising data struct to pass into @ref ble_advertising_init.
        memset(&advdata, 0, sizeof(advdata));
        advdata.name_type          = BLE_ADVDATA_FULL_NAME;
        advdata.include_appearance = false;
        advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    
        memset(&scanrsp, 0, sizeof(scanrsp));
        scanrsp.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        scanrsp.uuids_complete.p_uuids  = m_adv_uuids;
    
    		manuf_specific_data.data.p_data = (uint8_t *) m_tag_info;
        manuf_specific_data.data.size   = APP_TAG_INFO_LENGTH;
    
        // Build and set advertising data.
        memset(&advdata, 0, sizeof(advdata));
    
        advdata.name_type             = BLE_ADVDATA_FULL_NAME;
        advdata.flags                 = flags;
        advdata.p_manuf_specific_data = &manuf_specific_data;
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        
    
        memset(&options, 0, sizeof(options));
        options.ble_adv_fast_enabled  = true;
        options.ble_adv_fast_interval = APP_ADV_INTERVAL;
        options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;
    
        	
    		err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
        APP_ERROR_CHECK(err_code);
    	
    }
    

    Make sure that you actually have space in the adv packet + scan response data to send "device_name+manufacture data+uuids list. It sounds to me that you might not have that much space

    You will most likely get an error NRF_ERROR_DATA_SIZE in ble_advertising_init. You need to calculate the available space in packets and organise the data to be sent accordingly.

Children
  • Hi Susheel,

    First of all Thank you very much for the quick replies ... :-)

    I have copied your whole code of  void advertising_init(void) to my main code, but once it stop advertising.

    Best Regards

  • Hey,

    This is what was saying. You may not have enough space to advertise all this data. Check the response of the "ble_advertising_init" function.

  • Hi Ashish,

    Okay I got the point that space is fulled because of previous data.

    And I am new to this NRF - SDK and if I am going wrong then please guide me for the correct solutions.

    It would be great if can guide to advertise the data with manufacturer details.

    Looking forward for all guideline ... :-)

    Many Thanks

  • Hi Sachin,

    Take a look at this code. It includes the full name in the advertising data and the manufacturer data in the scan response.

    void advertising_init() {
    	ret_code_t				err_code;
    	ble_advertising_init_t	init;
    
    	// Build advertising data struct to pass into @ref ble_advertising_init.
    	memset(&init, 0, sizeof(init));
    
    	init.advdata.name_type				= BLE_ADVDATA_FULL_NAME;
    	init.advdata.include_appearance		= false;
    	init.advdata.flags					= BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    
    	init.config.ble_adv_fast_enabled	= true;
    	init.config.ble_adv_fast_interval	= APP_FAST_ADV_INTERVAL;
    	init.config.ble_adv_fast_timeout	= APP_FAST_ADV_TIMEOUT_IN_SECONDS;
    
    	init.config.ble_adv_slow_enabled	= true;
    	init.config.ble_adv_slow_interval	= APP_SLOW_ADV_INTERVAL;
    	init.config.ble_adv_slow_timeout	= APP_SLOW_ADV_TIMEOUT_IN_SECONDS;
    
    	init.config.ble_adv_whitelist_enabled = true;
    	init.config.ble_adv_extended_enabled = false;
    
    	// Advertising restart on disconnect should be handled in this file
    	init.config.ble_adv_on_disconnect_disabled = true;
    
    	ble_uuid_t main_service_uuid = {BLE_UUID_X_SERVICE, x_service_uuid};
    
    	ble_advdata_manuf_data_t manufacturer_data;
    
    	uint8_t data_array[4];
    	W_LE32(data_array, serial_number); //4 bytes
    
    	memset(&manufacturer_data, 0, sizeof(manufacturer_data));
    	manufacturer_data.company_identifier = COMPANY_ID;
    	manufacturer_data.data.size = 4;
    	manufacturer_data.data.p_data = data_array;
    
    	init.srdata.uuids_complete.uuid_cnt = 1;
    	init.srdata.uuids_complete.p_uuids = &main_service_uuid;
    	init.srdata.p_manuf_specific_data = &manufacturer_data;
    
    	init.evt_handler = on_adv_evt;
    
    	//Include scan response packet in advertising
    
    	err_code = ble_advertising_init(&m_advertising, &init);
    	if (err_code != NRF_SUCCESS) {
    		debug_error("Advertising initialization failed with error code 0x%02X", err_code);
    		APP_ERROR_CHECK(err_code);
    	}
    
    	// This will temporarily disable whitelisting
    	// The whitelist will be automatically reenabled on the first advertising timeout
    	ble_advertising_disable_whitelist(&m_advertising);
    
    	ble_advertising_conn_cfg_tag_set(&m_advertising, PERIPHERAL_CONN_CFG_TAG);
    
    	debug_line("Advertising initialized");
    }

  • Hi Ashish,

    I have already tested this code in main and this code is for the S130 or above, from the Nordic Advertising tutorial.

    And the  "init.srdata", "init.config", all these statements are not running in my main, it gives error. 

    I need to simply develop the same in the SDK S110.

    So can you guide me for the development of same in s110 SDK.

    Thanks 

Related