Lines Matching full:model

51 static int dev_comp_data_get(struct bt_mesh_model *model,  in dev_comp_data_get()  argument
82 if (bt_mesh_model_send(model, ctx, &sdu, NULL, NULL)) { in dev_comp_data_get()
116 static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, const uint8_t *uuid, in _mod_pub_set() argument
120 if (!model->pub) { in _mod_pub_set()
128 if (!model->pub->update && period) { in _mod_pub_set()
133 if (model->pub->addr == BT_MESH_ADDR_UNASSIGNED) { in _mod_pub_set()
137 model->pub->addr = BT_MESH_ADDR_UNASSIGNED; in _mod_pub_set()
138 model->pub->key = 0U; in _mod_pub_set()
139 model->pub->cred = 0U; in _mod_pub_set()
140 model->pub->ttl = 0U; in _mod_pub_set()
141 model->pub->period = 0U; in _mod_pub_set()
142 model->pub->retransmit = 0U; in _mod_pub_set()
143 model->pub->count = 0U; in _mod_pub_set()
144 model->pub->uuid = NULL; in _mod_pub_set()
146 if (model->pub->update) { in _mod_pub_set()
150 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
154 bt_mesh_model_pub_store(model); in _mod_pub_set()
160 if (!bt_mesh_app_key_exists(app_idx) || !bt_mesh_model_has_key(model, app_idx)) { in _mod_pub_set()
165 if (BT_MESH_ADDR_IS_VIRTUAL(model->pub->addr)) { in _mod_pub_set()
166 (void)bt_mesh_va_del(model->pub->uuid); in _mod_pub_set()
170 model->pub->addr = pub_addr; in _mod_pub_set()
171 model->pub->key = app_idx; in _mod_pub_set()
172 model->pub->cred = cred_flag; in _mod_pub_set()
173 model->pub->ttl = ttl; in _mod_pub_set()
174 model->pub->period = period; in _mod_pub_set()
175 model->pub->retransmit = retransmit; in _mod_pub_set()
176 model->pub->uuid = uuid; in _mod_pub_set()
178 if (model->pub->update) { in _mod_pub_set()
181 period_ms = bt_mesh_model_pub_period_get(model); in _mod_pub_set()
185 k_work_reschedule(&model->pub->timer, in _mod_pub_set()
191 (void)k_work_cancel_delayable(&model->pub->timer); in _mod_pub_set()
196 bt_mesh_model_pub_store(model); in _mod_pub_set()
202 static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx) in mod_bind() argument
206 LOG_DBG("model %p key_idx 0x%03x", model, key_idx); in mod_bind()
212 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
213 LOG_DBG("model %p id 0x%04x i %d key 0x%03x", model, model->id, i, model->keys[i]); in mod_bind()
215 if (model->keys[i] == key_idx) { in mod_bind()
220 for (i = 0; i < model->keys_cnt; i++) { in mod_bind()
221 if (model->keys[i] == BT_MESH_KEY_UNUSED) { in mod_bind()
222 model->keys[i] = key_idx; in mod_bind()
225 bt_mesh_model_bind_store(model); in mod_bind()
235 static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store) in mod_unbind() argument
239 LOG_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); in mod_unbind()
245 for (i = 0; i < model->keys_cnt; i++) { in mod_unbind()
246 if (model->keys[i] != key_idx) { in mod_unbind()
250 model->keys[i] = BT_MESH_KEY_UNUSED; in mod_unbind()
253 bt_mesh_model_bind_store(model); in mod_unbind()
256 if (model->pub && model->pub->key == key_idx) { in mod_unbind()
257 _mod_pub_set(model, BT_MESH_ADDR_UNASSIGNED, NULL, in mod_unbind()
287 static int send_app_key_status(struct bt_mesh_model *model, in send_app_key_status() argument
298 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_app_key_status()
305 static int app_key_add(struct bt_mesh_model *model, in app_key_add() argument
318 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_add()
321 static int app_key_update(struct bt_mesh_model *model, in app_key_update() argument
335 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_update()
357 static int app_key_del(struct bt_mesh_model *model, in app_key_del() argument
370 return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx); in app_key_del()
376 static int app_key_get(struct bt_mesh_model *model, in app_key_get() argument
418 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in app_key_get()
425 static int beacon_get(struct bt_mesh_model *model, in beacon_get() argument
437 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_get()
444 static int beacon_set(struct bt_mesh_model *model, in beacon_set() argument
463 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in beacon_set()
470 static int default_ttl_get(struct bt_mesh_model *model, in default_ttl_get() argument
482 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_get()
489 static int default_ttl_set(struct bt_mesh_model *model, in default_ttl_set() argument
508 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in default_ttl_set()
515 static int send_gatt_proxy_status(struct bt_mesh_model *model, in send_gatt_proxy_status() argument
523 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_gatt_proxy_status()
530 static int gatt_proxy_get(struct bt_mesh_model *model, in gatt_proxy_get() argument
537 return send_gatt_proxy_status(model, ctx); in gatt_proxy_get()
540 static int gatt_proxy_set(struct bt_mesh_model *model, in gatt_proxy_set() argument
561 return send_gatt_proxy_status(model, ctx); in gatt_proxy_set()
564 static int net_transmit_get(struct bt_mesh_model *model, in net_transmit_get() argument
576 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_get()
583 static int net_transmit_set(struct bt_mesh_model *model, in net_transmit_set() argument
600 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_transmit_set()
607 static int relay_get(struct bt_mesh_model *model, in relay_get() argument
620 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_get()
627 static int relay_set(struct bt_mesh_model *model, in relay_set() argument
647 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in relay_set()
688 LOG_ERR("Unable to send Model Publication Status"); in send_mod_pub_status()
694 static int mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in mod_pub_get() argument
741 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_get()
745 static int mod_pub_set(struct bt_mesh_model *model, in mod_pub_set() argument
806 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_set()
826 /* Unref stored labels related to this model */ in mod_sub_list_clear()
841 static int mod_pub_va_set(struct bt_mesh_model *model, in mod_pub_va_set() argument
914 return send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_va_set()
918 static int send_mod_sub_status(struct bt_mesh_model *model, in send_mod_sub_status() argument
939 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_mod_sub_status()
940 LOG_ERR("Unable to send Model Subscription Status"); in send_mod_sub_status()
946 static int mod_sub_add(struct bt_mesh_model *model, in mod_sub_add() argument
1020 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_add()
1024 static int mod_sub_del(struct bt_mesh_model *model, in mod_sub_del() argument
1091 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_del()
1106 static int mod_sub_overwrite(struct bt_mesh_model *model, in mod_sub_overwrite() argument
1173 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_overwrite()
1177 static int mod_sub_del_all(struct bt_mesh_model *model, in mod_sub_del_all() argument
1226 return send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_del_all()
1260 LOG_DBG("sublist: model %u:%x: %u groups", mod->elem_idx, mod->id, count); in mod_sub_list_visitor()
1265 static int mod_sub_get(struct bt_mesh_model *model, in mod_sub_get() argument
1313 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get()
1314 LOG_ERR("Unable to send Model Subscription List"); in mod_sub_get()
1320 static int mod_sub_get_vnd(struct bt_mesh_model *model, in mod_sub_get_vnd() argument
1372 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_sub_get_vnd()
1373 LOG_ERR("Unable to send Vendor Model Subscription List"); in mod_sub_get_vnd()
1379 static int mod_sub_va_add(struct bt_mesh_model *model, in mod_sub_va_add() argument
1452 /* bt_mesh_model_find_uuid() should find a model where both, uuids and groups lists have in mod_sub_va_add()
1477 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_add()
1481 static int mod_sub_va_del(struct bt_mesh_model *model, in mod_sub_va_del() argument
1561 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_del()
1565 static int mod_sub_va_overwrite(struct bt_mesh_model *model, in mod_sub_va_overwrite() argument
1637 return send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_overwrite()
1641 static int send_net_key_status(struct bt_mesh_model *model, in send_net_key_status() argument
1652 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_net_key_status()
1659 static int net_key_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in net_key_add() argument
1675 return send_net_key_status(model, ctx, idx, status); in net_key_add()
1678 static int net_key_update(struct bt_mesh_model *model, in net_key_update() argument
1693 return send_net_key_status(model, ctx, idx, status); in net_key_update()
1696 static int net_key_del(struct bt_mesh_model *model, in net_key_del() argument
1714 return send_net_key_status(model, ctx, del_idx, in net_key_del()
1720 return send_net_key_status(model, ctx, del_idx, STATUS_SUCCESS); in net_key_del()
1723 static int net_key_get(struct bt_mesh_model *model, in net_key_get() argument
1741 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in net_key_get()
1748 static int send_node_id_status(struct bt_mesh_model *model, in send_node_id_status() argument
1760 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_node_id_status()
1767 static int node_identity_get(struct bt_mesh_model *model, in node_identity_get() argument
1786 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_get()
1789 static int node_identity_set(struct bt_mesh_model *model, in node_identity_set() argument
1813 return send_node_id_status(model, ctx, status, idx, in node_identity_set()
1819 return send_node_id_status(model, ctx, STATUS_SUCCESS, idx, in node_identity_set()
1823 return send_node_id_status(model, ctx, status, idx, node_id); in node_identity_set()
1844 static int mod_app_bind(struct bt_mesh_model *model, in mod_app_bind() argument
1885 LOG_ERR("Client tried to bind AppKey to DevKey based model"); in mod_app_bind()
1901 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_bind()
1902 LOG_ERR("Unable to send Model App Bind Status response"); in mod_app_bind()
1908 static int mod_app_unbind(struct bt_mesh_model *model, in mod_app_unbind() argument
1958 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_unbind()
1959 LOG_ERR("Unable to send Model App Unbind Status response"); in mod_app_unbind()
1967 static int mod_app_get(struct bt_mesh_model *model, in mod_app_get() argument
2033 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in mod_app_get()
2034 LOG_ERR("Unable to send Model Application List message"); in mod_app_get()
2053 static int node_reset(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in node_reset() argument
2068 if (bt_mesh_model_send(model, ctx, &msg, &reset_cb, NULL)) { in node_reset()
2075 static int send_friend_status(struct bt_mesh_model *model, in send_friend_status() argument
2083 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_friend_status()
2090 static int friend_get(struct bt_mesh_model *model, in friend_get() argument
2097 return send_friend_status(model, ctx); in friend_get()
2100 static int friend_set(struct bt_mesh_model *model, in friend_set() argument
2114 return send_friend_status(model, ctx); in friend_set()
2117 static int lpn_timeout_get(struct bt_mesh_model *model, in lpn_timeout_get() argument
2156 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in lpn_timeout_get()
2163 static int send_krp_status(struct bt_mesh_model *model, in send_krp_status() argument
2175 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in send_krp_status()
2182 static int krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_get() argument
2198 return send_krp_status(model, ctx, idx, kr_phase, status); in krp_get()
2201 static int krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_set() argument
2221 return send_krp_status(model, ctx, idx, phase, status); in krp_set()
2257 static int hb_pub_send_status(struct bt_mesh_model *model, in hb_pub_send_status() argument
2276 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_pub_send_status()
2283 static int heartbeat_pub_get(struct bt_mesh_model *model, in heartbeat_pub_get() argument
2293 return hb_pub_send_status(model, ctx, STATUS_SUCCESS, &pub); in heartbeat_pub_get()
2296 static int heartbeat_pub_set(struct bt_mesh_model *model, in heartbeat_pub_set() argument
2353 return hb_pub_send_status(model, ctx, status, &pub); in heartbeat_pub_set()
2356 static int hb_sub_send_status(struct bt_mesh_model *model, in hb_sub_send_status() argument
2374 if (bt_mesh_model_send(model, ctx, &msg, NULL, NULL)) { in hb_sub_send_status()
2381 static int heartbeat_sub_get(struct bt_mesh_model *model, in heartbeat_sub_get() argument
2391 return hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_get()
2394 static int heartbeat_sub_set(struct bt_mesh_model *model, in heartbeat_sub_set() argument
2440 err = hb_sub_send_status(model, ctx, &sub); in heartbeat_sub_set()
2507 static int cfg_srv_init(struct bt_mesh_model *model) in cfg_srv_init() argument
2509 if (!bt_mesh_model_in_primary(model)) { in cfg_srv_init()
2515 * Configuration Model security is device-key based and only the local in cfg_srv_init()
2516 * device-key is allowed to access this model. in cfg_srv_init()
2518 model->keys[0] = BT_MESH_KEY_DEV_LOCAL; in cfg_srv_init()
2519 model->flags |= BT_MESH_MOD_DEVKEY_ONLY; in cfg_srv_init()
2533 /* Clear model state that isn't otherwise cleared. E.g. AppKey in mod_reset()
2534 * binding and model publication is cleared as a consequence in mod_reset()
2535 * of removing all app keys, however model subscription and user data in mod_reset()