fix(bluetooth): Split improvements
* Proper usage of bt_uuid_cmp. * Central's don't start scanning for peripherals if `ZMK_BLE_CLEAR_BONDS_ON_START` is enabled. * Split peripherals don't advertize if `ZMK_BLE_CLEAR_BONDS_ON_START` is enabled.
This commit is contained in:
parent
54c2e8e155
commit
5f6a13413b
2 changed files with 10 additions and 9 deletions
|
@ -251,8 +251,8 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn,
|
|||
|
||||
LOG_DBG("[ATTRIBUTE] handle %u", attr->handle);
|
||||
|
||||
if (!bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid,
|
||||
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID))) {
|
||||
if (bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid,
|
||||
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID)) == 0) {
|
||||
LOG_DBG("Found position state characteristic");
|
||||
slot->discover_params.uuid = NULL;
|
||||
slot->discover_params.start_handle = attr->handle + 2;
|
||||
|
@ -264,8 +264,8 @@ static uint8_t split_central_chrc_discovery_func(struct bt_conn *conn,
|
|||
slot->subscribe_params.notify = split_central_notify_func;
|
||||
slot->subscribe_params.value = BT_GATT_CCC_NOTIFY;
|
||||
split_central_subscribe(conn);
|
||||
} else if (!bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid,
|
||||
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_RUN_BEHAVIOR_UUID))) {
|
||||
} else if (bt_uuid_cmp(((struct bt_gatt_chrc *)attr->user_data)->uuid,
|
||||
BT_UUID_DECLARE_128(ZMK_SPLIT_BT_CHAR_RUN_BEHAVIOR_UUID)) == 0) {
|
||||
LOG_DBG("Found run behavior handle");
|
||||
slot->run_behavior_handle = bt_gatt_attr_value_handle(attr);
|
||||
}
|
||||
|
@ -292,7 +292,8 @@ static uint8_t split_central_service_discovery_func(struct bt_conn *conn,
|
|||
return BT_GATT_ITER_STOP;
|
||||
}
|
||||
|
||||
if (bt_uuid_cmp(slot->discover_params.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) {
|
||||
if (bt_uuid_cmp(slot->discover_params.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)) !=
|
||||
0) {
|
||||
LOG_DBG("Found other service");
|
||||
return BT_GATT_ITER_CONTINUE;
|
||||
}
|
||||
|
@ -418,7 +419,7 @@ static bool split_central_eir_parse(struct bt_data *data, void *user_data) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (bt_uuid_cmp(&uuid.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID))) {
|
||||
if (bt_uuid_cmp(&uuid.uuid, BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SERVICE_UUID)) != 0) {
|
||||
char uuid_str[BT_UUID_STR_LEN];
|
||||
char service_uuid_str[BT_UUID_STR_LEN];
|
||||
|
||||
|
@ -622,7 +623,7 @@ int zmk_split_bt_central_init(const struct device *_arg) {
|
|||
CONFIG_ZMK_BLE_THREAD_PRIORITY, NULL);
|
||||
bt_conn_cb_register(&conn_callbacks);
|
||||
|
||||
return start_scanning();
|
||||
return IS_ENABLED(CONFIG_ZMK_BLE_CLEAR_BONDS_ON_START) ? 0 : start_scanning();
|
||||
}
|
||||
|
||||
SYS_INIT(zmk_split_bt_central_init, APPLICATION, CONFIG_ZMK_BLE_INIT_PRIORITY);
|
||||
|
|
|
@ -116,11 +116,11 @@ static int zmk_peripheral_ble_init(const struct device *_arg) {
|
|||
LOG_WRN("Clearing all existing BLE bond information from the keyboard");
|
||||
|
||||
bt_unpair(BT_ID_DEFAULT, NULL);
|
||||
#endif
|
||||
|
||||
#else
|
||||
bt_conn_cb_register(&conn_callbacks);
|
||||
|
||||
start_advertising();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue