Lines Matching full:model

50 static int dev_comp_data_get(const struct bt_mesh_model *model,  in dev_comp_data_get()  argument
81 if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { in dev_comp_data_get()
115 static uint8_t _mod_pub_set(const struct bt_mesh_model *model, uint16_t pub_addr, in _mod_pub_set() argument
119 if (!model->pub) { in _mod_pub_set()
127 if (!model->pub->update && period) { in _mod_pub_set()
132 if (model->pub->addr == BT_MESH_ADDR_UNASSIGNED) { in _mod_pub_set()
136 model->pub->addr = BT_MESH_ADDR_UNASSIGNED; in _mod_pub_set()
137 model->pub->key = 0U; in _mod_pub_set()
138 model->pub->cred = 0U; in _mod_pub_set()
139 model->pub->ttl = 0U; in _mod_pub_set()
140 model->pub->period = 0U; in _mod_pub_set()
141 model->pub->retransmit = 0U; in _mod_pub_set()
142 model->pub->count = 0U; in _mod_pub_set()
143 model->pub->uuid = NULL; in _mod_pub_set()
145 if (model->pub->update) { in _mod_pub_set()
149 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
153 bt_mesh_model_pub_store(model); in _mod_pub_set()
159 if (!bt_mesh_app_key_exists(app_idx) || !bt_mesh_model_has_key(model, app_idx)) { in _mod_pub_set()
164 if (BT_MESH_ADDR_IS_VIRTUAL(model->pub->addr)) { in _mod_pub_set()
165 (void)bt_mesh_va_del(model->pub->uuid); in _mod_pub_set()
169 model->pub->addr = pub_addr; in _mod_pub_set()
170 model->pub->key = app_idx; in _mod_pub_set()
171 model->pub->cred = cred_flag; in _mod_pub_set()
172 model->pub->ttl = ttl; in _mod_pub_set()
173 model->pub->period = period; in _mod_pub_set()
174 model->pub->retransmit = retransmit; in _mod_pub_set()
175 model->pub->uuid = uuid; in _mod_pub_set()
177 if (model->pub->update) { in _mod_pub_set()
180 period_ms = bt_mesh_model_pub_period_get(model); in _mod_pub_set()
184 k_work_reschedule(&model->pub->timer, in _mod_pub_set()
190 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
195 bt_mesh_model_pub_store(model); in _mod_pub_set()
201 static uint8_t mod_bind(const struct bt_mesh_model *model, uint16_t key_idx) in mod_bind() argument
205 LOG_DBG("model %p key_idx 0x%03x", model, key_idx); in mod_bind()
211 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
212 LOG_DBG("model %p id 0x%04x i %d key 0x%03x", model, model->id, i, model->keys[i]); in mod_bind()
214 if (model->keys[i] == key_idx) { in mod_bind()
219 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
220 if (model->keys[i] == BT_MESH_KEY_UNUSED) { in mod_bind()
221 model->keys[i] = key_idx; in mod_bind()
224 bt_mesh_model_bind_store(model); in mod_bind()
234 static uint8_t mod_unbind(const struct bt_mesh_model *model, uint16_t key_idx, bool store) in mod_unbind() argument
238 LOG_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); in mod_unbind()
244 for (i = 0; i < model->keys_cnt; i++) { in mod_unbind()
245 if (model->keys[i] != key_idx) { in mod_unbind()
249 model->keys[i] = BT_MESH_KEY_UNUSED; in mod_unbind()
252 bt_mesh_model_bind_store(model); in mod_unbind()
255 if (model->pub && model->pub->key == key_idx) { in mod_unbind()
256 _mod_pub_set(model, BT_MESH_ADDR_UNASSIGNED, NULL, in mod_unbind()
286 static int send_app_key_status(const struct bt_mesh_model *model, in send_app_key_status() argument
297 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_app_key_status()
304 static int app_key_add(const struct bt_mesh_model *model, in app_key_add() argument
317 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_add()
320 static int app_key_update(const struct bt_mesh_model *model, in app_key_update() argument
334 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_update()
356 static int app_key_del(const struct bt_mesh_model *model, in app_key_del() argument
369 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_del()
375 static int app_key_get(const struct bt_mesh_model *model, in app_key_get() argument
417 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in app_key_get()
424 static int beacon_get(const struct bt_mesh_model *model, in beacon_get() argument
436 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_get()
443 static int beacon_set(const struct bt_mesh_model *model, in beacon_set() argument
462 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_set()
469 static int default_ttl_get(const struct bt_mesh_model *model, in default_ttl_get() argument
481 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_get()
488 static int default_ttl_set(const struct bt_mesh_model *model, in default_ttl_set() argument
507 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_set()
514 static int send_gatt_proxy_status(const struct bt_mesh_model *model, in send_gatt_proxy_status() argument
522 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_gatt_proxy_status()
529 static int gatt_proxy_get(const struct bt_mesh_model *model, in gatt_proxy_get() argument
536 return send_gatt_proxy_status(model, ctx); in gatt_proxy_get()
539 static int gatt_proxy_set(const struct bt_mesh_model *model, in gatt_proxy_set() argument
560 return send_gatt_proxy_status(model, ctx); in gatt_proxy_set()
563 static int net_transmit_get(const struct bt_mesh_model *model, in net_transmit_get() argument
575 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_get()
582 static int net_transmit_set(const struct bt_mesh_model *model, in net_transmit_set() argument
599 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_set()
606 static int relay_get(const struct bt_mesh_model *model, in relay_get() argument
619 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_get()
626 static int relay_set(const struct bt_mesh_model *model, in relay_set() argument
646 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_set()
687 LOG_ERR("Unable to send Model Publication Status"); in send_mod_pub_status()
693 static int mod_pub_get(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in mod_pub_get() argument
740 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_get()
744 static int mod_pub_set(const struct bt_mesh_model *model, in mod_pub_set() argument
805 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_set()
825 /* Unref stored labels related to this model */ in mod_sub_list_clear()
840 static int mod_pub_va_set(const struct bt_mesh_model *model, in mod_pub_va_set() argument
913 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_va_set()
917 static int send_mod_sub_status(const struct bt_mesh_model *model, in send_mod_sub_status() argument
938 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_mod_sub_status()
939 LOG_ERR("Unable to send Model Subscription Status"); in send_mod_sub_status()
945 static int mod_sub_add(const struct bt_mesh_model *model, in mod_sub_add() argument
1019 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_add()
1023 static int mod_sub_del(const struct bt_mesh_model *model, in mod_sub_del() argument
1090 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_del()
1105 static int mod_sub_overwrite(const struct bt_mesh_model *model, in mod_sub_overwrite() argument
1172 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_overwrite()
1176 static int mod_sub_del_all(const struct bt_mesh_model *model, in mod_sub_del_all() argument
1225 return send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_del_all()
1259 LOG_DBG("sublist: model %u:%x: %u groups", mod->rt->elem_idx, mod->id, count); in mod_sub_list_visitor()
1264 static int mod_sub_get(const struct bt_mesh_model *model, in mod_sub_get() argument
1312 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get()
1313 LOG_ERR("Unable to send Model Subscription List"); in mod_sub_get()
1319 static int mod_sub_get_vnd(const struct bt_mesh_model *model, in mod_sub_get_vnd() argument
1371 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get_vnd()
1372 LOG_ERR("Unable to send Vendor Model Subscription List"); in mod_sub_get_vnd()
1378 static int mod_sub_va_add(const struct bt_mesh_model *model, in mod_sub_va_add() argument
1451 /* bt_mesh_model_find_uuid() should find a model where both, uuids and groups lists have in mod_sub_va_add()
1476 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_add()
1480 static int mod_sub_va_del(const struct bt_mesh_model *model, in mod_sub_va_del() argument
1560 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_del()
1564 static int mod_sub_va_overwrite(const struct bt_mesh_model *model, in mod_sub_va_overwrite() argument
1636 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_overwrite()
1640 static int send_net_key_status(const struct bt_mesh_model *model, in send_net_key_status() argument
1651 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_net_key_status()
1658 static int net_key_add(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in net_key_add() argument
1674 return send_net_key_status(model, ctx, idx, status); in net_key_add()
1677 static int net_key_update(const struct bt_mesh_model *model, in net_key_update() argument
1692 return send_net_key_status(model, ctx, idx, status); in net_key_update()
1695 static int net_key_del(const struct bt_mesh_model *model, in net_key_del() argument
1713 return send_net_key_status(model, ctx, del_idx, in net_key_del()
1719 return send_net_key_status(model, ctx, del_idx, STATUS_SUCCESS); in net_key_del()
1722 static int net_key_get(const struct bt_mesh_model *model, in net_key_get() argument
1740 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_key_get()
1747 static int send_node_id_status(const struct bt_mesh_model *model, in send_node_id_status() argument
1759 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_node_id_status()
1766 static int node_identity_get(const struct bt_mesh_model *model, in node_identity_get() argument
1785 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_get()
1788 static int node_identity_set(const struct bt_mesh_model *model, in node_identity_set() argument
1812 return send_node_id_status(model, ctx, status, idx, in node_identity_set()
1818 return send_node_id_status(model, ctx, STATUS_SUCCESS, idx, in node_identity_set()
1822 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_set()
1843 static int mod_app_bind(const struct bt_mesh_model *model, in mod_app_bind() argument
1884 LOG_ERR("Client tried to bind AppKey to DevKey based model"); in mod_app_bind()
1900 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_bind()
1901 LOG_ERR("Unable to send Model App Bind Status response"); in mod_app_bind()
1907 static int mod_app_unbind(const struct bt_mesh_model *model, in mod_app_unbind() argument
1957 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_unbind()
1958 LOG_ERR("Unable to send Model App Unbind Status response"); in mod_app_unbind()
1966 static int mod_app_get(const struct bt_mesh_model *model, in mod_app_get() argument
2032 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_get()
2033 LOG_ERR("Unable to send Model Application List message"); in mod_app_get()
2052 static int node_reset(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in node_reset() argument
2067 if (bt_mesh_model_send(model, ctx, &msg, &reset_cb, NULL)) { in node_reset()
2074 static int send_friend_status(const struct bt_mesh_model *model, in send_friend_status() argument
2082 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_friend_status()
2089 static int friend_get(const struct bt_mesh_model *model, in friend_get() argument
2096 return send_friend_status(model, ctx); in friend_get()
2099 static int friend_set(const struct bt_mesh_model *model, in friend_set() argument
2113 return send_friend_status(model, ctx); in friend_set()
2116 static int lpn_timeout_get(const struct bt_mesh_model *model, in lpn_timeout_get() argument
2155 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in lpn_timeout_get()
2162 static int send_krp_status(const struct bt_mesh_model *model, in send_krp_status() argument
2174 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_krp_status()
2181 static int krp_get(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_get() argument
2197 return send_krp_status(model, ctx, idx, kr_phase, status); in krp_get()
2200 static int krp_set(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_set() argument
2220 return send_krp_status(model, ctx, idx, phase, status); in krp_set()
2256 static int hb_pub_send_status(const struct bt_mesh_model *model, in hb_pub_send_status() argument
2279 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_pub_send_status()
2286 static int heartbeat_pub_get(const struct bt_mesh_model *model, in heartbeat_pub_get() argument
2296 return hb_pub_send_status(model, ctx, STATUS_SUCCESS, &pub); in heartbeat_pub_get()
2299 static int heartbeat_pub_set(const struct bt_mesh_model *model, in heartbeat_pub_set() argument
2356 return hb_pub_send_status(model, ctx, status, &pub); in heartbeat_pub_set()
2359 static int hb_sub_send_status(const struct bt_mesh_model *model, in hb_sub_send_status() argument
2377 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_sub_send_status()
2384 static int heartbeat_sub_get(const struct bt_mesh_model *model, in heartbeat_sub_get() argument
2394 return hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_get()
2397 static int heartbeat_sub_set(const struct bt_mesh_model *model, in heartbeat_sub_set() argument
2443 err = hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_set()
2510 static int cfg_srv_init(const struct bt_mesh_model *model) in cfg_srv_init() argument
2512 if (!bt_mesh_model_in_primary(model)) { in cfg_srv_init()
2518 * Configuration Model security is device-key based and only the local in cfg_srv_init()
2519 * device-key is allowed to access this model. in cfg_srv_init()
2521 model->keys[0] = BT_MESH_KEY_DEV_LOCAL; in cfg_srv_init()
2522 model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; in cfg_srv_init()
2536 /* Clear model state that isn't otherwise cleared. E.g. AppKey in mod_reset()
2537 * binding and model publication is cleared as a consequence in mod_reset()
2538 * of removing all app keys, however model subscription and user data in mod_reset()