Skip to content
Snippets Groups Projects
Commit 8f842602 authored by schneider's avatar schneider
Browse files

feat(mp-ble): Allow to set the interval

parent 99998e7d
No related branches found
No related tags found
1 merge request!449BLE advertisement support for MicroPython
Pipeline #5135 passed
......@@ -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)
......
......@@ -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);
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment