|
68 | 68 | #define PTS_DSC_READ_WRITE 0x000b
|
69 | 69 | #define PTS_CHR_NOTIFY 0x0025
|
70 | 70 | #define PTS_CHR_NOTIFY_ALT 0x0026
|
| 71 | +#define PTS_CHR_READ_WRITE_AUTHOR 0x0027 |
71 | 72 | #define PTS_LONG_CHR_READ_WRITE 0x0015
|
72 | 73 | #define PTS_LONG_CHR_READ_WRITE_ALT 0x0016
|
73 | 74 | #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,
|
107 | 108 | struct ble_gatt_access_ctxt *ctxt,
|
108 | 109 | void *arg);
|
109 | 110 |
|
| 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 | + |
110 | 116 | static int
|
111 | 117 | gatt_svr_read_write_enc_test(uint16_t conn_handle, uint16_t attr_handle,
|
112 | 118 | struct ble_gatt_access_ctxt *ctxt,
|
@@ -210,6 +216,13 @@ static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
|
210 | 216 | BLE_GATT_CHR_F_WRITE_AUTHEN |
|
211 | 217 | BLE_GATT_CHR_F_WRITE |
|
212 | 218 | 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 |
213 | 226 | }, {
|
214 | 227 | .uuid = PTS_UUID_DECLARE(PTS_CHR_RELIABLE_WRITE),
|
215 | 228 | .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,
|
419 | 432 | }
|
420 | 433 | }
|
421 | 434 |
|
| 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 | + |
422 | 458 | static int
|
423 | 459 | gatt_svr_read_write_enc_test(uint16_t conn_handle, uint16_t attr_handle,
|
424 | 460 | struct ble_gatt_access_ctxt *ctxt,
|
|
0 commit comments