I have a question regarding fast/slow advertising
I'd like to advertise for 180s using a 100ms interval, then switch to a 1s interval, preferably for ever. I set advertise options as shown in the image.
When I test the software I find that advertising stops after 3 seconds. Why?
Thank you for helping me out on this
If you want to advertise indefinitely, advertising timeout should be set to '0'. When I test your advertising parameters for slow advertising, sd_ble_gap_adv_start(..) returns success.
If you run the chip in debug mode, could you check if there is an assert or a hardfault that occurs after approximately 3s? (For how to debug, it can be useful to take a look at this post.)
No, advertising just stops. The application keeps running.
Do you see the same problem if you use the same advertising parameters in one of our SDK examples?
Like you have suggested I have tried out your ANCS example. It turns out the example works as I would expect. Here is how I setup advertising, what do I do wrong?
#define APP_ADV_FAST_ENABLED true
#define APP_ADV_FAST_INTERVAL 160 /* (corresponding to 100ms) */
#define APP_ADV_FAST_TIMEOUT_IN_SECONDS 180 /* Adv. timeout [s] */
#define APP_ADV_SLOW_ENABLED true
#define APP_ADV_SLOW_INTERVAL 1600 /* (corresponding to 1s) */
#define APP_ADV_SLOW_TIMEOUT_IN_SECONDS 1000 /* Adv. timeout [s] */
static void initAdvertising (void)
ble_advdata_t adv_data, scan_data;
ble_uuid_t adv_list, scan_list;
/* Build advertising and scan response UUID lists:- */
adv_list.uuid = 0; /* Byte 12/13 -> zero'ed out (= service UUID) */
adv_list.type = BLE_UUID_TYPE_VENDOR_BEGIN + 4; /* service = MIDAS */
scan_list.uuid = 0; /* Byte 12/13 -> zero'ed out (= service UUID) */
scan_list.type = BLE_UUID_TYPE_VENDOR_BEGIN + 3; /* service = MDC */
/* Configure advertising: */
memset (&adv_data, 0, sizeof (adv_data));
adv_data.name_type = BLE_ADVDATA_FULL_NAME;
adv_data.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
adv_data.uuids_complete.uuid_cnt = 1;
adv_data.uuids_complete.p_uuids = &adv_list;
/* Configure scan response: */
memset (&scan_data, 0, sizeof (scan_data));
scan_data.uuids_complete.uuid_cnt = 1;
scan_data.uuids_complete.p_uuids = &scan_list;
/* Configure options: */
memset (&adv_opts, 0, sizeof (adv_opts));
adv_opts.ble_adv_fast_enabled = BLE_ADV_FAST_ENABLED;
adv_opts.ble_adv_fast_interval = APP_ADV_FAST_INTERVAL;
adv_opts.ble_adv_fast_timeout = APP_ADV_FAST_TIMEOUT_IN_SECONDS;
adv_opts.ble_adv_slow_enabled = BLE_ADV_SLOW_ENABLED;
adv_opts.ble_adv_slow_interval = APP_ADV_SLOW_INTERVAL;
adv_opts.ble_adv_slow_timeout = APP_ADV_SLOW_TIMEOUT_IN_SECONDS;
err_code = ble_advertising_init (&adv_data, &scan_data, &adv_opts, onAdvertisingEvent, NULL);
The advertising_init(..) function looks fine. Could you run the chip in debug mode and put a breakpoint in on_timeout(..), adv_mode_next_avail_get(..), and ble_advertising_start(..) all in ble_advertising.c, just to check if you can get some useful information form that.
Could you also upload your main.c here? Which SDK and softdevice do you use?