Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion device/prj.conf.overlays/c2usb.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CONFIG_NEWLIB_LIBC_NANO=y
# CONFIG_SHELL_BACKEND_C2USB_LOG_LEVEL_DBG=y
# CONFIG_WARN_EXPERIMENTAL=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_C2USB_HOGP_LOG_LEVEL_INF=y
CONFIG_C2USB_HOGP_LOG_LEVEL_DBG=y
CONFIG_C2USB_UDC_MAC_LOG_LEVEL_INF=y
CONFIG_WARN_EXPERIMENTAL=n

Expand Down
1 change: 1 addition & 0 deletions device/prj.conf.overlays/nrf_shared.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CONFIG_LOG_CMDS=y
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_BUFFER_SIZE=2048
CONFIG_LOG_BACKEND_SHOW_COLOR=y
CONFIG_LOG_RUNTIME_FILTERING=y


CONFIG_ASSERT=y
Expand Down
25 changes: 25 additions & 0 deletions device/src/bt_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "right/src/bt_defs.h"
#include "bt_health.h"
#include "macros/status_buffer.h"
#include <zephyr/logging/log_ctrl.h>

LOG_MODULE_REGISTER(Bt, LOG_LEVEL_INF);

Expand Down Expand Up @@ -270,6 +271,26 @@ static void enableDataLengthExtension(struct bt_conn *conn) {
}
}

static void mtuExchangeCallback(struct bt_conn *conn, uint8_t err, struct bt_gatt_exchange_params *params) {
if (err) {
LOG_WRN("MTU exchange failed for %s (err %u)", GetPeerStringByConn(conn), err);
} else {
LOG_INF("MTU exchange done for %s", GetPeerStringByConn(conn));
}
}

static void requestMtuExchange(struct bt_conn *conn) {
static struct bt_gatt_exchange_params exchange_params;
exchange_params.func = mtuExchangeCallback;

LOG_INF("MTU exchanging %s", GetPeerStringByConn(conn));

int err = bt_gatt_exchange_mtu(conn, &exchange_params);
if (err && err != -EALREADY) {
LOG_WRN("MTU exchange request failed for %s (err %d)", GetPeerStringByConn(conn), err);
}
}

static void setLatency(struct bt_conn* conn, const struct bt_le_conn_param* params) {
int err = bt_conn_le_param_update(conn, params);
if (err) {
Expand Down Expand Up @@ -595,6 +616,7 @@ static void connected(struct bt_conn *conn, uint8_t err) {
// Without this, linux pairing fails, because tiny 27 byte packets
// exhaust acl buffers easily
enableDataLengthExtension(conn);
requestMtuExchange(conn);

if (err) {
LOG_WRN("Failed to connect to %s, err %u", GetPeerStringByConn(conn), err);
Expand Down Expand Up @@ -959,6 +981,9 @@ void BtConn_Init(void) {
BT_TRACE_AND_ASSERT("bc6");
int err = 0;

int sourceId = log_source_id_get("hogp");
log_filter_set(NULL, 0, sourceId, LOG_LEVEL_INF);

for (uint8_t peerId = PeerIdFirstHost; peerId <= PeerIdLastHost; peerId++) {
Peers[peerId].id = peerId;
Peers[peerId].conn = NULL;
Expand Down
Loading