Skip to content
Snippets Groups Projects
Commit 99998e7d authored by schneider's avatar schneider
Browse files

change(ble): Go back to standard adv set when resetting hardware

parent b7f11c05
No related branches found
No related tags found
1 merge request!449BLE advertisement support for MicroPython
...@@ -137,11 +137,6 @@ void ble_adv_proc_msg(bleMsg_t *pMsg) ...@@ -137,11 +137,6 @@ void ble_adv_proc_msg(bleMsg_t *pMsg)
} }
void ble_adv_init(void) void ble_adv_init(void)
{
pAppAdvCfg = (appAdvCfg_t *)&bleAdvCfg;
}
void ble_adv_setup(void)
{ {
char buf[32]; char buf[32];
char a, b, c, d, e, f, K; char a, b, c, d, e, f, K;
...@@ -163,6 +158,11 @@ void ble_adv_setup(void) ...@@ -163,6 +158,11 @@ void ble_adv_setup(void)
} }
/* clang-format on */ /* clang-format on */
pAppAdvCfg = (appAdvCfg_t *)&bleAdvCfg;
}
void ble_adv_setup(void)
{
/* set advertising and scan response data for discoverable mode */ /* set advertising and scan response data for discoverable mode */
if (config_get_boolean_with_default("ble_hid_enable", false)) { if (config_get_boolean_with_default("ble_hid_enable", false)) {
AppAdvSetData( AppAdvSetData(
...@@ -202,7 +202,7 @@ void ble_adv_stop(void) ...@@ -202,7 +202,7 @@ void ble_adv_stop(void)
} }
} }
void ble_adv_start(uint8_t mode) static void adv_start(uint8_t mode)
{ {
if (advertising_mode != APP_MODE_NONE) { if (advertising_mode != APP_MODE_NONE) {
/* We need to stop advertising in between or the /* We need to stop advertising in between or the
...@@ -219,21 +219,29 @@ void ble_adv_start(uint8_t mode) ...@@ -219,21 +219,29 @@ void ble_adv_start(uint8_t mode)
advertising_mode_target = mode; advertising_mode_target = mode;
AppAdvStart(advertising_mode); AppAdvStart(advertising_mode);
} }
tainted = false;
}
void ble_adv_start(uint8_t mode)
{
adv_start(mode);
tainted = true;
} }
void ble_adv_discoverable(bool discoverable) void ble_adv_discoverable(bool discoverable)
{ {
if (discoverable) { if (discoverable) {
if (advertising_mode != APP_MODE_DISCOVERABLE) { if (advertising_mode != APP_MODE_DISCOVERABLE || tainted) {
LOG_INFO("ble", "Making bondable and discoverable"); LOG_INFO("ble", "Making bondable and discoverable");
ble_adv_start(APP_MODE_DISCOVERABLE); adv_start(APP_MODE_DISCOVERABLE);
} }
} else { } else {
/* TODO: This does way more than the function name indicates */ /* TODO: This does way more than the function name indicates */
if (AppDbCheckBonded()) { if (AppDbCheckBonded()) {
if (advertising_mode != APP_MODE_CONNECTABLE) { if (advertising_mode != APP_MODE_CONNECTABLE ||
tainted) {
LOG_INFO("ble", "Bonded. Making connectable"); LOG_INFO("ble", "Bonded. Making connectable");
ble_adv_start(APP_MODE_CONNECTABLE); adv_start(APP_MODE_CONNECTABLE);
} }
} else { } else {
LOG_INFO("ble", "Not bonded. Stop advertising"); LOG_INFO("ble", "Not bonded. Stop advertising");
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "pmic.h" #include "pmic.h"
#include "portexpander.h" #include "portexpander.h"
#include "max86150.h" #include "max86150.h"
#include "ble/ble_api.h"
#include "gpio.h" #include "gpio.h"
#include "i2c.h" #include "i2c.h"
...@@ -288,6 +289,11 @@ int hardware_reset(void) ...@@ -288,6 +289,11 @@ int hardware_reset(void)
/* /*
* BLE * BLE
*/ */
/* Reset advertisement data */
ble_adv_setup();
/* Start advertising again if needed */
epic_ble_set_mode(false, false); epic_ble_set_mode(false, false);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment