1 /** @file 2 * @brief Bluetooth Mesh Configuration Client Model APIs. 3 */ 4 5 /* 6 * Copyright (c) 2017 Intel Corporation 7 * 8 * SPDX-License-Identifier: Apache-2.0 9 */ 10 #ifndef __BT_MESH_CFG_CLI_H 11 #define __BT_MESH_CFG_CLI_H 12 13 /** 14 * @brief Bluetooth Mesh 15 * @defgroup bt_mesh_cfg_cli Bluetooth Mesh Configuration Client Model 16 * @ingroup bt_mesh 17 * @{ 18 */ 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 /** Mesh Configuration Client Model Context */ 24 struct bt_mesh_cfg_cli { 25 struct bt_mesh_model *model; 26 27 struct k_sem op_sync; 28 bt_u32_t op_pending; 29 void *op_param; 30 }; 31 32 extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[]; 33 extern struct bt_mesh_cfg_cli g_cfg_cli; 34 35 #define BT_MESH_MODEL_CFG_CLI(cli_data) BT_MESH_MODEL(BT_MESH_MODEL_ID_CFG_CLI, bt_mesh_cfg_cli_op, NULL, cli_data) 36 37 #define MESH_MODEL_CFG_CLI_NULL() BT_MESH_MODEL_CFG_CLI(&g_cfg_cli) 38 39 int bt_mesh_cfg_comp_data_get(u16_t net_idx, u16_t addr, u8_t page, u8_t *status, struct net_buf_simple *comp); 40 41 int bt_mesh_cfg_beacon_get(u16_t net_idx, u16_t addr, u8_t *status); 42 43 int bt_mesh_cfg_beacon_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status); 44 45 int bt_mesh_cfg_ttl_get(u16_t net_idx, u16_t addr, u8_t *ttl); 46 47 int bt_mesh_cfg_ttl_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *ttl); 48 49 int bt_mesh_cfg_friend_get(u16_t net_idx, u16_t addr, u8_t *status); 50 51 int bt_mesh_cfg_friend_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status); 52 53 int bt_mesh_cfg_gatt_proxy_get(u16_t net_idx, u16_t addr, u8_t *status); 54 55 int bt_mesh_cfg_gatt_proxy_set(u16_t net_idx, u16_t addr, u8_t val, u8_t *status); 56 57 int bt_mesh_cfg_relay_get(u16_t net_idx, u16_t addr, u8_t *status, u8_t *transmit); 58 59 int bt_mesh_cfg_relay_set(u16_t net_idx, u16_t addr, u8_t new_relay, u8_t new_transmit, u8_t *status, u8_t *transmit); 60 61 int bt_mesh_cfg_net_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, const u8_t net_key[16], u8_t *status); 62 63 int bt_mesh_cfg_app_key_add(u16_t net_idx, u16_t addr, u16_t key_net_idx, u16_t key_app_idx, const u8_t app_key[16], 64 u8_t *status); 65 66 int bt_mesh_cfg_mod_app_bind(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx, u16_t mod_id, u8_t *status); 67 68 int bt_mesh_cfg_mod_app_bind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx, u16_t mod_id, u16_t cid, 69 u8_t *status); 70 71 int bt_mesh_cfg_mod_app_unbind(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx, u16_t mod_id, 72 u8_t *status); 73 74 int bt_mesh_cfg_mod_app_unbind_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_app_idx, u16_t mod_id, 75 u16_t cid, u8_t *status); 76 77 int bt_mesh_cfg_net_key_update(u16_t net_idx, u16_t addr, u16_t key_net_idx, const u8_t net_key[16], u8_t *status); 78 79 int bt_mesh_cfg_app_key_update(u16_t net_idx, u16_t addr, u16_t key_net_idx, u16_t key_app_idx, const u8_t app_key[16], 80 u8_t *status); 81 82 /** @def BT_MESH_PUB_PERIOD_100MS 83 * 84 * @brief Helper macro to encode model publication period in units of 100ms 85 * 86 * @param steps Number of 100ms steps. 87 * 88 * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period 89 */ 90 #define BT_MESH_PUB_PERIOD_100MS(steps) ((steps) & BIT_MASK(6)) 91 92 /** @def BT_MESH_PUB_PERIOD_SEC 93 * 94 * @brief Helper macro to encode model publication period in units of 1 second 95 * 96 * @param steps Number of 1 second steps. 97 * 98 * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period 99 */ 100 #define BT_MESH_PUB_PERIOD_SEC(steps) (((steps) & BIT_MASK(6)) | (1 << 6)) 101 102 /** @def BT_MESH_PUB_PERIOD_10SEC 103 * 104 * @brief Helper macro to encode model publication period in units of 10 105 * seconds 106 * 107 * @param steps Number of 10 second steps. 108 * 109 * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period 110 */ 111 #define BT_MESH_PUB_PERIOD_10SEC(steps) (((steps) & BIT_MASK(6)) | (2 << 6)) 112 113 /** @def BT_MESH_PUB_PERIOD_10MIN 114 * 115 * @brief Helper macro to encode model publication period in units of 10 116 * minutes 117 * 118 * @param steps Number of 10 minute steps. 119 * 120 * @return Encoded value that can be assigned to bt_mesh_cfg_mod_pub.period 121 */ 122 #define BT_MESH_PUB_PERIOD_10MIN(steps) (((steps) & BIT_MASK(6)) | (3 << 6)) 123 124 struct bt_mesh_cfg_mod_pub { 125 u16_t addr; 126 u16_t app_idx; 127 bool cred_flag; 128 u8_t ttl; 129 u8_t period; 130 u8_t transmit; 131 }; 132 133 int bt_mesh_cfg_mod_pub_get(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, 134 u8_t *status); 135 136 int bt_mesh_cfg_mod_pub_get_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_id, u16_t cid, 137 struct bt_mesh_cfg_mod_pub *pub, u8_t *status); 138 139 int bt_mesh_cfg_mod_pub_set(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_id, struct bt_mesh_cfg_mod_pub *pub, 140 u8_t *status); 141 142 int bt_mesh_cfg_mod_pub_set_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t mod_id, u16_t cid, 143 struct bt_mesh_cfg_mod_pub *pub, u8_t *status); 144 145 int bt_mesh_cfg_mod_sub_add(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, u8_t *status); 146 147 int bt_mesh_cfg_mod_sub_get(u16_t net_idx, u16_t addr, u16_t mod_id, uint16_t *sub, u8_t *status); 148 149 int bt_mesh_cfg_mod_sub_get_vnd(u16_t net_idx, u16_t addr, u16_t mod_id, u16_t cid, uint16_t *sub, u8_t *status); 150 151 int bt_mesh_cfg_mod_sub_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, u16_t cid, 152 u8_t *status); 153 154 int bt_mesh_cfg_mod_sub_del(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, u8_t *status); 155 156 int bt_mesh_cfg_mod_sub_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, u16_t cid, 157 u8_t *status); 158 159 int bt_mesh_cfg_mod_sub_overwrite(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, 160 u8_t *status); 161 162 int bt_mesh_cfg_mod_sub_overwrite_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, u16_t sub_addr, u16_t mod_id, 163 u16_t cid, u8_t *status); 164 165 int bt_mesh_cfg_mod_sub_va_add(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 166 u16_t *virt_addr, u8_t *status); 167 168 int bt_mesh_cfg_mod_sub_va_add_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 169 u16_t cid, u16_t *virt_addr, u8_t *status); 170 171 int bt_mesh_cfg_mod_sub_va_del(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 172 u16_t *virt_addr, u8_t *status); 173 174 int bt_mesh_cfg_mod_sub_va_del_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 175 u16_t cid, u16_t *virt_addr, u8_t *status); 176 177 int bt_mesh_cfg_mod_sub_va_overwrite(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 178 u16_t *virt_addr, u8_t *status); 179 180 int bt_mesh_cfg_mod_sub_va_overwrite_vnd(u16_t net_idx, u16_t addr, u16_t elem_addr, const u8_t label[16], u16_t mod_id, 181 u16_t cid, u16_t *virt_addr, u8_t *status); 182 183 int bt_mesh_cfg_node_reset(u16_t net_idx, u16_t addr); 184 185 int bt_mesh_cfg_krp_set(u16_t net_idx, u16_t addr, u16_t key_net_idx, u8_t *phase, u8_t *status); 186 int bt_mesh_cfg_krp_get(u16_t net_idx, u16_t addr, u16_t key_net_idx, u8_t *phase, u8_t *status); 187 188 struct bt_mesh_cfg_hb_sub { 189 u16_t src; 190 u16_t dst; 191 u8_t period; 192 u8_t count; 193 u8_t min; 194 u8_t max; 195 }; 196 197 int bt_mesh_cfg_hb_sub_set(u16_t net_idx, u16_t addr, struct bt_mesh_cfg_hb_sub *sub, u8_t *status); 198 199 int bt_mesh_cfg_hb_sub_get(u16_t net_idx, u16_t addr, struct bt_mesh_cfg_hb_sub *sub, u8_t *status); 200 201 struct bt_mesh_cfg_hb_pub { 202 u16_t dst; 203 u8_t count; 204 u8_t period; 205 u8_t ttl; 206 u16_t feat; 207 u16_t net_idx; 208 }; 209 210 int bt_mesh_cfg_hb_pub_set(u16_t net_idx, u16_t addr, const struct bt_mesh_cfg_hb_pub *pub, u8_t *status); 211 212 int bt_mesh_cfg_hb_pub_get(u16_t net_idx, u16_t addr, struct bt_mesh_cfg_hb_pub *pub, u8_t *status); 213 214 /*[Genie begin] add by wenbing.cwb at 2021-01-21*/ 215 #ifdef CONFIG_BT_MESH_CTRL_RELAY 216 int bt_mesh_cfg_ctrl_relay_get(u16_t net_idx, u16_t addr, struct ctrl_relay_param *cr, u8_t *status); 217 218 int bt_mesh_cfg_ctrl_relay_set(u16_t net_idx, u16_t addr, const struct ctrl_relay_param *cr, u8_t *status); 219 #endif 220 /*[Genie end] add by wenbing.cwb at 2021-01-21*/ 221 222 bt_s32_t bt_mesh_cfg_cli_timeout_get(void); 223 void bt_mesh_cfg_cli_timeout_set(bt_s32_t timeout); 224 225 #ifdef __cplusplus 226 } 227 #endif 228 /** 229 * @} 230 */ 231 232 #endif /* __BT_MESH_CFG_CLI_H */ 233