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

Device name changing problem after addng All tha functions also

all the details needed to reproduce my situation, including:
        development software, with versions soft device s110, nrf51822
        Computer platform, with versions (Windows)
        
        general setup and configuration

device name is not display it s displayed as N/A i have added all the functions required

nt main(void)
{
uint32_t err_code;
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);
err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);
ble_stack_init();
gap_params_init();// Nishtha
advertising_init();

// Start execution.
advertising_start();
//gap_params_init();// Nishtha
// Enter main loop.
for (;; )
{
power_manage();
}
}


static void gap_params_init(void)
{
uint32_t err_code;
ble_gap_conn_params_t gap_conn_params;
ble_gap_conn_sec_mode_t sec_mode;
ble_advdata_t advdata;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
//if(at_com_data.device_name[0]=='n') // Device name has been saved in the flash.
{
// printf("change device name: ");
//printf("change device name: %s",(uint8_t *)&at_com_data.device_name[1]);
//printf("\r\n");

err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
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;

err_code = ble_advdata_set(&advdata, NULL);
APP_ERROR_CHECK(err_code);
// printf("err_code=0x%08x\r\n",err_code);
}
/*else
// Device name isn't in the flash.
{
printf("defaule name\r\n");
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *) DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
}*/
/* err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
*/
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_HEART_RATE_SENSOR_HEART_RATE_BELT);
APP_ERROR_CHECK(err_code);

memset(&gap_conn_params, 0, sizeof(gap_conn_params));

//gap_conn_params.min_conn_interval = MIN_CONN_INTERVAL;
//gap_conn_params.max_conn_interval = MAX_CONN_INTERVAL;
//gap_conn_params.slave_latency = SLAVE_LATENCY;
//gap_conn_params.conn_sup_timeout = CONN_SUP_TIMEOUT;

err_code = sd_ble_gap_ppcp_set(&gap_conn_params);
APP_ERROR_CHECK(err_code);

ble_gap_addr_t gap_address;
gap_address.addr_type = BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE;
err_code = sd_ble_gap_address_set(BLE_GAP_ADDR_CYCLE_MODE_AUTO, &gap_address);
APP_ERROR_CHECK(err_code);// Check for errors
}

static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t srdata; //Nishtha
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;

#if defined(USE_UICR_FOR_MAJ_MIN_VALUES)
// If USE_UICR_FOR_MAJ_MIN_VALUES is defined, the major and minor values will be read from the
// UICR instead of using the default values. The major and minor values obtained from the UICR
// are encoded into advertising data in big endian order (MSB First).
// To set the UICR used by this example to a desired value, write to the address 0x10001080
// using the nrfjprog tool. The command to be used is as follows.
// nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val <your major/minor value>
// For example, for a major value and minor value of 0xabcd and 0x0102 respectively, the
// the following command should be used.
// nrfjprog --snr <Segger-chip-Serial-Number> --memwr 0x10001080 --val 0xabcd0102
uint16_t major_value = ((*(uint32_t *)UICR_ADDRESS) & 0xFFFF0000) >> 16;
uint16_t minor_value = ((*(uint32_t *)UICR_ADDRESS) & 0x0000FFFF);

uint8_t index = MAJ_VAL_OFFSET_IN_BEACON_INFO;

m_beacon_info[index++] = MSB(major_value);
m_beacon_info[index++] = LSB(major_value);

m_beacon_info[index++] = MSB(minor_value);
m_beacon_info[index++] = LSB(minor_value);
#endif



manuf_specific_data.data.p_data = (uint8_t *) m_beacon_info;
manuf_specific_data.data.size = APP_BEACON_INFO_LENGTH;

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

advdata.name_type = BLE_ADVDATA_FULL_NAME;//BLE_ADVDATA_NO_NAME;
advdata.flags = flags;
advdata.short_name_len = 5;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

advdata.p_manuf_specific_data = &manuf_specific_data;

// Nishtha Start
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
APP_ERROR_CHECK(err_code);
// Build and set scan response data. Nishtha start
memset(&srdata, 0, sizeof(srdata));
srdata.name_type = BLE_ADVDATA_FULL_NAME;
err_code = ble_advdata_set(&advdata, &srdata);
APP_ERROR_CHECK(err_code);

//Nishtha End

// 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_SCAN_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;



}

static void ble_stack_init(void)
{
// Initialize the SoftDevice handler module.
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
// Enable BLE stack
uint32_t err_code;
ble_enable_params_t ble_enable_params;
memset(&ble_enable_params, 0, sizeof(ble_enable_params));


#ifdef S130
ble_enable_params.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
#endif
ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
err_code = sd_ble_enable(&ble_enable_params);
APP_ERROR_CHECK(err_code);
//Nishtha
ble_gap_conn_sec_mode_t sec_mode;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);
err_code = sd_ble_gap_device_name_set(&sec_mode,
(const uint8_t *)DEVICE_NAME,
strlen(DEVICE_NAME));
//nishtha end
}

Please help me out so that device name displayed




Related