Select one of the symbols to view example projects that use it.
 
Outline
#include <string.h>
#include <errno.h>
#include "adv.h"
#include "scan.h"
#include "mesh.h"
#include "test.h"
#include "crypto.h"
#include "access.h"
#include "foundation.h"
#include "mesh/main.h"
#include "transport.h"
#include "proxy_common.h"
#include "proxy_server.h"
bt_mesh_test()
bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *)
bt_mesh_test_update_white_list(struct bt_mesh_white_list *)
bt_mesh_test_start_scanning(bool)
bt_mesh_test_stop_scanning()
net_pdu_test_cb
bt_mesh_test_register_net_pdu_cb(bt_mesh_test_net_pdu_cb_t)
bt_mesh_test_set_seq(uint32_t)
Files
loading...
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/bt/esp_ble_mesh/core/test.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* Bluetooth Mesh */ /* * SPDX-FileCopyrightText: 2017 Intel Corporation * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ #include <string.h> #include <errno.h> #include "adv.h" #include "scan.h" #include "mesh.h" #include "test.h" #include "crypto.h" #include "access.h" #include "foundation.h" #include "mesh/main.h" #include "transport.h" #include "proxy_common.h" #include "proxy_server.h"13 includes #if CONFIG_BLE_MESH_SELF_TEST int bt_mesh_test(void) { return 0; }{ ... } #if CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK int bt_mesh_device_auto_enter_network(struct bt_mesh_device_network_info *info) { const struct bt_mesh_comp *comp = NULL; struct bt_mesh_model *model = NULL; struct bt_mesh_elem *elem = NULL; struct bt_mesh_app_keys *keys = NULL; struct bt_mesh_app_key *key = NULL; struct bt_mesh_subnet *sub = NULL; int i, j, k; int err = 0; if (info == NULL || !BLE_MESH_ADDR_IS_UNICAST(info->unicast_addr) || !BLE_MESH_ADDR_IS_GROUP(info->group_addr)) { return -EINVAL; }{...} bt_mesh_atomic_set_bit(bt_mesh.flags, BLE_MESH_NODE); /* The device becomes a node and enters the network */ err = bt_mesh_provision(info->net_key, info->net_idx, info->flags, info->iv_index, info->unicast_addr, info->dev_key); if (err) { BT_ERR("bt_mesh_provision() failed (err %d)", err); return err; }{...} /* Adds application key to device */ sub = bt_mesh_subnet_get(info->net_idx); if (!sub) { BT_ERR("Invalid NetKeyIndex 0x%04x", info->net_idx); return -ENODEV; }{...} for (i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) { key = &bt_mesh.app_keys[i]; if (key->net_idx == BLE_MESH_KEY_UNUSED) { break; }{...} }{...} if (i == ARRAY_SIZE(bt_mesh.app_keys)) { BT_ERR("Failed to allocate AppKey, 0x%04x", info->app_idx); return -ENOMEM; }{...} keys = sub->kr_flag ? &key->keys[1] : &key->keys[0]; if (bt_mesh_app_id(info->app_key, &keys->id)) { BT_ERR("Failed to calculate AID, 0x%04x", info->app_idx); return -EIO; }{...} key->net_idx = info->net_idx; key->app_idx = info->app_idx; memcpy(keys->val, info->app_key, 16); /* Binds AppKey with all non-config models, adds group address to all these models */ comp = bt_mesh_comp_get(); if (!comp) { BT_ERR("Invalid composition data"); return -ENODEV; }{...} for (i = 0; i < comp->elem_count; i++) { elem = &comp->elem[i]; for (j = 0; j < elem->model_count; j++) { model = &elem->models[j]; if (model->id == BLE_MESH_MODEL_ID_CFG_SRV || model->id == BLE_MESH_MODEL_ID_CFG_CLI) { continue; }{...} for (k = 0; k < ARRAY_SIZE(model->keys); k++) { if (model->keys[k] == BLE_MESH_KEY_UNUSED) { model->keys[k] = info->app_idx; break; }{...} }{...} for (k = 0; k < ARRAY_SIZE(model->groups); k++) { if (model->groups[k] == BLE_MESH_ADDR_UNASSIGNED) { model->groups[k] = info->group_addr; break; }{...} }{...} }{...} for (j = 0; j < elem->vnd_model_count; j++) { model = &elem->vnd_models[j]; for (k = 0; k < ARRAY_SIZE(model->keys); k++) { if (model->keys[k] == BLE_MESH_KEY_UNUSED) { model->keys[k] = info->app_idx; break; }{...} }{...} for (k = 0; k < ARRAY_SIZE(model->groups); k++) { if (model->groups[k] == BLE_MESH_ADDR_UNASSIGNED) { model->groups[k] = info->group_addr; break; }{...} }{...} }{...} }{...} return 0; }{ ... } /* ... */#endif /* CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_TEST_AUTO_ENTER_NETWORK */ #if CONFIG_BLE_MESH_TEST_USE_WHITE_LIST int bt_mesh_test_update_white_list(struct bt_mesh_white_list *wl) { int err = 0; if (wl == NULL) { BT_ERR("%s, Invalid parameter", __func__); return -EINVAL; }{...} BT_INFO("%s, addr %s, addr_type 0x%02x", wl->add_remove ? "Add" : "Remove", bt_hex(wl->remote_bda, BLE_MESH_ADDR_LEN), wl->addr_type); err = bt_le_update_white_list(wl); if (err) { BT_ERR("Failed to update white list"); }{...} return err; }{ ... } int bt_mesh_test_start_scanning(bool wl_en) { BT_INFO("Scan with filter policy %s", wl_en ? "enabled" : "disabled"); if (wl_en) { return bt_mesh_scan_with_wl_enable(); }{...} return bt_mesh_scan_enable(); }{ ... } int bt_mesh_test_stop_scanning(void) { return bt_mesh_scan_disable(); }{ ... } #endif/* ... */ /* CONFIG_BLE_MESH_TEST_USE_WHITE_LIST */ bt_mesh_test_net_pdu_cb_t net_pdu_test_cb; void bt_mesh_test_register_net_pdu_cb(bt_mesh_test_net_pdu_cb_t cb) { net_pdu_test_cb = cb; }{ ... } void bt_mesh_test_set_seq(uint32_t seq) { if (seq > 0xFFFFFF) { BT_ERR("Invalid SEQ 0x%08x", seq); return; }{...} bt_mesh.seq = seq; }{ ... } /* ... */#endif /* CONFIG_BLE_MESH_SELF_TEST */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.