Lines Matching full:model
43 static void hb_send(struct bt_mesh_model *model) in hb_send() argument
46 struct bt_mesh_cfg_srv *cfg = model->user_data; in hb_send()
61 .src = bt_mesh_model_elem(model)->addr, in hb_send()
166 static void dev_comp_data_get(struct bt_mesh_model *model, in dev_comp_data_get() argument
191 if (bt_mesh_model_send(model, ctx, sdu, NULL, NULL)) { in dev_comp_data_get()
243 static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr, in _mod_pub_set() argument
247 if (!model->pub) { in _mod_pub_set()
255 if (!model->pub->update && period) { in _mod_pub_set()
260 if (model->pub->addr == BT_MESH_ADDR_UNASSIGNED) { in _mod_pub_set()
264 model->pub->addr = BT_MESH_ADDR_UNASSIGNED; in _mod_pub_set()
265 model->pub->key = 0; in _mod_pub_set()
266 model->pub->cred = 0; in _mod_pub_set()
267 model->pub->ttl = 0; in _mod_pub_set()
268 model->pub->period = 0; in _mod_pub_set()
269 model->pub->retransmit = 0; in _mod_pub_set()
270 model->pub->count = 0; in _mod_pub_set()
272 if (model->pub->update) { in _mod_pub_set()
273 k_delayed_work_cancel(&model->pub->timer); in _mod_pub_set()
277 bt_mesh_store_mod_pub(model); in _mod_pub_set()
287 model->pub->addr = pub_addr; in _mod_pub_set()
288 model->pub->key = app_idx; in _mod_pub_set()
289 model->pub->cred = cred_flag; in _mod_pub_set()
290 model->pub->ttl = ttl; in _mod_pub_set()
291 model->pub->period = period; in _mod_pub_set()
292 model->pub->retransmit = retransmit; in _mod_pub_set()
294 if (model->pub->update) { in _mod_pub_set()
297 period_ms = bt_mesh_model_pub_period_get(model); in _mod_pub_set()
301 k_delayed_work_submit(&model->pub->timer, period_ms); in _mod_pub_set()
303 k_delayed_work_cancel(&model->pub->timer); in _mod_pub_set()
308 bt_mesh_store_mod_pub(model); in _mod_pub_set()
314 u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx) in mod_bind() argument
318 BT_DBG("model %p key_idx 0x%03x", model, key_idx); in mod_bind()
324 for (i = 0; i < ARRAY_SIZE(model->keys); i++) { in mod_bind()
326 if (model->keys[i] == key_idx) { in mod_bind()
331 for (i = 0; i < ARRAY_SIZE(model->keys); i++) { in mod_bind()
332 if (model->keys[i] == BT_MESH_KEY_UNUSED) { in mod_bind()
333 model->keys[i] = key_idx; in mod_bind()
336 bt_mesh_store_mod_bind(model); in mod_bind()
346 u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store) in mod_unbind() argument
350 BT_DBG("model %p key_idx 0x%03x store %u", model, key_idx, store); in mod_unbind()
356 for (i = 0; i < ARRAY_SIZE(model->keys); i++) { in mod_unbind()
357 if (model->keys[i] != key_idx) { in mod_unbind()
361 model->keys[i] = BT_MESH_KEY_UNUSED; in mod_unbind()
364 bt_mesh_store_mod_bind(model); in mod_unbind()
367 if (model->pub && model->pub->key == key_idx) { in mod_unbind()
368 _mod_pub_set(model, BT_MESH_ADDR_UNASSIGNED, in mod_unbind()
480 static void app_key_add(struct bt_mesh_model *model, in app_key_add() argument
500 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in app_key_add()
507 static void app_key_update(struct bt_mesh_model *model, in app_key_update() argument
527 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in app_key_update()
563 static void app_key_del(struct bt_mesh_model *model, in app_key_del() argument
605 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in app_key_del()
615 static void app_key_get(struct bt_mesh_model *model, in app_key_get() argument
670 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in app_key_get()
678 static void beacon_get(struct bt_mesh_model *model, in beacon_get() argument
692 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in beacon_get()
698 static void beacon_set(struct bt_mesh_model *model, in beacon_set() argument
704 struct bt_mesh_cfg_srv *cfg = model->user_data; in beacon_set()
734 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in beacon_set()
743 static void default_ttl_get(struct bt_mesh_model *model, in default_ttl_get() argument
757 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in default_ttl_get()
765 static void default_ttl_set(struct bt_mesh_model *model, in default_ttl_set() argument
771 struct bt_mesh_cfg_srv *cfg = model->user_data; in default_ttl_set()
795 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in default_ttl_set()
803 static void send_gatt_proxy_status(struct bt_mesh_model *model, in send_gatt_proxy_status() argument
812 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in send_gatt_proxy_status()
820 static void gatt_proxy_get(struct bt_mesh_model *model, in gatt_proxy_get() argument
828 send_gatt_proxy_status(model, ctx); in gatt_proxy_get()
831 static void gatt_proxy_set(struct bt_mesh_model *model, in gatt_proxy_set() argument
835 struct bt_mesh_cfg_srv *cfg = model->user_data; in gatt_proxy_set()
895 hb_send(model); in gatt_proxy_set()
899 send_gatt_proxy_status(model, ctx); in gatt_proxy_set()
902 static void net_transmit_get(struct bt_mesh_model *model, in net_transmit_get() argument
916 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in net_transmit_get()
924 static void net_transmit_set(struct bt_mesh_model *model, in net_transmit_set() argument
930 struct bt_mesh_cfg_srv *cfg = model->user_data; in net_transmit_set()
953 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in net_transmit_set()
960 static void relay_get(struct bt_mesh_model *model, in relay_get() argument
975 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in relay_get()
983 static void relay_set(struct bt_mesh_model *model, in relay_set() argument
989 struct bt_mesh_cfg_srv *cfg = model->user_data; in relay_set()
1021 hb_send(model); in relay_set()
1032 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in relay_set()
1076 BT_ERR("Unable to send Model Publication Status"); in send_mod_pub_status()
1082 static void mod_pub_get(struct bt_mesh_model *model, in mod_pub_get() argument
1125 send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_get()
1129 static void mod_pub_set(struct bt_mesh_model *model, in mod_pub_set() argument
1187 send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_set()
1252 /* Unref stored labels related to this model */ in mod_sub_list_clear()
1271 static void mod_pub_va_set(struct bt_mesh_model *model, in mod_pub_va_set() argument
1336 send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_va_set()
1346 static void mod_pub_va_set(struct bt_mesh_model *model, in mod_pub_va_set() argument
1390 send_mod_pub_status(model, ctx, elem_addr, pub_addr, vnd, mod, in mod_pub_va_set()
1395 static void send_mod_sub_status(struct bt_mesh_model *model, in send_mod_sub_status() argument
1418 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in send_mod_sub_status()
1419 BT_ERR("Unable to send Model Subscription Status"); in send_mod_sub_status()
1425 static void mod_sub_add(struct bt_mesh_model *model, in mod_sub_add() argument
1496 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_add()
1500 static void mod_sub_del(struct bt_mesh_model *model, in mod_sub_del() argument
1562 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_del()
1566 static void mod_sub_overwrite(struct bt_mesh_model *model, in mod_sub_overwrite() argument
1631 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_overwrite()
1635 static void mod_sub_del_all(struct bt_mesh_model *model, in mod_sub_del_all() argument
1683 send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_del_all()
1687 static void mod_sub_get(struct bt_mesh_model *model, in mod_sub_get() argument
1739 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in mod_sub_get()
1740 BT_ERR("Unable to send Model Subscription List"); in mod_sub_get()
1748 static void mod_sub_get_vnd(struct bt_mesh_model *model, in mod_sub_get_vnd() argument
1804 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in mod_sub_get_vnd()
1805 BT_ERR("Unable to send Vendor Model Subscription List"); in mod_sub_get_vnd()
1814 static void mod_sub_va_add(struct bt_mesh_model *model, in mod_sub_va_add() argument
1888 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_add()
1892 static void mod_sub_va_del(struct bt_mesh_model *model, in mod_sub_va_del() argument
1957 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_del()
1961 static void mod_sub_va_overwrite(struct bt_mesh_model *model, in mod_sub_va_overwrite() argument
2024 send_mod_sub_status(model, ctx, status, elem_addr, sub_addr, in mod_sub_va_overwrite()
2028 static void mod_sub_va_add(struct bt_mesh_model *model, in mod_sub_va_add() argument
2066 send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_va_add()
2070 static void mod_sub_va_del(struct bt_mesh_model *model, in mod_sub_va_del() argument
2105 send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_va_del()
2109 static void mod_sub_va_overwrite(struct bt_mesh_model *model, in mod_sub_va_overwrite() argument
2144 send_mod_sub_status(model, ctx, status, elem_addr, in mod_sub_va_overwrite()
2149 static void send_net_key_status(struct bt_mesh_model *model, in send_net_key_status() argument
2161 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in send_net_key_status()
2168 static void net_key_add(struct bt_mesh_model *model, in net_key_add() argument
2196 send_net_key_status(model, ctx, idx, in net_key_add()
2212 send_net_key_status(model, ctx, idx, status); in net_key_add()
2218 send_net_key_status(model, ctx, idx, STATUS_UNSPECIFIED); in net_key_add()
2240 send_net_key_status(model, ctx, idx, STATUS_SUCCESS); in net_key_add()
2243 static void net_key_update(struct bt_mesh_model *model, in net_key_update() argument
2261 send_net_key_status(model, ctx, idx, STATUS_INVALID_NETKEY); in net_key_update()
2279 send_net_key_status(model, ctx, idx, STATUS_SUCCESS); in net_key_update()
2285 send_net_key_status(model, ctx, idx, STATUS_CANNOT_UPDATE); in net_key_update()
2296 send_net_key_status(model, ctx, idx, STATUS_UNSPECIFIED); in net_key_update()
2309 send_net_key_status(model, ctx, idx, STATUS_SUCCESS); in net_key_update()
2324 static void net_key_del(struct bt_mesh_model *model, in net_key_del() argument
2361 send_net_key_status(model, ctx, del_idx, status); in net_key_del()
2364 static void net_key_get(struct bt_mesh_model *model, in net_key_get() argument
2396 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in net_key_get()
2403 static void node_identity_get(struct bt_mesh_model *model, in node_identity_get() argument
2437 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in node_identity_get()
2445 static void node_identity_set(struct bt_mesh_model *model, in node_identity_set() argument
2499 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in node_identity_set()
2526 static void mod_app_bind(struct bt_mesh_model *model, in mod_app_bind() argument
2561 if (model == mod) { in mod_app_bind()
2562 BT_ERR("Client tried to bind AppKey to Configuration Model"); in mod_app_bind()
2578 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in mod_app_bind()
2579 BT_ERR("Unable to send Model App Bind Status response"); in mod_app_bind()
2587 static void mod_app_unbind(struct bt_mesh_model *model, in mod_app_unbind() argument
2632 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in mod_app_unbind()
2633 BT_ERR("Unable to send Model App Unbind Status response"); in mod_app_unbind()
2642 static void mod_app_get(struct bt_mesh_model *model, in mod_app_get() argument
2705 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in mod_app_get()
2706 BT_ERR("Unable to send Model Application List message"); in mod_app_get()
2713 static void node_reset(struct bt_mesh_model *model, in node_reset() argument
2730 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in node_reset()
2738 static void send_friend_status(struct bt_mesh_model *model, in send_friend_status() argument
2743 struct bt_mesh_cfg_srv *cfg = model->user_data; in send_friend_status()
2748 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in send_friend_status()
2754 static void friend_get(struct bt_mesh_model *model, in friend_get() argument
2762 send_friend_status(model, ctx); in friend_get()
2765 static void friend_set(struct bt_mesh_model *model, in friend_set() argument
2769 struct bt_mesh_cfg_srv *cfg = model->user_data; in friend_set()
2806 hb_send(model); in friend_set()
2810 send_friend_status(model, ctx); in friend_set()
2813 static void lpn_timeout_get(struct bt_mesh_model *model, in lpn_timeout_get() argument
2855 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in lpn_timeout_get()
2863 static void send_krp_status(struct bt_mesh_model *model, in send_krp_status() argument
2876 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in send_krp_status()
2883 static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_get() argument
2899 send_krp_status(model, ctx, idx, 0x00, STATUS_INVALID_NETKEY); in krp_get()
2901 send_krp_status(model, ctx, idx, sub->kr_phase, in krp_get()
2906 static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, in krp_set() argument
2925 send_krp_status(model, ctx, idx, 0x00, STATUS_INVALID_NETKEY); in krp_set()
2956 send_krp_status(model, ctx, idx, sub->kr_phase, STATUS_SUCCESS); in krp_set()
3003 static void hb_pub_send_status(struct bt_mesh_model *model, in hb_pub_send_status() argument
3009 struct bt_mesh_cfg_srv *cfg = model->user_data; in hb_pub_send_status()
3031 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in hb_pub_send_status()
3038 static void heartbeat_pub_get(struct bt_mesh_model *model, in heartbeat_pub_get() argument
3044 hb_pub_send_status(model, ctx, STATUS_SUCCESS, NULL); in heartbeat_pub_get()
3047 static void heartbeat_pub_set(struct bt_mesh_model *model, in heartbeat_pub_set() argument
3052 struct bt_mesh_cfg_srv *cfg = model->user_data; in heartbeat_pub_set()
3122 hb_pub_send_status(model, ctx, STATUS_SUCCESS, NULL); in heartbeat_pub_set()
3127 hb_pub_send_status(model, ctx, status, param); in heartbeat_pub_set()
3130 static void hb_sub_send_status(struct bt_mesh_model *model, in hb_sub_send_status() argument
3135 struct bt_mesh_cfg_srv *cfg = model->user_data; in hb_sub_send_status()
3161 if (bt_mesh_model_send(model, ctx, msg, NULL, NULL)) { in hb_sub_send_status()
3168 static void heartbeat_sub_get(struct bt_mesh_model *model, in heartbeat_sub_get() argument
3174 hb_sub_send_status(model, ctx, STATUS_SUCCESS); in heartbeat_sub_get()
3177 static void heartbeat_sub_set(struct bt_mesh_model *model, in heartbeat_sub_set() argument
3181 struct bt_mesh_cfg_srv *cfg = model->user_data; in heartbeat_sub_set()
3250 hb_sub_send_status(model, ctx, STATUS_SUCCESS); in heartbeat_sub_set()
3314 struct bt_mesh_model *model = cfg->model; in hb_publish() local
3337 hb_send(model); in hb_publish()
3361 int bt_mesh_cfg_srv_init(struct bt_mesh_model *model, bool primary) in bt_mesh_cfg_srv_init() argument
3363 struct bt_mesh_cfg_srv *cfg = model->user_data; in bt_mesh_cfg_srv_init()
3375 /* Configuration Model security is device-key based */ in bt_mesh_cfg_srv_init()
3376 model->keys[0] = BT_MESH_KEY_DEV; in bt_mesh_cfg_srv_init()
3395 cfg->model = model; in bt_mesh_cfg_srv_init()
3405 /* Clear model state that isn't otherwise cleared. E.g. AppKey in mod_reset()
3406 * binding and model publication is cleared as a consequence in mod_reset()
3407 * of removing all app keys, however model subscription clearing in mod_reset()