Lines Matching full:model

50 static int dev_comp_data_get(struct bt_mesh_model *model,  in dev_comp_data_get()  argument
99 if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { in dev_comp_data_get()
133 static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, in _mod_pub_set() argument
137 if (!model->pub) { in _mod_pub_set()
145 if (!model->pub->update && period) { in _mod_pub_set()
150 if (model->pub->addr == BT_MESH_ADDR_UNASSIGNED) { in _mod_pub_set()
154 model->pub->addr = BT_MESH_ADDR_UNASSIGNED; in _mod_pub_set()
155 model->pub->key = 0U; in _mod_pub_set()
156 model->pub->cred = 0U; in _mod_pub_set()
157 model->pub->ttl = 0U; in _mod_pub_set()
158 model->pub->period = 0U; in _mod_pub_set()
159 model->pub->retransmit = 0U; in _mod_pub_set()
160 model->pub->count = 0U; in _mod_pub_set()
162 if (model->pub->update) { in _mod_pub_set()
166 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
170 bt_mesh_model_pub_store(model); in _mod_pub_set()
176 if (!bt_mesh_app_key_exists(app_idx) || !bt_mesh_model_has_key(model, app_idx)) { in _mod_pub_set()
181 if (BT_MESH_ADDR_IS_VIRTUAL(model->pub->addr)) { in _mod_pub_set()
182 uint8_t *uuid = bt_mesh_va_label_get(model->pub->addr); in _mod_pub_set()
190 model->pub->addr = pub_addr; in _mod_pub_set()
191 model->pub->key = app_idx; in _mod_pub_set()
192 model->pub->cred = cred_flag; in _mod_pub_set()
193 model->pub->ttl = ttl; in _mod_pub_set()
194 model->pub->period = period; in _mod_pub_set()
195 model->pub->retransmit = retransmit; in _mod_pub_set()
197 if (model->pub->update) { in _mod_pub_set()
200 period_ms = bt_mesh_model_pub_period_get(model); in _mod_pub_set()
204 k_work_reschedule(&model->pub->timer, in _mod_pub_set()
210 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
215 bt_mesh_model_pub_store(model); in _mod_pub_set()
221 static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx) in mod_bind() argument
225 LOG_DBG("model %p key_idx 0x%03x", model, key_idx); in mod_bind()
231 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
232 LOG_DBG("model %p id 0x%04x i %d key 0x%03x", model, model->id, i, model->keys[i]); in mod_bind()
234 if (model->keys[i] == key_idx) { in mod_bind()
239 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
240 if (model->keys[i] == BT_MESH_KEY_UNUSED) { in mod_bind()
241 model->keys[i] = key_idx; in mod_bind()
244 bt_mesh_model_bind_store(model); in mod_bind()
254 static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store) in mod_unbind() argument
258 LOG_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); in mod_unbind()
264 for (i = 0; i < model->keys_cnt; i++) { in mod_unbind()
265 if (model->keys[i] != key_idx) { in mod_unbind()
269 model->keys[i] = BT_MESH_KEY_UNUSED; in mod_unbind()
272 bt_mesh_model_bind_store(model); in mod_unbind()
275 if (model->pub && model->pub->key == key_idx) { in mod_unbind()
276 _mod_pub_set(model, BT_MESH_ADDR_UNASSIGNED, in mod_unbind()
284 static int send_app_key_status(struct bt_mesh_model *model, in send_app_key_status() argument
295 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_app_key_status()
302 static int app_key_add(struct bt_mesh_model *model, in app_key_add() argument
315 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_add()
318 static int app_key_update(struct bt_mesh_model *model, in app_key_update() argument
332 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_update()
354 static int app_key_del(struct bt_mesh_model *model, in app_key_del() argument
367 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_del()
373 static int app_key_get(struct bt_mesh_model *model, in app_key_get() argument
422 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in app_key_get()
429 static int beacon_get(struct bt_mesh_model *model, in beacon_get() argument
441 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_get()
448 static int beacon_set(struct bt_mesh_model *model, in beacon_set() argument
467 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_set()
474 static int default_ttl_get(struct bt_mesh_model *model, in default_ttl_get() argument
486 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_get()
493 static int default_ttl_set(struct bt_mesh_model *model, in default_ttl_set() argument
512 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_set()
519 static int send_gatt_proxy_status(struct bt_mesh_model *model, in send_gatt_proxy_status() argument
527 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_gatt_proxy_status()
534 static int gatt_proxy_get(struct bt_mesh_model *model, in gatt_proxy_get() argument
541 return send_gatt_proxy_status(model, ctx); in gatt_proxy_get()
544 static int gatt_proxy_set(struct bt_mesh_model *model, in gatt_proxy_set() argument
565 return send_gatt_proxy_status(model, ctx); in gatt_proxy_set()
568 static int net_transmit_get(struct bt_mesh_model *model, in net_transmit_get() argument
580 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_get()
587 static int net_transmit_set(struct bt_mesh_model *model, in net_transmit_set() argument
604 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_set()
611 static int relay_get(struct bt_mesh_model *model, in relay_get() argument
624 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_get()
631 static int relay_set(struct bt_mesh_model *model, in relay_set() argument
651 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_set()
692 LOG_ERR("Unable to send Model Publication Status"); in send_mod_pub_status()
698 static int mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in mod_pub_get() argument
745 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_get()
749 static int mod_pub_set(struct bt_mesh_model *model, in mod_pub_set() argument
810 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_set()
820 /* Unref stored labels related to this model */ in mod_sub_list_clear()
846 static int mod_pub_va_set(struct bt_mesh_model *model, in mod_pub_va_set() argument
917 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_va_set()
921 static int send_mod_sub_status(struct bt_mesh_model *model, in send_mod_sub_status() argument
942 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_mod_sub_status()
943 LOG_ERR("Unable to send Model Subscription Status"); in send_mod_sub_status()
949 static int mod_sub_add(struct bt_mesh_model *model, in mod_sub_add() argument
1023 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_add()
1027 static int mod_sub_del(struct bt_mesh_model *model, in mod_sub_del() argument
1094 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_del()
1109 static int mod_sub_overwrite(struct bt_mesh_model *model, in mod_sub_overwrite() argument
1176 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_overwrite()
1180 static int mod_sub_del_all(struct bt_mesh_model *model, in mod_sub_del_all() argument
1229 return send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_del_all()
1263 LOG_DBG("sublist: model %u:%x: %u groups", mod->elem_idx, mod->id, count); in mod_sub_list_visitor()
1268 static int mod_sub_get(struct bt_mesh_model *model, in mod_sub_get() argument
1316 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get()
1317 LOG_ERR("Unable to send Model Subscription List"); in mod_sub_get()
1323 static int mod_sub_get_vnd(struct bt_mesh_model *model, in mod_sub_get_vnd() argument
1375 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get_vnd()
1376 LOG_ERR("Unable to send Vendor Model Subscription List"); in mod_sub_get_vnd()
1382 static int mod_sub_va_add(struct bt_mesh_model *model, in mod_sub_va_add() argument
1460 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_add()
1464 static int mod_sub_va_del(struct bt_mesh_model *model, in mod_sub_va_del() argument
1533 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_del()
1537 static int mod_sub_va_overwrite(struct bt_mesh_model *model, in mod_sub_va_overwrite() argument
1601 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_overwrite()
1605 static int send_net_key_status(struct bt_mesh_model *model, in send_net_key_status() argument
1616 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_net_key_status()
1623 static int net_key_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in net_key_add() argument
1639 return send_net_key_status(model, ctx, idx, status); in net_key_add()
1642 static int net_key_update(struct bt_mesh_model *model, in net_key_update() argument
1657 return send_net_key_status(model, ctx, idx, status); in net_key_update()
1660 static int net_key_del(struct bt_mesh_model *model, in net_key_del() argument
1678 return send_net_key_status(model, ctx, del_idx, in net_key_del()
1684 return send_net_key_status(model, ctx, del_idx, STATUS_SUCCESS); in net_key_del()
1687 static int net_key_get(struct bt_mesh_model *model, in net_key_get() argument
1712 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_key_get()
1719 static int send_node_id_status(struct bt_mesh_model *model, in send_node_id_status() argument
1731 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_node_id_status()
1738 static int node_identity_get(struct bt_mesh_model *model, in node_identity_get() argument
1757 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_get()
1760 static int node_identity_set(struct bt_mesh_model *model, in node_identity_set() argument
1784 return send_node_id_status(model, ctx, status, idx, in node_identity_set()
1790 return send_node_id_status(model, ctx, STATUS_SUCCESS, idx, in node_identity_set()
1794 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_set()
1815 static int mod_app_bind(struct bt_mesh_model *model, in mod_app_bind() argument
1856 LOG_ERR("Client tried to bind AppKey to DevKey based model"); in mod_app_bind()
1872 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_bind()
1873 LOG_ERR("Unable to send Model App Bind Status response"); in mod_app_bind()
1879 static int mod_app_unbind(struct bt_mesh_model *model, in mod_app_unbind() argument
1929 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_unbind()
1930 LOG_ERR("Unable to send Model App Unbind Status response"); in mod_app_unbind()
1938 static int mod_app_get(struct bt_mesh_model *model, in mod_app_get() argument
2010 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_get()
2011 LOG_ERR("Unable to send Model Application List message"); in mod_app_get()
2030 static int node_reset(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in node_reset() argument
2045 if (bt_mesh_model_send(model, ctx, &msg, &reset_cb, NULL)) { in node_reset()
2052 static int send_friend_status(struct bt_mesh_model *model, in send_friend_status() argument
2060 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_friend_status()
2067 static int friend_get(struct bt_mesh_model *model, in friend_get() argument
2074 return send_friend_status(model, ctx); in friend_get()
2077 static int friend_set(struct bt_mesh_model *model, in friend_set() argument
2091 return send_friend_status(model, ctx); in friend_set()
2094 static int lpn_timeout_get(struct bt_mesh_model *model, in lpn_timeout_get() argument
2133 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in lpn_timeout_get()
2140 static int send_krp_status(struct bt_mesh_model *model, in send_krp_status() argument
2152 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_krp_status()
2159 static int krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_get() argument
2175 return send_krp_status(model, ctx, idx, kr_phase, status); in krp_get()
2178 static int krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_set() argument
2198 return send_krp_status(model, ctx, idx, phase, status); in krp_set()
2234 static int hb_pub_send_status(struct bt_mesh_model *model, in hb_pub_send_status() argument
2253 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_pub_send_status()
2260 static int heartbeat_pub_get(struct bt_mesh_model *model, in heartbeat_pub_get() argument
2270 return hb_pub_send_status(model, ctx, STATUS_SUCCESS, &pub); in heartbeat_pub_get()
2273 static int heartbeat_pub_set(struct bt_mesh_model *model, in heartbeat_pub_set() argument
2330 return hb_pub_send_status(model, ctx, status, &pub); in heartbeat_pub_set()
2333 static int hb_sub_send_status(struct bt_mesh_model *model, in hb_sub_send_status() argument
2351 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_sub_send_status()
2358 static int heartbeat_sub_get(struct bt_mesh_model *model, in heartbeat_sub_get() argument
2368 return hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_get()
2371 static int heartbeat_sub_set(struct bt_mesh_model *model, in heartbeat_sub_set() argument
2417 err = hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_set()
2484 static int cfg_srv_init(struct bt_mesh_model *model) in cfg_srv_init() argument
2486 if (!bt_mesh_model_in_primary(model)) { in cfg_srv_init()
2492 * Configuration Model security is device-key based and only the local in cfg_srv_init()
2493 * device-key is allowed to access this model. in cfg_srv_init()
2495 model->keys[0] = BT_MESH_KEY_DEV_LOCAL; in cfg_srv_init()
2496 model->flags |= BT_MESH_MOD_DEVKEY_ONLY; in cfg_srv_init()
2510 /* Clear model state that isn't otherwise cleared. E.g. AppKey in mod_reset()
2511 * binding and model publication is cleared as a consequence in mod_reset()
2512 * of removing all app keys, however model subscription and user data in mod_reset()