SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (MTB & µPython)
Toggle main menu visibility
Loading...
Searching...
No Matches
nus_gatt_db.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* File Name: nus_gatt_db.h
3
*
4
* Description: Nordic UART Service GATT database for the AIROC BTSTACK host.
5
* Exposes UUIDs and attribute handles consumed by
6
* wiced_bt_gatt_db_init() and the NUS write/notify paths.
7
*
8
* Layout (mirrors the spec published by Nordic Semiconductor):
9
* GAP (0x1800): Device Name, Appearance
10
* GATT (0x1801): Service Changed
11
* NUS (6E400001-...):
12
* RX (6E400002, Write / Write-No-Response) — host -> device
13
* TX (6E400003, Notify, CCCD) — device -> host
14
*
15
* Security: NONE. No attribute in this database carries an
16
* authentication or encryption requirement — no GATTDB_PERM_AUTH_*
17
* bit is set anywhere in nus_gatt_db.c. As declared there:
18
* RX GATTDB_PERM_WRITE_CMD | GATTDB_PERM_WRITE_REQ
19
* TX GATTDB_PERM_READABLE
20
* TX CCCD GATTDB_PERM_READABLE | GATTDB_PERM_WRITE_REQ
21
* An UNPAIRED peer can write RX and enable TX notifications.
22
* Insufficient Authentication is never returned. Advertising is
23
* open and the device accepts any central.
24
*
25
* Pairing, if a central asks for it, is Just Works: the link is
26
* encrypted against passive sniffing but has NO MITM protection,
27
* and the bond is held in RAM only (lost on reboot).
28
*
29
* Requiring LE Secure Connections on these characteristics is
30
* NOT YET IMPLEMENTED. The AUTH_* bits were removed deliberately;
31
* the reason is recorded in the comment above the RX declaration
32
* in nus_gatt_db.c.
33
*
34
* What limits the exposure: none of this is built by default.
35
* The whole module is gated on ENABLE_PAGE_BENTO_BUDDY, which is
36
* 0 in both shipped templates (proj_cm33_ns/Makefile, and set
37
* hard to 0 in bsps/TARGET_KIT_PSE84_AI/bsp_features.mk). The
38
* three prebuilt template images carry zero nus_/ble_nus_/
39
* wiced_bt_ symbols; the radio is not brought up at all. The
40
* statements above apply only once you turn the flag on.
41
*
42
* Attribute handles are contiguous (0x01..0x14) because some
43
* AIROC stack versions reject gaps during GATT DB init.
44
*
45
*******************************************************************************/
46
47
#ifndef NUS_GATT_DB_H
48
#define NUS_GATT_DB_H
49
50
#include <stddef.h>
51
#include <stdint.h>
52
53
#ifdef __cplusplus
54
extern
"C"
{
55
#endif
56
57
/* 128-bit NUS UUIDs, little-endian byte order (BLE on-air format). */
58
extern
const
uint8_t
NUS_UUID_SERVICE
[16];
59
extern
const
uint8_t
NUS_UUID_CHAR_RX
[16];
60
extern
const
uint8_t
NUS_UUID_CHAR_TX
[16];
61
62
/*******************************************************************************
63
* Attribute Handles — contiguous, 0x01..0x14.
64
* Keep in lock-step with nus_gatt_database[] in nus_gatt_db.c.
65
******************************************************************************/
66
enum
nus_attr_handle
{
67
/* GAP Service 0x1800 */
68
HDLS_GAP
= 0x01,
69
HDLC_GAP_DEVICE_NAME
= 0x02,
70
HDLC_GAP_DEVICE_NAME_VALUE
= 0x03,
71
HDLC_GAP_APPEARANCE
= 0x04,
72
HDLC_GAP_APPEARANCE_VALUE
= 0x05,
73
74
/* GATT Service 0x1801 */
75
HDLS_GATT
= 0x06,
76
HDLC_GATT_SERVICE_CHANGED
= 0x07,
77
HDLC_GATT_SERVICE_CHANGED_VALUE
= 0x08,
78
HDLD_GATT_SERVICE_CHANGED_CCCD
= 0x09,
79
80
/* Nordic UART Service */
81
HDLS_NUS
= 0x0A,
82
HDLC_NUS_RX
= 0x0B,
/* host -> device declaration */
83
HDLC_NUS_RX_VALUE
= 0x0C,
84
HDLC_NUS_TX
= 0x0D,
/* device -> host declaration */
85
HDLC_NUS_TX_VALUE
= 0x0E,
86
HDLD_NUS_TX_CCCD
= 0x0F,
/* client config descriptor */
87
88
HDLS_NUS_END
= 0x0F,
89
};
90
91
/* BLE appearance code: 0x0540 = "Generic Remote Control" (closest match for
92
* an approval companion). Replace when Anthropic publishes a buddy code. */
93
#define NUS_APPEARANCE 0x0540
94
95
/* Max NUS payload per frame: MTU (247) - ATT header (3). */
96
#define NUS_MAX_FRAME 244
97
98
/* Expose the byte-packed GATT database blob to wiced_bt_gatt_db_init(). */
99
extern
const
uint8_t
nus_gatt_database
[];
100
extern
const
uint16_t
nus_gatt_database_len
;
101
102
#ifdef __cplusplus
103
}
104
#endif
105
106
#endif
/* NUS_GATT_DB_H */
NUS_UUID_CHAR_RX
const uint8_t NUS_UUID_CHAR_RX[16]
UUID ของ characteristic RX (6E400002-... จาก host ไปยังอุปกรณ์) ไม่มีที่ใดอ้างถึงในฐานะ symbol.
nus_gatt_database
const uint8_t nus_gatt_database[]
blob ฐานข้อมูล GATT ที่อัดแน่นระดับไบต์ ซึ่งส่งให้ wiced_bt_gatt_db_init()
nus_gatt_database_len
const uint16_t nus_gatt_database_len
ความยาวของ blob เป็นไบต์ ส่งไปคู่กับตัว blob
NUS_UUID_SERVICE
const uint8_t NUS_UUID_SERVICE[16]
UUID ของบริการขนาด 128 บิต (6E400001-B5A3-F393-E0A9-E50E24DCCA9E) เรียงไบต์ตามที่ส่งออกอากาศ
NUS_UUID_CHAR_TX
const uint8_t NUS_UUID_CHAR_TX[16]
UUID ของ characteristic TX (6E400003-... จากอุปกรณ์ไปยัง host แบบ notify) มีสถานะเดียวกับ RX.
nus_attr_handle
nus_attr_handle
Definition
nus_gatt_db.h:66
HDLC_GAP_APPEARANCE
@ HDLC_GAP_APPEARANCE
Definition
nus_gatt_db.h:71
HDLD_GATT_SERVICE_CHANGED_CCCD
@ HDLD_GATT_SERVICE_CHANGED_CCCD
Definition
nus_gatt_db.h:78
HDLC_GAP_APPEARANCE_VALUE
@ HDLC_GAP_APPEARANCE_VALUE
Definition
nus_gatt_db.h:72
HDLS_GATT
@ HDLS_GATT
Definition
nus_gatt_db.h:75
HDLC_GAP_DEVICE_NAME
@ HDLC_GAP_DEVICE_NAME
Definition
nus_gatt_db.h:69
HDLC_NUS_TX
@ HDLC_NUS_TX
Definition
nus_gatt_db.h:84
HDLC_NUS_TX_VALUE
@ HDLC_NUS_TX_VALUE
Definition
nus_gatt_db.h:85
HDLC_GATT_SERVICE_CHANGED
@ HDLC_GATT_SERVICE_CHANGED
Definition
nus_gatt_db.h:76
HDLS_NUS_END
@ HDLS_NUS_END
Definition
nus_gatt_db.h:88
HDLC_NUS_RX
@ HDLC_NUS_RX
Definition
nus_gatt_db.h:82
HDLS_NUS
@ HDLS_NUS
Definition
nus_gatt_db.h:81
HDLC_NUS_RX_VALUE
@ HDLC_NUS_RX_VALUE
Definition
nus_gatt_db.h:83
HDLS_GAP
@ HDLS_GAP
Definition
nus_gatt_db.h:68
HDLC_GAP_DEVICE_NAME_VALUE
@ HDLC_GAP_DEVICE_NAME_VALUE
Definition
nus_gatt_db.h:70
HDLC_GATT_SERVICE_CHANGED_VALUE
@ HDLC_GATT_SERVICE_CHANGED_VALUE
Definition
nus_gatt_db.h:77
HDLD_NUS_TX_CCCD
@ HDLD_NUS_TX_CCCD
Definition
nus_gatt_db.h:86
dist
ble_nus
include
nus_gatt_db.h
Generated by
1.18.0