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

How to change the device name? nRF51822 (s110)

Hi, I am studying with nRF51822 (s110).

I found some source code from devzone.nordicsemi.com/.../

and I am trying to change the device name,

And I don't know why it is not works.

Help me plz.

static void advertising_init(void) {

uint32_t        err_code;
ble_advdata_t   advdata;	
//
ble_advdata_manuf_data_t adv_manuf_data;
uint8_array_t            adv_manuf_data_array;
uint8_t                  adv_manuf_data_data[23];
//
uint8_t         flags = BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;

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

// Configuration of manufacturer specific data

adv_manuf_data_data[0] = 0x02;   //BLE Type
adv_manuf_data_data[1] = 0x15;			//iBeacon 
adv_manuf_data_data[2] = 0x03;   //UUID
adv_manuf_data_data[3] = 0x04;			//UUID
adv_manuf_data_data[4] = 0x05;   
adv_manuf_data_data[5] = 0x06;		
adv_manuf_data_data[6] = 0x07;   
adv_manuf_data_data[7] = 0x08;		
adv_manuf_data_data[8] = 0x09;   
adv_manuf_data_data[9] = 0x10;		
adv_manuf_data_data[10] = 0x11;			//UUID
adv_manuf_data_data[11] = 0x12;			//UUID
adv_manuf_data_data[12] = 0x13;			//UUID
adv_manuf_data_data[13] = 0x14;			//UUID
adv_manuf_data_data[14] = 0x15;			//UUID
adv_manuf_data_data[15] = 0x16;			//UUID
adv_manuf_data_data[16] = 0x17;			//UUID
adv_manuf_data_data[17] = 0x18;			//UUID
adv_manuf_data_data[18] = 0x19;			//Major
adv_manuf_data_data[19] = 0x20;			//Major
adv_manuf_data_data[20] = 0x21;			//Minor
adv_manuf_data_data[21] = 0x22;			//Minor
adv_manuf_data_data[22] = 0x23;			//TxPwer
    

adv_manuf_data_array.p_data = adv_manuf_data_data;
adv_manuf_data_array.size = sizeof(adv_manuf_data_data);
	
adv_manuf_data.company_identifier = APP_COMPANY_IDENTIFIER;
adv_manuf_data.data = adv_manuf_data_array;
	
advdata.p_manuf_specific_data = &adv_manuf_data;

 
 //advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
 	//advdata.short_name_len          = 2;
 advdata.flags.size              = sizeof(flags);
advdata.flags.p_data            = &flags;
			
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));



m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
m_adv_params.p_peer_addr = NULL;                             // Undirected advertisement.
m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
m_adv_params.interval    = NON_CONNECTABLE_ADV_INTERVAL;
m_adv_params.timeout     = APP_CFG_NON_CONN_ADV_TIMEOUT;

}

When I put these lines,

 //advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
 //advdata.short_name_len          = 2;

These two lines occurs error.

It there any way to fix this error?

Thanks.

Parents
  • It would be helpful to know what the error code is that you are seeing. Without that I can speculate. First guess would be that you have exceeded the size allowed for the advertising packet and that is why you are getting the error. You can move some of your data into the scan response if that is the case.

    I do find some of the in line comments where you are initializing your adv_manuf_data_data array intriguing. Things like UUIDs, and tx Power can be encoded into the standard advertising packet rather than in manufacturer specific data. Are you doing that to save space?

  • @Inspectron Yes that is all. but you should set the device name length. And if you want to display device name in the beacon mode, you must think about advertising data length.

Reply Children
No Data
Related