1 /*
2 * Copyright (c) 2017 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #define OP_APP_KEY_ADD BT_MESH_MODEL_OP_1(0x00)
8 #define OP_APP_KEY_UPDATE BT_MESH_MODEL_OP_1(0x01)
9 #define OP_DEV_COMP_DATA_STATUS BT_MESH_MODEL_OP_1(0x02)
10 #define OP_MOD_PUB_SET BT_MESH_MODEL_OP_1(0x03)
11 #define OP_HEALTH_CURRENT_STATUS BT_MESH_MODEL_OP_1(0x04)
12 #define OP_HEALTH_FAULT_STATUS BT_MESH_MODEL_OP_1(0x05)
13 #define OP_HEARTBEAT_PUB_STATUS BT_MESH_MODEL_OP_1(0x06)
14 #define OP_APP_KEY_DEL BT_MESH_MODEL_OP_2(0x80, 0x00)
15 #define OP_APP_KEY_GET BT_MESH_MODEL_OP_2(0x80, 0x01)
16 #define OP_APP_KEY_LIST BT_MESH_MODEL_OP_2(0x80, 0x02)
17 #define OP_APP_KEY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x03)
18 #define OP_ATTENTION_GET BT_MESH_MODEL_OP_2(0x80, 0x04)
19 #define OP_ATTENTION_SET BT_MESH_MODEL_OP_2(0x80, 0x05)
20 #define OP_ATTENTION_SET_UNREL BT_MESH_MODEL_OP_2(0x80, 0x06)
21 #define OP_ATTENTION_STATUS BT_MESH_MODEL_OP_2(0x80, 0x07)
22 #define OP_DEV_COMP_DATA_GET BT_MESH_MODEL_OP_2(0x80, 0x08)
23 #define OP_BEACON_GET BT_MESH_MODEL_OP_2(0x80, 0x09)
24 #define OP_BEACON_SET BT_MESH_MODEL_OP_2(0x80, 0x0a)
25 #define OP_BEACON_STATUS BT_MESH_MODEL_OP_2(0x80, 0x0b)
26 #define OP_DEFAULT_TTL_GET BT_MESH_MODEL_OP_2(0x80, 0x0c)
27 #define OP_DEFAULT_TTL_SET BT_MESH_MODEL_OP_2(0x80, 0x0d)
28 #define OP_DEFAULT_TTL_STATUS BT_MESH_MODEL_OP_2(0x80, 0x0e)
29 #define OP_FRIEND_GET BT_MESH_MODEL_OP_2(0x80, 0x0f)
30 #define OP_FRIEND_SET BT_MESH_MODEL_OP_2(0x80, 0x10)
31 #define OP_FRIEND_STATUS BT_MESH_MODEL_OP_2(0x80, 0x11)
32 #define OP_GATT_PROXY_GET BT_MESH_MODEL_OP_2(0x80, 0x12)
33 #define OP_GATT_PROXY_SET BT_MESH_MODEL_OP_2(0x80, 0x13)
34 #define OP_GATT_PROXY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x14)
35 #define OP_KRP_GET BT_MESH_MODEL_OP_2(0x80, 0x15)
36 #define OP_KRP_SET BT_MESH_MODEL_OP_2(0x80, 0x16)
37 #define OP_KRP_STATUS BT_MESH_MODEL_OP_2(0x80, 0x17)
38 #define OP_MOD_PUB_GET BT_MESH_MODEL_OP_2(0x80, 0x18)
39 #define OP_MOD_PUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x19)
40 #define OP_MOD_PUB_VA_SET BT_MESH_MODEL_OP_2(0x80, 0x1a)
41 #define OP_MOD_SUB_ADD BT_MESH_MODEL_OP_2(0x80, 0x1b)
42 #define OP_MOD_SUB_DEL BT_MESH_MODEL_OP_2(0x80, 0x1c)
43 #define OP_MOD_SUB_DEL_ALL BT_MESH_MODEL_OP_2(0x80, 0x1d)
44 #define OP_MOD_SUB_OVERWRITE BT_MESH_MODEL_OP_2(0x80, 0x1e)
45 #define OP_MOD_SUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x1f)
46 #define OP_MOD_SUB_VA_ADD BT_MESH_MODEL_OP_2(0x80, 0x20)
47 #define OP_MOD_SUB_VA_DEL BT_MESH_MODEL_OP_2(0x80, 0x21)
48 #define OP_MOD_SUB_VA_OVERWRITE BT_MESH_MODEL_OP_2(0x80, 0x22)
49 #define OP_NET_TRANSMIT_GET BT_MESH_MODEL_OP_2(0x80, 0x23)
50 #define OP_NET_TRANSMIT_SET BT_MESH_MODEL_OP_2(0x80, 0x24)
51 #define OP_NET_TRANSMIT_STATUS BT_MESH_MODEL_OP_2(0x80, 0x25)
52 #define OP_RELAY_GET BT_MESH_MODEL_OP_2(0x80, 0x26)
53 #define OP_RELAY_SET BT_MESH_MODEL_OP_2(0x80, 0x27)
54 #define OP_RELAY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x28)
55 #define OP_MOD_SUB_GET BT_MESH_MODEL_OP_2(0x80, 0x29)
56 #define OP_MOD_SUB_LIST BT_MESH_MODEL_OP_2(0x80, 0x2a)
57 #define OP_MOD_SUB_GET_VND BT_MESH_MODEL_OP_2(0x80, 0x2b)
58 #define OP_MOD_SUB_LIST_VND BT_MESH_MODEL_OP_2(0x80, 0x2c)
59 #define OP_LPN_TIMEOUT_GET BT_MESH_MODEL_OP_2(0x80, 0x2d)
60 #define OP_LPN_TIMEOUT_STATUS BT_MESH_MODEL_OP_2(0x80, 0x2e)
61 #define OP_HEALTH_FAULT_CLEAR BT_MESH_MODEL_OP_2(0x80, 0x2f)
62 #define OP_HEALTH_FAULT_CLEAR_UNREL BT_MESH_MODEL_OP_2(0x80, 0x30)
63 #define OP_HEALTH_FAULT_GET BT_MESH_MODEL_OP_2(0x80, 0x31)
64 #define OP_HEALTH_FAULT_TEST BT_MESH_MODEL_OP_2(0x80, 0x32)
65 #define OP_HEALTH_FAULT_TEST_UNREL BT_MESH_MODEL_OP_2(0x80, 0x33)
66 #define OP_HEALTH_PERIOD_GET BT_MESH_MODEL_OP_2(0x80, 0x34)
67 #define OP_HEALTH_PERIOD_SET BT_MESH_MODEL_OP_2(0x80, 0x35)
68 #define OP_HEALTH_PERIOD_SET_UNREL BT_MESH_MODEL_OP_2(0x80, 0x36)
69 #define OP_HEALTH_PERIOD_STATUS BT_MESH_MODEL_OP_2(0x80, 0x37)
70 #define OP_HEARTBEAT_PUB_GET BT_MESH_MODEL_OP_2(0x80, 0x38)
71 #define OP_HEARTBEAT_PUB_SET BT_MESH_MODEL_OP_2(0x80, 0x39)
72 #define OP_HEARTBEAT_SUB_GET BT_MESH_MODEL_OP_2(0x80, 0x3a)
73 #define OP_HEARTBEAT_SUB_SET BT_MESH_MODEL_OP_2(0x80, 0x3b)
74 #define OP_HEARTBEAT_SUB_STATUS BT_MESH_MODEL_OP_2(0x80, 0x3c)
75 #define OP_MOD_APP_BIND BT_MESH_MODEL_OP_2(0x80, 0x3d)
76 #define OP_MOD_APP_STATUS BT_MESH_MODEL_OP_2(0x80, 0x3e)
77 #define OP_MOD_APP_UNBIND BT_MESH_MODEL_OP_2(0x80, 0x3f)
78 #define OP_NET_KEY_ADD BT_MESH_MODEL_OP_2(0x80, 0x40)
79 #define OP_NET_KEY_DEL BT_MESH_MODEL_OP_2(0x80, 0x41)
80 #define OP_NET_KEY_GET BT_MESH_MODEL_OP_2(0x80, 0x42)
81 #define OP_NET_KEY_LIST BT_MESH_MODEL_OP_2(0x80, 0x43)
82 #define OP_NET_KEY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x44)
83 #define OP_NET_KEY_UPDATE BT_MESH_MODEL_OP_2(0x80, 0x45)
84 #define OP_NODE_IDENTITY_GET BT_MESH_MODEL_OP_2(0x80, 0x46)
85 #define OP_NODE_IDENTITY_SET BT_MESH_MODEL_OP_2(0x80, 0x47)
86 #define OP_NODE_IDENTITY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x48)
87 #define OP_NODE_RESET BT_MESH_MODEL_OP_2(0x80, 0x49)
88 #define OP_NODE_RESET_STATUS BT_MESH_MODEL_OP_2(0x80, 0x4a)
89 #define OP_SIG_MOD_APP_GET BT_MESH_MODEL_OP_2(0x80, 0x4b)
90 #define OP_SIG_MOD_APP_LIST BT_MESH_MODEL_OP_2(0x80, 0x4c)
91 #define OP_VND_MOD_APP_GET BT_MESH_MODEL_OP_2(0x80, 0x4d)
92 #define OP_VND_MOD_APP_LIST BT_MESH_MODEL_OP_2(0x80, 0x4e)
93
94 #define OP_SAR_CFG_TX_GET BT_MESH_MODEL_OP_2(0x80, 0x6c)
95 #define OP_SAR_CFG_TX_SET BT_MESH_MODEL_OP_2(0x80, 0x6d)
96 #define OP_SAR_CFG_TX_STATUS BT_MESH_MODEL_OP_2(0x80, 0x6e)
97 #define OP_SAR_CFG_RX_GET BT_MESH_MODEL_OP_2(0x80, 0x6f)
98 #define OP_SAR_CFG_RX_SET BT_MESH_MODEL_OP_2(0x80, 0x70)
99 #define OP_SAR_CFG_RX_STATUS BT_MESH_MODEL_OP_2(0x80, 0x71)
100 #define OP_OPCODES_AGGREGATOR_SEQUENCE BT_MESH_MODEL_OP_2(0x80, 0x72)
101 #define OP_OPCODES_AGGREGATOR_STATUS BT_MESH_MODEL_OP_2(0x80, 0x73)
102 #define OP_LARGE_COMP_DATA_GET BT_MESH_MODEL_OP_2(0x80, 0x74)
103 #define OP_LARGE_COMP_DATA_STATUS BT_MESH_MODEL_OP_2(0x80, 0x75)
104 #define OP_MODELS_METADATA_GET BT_MESH_MODEL_OP_2(0x80, 0x76)
105 #define OP_MODELS_METADATA_STATUS BT_MESH_MODEL_OP_2(0x80, 0x77)
106
107 #define OP_PRIV_BEACON_GET BT_MESH_MODEL_OP_2(0x80, 0x60)
108 #define OP_PRIV_BEACON_SET BT_MESH_MODEL_OP_2(0x80, 0x61)
109 #define OP_PRIV_BEACON_STATUS BT_MESH_MODEL_OP_2(0x80, 0x62)
110 #define OP_PRIV_GATT_PROXY_GET BT_MESH_MODEL_OP_2(0x80, 0x63)
111 #define OP_PRIV_GATT_PROXY_SET BT_MESH_MODEL_OP_2(0x80, 0x64)
112 #define OP_PRIV_GATT_PROXY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x65)
113 #define OP_PRIV_NODE_ID_GET BT_MESH_MODEL_OP_2(0x80, 0x66)
114 #define OP_PRIV_NODE_ID_SET BT_MESH_MODEL_OP_2(0x80, 0x67)
115 #define OP_PRIV_NODE_ID_STATUS BT_MESH_MODEL_OP_2(0x80, 0x68)
116
117 #define OP_OD_PRIV_PROXY_GET BT_MESH_MODEL_OP_2(0x80, 0x69)
118 #define OP_OD_PRIV_PROXY_SET BT_MESH_MODEL_OP_2(0x80, 0x6a)
119 #define OP_OD_PRIV_PROXY_STATUS BT_MESH_MODEL_OP_2(0x80, 0x6b)
120
121 #define OP_SOL_PDU_RPL_ITEM_CLEAR BT_MESH_MODEL_OP_2(0x80, 0x78)
122 #define OP_SOL_PDU_RPL_ITEM_CLEAR_UNACKED BT_MESH_MODEL_OP_2(0x80, 0x79)
123 #define OP_SOL_PDU_RPL_ITEM_STATUS BT_MESH_MODEL_OP_2(0x80, 0x7a)
124
125 #define STATUS_SUCCESS 0x00
126 #define STATUS_INVALID_ADDRESS 0x01
127 #define STATUS_INVALID_MODEL 0x02
128 #define STATUS_INVALID_APPKEY 0x03
129 #define STATUS_INVALID_NETKEY 0x04
130 #define STATUS_INSUFF_RESOURCES 0x05
131 #define STATUS_IDX_ALREADY_STORED 0x06
132 #define STATUS_NVAL_PUB_PARAM 0x07
133 #define STATUS_NOT_SUB_MOD 0x08
134 #define STATUS_STORAGE_FAIL 0x09
135 #define STATUS_FEAT_NOT_SUPP 0x0a
136 #define STATUS_CANNOT_UPDATE 0x0b
137 #define STATUS_CANNOT_REMOVE 0x0c
138 #define STATUS_CANNOT_BIND 0x0d
139 #define STATUS_TEMP_STATE_CHG_FAIL 0x0e
140 #define STATUS_CANNOT_SET 0x0f
141 #define STATUS_UNSPECIFIED 0x10
142 #define STATUS_INVALID_BINDING 0x11
143
144 #define ACCESS_STATUS_SUCCESS 0x00
145 #define ACCESS_STATUS_INVALID_ADDRESS 0x01
146 #define ACCESS_STATUS_WRONG_KEY 0x02
147 #define ACCESS_STATUS_WRONG_OPCODE 0x03
148 #define ACCESS_STATUS_MESSAGE_NOT_UNDERSTOOD 0x04
149 #define ACCESS_STATUS_RESPONSE_OVERFLOW 0x05
150
151 void bt_mesh_model_reset(void);
152
153 void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time);
154
155 #include <zephyr/sys/byteorder.h>
156
key_idx_pack_pair(struct net_buf_simple * buf,uint16_t idx1,uint16_t idx2)157 static inline void key_idx_pack_pair(struct net_buf_simple *buf, uint16_t idx1, uint16_t idx2)
158 {
159 net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12));
160 net_buf_simple_add_u8(buf, idx2 >> 4);
161 }
162
key_idx_unpack_pair(struct net_buf_simple * buf,uint16_t * idx1,uint16_t * idx2)163 static inline void key_idx_unpack_pair(struct net_buf_simple *buf, uint16_t *idx1, uint16_t *idx2)
164 {
165 *idx1 = sys_get_le16(&buf->data[0]) & 0xfff;
166 *idx2 = sys_get_le16(&buf->data[1]) >> 4;
167 net_buf_simple_pull(buf, 3);
168 }
169