Hi, everyone
I am migrating from nrf51, sdk11, s130 programs to nrf52810, sdk15.3, s112
err_code = 0x0C is output from ble_advertising_init(&m_advertising, &init);
The previous program is as follows
static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
ble_adv_modes_config_t options;
ble_uuid_t adv_uuids[] = {{APP_EDDYSTONE_UUID, BLE_UUID_TYPE_BLE}};
uint8_array_t eddystone_data_array; // Array for Service Data structure.
eddystone_uid_data[17]=batt_percent;
eddystone_data_array.p_data = (uint8_t *) eddystone_uid_data; // Pointer to the data to advertise.
eddystone_data_array.size = sizeof(eddystone_uid_data); // Size of the data to advertise.
ble_advdata_service_data_t service_data; // Structure to hold Service Data.
service_data.service_uuid = APP_EDDYSTONE_UUID; // Eddystone UUID to allow discoverability on iOS devices.
service_data.data = eddystone_data_array; // Array for service advertisement data.
// Build and set advertising data.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_NO_NAME;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
advdata.uuids_complete.p_uuids = adv_uuids;
advdata.p_service_data_array = &service_data; // Pointer to Service Data structure.
advdata.service_data_count = 1;
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;
options.ble_adv_slow_enabled = true;
options.ble_adv_slow_interval = APP_ADV_INTERVAL_SLOW;
options.ble_adv_slow_timeout = APP_ADV_TIMEOUT_IN_SECONDS;
// Build and set scan response data.
memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.name_type = BLE_ADVDATA_FULL_NAME;
err_code = ble_advertising_init(&advdata, &scanrsp, &options, on_adv_evt, NULL);
APP_ERROR_CHECK(err_code);
sd_ble_gap_tx_power_set(0);
}
The migrated program is as follows
static void advertising_init(void)
{
uint32_t err_code;
//ble_advdata_t advdata;
//ble_advdata_t scanrsp;
//ble_adv_modes_config_t options;
ble_advertising_init_t init;
memset(&init, 0, sizeof(init));
ble_uuid_t adv_uuids[] = {{APP_EDDYSTONE_UUID, BLE_UUID_TYPE_BLE}};
uint8_array_t eddystone_data_array; // Array for Service Data structure.
eddystone_uid_data[17]=batt_percent;
eddystone_data_array.p_data = (uint8_t *) eddystone_uid_data; // Pointer to the data to advertise.
eddystone_data_array.size = sizeof(eddystone_uid_data); // Size of the data to advertise.
ble_advdata_service_data_t service_data; // Structure to hold Service Data.
init.advdata.p_service_data_array->service_uuid = APP_EDDYSTONE_UUID; // Eddystone UUID to allow discoverability on iOS devices.
init.advdata.p_service_data_array->data = eddystone_data_array; // Array for service advertisement data.
// Build and set advertising data.
//memset(&advdata, 0, sizeof(advdata));
init.advdata.name_type = BLE_ADVDATA_NO_NAME;
init.advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
init.advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]);
init.advdata.uuids_complete.p_uuids = adv_uuids;
init.advdata.p_service_data_array = &service_data; // Pointer to Service Data structure.
init.advdata.service_data_count = 1;
//memset(&options, 0, sizeof(options));
init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
init.config.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS;
init.config.ble_adv_slow_enabled = true;
init.config.ble_adv_slow_interval = APP_ADV_INTERVAL_SLOW;
init.config.ble_adv_slow_timeout = APP_ADV_TIMEOUT_IN_SECONDS;
// Build and set scan response data.
//memset(&scanrsp, 0, sizeof(scanrsp));
init.srdata.name_type = BLE_ADVDATA_FULL_NAME;
init.evt_handler = on_adv_evt;
err_code = ble_advertising_init(&m_advertising, &init);
APP_ERROR_CHECK(err_code);
ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle,0);
}
Please advice
Alex