Skip to content

Commit 7b14eab

Browse files
piotrnarajowskisjanc
authored andcommitted
apps: bttester: add characteristic to bttester database
This characteristic is needed to pass tests that verify if IUT is able to respond with Insufficient Authorization error code to read, write requests from PTS.
1 parent c884246 commit 7b14eab

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

apps/bttester/src/btp_gatt.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#define PTS_DSC_READ_WRITE 0x000b
6969
#define PTS_CHR_NOTIFY 0x0025
7070
#define PTS_CHR_NOTIFY_ALT 0x0026
71+
#define PTS_CHR_READ_WRITE_AUTHOR 0x0027
7172
#define PTS_LONG_CHR_READ_WRITE 0x0015
7273
#define PTS_LONG_CHR_READ_WRITE_ALT 0x0016
7374
#define PTS_LONG_DSC_READ_WRITE 0x001b
@@ -107,6 +108,11 @@ gatt_svr_read_write_auth_test(uint16_t conn_handle, uint16_t attr_handle,
107108
struct ble_gatt_access_ctxt *ctxt,
108109
void *arg);
109110

111+
static int
112+
gatt_svr_read_write_author_test(uint16_t conn_handle, uint16_t attr_handle,
113+
struct ble_gatt_access_ctxt *ctxt,
114+
void *arg);
115+
110116
static int
111117
gatt_svr_read_write_enc_test(uint16_t conn_handle, uint16_t attr_handle,
112118
struct ble_gatt_access_ctxt *ctxt,
@@ -210,6 +216,13 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
210216
BLE_GATT_CHR_F_WRITE_AUTHEN |
211217
BLE_GATT_CHR_F_WRITE |
212218
BLE_GATT_CHR_F_WRITE_AUTHEN,
219+
}, {
220+
.uuid = PTS_UUID_DECLARE(PTS_CHR_READ_WRITE_AUTHOR),
221+
.access_cb = gatt_svr_read_write_author_test,
222+
.flags = BLE_GATT_CHR_F_READ_AUTHOR |
223+
BLE_GATT_CHR_F_READ |
224+
BLE_GATT_CHR_F_WRITE_AUTHOR |
225+
BLE_GATT_CHR_F_WRITE
213226
}, {
214227
.uuid = PTS_UUID_DECLARE(PTS_CHR_RELIABLE_WRITE),
215228
.access_cb = gatt_svr_rel_write_test,
@@ -419,6 +432,29 @@ gatt_svr_read_write_auth_test(uint16_t conn_handle, uint16_t attr_handle,
419432
}
420433
}
421434

435+
static int
436+
gatt_svr_read_write_author_test(uint16_t conn_handle, uint16_t attr_handle,
437+
struct ble_gatt_access_ctxt *ctxt,
438+
void *arg)
439+
{
440+
uint16_t uuid16;
441+
442+
uuid16 = extract_uuid16_from_pts_uuid128(ctxt->chr->uuid);
443+
assert(uuid16 != 0);
444+
445+
switch (uuid16) {
446+
case PTS_CHR_READ_WRITE_AUTHOR:
447+
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
448+
return BLE_ATT_ERR_INSUFFICIENT_AUTHOR;
449+
} else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
450+
return BLE_ATT_ERR_INSUFFICIENT_AUTHOR;
451+
}
452+
default:
453+
assert(0);
454+
return BLE_ATT_ERR_UNLIKELY;
455+
}
456+
}
457+
422458
static int
423459
gatt_svr_read_write_enc_test(uint16_t conn_handle, uint16_t attr_handle,
424460
struct ble_gatt_access_ctxt *ctxt,

0 commit comments

Comments
 (0)