forked from kofal.net/zmk
feat(bluetooth): Add back profiles, split fixes.
* Add back in profiles, not using Zephyr BT identity infrastructure. * Restore additional `&bt` commands for profile operations. * Fix for split pairing and subscriptions, since Zephyr persists subscriptions across connects. * Remove keymap from peripheral builds, reduces firmware size, and avoids unneeded attempts to send HID data.
This commit is contained in:
@@ -76,10 +76,19 @@ static u8_t split_central_notify_func(struct bt_conn *conn,
|
||||
static int split_central_subscribe(struct bt_conn *conn)
|
||||
{
|
||||
int err = bt_gatt_subscribe(conn, &subscribe_params);
|
||||
if (err && err != -EALREADY) {
|
||||
LOG_ERR("Subscribe failed (err %d)", err);
|
||||
} else {
|
||||
switch (err) {
|
||||
case -EALREADY:
|
||||
LOG_DBG("[ALREADY SUBSCRIBED]");
|
||||
break;
|
||||
// break;
|
||||
// bt_gatt_unsubscribe(conn, &subscribe_params);
|
||||
// return split_central_subscribe(conn);
|
||||
case 0:
|
||||
LOG_DBG("[SUBSCRIBED]");
|
||||
break;
|
||||
default:
|
||||
LOG_ERR("Subscribe failed (err %d)", err);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -145,21 +154,17 @@ static void split_central_process_connection(struct bt_conn *conn) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (conn == default_conn) {
|
||||
if (subscribe_params.value) {
|
||||
split_central_subscribe(conn);
|
||||
} else {
|
||||
discover_params.uuid = &uuid.uuid;
|
||||
discover_params.func = split_central_discovery_func;
|
||||
discover_params.start_handle = 0x0001;
|
||||
discover_params.end_handle = 0xffff;
|
||||
discover_params.type = BT_GATT_DISCOVER_PRIMARY;
|
||||
if (conn == default_conn && !subscribe_params.value) {
|
||||
discover_params.uuid = &uuid.uuid;
|
||||
discover_params.func = split_central_discovery_func;
|
||||
discover_params.start_handle = 0x0001;
|
||||
discover_params.end_handle = 0xffff;
|
||||
discover_params.type = BT_GATT_DISCOVER_PRIMARY;
|
||||
|
||||
err = bt_gatt_discover(default_conn, &discover_params);
|
||||
if (err) {
|
||||
LOG_ERR("Discover failed(err %d)", err);
|
||||
return;
|
||||
}
|
||||
err = bt_gatt_discover(default_conn, &discover_params);
|
||||
if (err) {
|
||||
LOG_ERR("Discover failed(err %d)", err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +286,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err)
|
||||
|
||||
|
||||
if (conn_err) {
|
||||
LOG_ERR("Failed to connect to %s (%u)", addr, conn_err);
|
||||
LOG_ERR("Failed to connect to %s (%u)", log_strdup(addr), conn_err);
|
||||
|
||||
bt_conn_unref(default_conn);
|
||||
default_conn = NULL;
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <sys/util.h>
|
||||
|
||||
#include <logging/log.h>
|
||||
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#include <bluetooth/gatt.h>
|
||||
#include <bluetooth/uuid.h>
|
||||
|
||||
@@ -28,6 +33,7 @@ static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_
|
||||
|
||||
static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value)
|
||||
{
|
||||
LOG_DBG("value %d", value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user