hello there can i periodically advertisement with random data??
hello there can i periodically advertisement with random data??
like my one data is AA:AB:AC:AD:AE:AF after 1 second i want to make 11:12:13:14:15:16. then after 1 second i want to make it 21:22:23:24:25:26. can you tell me how to do it??
You change value in advdata and use this method to update: ble_advdata_set(&advdata, NULL);
i can't understand what are you saying. my advertisement function is like
static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
// Build advertising data struct to pass into @ref ble_advertising_init.
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_SHORT_NAME;
advdata.short_name_len = 1;
advdata.include_appearance = false;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
//ble_uuid_t adv_uuids[] = {{0x1234, BLE_UUID_TYPE_BLE}};
ble_advdata_manuf_data_t manuf_data;
uint8_t x1,x,x2,x3,x4,x5,y,y1,y2,y3,y4,y5,z,z1,z2,z3,z4,z5,z6,z7;
x1=0x50;
x =0x30;
y=0x20;
y1=0x21;
z1 =0x33;
z=0x35;
x2=0x50;
x3 =0x30;
y2=0x20;
y3=0x21;
z2 =0x33;
z3=0x35;
x4=0x50;
x5 =0x30;
y4=0x20;
y5=0x21;
z4 =0x33;
z5=0x35;
z6 =0x33;
z7=0x35;
uint8_t r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19,r20;
//HTU21D_Temperature1(&r1,&r2,&r3,&r4,&r5,&r6,&r7,&r8,&r9,&r10,&r11,&r12,&r13,&r14,&r15,&r16,&r17,&r18,&r19,&r20);
// uint8_t data[19] = {r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19}; // Our data to adverise
uint8_t data[20] ={x,x1,x2,x3,x4,x5,y,y1,y2,y3,y4,y5,z,z1,z2,z3,z4,z5,z6,z7};
// uint8_t data[20] ={x,x1,y,y1,z,z1,z2,z3,z4};
manuf_data.company_identifier = 0x0059; // Nordics company ID
manuf_data.data.p_data = data;
manuf_data.data.size = sizeof(data);
// advdata.flags = flags; // Set some flags. This is a topic for another tutorial
//advdata.uuids_complete.uuid_cnt = sizeof(adv_uuids) / sizeof(adv_uuids[0]); // Create a list of UUIDs. This is a topic for another tutorial
//advdata.uuids_complete.p_uuids = adv_uuids; // Create a list of UUIDs. This is a topic for another tutorial
advdata.p_manuf_specific_data = &manuf_data;
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;
ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
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);
}
You want manuf_data.data.p_data to random data, right?
advdata, uint8_t data[20] is declared static and global.
in while loop, you change any value in data[20].
the end, you call ble_advdata_set(&advdata, NULL);
i write function like that
static void advertising_init(void)
{
uint32_t err_code;
ble_advdata_t advdata;
ble_advdata_t scanrsp;
uint8_t a;
memset(&advdata, 0, sizeof(advdata));
advdata.name_type = BLE_ADVDATA_SHORT_NAME;
advdata.short_name_len = 2;
advdata.include_appearance = false;
advdata.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
ble_advdata_manuf_data_t manuf_data;
uint8_t x1,x,x2,x3,x4,x5,y,y1,y2,y3,y4,y5,z,z1,z2,z3,z4,z5,z6,z7;
x1=0x50;
x =0x30;
y=0x20;
y1=0x21;
z1 =0x33;
z=0x35;
x2=0x50;
x3 =0x30;
y2=0x20;
y3=0x21;
z2 =0x33;
z3=0x35;
x4=0x50;
x5 =0x30;
y4=0x20;
y5=0x21;
z4 =0x33;
z5=0x35;
z6 =0x33;
z7=0x35;
uint8_t r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16,r17,r18,r19,r20;
uint8_t data[20] ={x,x1,x2,x3,x4,x5,y,y1,y2,y3,y4,y5,z,z1,z2,z3,z4,z5,z6,z7};
manuf_data.company_identifier = 0x0059; // Nordics company ID
manuf_data.data.p_data = data;
manuf_data.data.size = sizeof(data);
advdata.p_manuf_specific_data = &manuf_data;
ble_advdata_manuf_data_t manuf_data_response;
uint8_t data_response[] = "s"; // Remember there is a 0 terminator at the end of string
manuf_data_response.company_identifier = 0x0059;
manuf_data_response.data.p_data = data_response;
manuf_data_response.data.size = sizeof(data_response);
memset(&scanrsp, 0, sizeof(scanrsp));
scanrsp.name_type = BLE_ADVDATA_NO_NAME;
scanrsp.p_manuf_specific_data = &manuf_data_response;
ble_adv_modes_config_t options = {0};
options.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
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);
err_code = ble_advdata_set(&advdata,&scanrsp);
APP_ERROR_CHECK(err_code);
}