diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-12-03 22:53:03 -0500 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-12-06 22:47:21 -0500 |
commit | 0d80220e14200b38b3e244d9f24e8bd7b61768d2 (patch) | |
tree | 4c5471dfc70026c0c3fc66694622c556d57e56ea | |
parent | e00eceb5089d50fce2e298628c5bcf6c3b0596cd (diff) |
fix(ble): Raise profile events from work thread.
* Make sure we don't raise events from BLE
host thread.
-rw-r--r-- | app/src/ble.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/src/ble.c b/app/src/ble.c index 817cb84..32c1350 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -114,7 +114,7 @@ void set_profile_address(u8_t index, const bt_addr_le_t *addr) { sprintf(setting_name, "ble/profiles/%d", index); LOG_DBG("Setting profile addr for %s to %s", log_strdup(setting_name), log_strdup(addr_str)); settings_save_one(setting_name, &profiles[index], sizeof(struct zmk_ble_profile)); - raise_profile_changed_event(); + k_work_submit(&raise_profile_changed_event_work); } bool zmk_ble_active_profile_is_connected() { @@ -342,6 +342,7 @@ static bool is_conn_active_profile(const struct bt_conn *conn) { static void connected(struct bt_conn *conn, u8_t err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + LOG_DBG("Connected thread: %p", k_current_get()); advertising_status = ZMK_ADV_NONE; @@ -367,7 +368,7 @@ static void connected(struct bt_conn *conn, u8_t err) { if (is_conn_active_profile(conn)) { LOG_DBG("Active profile connected"); - raise_profile_changed_event(); + k_work_submit(&raise_profile_changed_event_work); } } |