forked from kofal.net/zmk
refactor(ble): Extract API to get active profile connection.
* Add `struct bt_conn *zmk_ble_active_profile_conn(void)` function for fetching a connection for the current profile.
This commit is contained in:
committed by
Pete Johanson
parent
b576d52d58
commit
f7c34c70ba
@@ -318,6 +318,21 @@ int zmk_ble_prof_disconnect(uint8_t index) {
|
||||
|
||||
bt_addr_le_t *zmk_ble_active_profile_addr(void) { return &profiles[active_profile].peer; }
|
||||
|
||||
struct bt_conn *zmk_ble_active_profile_conn(void) {
|
||||
struct bt_conn *conn;
|
||||
bt_addr_le_t *addr = zmk_ble_active_profile_addr();
|
||||
|
||||
if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) {
|
||||
LOG_WRN("Not sending, no active address for current profile");
|
||||
return NULL;
|
||||
} else if ((conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr)) == NULL) {
|
||||
LOG_WRN("Not sending, not connected to active profile");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
char *zmk_ble_active_profile_name(void) { return profiles[active_profile].name; }
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
||||
|
||||
Reference in New Issue
Block a user