Skip to content

Commit fc6f1ce

Browse files
committed
necessary descriptors added
1 parent b06c324 commit fc6f1ce

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

main/blehr_sens.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ extern "C" {
5050
#define GATT_HID_CONTROL_POINT_UUID 0x2A4C
5151
#define GATT_HID_REPORT_UUID 0x2A4D
5252

53+
/*hid report configuration*/
54+
#define GATT_REPORT_REFERENCE_CHAR_UUID 0x2908
55+
5356
/*hid information infos*/
5457
#define HID_FLAGS_REMOTE_WAKE 0x01 // RemoteWake
5558
#define HID_FLAGS_NORMALLY_CONNECTABLE 0x02 // NormallyConnectable

main/gatt_svr.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ static const uint8_t hidInfo[HID_INFORMATION_LEN] = {
172172
HID_KBD_FLAGS // Flags
173173
};
174174

175+
static const uint8_t reportReferenceChar[2] = {
176+
0x01, //report-id des reports vom report deskriptor
177+
0x01 //input: 0x01, output: 0x02, feature: 0x03
178+
};
179+
180+
static const uint8_t reportData[2] = {
181+
0x12,
182+
0xEF
183+
};
184+
175185
uint16_t hrs_hrm_handle;
176186

177187
static int
@@ -186,6 +196,10 @@ static int
186196
gatt_svr_chr_hid(uint16_t conn_handle, uint16_t attr_handle,
187197
struct ble_gatt_access_ctxt *ctxt, void *arg);
188198

199+
static int
200+
report_descriptor_callback(uint16_t conn_handle, uint16_t attr_handle,
201+
struct ble_gatt_access_ctxt *ctxt, void *arg);
202+
189203
static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
190204
{
191205
/* Service: Heart-rate */
@@ -276,6 +290,22 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
276290
.uuid = BLE_UUID16_DECLARE(GATT_HID_CONTROL_POINT_UUID),
277291
.access_cb = gatt_svr_chr_hid,
278292
.flags = BLE_GATT_CHR_F_WRITE_NO_RSP,
293+
}, {
294+
/* Characteristic: Report Input, Pro Report Collection wird ein Reportmerkmal benötigt */
295+
.uuid = BLE_UUID16_DECLARE(GATT_HID_REPORT_UUID),
296+
.access_cb = gatt_svr_chr_hid,
297+
//.val_handle = &hrs_hrm_handle,
298+
.flags = BLE_GATT_CHR_F_READ | BLE_GATT_CHR_F_NOTIFY,
299+
.descriptors = (struct ble_gatt_dsc_def[]){
300+
//client configuration descriptor soll nicht manuell hinzugefügt werden, da dieser mittels dem flag notify automatisch hinzugefügt wird
301+
{
302+
.att_flags = BLE_ATT_F_READ,
303+
.access_cb = report_descriptor_callback,
304+
.uuid = BLE_UUID16_DECLARE(GATT_REPORT_REFERENCE_CHAR_UUID) //damit wird angegeben welche report id und report type abgedeckt werden
305+
}, {
306+
0, /* No more descriptors */
307+
},
308+
}
279309
}, {
280310
0, /* No more characteristics in this service */
281311
},
@@ -287,6 +317,24 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
287317
},
288318
};
289319

320+
static int report_descriptor_callback(uint16_t conn_handle, uint16_t attr_handle,
321+
struct ble_gatt_access_ctxt *ctxt, void *arg)
322+
{
323+
uint16_t uuid;
324+
int rc;
325+
326+
uuid = ble_uuid_u16(ctxt->chr->uuid);
327+
328+
if (uuid == GATT_REPORT_REFERENCE_CHAR_UUID) {
329+
//report id soll ungleich 0 sein, wenn es mehr als einen reportmerkmal gibt für einen bestimmten typen
330+
rc = os_mbuf_append(ctxt->om, reportReferenceChar, sizeof(reportReferenceChar)/sizeof(reportReferenceChar[0]));
331+
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
332+
}
333+
334+
assert(0);
335+
return BLE_ATT_ERR_UNLIKELY;
336+
}
337+
290338
static int gatt_svr_chr_hid(uint16_t conn_handle, uint16_t attr_handle,
291339
struct ble_gatt_access_ctxt *ctxt, void *arg)
292340
{
@@ -313,6 +361,12 @@ static int gatt_svr_chr_hid(uint16_t conn_handle, uint16_t attr_handle,
313361
return 0;
314362
}
315363

364+
//Daten des reports übermitteln
365+
if (uuid == GATT_HID_REPORT_UUID) {
366+
rc = os_mbuf_append(ctxt->om, reportData, sizeof(reportData)/sizeof(reportData[0]));
367+
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
368+
}
369+
316370
assert(0);
317371
return BLE_ATT_ERR_UNLIKELY;
318372
}

0 commit comments

Comments
 (0)