Skip to content

Commit 3dcc877

Browse files
committed
bluetooth: service: HID service
Work in progress. Signed-off-by: Emanuele Di Santo <[email protected]>
1 parent 9389c74 commit 3dcc877

File tree

8 files changed

+2313
-9
lines changed

8 files changed

+2313
-9
lines changed

include/bluetooth/services/ble_hids.h

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.

include/bluetooth/services/common.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
#include "ble_gap.h"
23
#include <ble.h>
34
#include <zephyr/sys/byteorder.h>
45

@@ -13,3 +14,72 @@ static inline uint16_t is_notification_enabled(const uint8_t *gatts_write_data)
1314
{ \
1415
.sm = ((x) >> 4) & 0xf, .lv = (x) & 0xf, \
1516
}
17+
18+
static inline bool ble_gap_conn_sec_mode_equal(const ble_gap_conn_sec_mode_t *a,
19+
const ble_gap_conn_sec_mode_t *b)
20+
{
21+
return (a->sm == b->sm) && (a->lv == b->lv);
22+
}
23+
24+
/**
25+
* @brief Set sec_mode to have no access rights.
26+
*/
27+
#define BLE_GAP_CONN_SEC_MODE_NO_ACCESS \
28+
(ble_gap_conn_sec_mode_t) \
29+
{ \
30+
.sm = 0, .lv = 0 \
31+
}
32+
33+
/**
34+
* @brief Set sec_mode to require no protection, open link.
35+
*/
36+
#define BLE_GAP_CONN_SEC_MODE_OPEN \
37+
(ble_gap_conn_sec_mode_t) \
38+
{ \
39+
.sm = 1, .lv = 1 \
40+
}
41+
42+
/**
43+
* @brief Set sec_mode to require encryption, but no MITM protection.
44+
*/
45+
#define BLE_GAP_CONN_SEC_MODE_ENC_NO_MITM \
46+
(ble_gap_conn_sec_mode_t) \
47+
{ \
48+
.sm = 1, .lv = 2 \
49+
}
50+
51+
/**
52+
* @brief Set sec_mode to require encryption and MITM protection.
53+
*/
54+
#define BLE_GAP_CONN_SEC_MODE_ENC_WITH_MITM \
55+
(ble_gap_conn_sec_mode_t) \
56+
{ \
57+
.sm = 1, .lv = 3 \
58+
}
59+
60+
/**
61+
* @brief Set sec_mode to require LESC encryption and MITM protection.
62+
*/
63+
#define BLE_GAP_CONN_SEC_MODE_LESC_ENC_WITH_MITM \
64+
(ble_gap_conn_sec_mode_t) \
65+
{ \
66+
.sm = 1, .lv = 4 \
67+
}
68+
69+
/**
70+
* @brief Set sec_mode to require signing or encryption, no MITM protection needed.
71+
*/
72+
#define BLE_GAP_CONN_SEC_MODE_SIGNED_NO_MITM \
73+
(ble_gap_conn_sec_mode_t) \
74+
{ \
75+
.sm = 2, .lv = 1 \
76+
}
77+
78+
/**
79+
* @brief Set sec_mode to require signing or encryption with MITM protection.
80+
*/
81+
#define BLE_GAP_CONN_SEC_MODE_SIGNED_WITH_MITM \
82+
(ble_gap_conn_sec_mode_t) \
83+
{ \
84+
.sm = 2, .lv = 2 \
85+
}

samples/ble_services/prj.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ CONFIG_BLE_DIS_HW_REVISION="hw 54.15.0"
2929
CONFIG_BLE_DIS_FW_REVISION="fw 17.2.0" # wink
3030
CONFIG_BLE_DIS_SW_REVISION="sw 1.0.0"
3131

32+
CONFIG_BLE_HIDS=y
33+
CONFIG_BLE_HIDS_KEYBOARD=y
34+
#debug
35+
CONFIG_MAIN_STACK_SIZE=4096
36+
CONFIG_NO_OPTIMIZATIONS=y
37+
CONFIG_BLE_HIDS_LOG_LEVEL_DBG=y
38+
3239
# Shrink
3340
CONFIG_GPIO=n
3441
CONFIG_PARTITION_MANAGER_ENABLED=n

0 commit comments

Comments
 (0)