diff --git a/epicardium/ble/ble_adv.c b/epicardium/ble/ble_adv.c index 6b129c50ace26a4babea13fa51d2e436121d75a5..4aea57c5b651be0c680d4e4526b6f069f9b0229b 100644 --- a/epicardium/ble/ble_adv.c +++ b/epicardium/ble/ble_adv.c @@ -15,12 +15,17 @@ #include <stdio.h> #include <string.h> +#define DEFAULT_ADV_INTERVAL_US 500000 + /*! configurable parameters for advertising */ -static const appAdvCfg_t bleAdvCfg = { - { 0, 0 }, /*! Advertising durations in ms */ - { 500 / 0.625, 0 } /*! Advertising intervals in 0.625 ms units */ +static appAdvCfg_t bleAdvCfg = { + { 0, 0 }, /*! Advertising durations in ms */ + { DEFAULT_ADV_INTERVAL_US / 625, + 0 } /*! Advertising intervals in 0.625 ms units */ }; +static bool tainted; + /************************************************************************************************** Advertising Data **************************************************************************************************/ @@ -191,6 +196,14 @@ void ble_adv_setup(void) (uint8_t *)bleAdvDataConn ); AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL); + + bleAdvCfg.advInterval[0] = DEFAULT_ADV_INTERVAL_US / 625; +} + +void ble_adv_set_interval(uint32_t interval_us) +{ + bleAdvCfg.advInterval[0] = interval_us / 625; + tainted = true; } void ble_adv_stop(void) diff --git a/epicardium/ble/ble_api.h b/epicardium/ble/ble_api.h index 18f86baa4eeac740f9aeb0c88d7ee1fa0d7d8ec7..dd4ae3c6d590abf2029f7a8dbdc45c3af4e14505 100644 --- a/epicardium/ble/ble_api.h +++ b/epicardium/ble/ble_api.h @@ -51,6 +51,7 @@ void ble_epic_dm_api_event(dmEvt_t *dm_event); void ble_adv_init(void); void ble_adv_setup(void); +void ble_adv_set_interval(uint32_t interval_ms); void ble_adv_stop(void); void ble_adv_start(uint8_t mode); void ble_adv_discoverable(bool discoverable); diff --git a/epicardium/ble/epic_ble_api.c b/epicardium/ble/epic_ble_api.c index 623ff567b500c4f4c6087a2fa4e91a48a187db9b..bc50a72b6660bf69cfb7255ff059665c203507cc 100644 --- a/epicardium/ble/epic_ble_api.c +++ b/epicardium/ble/epic_ble_api.c @@ -137,6 +137,8 @@ int epic_ble_advertise( memcpy(adv_data_buf, adv_data, adv_data_len); memcpy(sr_data_buf, sr_data, sr_data_len); + ble_adv_set_interval(interval_us); + if (connectable) { AppAdvSetData( APP_ADV_DATA_CONNECTABLE, adv_data_len, adv_data_buf