11#include " ble_app.hpp"
22#include < bluetooth/hid_over_gatt.hpp>
3+ #include < new>
34#include < zephyr/bluetooth/conn.h>
45#include < zephyr/kernel.h>
5- #include < new>
66extern " C" {
77#include " bt_conn.h"
88}
99
1010using namespace magic_enum ::bitwise_operators;
1111
12- static_assert (sizeof (ble_session) <= BLE_HID_SESSION_STORAGE_SIZE , " BLE_HID_SESSION_STORAGE_SIZE too small for ble_session" );
12+ static_assert (sizeof (ble_session) <= BLE_HID_SESSION_STORAGE_SIZE ,
13+ " BLE_HID_SESSION_STORAGE_SIZE too small for ble_session" );
1314static_assert (alignof (ble_session) <= 8 , " ble_session alignment exceeds peer storage alignment" );
1415
1516static ble_session *peerSession (peer_t *peer)
@@ -44,14 +45,15 @@ ::bt_conn *ble_session::get_conn()
4445 return hog_service ().get_session_conn (*this );
4546}
4647
47- hid::session &ble_app::start (const hid::session_params ¶ms)
48+ hid::session &ble_app::start (const hid::session::params ¶ms)
4849{
4950 ::bt_conn *conn = static_cast <const bluetooth::hid_over_gatt::session_params &>(params).conn ;
5051 int8_t peerId = GetPeerIdByConn (conn);
5152 if (peerId < PeerIdFirstHost || peerId > PeerIdLastHost) {
52- // A HOGP session should only ever start for a connected host peer
53+ // A HOGP session should only ever start for a connected host peer
5354 printk (" ble_app::start: no host peer for conn (peerId %d)\n " , peerId);
54- static ble_session fallback;
55+ assert (false && " ble_app::start: no host peer for conn" );
56+ static ble_session fallback{params};
5557 return fallback;
5658 }
5759 peer_t *peer = &Peers[peerId];
@@ -62,15 +64,15 @@ hid::session &ble_app::start(const hid::session_params ¶ms)
6264 peer->hidSessionActive = false ;
6365 }
6466
65- ble_session *sess = new (peer->hidSessionStorage ) ble_session ();
67+ ble_session *sess = new (peer->hidSessionStorage ) ble_session (params );
6668 peer->hidSessionActive = true ;
6769
6870 // Mirror mouse_app::start: initialise the scroll multiplier from the new session.
6971 mouse_resolution_changed_callback (*sess, sess->resolution_report ());
7072
7173 if (peer->connectionId != ConnectionId_Invalid) {
72- printk (" ble_app::start: marking BtHid connection %d (peer %d) ready\n " ,
73- peer-> connectionId , peerId);
74+ printk (" ble_app::start: marking BtHid connection %d (peer %d) ready\n " , peer-> connectionId ,
75+ peerId);
7476 Connections_SetStateAsync ((connection_id_t )peer->connectionId , ConnectionState_Ready);
7577 } else {
7678 printk (" ble_app::start: peer %d has invalid connectionId, cannot mark ready\n " , peerId);
@@ -126,7 +128,8 @@ extern "C" int HOGP_HealthCheck()
126128 struct bt_conn_info info;
127129 int err = bt_conn_get_info (peer->conn , &info);
128130 if (err) {
129- printk (" HOGP HealthCheck: peer %s has INVALID conn pointer (err %d)\n " , peer->name , err);
131+ printk (
132+ " HOGP HealthCheck: peer %s has INVALID conn pointer (err %d)\n " , peer->name , err);
130133 return -3 ;
131134 }
132135 }
0 commit comments