Lines Matching +full:divide +full:- +full:20
5 * SPDX-License-Identifier: Apache-2.0
72 [0 ... (CONFIG_BT_MAX_CONN - 1)] = {
92 return -EINVAL; in gatt_recv()
97 return -EINVAL; in gatt_recv()
111 if (buf->len < 1) { in filter_set()
113 return -EINVAL; in filter_set()
121 (void)memset(client->filter, 0, sizeof(client->filter)); in filter_set()
122 client->filter_type = ACCEPT; in filter_set()
125 (void)memset(client->filter, 0, sizeof(client->filter)); in filter_set()
126 client->filter_type = REJECT; in filter_set()
130 return -EINVAL; in filter_set()
146 for (i = 0; i < ARRAY_SIZE(client->filter); i++) { in filter_add()
147 if (client->filter[i] == addr) { in filter_add()
152 for (i = 0; i < ARRAY_SIZE(client->filter); i++) { in filter_add()
153 if (client->filter[i] == BT_MESH_ADDR_UNASSIGNED) { in filter_add()
154 client->filter[i] = addr; in filter_add()
170 for (i = 0; i < ARRAY_SIZE(client->filter); i++) { in filter_remove()
171 if (client->filter[i] == addr) { in filter_remove()
172 client->filter[i] = BT_MESH_ADDR_UNASSIGNED; in filter_remove()
183 .sub = rx->sub, in send_filter_status()
184 .ctx = &rx->ctx, in send_filter_status()
191 tx.ctx->addr = BT_MESH_ADDR_UNASSIGNED; in send_filter_status()
198 if (client->filter_type == ACCEPT) { in send_filter_status()
204 for (filter_size = 0U, i = 0; i < ARRAY_SIZE(client->filter); i++) { in send_filter_status()
205 if (client->filter[i] != BT_MESH_ADDR_UNASSIGNED) { in send_filter_status()
212 LOG_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len)); in send_filter_status()
220 err = bt_mesh_proxy_msg_send(client->cli->conn, BT_MESH_PROXY_CONFIG, in send_filter_status()
242 while (buf->len >= 2) { in proxy_filter_recv()
251 while (buf->len >= 2) { in proxy_filter_recv()
271 err = bt_mesh_net_decode(&role->buf, BT_MESH_NET_IF_PROXY_CFG, in proxy_cfg()
296 proxy_filter_recv(role->conn, &rx, &buf); in proxy_cfg()
301 switch (role->msg_type) { in proxy_msg_recv()
304 bt_mesh_net_recv(&role->buf, 0, BT_MESH_NET_IF_PROXY); in proxy_msg_recv()
308 bt_mesh_beacon_recv(&role->buf); in proxy_msg_recv()
315 LOG_WRN("Unhandled Message Type 0x%02x", role->msg_type); in proxy_msg_recv()
330 err = bt_mesh_beacon_create(sub, &buf, client->privacy); in beacon_send()
338 return bt_mesh_proxy_msg_send(client->cli->conn, BT_MESH_PROXY_BEACON, in beacon_send()
377 sub->node_id = BT_MESH_NODE_IDENTITY_RUNNING; in identity_enabled()
378 sub->node_id_start = k_uptime_get_32(); in identity_enabled()
381 if (cb->identity_enabled) { in identity_enabled()
382 cb->identity_enabled(sub->net_idx); in identity_enabled()
390 sub->priv_beacon_ctx.node_id = false; in node_id_start()
399 sub->priv_beacon_ctx.node_id = true; in private_node_id_start()
419 sub->node_id = BT_MESH_NODE_IDENTITY_STOPPED; in bt_mesh_proxy_identity_stop()
420 sub->node_id_start = 0U; in bt_mesh_proxy_identity_stop()
423 if (cb->identity_disabled) { in bt_mesh_proxy_identity_stop()
424 cb->identity_disabled(sub->net_idx); in bt_mesh_proxy_identity_stop()
434 return -EAGAIN; in bt_mesh_proxy_identity_enable()
449 return -ENOTSUP; in bt_mesh_proxy_private_identity_enable()
453 return -EAGAIN; in bt_mesh_proxy_private_identity_enable()
510 err = bt_mesh_encrypt(&sub->keys[SUBNET_KEY_TX_IDX(sub)].identity, hash, hash); in enc_id_adv()
552 LOG_DBG("0x%03x", sub->net_idx); in node_id_adv()
572 LOG_DBG("0x%03x", sub->net_idx); in priv_node_id_adv()
593 LOG_DBG("0x%03x", sub->net_idx); in priv_net_id_adv()
600 memcpy(&tmp[0], sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8); in priv_net_id_adv()
618 LOG_DBG("Advertising with NetId %s", bt_hex(sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8)); in net_id_adv()
620 memcpy(proxy_svc_data + 3, sub->keys[SUBNET_KEY_TX_IDX(sub)].net_id, 8); in net_id_adv()
643 if (sub->net_idx == BT_MESH_KEY_UNUSED) { in is_sub_proxy_active()
647 return (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING || in is_sub_proxy_active()
649 (bt_mesh_od_priv_proxy_get() > 0 && sub->solicited) || in is_sub_proxy_active()
682 if (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING) { in proxy_adv_timeout_eval()
683 time_passed = k_uptime_get_32() - sub->node_id_start; in proxy_adv_timeout_eval()
684 if (time_passed > (NODE_ID_TIMEOUT - MSEC_PER_SEC)) { in proxy_adv_timeout_eval()
686 LOG_DBG("Node ID stopped for subnet %d after %dms", sub->net_idx, in proxy_adv_timeout_eval()
692 if (bt_mesh_od_priv_proxy_get() > 0 && sub->solicited && sub->priv_net_id_sent) { in proxy_adv_timeout_eval()
693 time_passed = k_uptime_get_32() - sub->priv_net_id_sent; in proxy_adv_timeout_eval()
694 if (time_passed > ((MSEC_PER_SEC * bt_mesh_od_priv_proxy_get()) - MSEC_PER_SEC)) { in proxy_adv_timeout_eval()
695 sub->priv_net_id_sent = 0; in proxy_adv_timeout_eval()
696 sub->solicited = false; in proxy_adv_timeout_eval()
699 sub->net_idx, time_passed); in proxy_adv_timeout_eval()
724 if (sub->net_idx == BT_MESH_KEY_UNUSED) { in proxy_adv_request_get()
736 if (bt_mesh_od_priv_proxy_get() > 0 && sub->solicited) { in proxy_adv_request_get()
739 request->evt = OD_PRIV_NET_ID; in proxy_adv_request_get()
740 request->duration = !sub->priv_net_id_sent in proxy_adv_request_get()
742 : timeout - (k_uptime_get_32() - sub->priv_net_id_sent); in proxy_adv_request_get()
747 if (sub->node_id == BT_MESH_NODE_IDENTITY_RUNNING) { in proxy_adv_request_get()
748 request->duration = NODE_ID_TIMEOUT - (k_uptime_get_32() - sub->node_id_start); in proxy_adv_request_get()
749 request->evt = in proxy_adv_request_get()
751 sub->priv_beacon_ctx.node_id ? PRIV_NODE_ID : in proxy_adv_request_get()
759 request->evt = PRIV_NET_ID; in proxy_adv_request_get()
760 request->duration = PROXY_RANDOM_UPDATE_INTERVAL; in proxy_adv_request_get()
765 request->evt = NET_ID; in proxy_adv_request_get()
766 request->duration = SYS_FOREVER_MS; in proxy_adv_request_get()
811 return -ENOMEM; in gatt_proxy_advertise()
817 return -ENOENT; in gatt_proxy_advertise()
824 * be less than 60 seconds. Divide this period into at least in gatt_proxy_advertise()
829 max_adv_duration = MAX(max_adv_duration, MSEC_PER_SEC + 20); in gatt_proxy_advertise()
835 int32_t time_passed = k_uptime_get_32() - sub_adv.start; in gatt_proxy_advertise()
838 ((sub_adv.request.duration - time_passed) >= MSEC_PER_SEC)) { in gatt_proxy_advertise()
840 request.duration = sub_adv.request.duration - time_passed; in gatt_proxy_advertise()
849 return -ENOENT; in gatt_proxy_advertise()
869 if (!sub->priv_net_id_sent) { in gatt_proxy_advertise()
870 sub->priv_net_id_sent = k_uptime_get(); in gatt_proxy_advertise()
885 return -ENODEV; in gatt_proxy_advertise()
893 LOG_DBG("Advertising %d ms for net_idx 0x%04x", request.duration, sub->net_idx); in gatt_proxy_advertise()
931 if (client->filter_type == NONE) { in proxy_ccc_write()
932 client->filter_type = ACCEPT; in proxy_ccc_write()
933 bt_mesh_wq_submit(&client->send_beacons); in proxy_ccc_write()
969 if ((err == -EINVAL) && ((--svc_reg_attempts) > 0)) { in svc_reg_work_handler()
996 return -ENOTSUP; in bt_mesh_proxy_gatt_enable()
1000 return -EBUSY; in bt_mesh_proxy_gatt_enable()
1022 if (client->cli && (client->filter_type == ACCEPT || in bt_mesh_proxy_gatt_disconnect()
1023 client->filter_type == REJECT)) { in bt_mesh_proxy_gatt_disconnect()
1024 client->filter_type = NONE; in bt_mesh_proxy_gatt_disconnect()
1025 bt_conn_disconnect(client->cli->conn, in bt_mesh_proxy_gatt_disconnect()
1036 return -EALREADY; in bt_mesh_proxy_gatt_disable()
1053 client = find_client(cli->conn); in bt_mesh_proxy_addr_add()
1055 LOG_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); in bt_mesh_proxy_addr_add()
1057 if (client->filter_type == ACCEPT) { in bt_mesh_proxy_addr_add()
1059 } else if (client->filter_type == REJECT) { in bt_mesh_proxy_addr_add()
1069 LOG_DBG("filter_type %u addr 0x%04x", client->filter_type, addr); in client_filter_match()
1071 if (client->filter_type == REJECT) { in client_filter_match()
1072 for (i = 0; i < ARRAY_SIZE(client->filter); i++) { in client_filter_match()
1073 if (client->filter[i] == addr) { in client_filter_match()
1085 if (client->filter_type == ACCEPT) { in client_filter_match()
1086 for (i = 0; i < ARRAY_SIZE(client->filter); i++) { in client_filter_match()
1087 if (client->filter[i] == addr) { in client_filter_match()
1101 LOG_DBG("%u bytes to dst 0x%04x", adv->b.len, dst); in bt_mesh_proxy_relay()
1106 if (!client->cli) { in bt_mesh_proxy_relay()
1114 if (bt_mesh_proxy_relay_send(client->cli->conn, adv)) { in bt_mesh_proxy_relay()
1127 sub->solicited = false; in solicitation_reset()
1128 sub->priv_net_id_sent = 0; in solicitation_reset()
1148 client->filter_type = NONE; in gatt_connected()
1149 (void)memset(client->filter, 0, sizeof(client->filter)); in gatt_connected()
1150 client->cli = bt_mesh_proxy_role_setup(conn, proxy_send, in gatt_connected()
1159 client->privacy = false; in gatt_connected()
1161 client->privacy = (bt_mesh_priv_gatt_proxy_get() == BT_MESH_FEATURE_ENABLED) || in gatt_connected()
1165 LOG_DBG("privacy: %d", client->privacy); in gatt_connected()
1173 /* Try to re-enable advertising in case it's possible */ in gatt_connected()
1196 if (client->cli) { in gatt_disconnected()
1197 bt_mesh_proxy_role_cleanup(client->cli); in gatt_disconnected()
1198 client->cli = NULL; in gatt_disconnected()
1224 return -ENOTSUP; in bt_mesh_proxy_adv_start()