forked from espressif/esp-idf
Compare commits
617 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ab8f793ca | ||
|
|
1e36383909 | ||
|
|
1e8fca74f2 | ||
|
|
32c63fca90 | ||
|
|
4921446d3d | ||
|
|
96a00e59f4 | ||
|
|
36c2ef2828 | ||
|
|
8491705b63 | ||
|
|
2c5f35fa8a | ||
|
|
e632f2b366 | ||
|
|
72f4f9542c | ||
|
|
cbe42f1132 | ||
|
|
8aa7eaa646 | ||
|
|
d21e948381 | ||
|
|
b50a8e0878 | ||
|
|
fa734e6af8 | ||
|
|
ca44fb1528 | ||
|
|
f8b9cb2864 | ||
|
|
7b70154566 | ||
|
|
fd50bcf704 | ||
|
|
c1e204634f | ||
|
|
96d00c5fa5 | ||
|
|
054d3b81a6 | ||
|
|
daeaa8092b | ||
|
|
56b4596b53 | ||
|
|
bebc75af48 | ||
|
|
71cf821659 | ||
|
|
652e214f55 | ||
|
|
345e6acf80 | ||
|
|
e8e6021ada | ||
|
|
df0ca79bdb | ||
|
|
ca77bdddbf | ||
|
|
e459f7b498 | ||
|
|
841aca897c | ||
|
|
b860069c10 | ||
|
|
bb1aa0ed5e | ||
|
|
481da3143d | ||
|
|
536d6eea61 | ||
|
|
176ea97dd0 | ||
|
|
ca2a15dca7 | ||
|
|
5d88861dba | ||
|
|
f8e633a352 | ||
|
|
9e40c13d4e | ||
|
|
6e0c046bd9 | ||
|
|
9e1324fbbb | ||
|
|
95c118171a | ||
|
|
2af8fac1d9 | ||
|
|
93c28d1fac | ||
|
|
97ed80f415 | ||
|
|
b18f37b2e2 | ||
|
|
0ca5134d5f | ||
|
|
a7c17edc8a | ||
|
|
bab80796ca | ||
|
|
c219c9dcb2 | ||
|
|
e892fed593 | ||
|
|
18a262a6fa | ||
|
|
7988705558 | ||
|
|
8e7f7dfe59 | ||
|
|
b257ad7d9e | ||
|
|
4d95ffcca2 | ||
|
|
adb20fb2f3 | ||
|
|
a8227a1d13 | ||
|
|
d2715324e5 | ||
|
|
2deea3b1b0 | ||
|
|
e60640ab04 | ||
|
|
899c7852a4 | ||
|
|
be74e06e50 | ||
|
|
d3e730ff57 | ||
|
|
06bf491f13 | ||
|
|
54bf4dccfa | ||
|
|
d9ec7df393 | ||
|
|
71cddbdf8f | ||
|
|
a699475df2 | ||
|
|
b5976a7167 | ||
|
|
1c7340d229 | ||
|
|
b3e1829f10 | ||
|
|
2515cd72c1 | ||
|
|
8a841d7cdf | ||
|
|
31d05a5072 | ||
|
|
bfb7c66a9f | ||
|
|
3bb84e7738 | ||
|
|
ff4ca61cc6 | ||
|
|
f195a1d8ae | ||
|
|
d52331849e | ||
|
|
d29cce7f0a | ||
|
|
6b47fcdbdc | ||
|
|
9a2362b5c7 | ||
|
|
abe7a9d020 | ||
|
|
9f63baf061 | ||
|
|
bf4320ba68 | ||
|
|
5c175721e9 | ||
|
|
78ea042e7d | ||
|
|
af7b21851e | ||
|
|
974b8dd4c4 | ||
|
|
87da4bccd4 | ||
|
|
c68f520389 | ||
|
|
232786235b | ||
|
|
61fdb62c54 | ||
|
|
c4155d4b47 | ||
|
|
34e8265821 | ||
|
|
3ebcb25fb1 | ||
|
|
7223c8db5b | ||
|
|
fc7bf950f3 | ||
|
|
c37b15fa22 | ||
|
|
e3fd4b097b | ||
|
|
86141ad01c | ||
|
|
223cf48c26 | ||
|
|
6d9d40e888 | ||
|
|
45c90be913 | ||
|
|
e7dc6eb8da | ||
|
|
56e7cb0c70 | ||
|
|
ad095f555b | ||
|
|
e349f1b484 | ||
|
|
be8295a918 | ||
|
|
c8912b79a6 | ||
|
|
ec510fdf18 | ||
|
|
e8f5b76112 | ||
|
|
0f0cfb2cbc | ||
|
|
62589fa251 | ||
|
|
f16e8cb48e | ||
|
|
21ecef5c56 | ||
|
|
532912b025 | ||
|
|
176d6fa4d0 | ||
|
|
7ad3837244 | ||
|
|
e7f75e6559 | ||
|
|
03e6d07b50 | ||
|
|
c71b1f6d4d | ||
|
|
40b7ea1f95 | ||
|
|
48d3badc0f | ||
|
|
fa270d72c7 | ||
|
|
baaf4de703 | ||
|
|
34a84c829c | ||
|
|
340e2dff12 | ||
|
|
c8d15588e5 | ||
|
|
deaad551c4 | ||
|
|
19634e34e9 | ||
|
|
4f4640b1df | ||
|
|
92e511a5b6 | ||
|
|
7064eb9729 | ||
|
|
a7b419b652 | ||
|
|
6ed64c2a2d | ||
|
|
ac179dcd99 | ||
|
|
82801321e8 | ||
|
|
4200af3e26 | ||
|
|
46560be284 | ||
|
|
bbc05c5095 | ||
|
|
8de16142a5 | ||
|
|
e378ecd6cf | ||
|
|
d20b442af2 | ||
|
|
726ce37b14 | ||
|
|
df079d4ca9 | ||
|
|
2ec1b7434e | ||
|
|
cf53feff6f | ||
|
|
2f5eba9263 | ||
|
|
f4e11dce34 | ||
|
|
a866f0d8f6 | ||
|
|
dd56e9523b | ||
|
|
e66ac8b2e5 | ||
|
|
a607e0651c | ||
|
|
b06b8273ee | ||
|
|
7dbd5e1855 | ||
|
|
dbaee379ba | ||
|
|
4fb18da50b | ||
|
|
60b604ae6d | ||
|
|
f2f42c4bfc | ||
|
|
74649219f4 | ||
|
|
1c6ab10a70 | ||
|
|
c8ef66abad | ||
|
|
c04489cede | ||
|
|
9cb875949c | ||
|
|
8507f1f777 | ||
|
|
bb067c0883 | ||
|
|
0c1ff94823 | ||
|
|
def9153200 | ||
|
|
bfa07bb9d8 | ||
|
|
f8307bcd4e | ||
|
|
1d227bbb2e | ||
|
|
d7ea6266b7 | ||
|
|
ad5ef10343 | ||
|
|
20256c5dfd | ||
|
|
c083d7278d | ||
|
|
d417ba0c11 | ||
|
|
d734c533a5 | ||
|
|
c9f2790474 | ||
|
|
98d19efe6f | ||
|
|
4407c9eb83 | ||
|
|
f8c691faaf | ||
|
|
5151fb52ec | ||
|
|
399ab25967 | ||
|
|
f90b14175c | ||
|
|
1ef10dc284 | ||
|
|
59d3116e41 | ||
|
|
b58d888b77 | ||
|
|
e4c021757c | ||
|
|
fa62dfd5f9 | ||
|
|
fd032425f1 | ||
|
|
c8f8def780 | ||
|
|
d340fa68aa | ||
|
|
c9cf7bcb0e | ||
|
|
98e703340b | ||
|
|
9ca4799b20 | ||
|
|
66c533b3d5 | ||
|
|
9bd9e939ba | ||
|
|
7fc2f91841 | ||
|
|
eedcb8c97f | ||
|
|
e305c09b12 | ||
|
|
0d5286471a | ||
|
|
42fc36ef17 | ||
|
|
50bc7db63a | ||
|
|
07ca98b5f0 | ||
|
|
4650db0841 | ||
|
|
349b0b5ec5 | ||
|
|
f6f644bf81 | ||
|
|
8b0ac7f81e | ||
|
|
7aeaf604c2 | ||
|
|
747ecb27d0 | ||
|
|
359784f0b6 | ||
|
|
1e1fc92fc2 | ||
|
|
8a26bc72be | ||
|
|
caa7dc187d | ||
|
|
2e03275406 | ||
|
|
b517b64a30 | ||
|
|
c4c500e241 | ||
|
|
aafcc2ca60 | ||
|
|
e027f962df | ||
|
|
4f4cd08aad | ||
|
|
9f3750cee7 | ||
|
|
f4c56216e5 | ||
|
|
be3fc35533 | ||
|
|
068dfcf1ba | ||
|
|
ce2c615bb3 | ||
|
|
6c2489682f | ||
|
|
f80f4cbf2d | ||
|
|
54b817a59e | ||
|
|
fa2c4fe622 | ||
|
|
00e2f2e880 | ||
|
|
e5830907ca | ||
|
|
32b0264529 | ||
|
|
5b6e62d2c4 | ||
|
|
fdfef114ae | ||
|
|
c8900823d8 | ||
|
|
37a8c8ce6c | ||
|
|
2289d4fcc0 | ||
|
|
e1f1d11b76 | ||
|
|
24157cc60a | ||
|
|
a2ccb3c0ac | ||
|
|
a2e6db19e6 | ||
|
|
d66ad18853 | ||
|
|
e7435a75f5 | ||
|
|
10d40bd526 | ||
|
|
60b6968e80 | ||
|
|
a177897f4d | ||
|
|
1f3b6b2e6d | ||
|
|
2c85d01603 | ||
|
|
33236c9593 | ||
|
|
70de8f5158 | ||
|
|
77a78a22f6 | ||
|
|
8375bb94a4 | ||
|
|
9689f87887 | ||
|
|
66c89f1093 | ||
|
|
76b0097103 | ||
|
|
da809e92b7 | ||
|
|
cf87e114cb | ||
|
|
af8bc4c436 | ||
|
|
bfb14130ac | ||
|
|
807e864d7d | ||
|
|
d960752cd9 | ||
|
|
c0ae1f03a4 | ||
|
|
c4fe55d42a | ||
|
|
15f406ddb7 | ||
|
|
e511dd58b3 | ||
|
|
af1ebd7e01 | ||
|
|
9ebdeea54e | ||
|
|
cbe966135e | ||
|
|
9240750bf4 | ||
|
|
cd9237f871 | ||
|
|
1b1c917321 | ||
|
|
171e2c5b1e | ||
|
|
6d8a3f0d94 | ||
|
|
c759dade01 | ||
|
|
2e949ca9ac | ||
|
|
5d514fdb35 | ||
|
|
d5951d3c9e | ||
|
|
70589fc49d | ||
|
|
66b1f37c8b | ||
|
|
c5afe0ea2d | ||
|
|
8455518127 | ||
|
|
24291f7a3b | ||
|
|
359509ccdc | ||
|
|
ceb11fd543 | ||
|
|
be68c0e8d8 | ||
|
|
2c66dfc089 | ||
|
|
391b2ebcf0 | ||
|
|
3b5b61f402 | ||
|
|
d228fc826c | ||
|
|
328254c631 | ||
|
|
2dd5a87cf1 | ||
|
|
4abc541d6f | ||
|
|
1df0c17b98 | ||
|
|
660f41772c | ||
|
|
ea476f1731 | ||
|
|
6514009b8a | ||
|
|
7c5afa262d | ||
|
|
bf9b9c5a97 | ||
|
|
4070a6dc70 | ||
|
|
0ab739f72c | ||
|
|
3f46cb9789 | ||
|
|
c74c7fdb5a | ||
|
|
02d3d358b5 | ||
|
|
74e1613b17 | ||
|
|
89cab3140d | ||
|
|
040f5c8e0a | ||
|
|
aa3efa6cf1 | ||
|
|
a8df2af065 | ||
|
|
d254804a62 | ||
|
|
7da388e52a | ||
|
|
5c6b9d0625 | ||
|
|
024aaeb201 | ||
|
|
79aa9636b9 | ||
|
|
19b7705b8d | ||
|
|
294fe8238c | ||
|
|
0382c2e04e | ||
|
|
81680a633f | ||
|
|
6fd3557d99 | ||
|
|
f697f475e5 | ||
|
|
d9455d8587 | ||
|
|
2ea3519964 | ||
|
|
0dedf0e1f5 | ||
|
|
250805d991 | ||
|
|
48dc6e9347 | ||
|
|
87b051c87a | ||
|
|
10f16c5d72 | ||
|
|
fd5f65a2d4 | ||
|
|
90218b4e9b | ||
|
|
cbca521e28 | ||
|
|
186ebc61e7 | ||
|
|
c4d0a384b0 | ||
|
|
be26d45d78 | ||
|
|
6b054fb4a6 | ||
|
|
ecbf436de4 | ||
|
|
4d1ada8ab5 | ||
|
|
1c732d7556 | ||
|
|
29feb17636 | ||
|
|
7ceaac64bf | ||
|
|
84219fe844 | ||
|
|
a5cf243ea0 | ||
|
|
56de4bbc4d | ||
|
|
7c9be015aa | ||
|
|
54d8a1f76b | ||
|
|
4510332e96 | ||
|
|
370e65ec8a | ||
|
|
962b14d653 | ||
|
|
d8ba0f9b0e | ||
|
|
967c07b6ae | ||
|
|
ad47ed5ef1 | ||
|
|
db2ddebc23 | ||
|
|
f56fe3f877 | ||
|
|
571da869f5 | ||
|
|
d545f1223f | ||
|
|
8cd16b60f5 | ||
|
|
a4525284bd | ||
|
|
e36282787e | ||
|
|
b24ccd8a20 | ||
|
|
c44dc1f262 | ||
|
|
de166facd7 | ||
|
|
71f4c476cb | ||
|
|
b4735859d6 | ||
|
|
28371f45a4 | ||
|
|
84039dc77d | ||
|
|
67a3ff8a4b | ||
|
|
500edd412a | ||
|
|
cc0ad534e9 | ||
|
|
b78fbdab12 | ||
|
|
30becdfaab | ||
|
|
95c360fcbd | ||
|
|
7ff123562b | ||
|
|
53fc156adb | ||
|
|
cf7bea6dff | ||
|
|
67fb958b8c | ||
|
|
cd1fbfdee1 | ||
|
|
8911c29122 | ||
|
|
a3fa7dda33 | ||
|
|
c8890a40e4 | ||
|
|
a91addb716 | ||
|
|
396c6a3bc5 | ||
|
|
96182bdc43 | ||
|
|
4cfece437d | ||
|
|
73023f7ff7 | ||
|
|
bd0f520a95 | ||
|
|
e5553b964d | ||
|
|
7453507d93 | ||
|
|
b979dacc6c | ||
|
|
21eac48ea0 | ||
|
|
fe6103c088 | ||
|
|
f031dc6d29 | ||
|
|
85de3a84e1 | ||
|
|
3f361cc262 | ||
|
|
8f20b9dc8a | ||
|
|
e33cfbaef9 | ||
|
|
60a808372e | ||
|
|
3a1018f603 | ||
|
|
c5d9601e69 | ||
|
|
2aafcd9b1f | ||
|
|
0e4f43ddde | ||
|
|
0c3c09e7ef | ||
|
|
1efa401884 | ||
|
|
0432d11509 | ||
|
|
8c4839e9e6 | ||
|
|
ce72deea7f | ||
|
|
929632739a | ||
|
|
5e9783f4a6 | ||
|
|
474224d668 | ||
|
|
53935d5933 | ||
|
|
47aa7408f5 | ||
|
|
70ecd0e92c | ||
|
|
caddd5d9fa | ||
|
|
c5b2252e03 | ||
|
|
f3c9a71138 | ||
|
|
5da8c3f8de | ||
|
|
248857bf91 | ||
|
|
6216f99265 | ||
|
|
6d6fbc3860 | ||
|
|
14587e7e73 | ||
|
|
9f9013c8c3 | ||
|
|
076ad543fb | ||
|
|
24f98bf80b | ||
|
|
4360410107 | ||
|
|
68095a65ac | ||
|
|
235628355f | ||
|
|
567562a0fb | ||
|
|
d694036789 | ||
|
|
26ba5e1b51 | ||
|
|
ecc2dd4b23 | ||
|
|
774fb48f9e | ||
|
|
40873d2026 | ||
|
|
ac5b7be7c2 | ||
|
|
c09a265f32 | ||
|
|
ef84e386e4 | ||
|
|
44b1c3b307 | ||
|
|
3acd9861bf | ||
|
|
0bd758c0b1 | ||
|
|
12eb9d6d80 | ||
|
|
33c296b78e | ||
|
|
e6d74b2d7e | ||
|
|
866399cbf7 | ||
|
|
573708ea1e | ||
|
|
4c66d146eb | ||
|
|
cfd234da3a | ||
|
|
fd68c06824 | ||
|
|
d9cea5dfdb | ||
|
|
98a536894d | ||
|
|
9ca6aee845 | ||
|
|
b1b673eaa2 | ||
|
|
a57576cec4 | ||
|
|
7d226ce542 | ||
|
|
4fb4178f06 | ||
|
|
aa416a377b | ||
|
|
2b88ed8827 | ||
|
|
0386b19d8b | ||
|
|
683d0f4edb | ||
|
|
4bca971865 | ||
|
|
c1d5ad61b5 | ||
|
|
d315bf722f | ||
|
|
210bd3787d | ||
|
|
dceb9b4a22 | ||
|
|
a1d5fcfece | ||
|
|
211a2a9957 | ||
|
|
b1b19495a1 | ||
|
|
6a723ad1e7 | ||
|
|
a82d0cf9f1 | ||
|
|
8224c75211 | ||
|
|
e64934be6b | ||
|
|
e95f97d40e | ||
|
|
05211963ee | ||
|
|
e1e481f438 | ||
|
|
faef936581 | ||
|
|
26bca96029 | ||
|
|
a1e1470447 | ||
|
|
9fb05897db | ||
|
|
c8d1b18a3c | ||
|
|
99cb0f25eb | ||
|
|
99be1aca73 | ||
|
|
7fcb8ffe0a | ||
|
|
cbd0af7217 | ||
|
|
3b63476e31 | ||
|
|
440b5f6e7b | ||
|
|
97cd07007d | ||
|
|
c0e3aa1ef8 | ||
|
|
e1d62cda5f | ||
|
|
8c3526d91f | ||
|
|
f5f91a4d05 | ||
|
|
3a5de540f1 | ||
|
|
48cd4d65e6 | ||
|
|
12a0f93f87 | ||
|
|
9ff5f94233 | ||
|
|
72dbf03b6c | ||
|
|
fad8a27cf7 | ||
|
|
465d911052 | ||
|
|
b951b5adec | ||
|
|
9fce81f9af | ||
|
|
4167401a00 | ||
|
|
18a1bc9e7f | ||
|
|
a23449ee23 | ||
|
|
a46d8b2831 | ||
|
|
6510fbb66d | ||
|
|
5f2a5cdcab | ||
|
|
938b9f3098 | ||
|
|
5bb0237860 | ||
|
|
c923c99f09 | ||
|
|
7505e1458f | ||
|
|
d4575ccfe9 | ||
|
|
71e7f000c4 | ||
|
|
58afa32a1a | ||
|
|
81eb9f280f | ||
|
|
d0d7c53ee1 | ||
|
|
19e6434f37 | ||
|
|
6f104362c7 | ||
|
|
da8a577408 | ||
|
|
2b2abcd6f9 | ||
|
|
5fd4d53922 | ||
|
|
7f1a0e1552 | ||
|
|
e4451376f3 | ||
|
|
2602f26753 | ||
|
|
9c8c56f081 | ||
|
|
7e945e5fa8 | ||
|
|
f27a151478 | ||
|
|
01d0843c4d | ||
|
|
1771aea076 | ||
|
|
c3c0ca0aff | ||
|
|
22b33adb2f | ||
|
|
e287e3ef9d | ||
|
|
f03d543139 | ||
|
|
5a17387c3d | ||
|
|
996e270f90 | ||
|
|
4ff9a93490 | ||
|
|
f5c45576cf | ||
|
|
2532ddd9f4 | ||
|
|
d1a9f9ec74 | ||
|
|
e2cb5ee379 | ||
|
|
0c8cf83131 | ||
|
|
2ef417df5f | ||
|
|
452992bcd5 | ||
|
|
c2f08b3e35 | ||
|
|
49dde3ca91 | ||
|
|
cf644d4de3 | ||
|
|
fb81c46999 | ||
|
|
addabc392d | ||
|
|
8a47006b72 | ||
|
|
1591141237 | ||
|
|
74c7a84c4c | ||
|
|
5cc8660a32 | ||
|
|
82bcdcaeaf | ||
|
|
117be7a870 | ||
|
|
244922a3e3 | ||
|
|
922abdc51b | ||
|
|
59ad2b48ee | ||
|
|
0c75a3a8e7 | ||
|
|
c667af2683 | ||
|
|
305bc4983f | ||
|
|
171eddcd01 | ||
|
|
7dc03f16e7 | ||
|
|
a0bb9b2f57 | ||
|
|
9dbf59af9c | ||
|
|
4e8d383d01 | ||
|
|
8533c452a1 | ||
|
|
82b65d5de0 | ||
|
|
0740090682 | ||
|
|
fa7c5fcd42 | ||
|
|
1160da7fdf | ||
|
|
e1b7a02786 | ||
|
|
4c533a1e53 | ||
|
|
3d03264b0a | ||
|
|
6270de58ad | ||
|
|
99cb5a7c8d | ||
|
|
bdc914bbf4 | ||
|
|
cd045c60d9 | ||
|
|
1be101f342 | ||
|
|
7097ff286c | ||
|
|
65c5a57033 | ||
|
|
e9dae152cd | ||
|
|
e2b6ab00dc | ||
|
|
92eebb885c | ||
|
|
c4e4a05002 | ||
|
|
405f2ee995 | ||
|
|
501fce7fdd | ||
|
|
3c2367d158 | ||
|
|
2a4c338ac4 | ||
|
|
6928e6b5b0 | ||
|
|
cc10f1943c | ||
|
|
e0a02c1a7c | ||
|
|
eae8933b85 | ||
|
|
dd6405fcef | ||
|
|
57571ae908 | ||
|
|
b2bd4d1cb7 | ||
|
|
707dde46a8 | ||
|
|
c09d3c6bac | ||
|
|
e05164cb4f | ||
|
|
c0a9ef0e1d | ||
|
|
978b54796f | ||
|
|
882e924629 | ||
|
|
a88c479160 | ||
|
|
2a7dfb2320 | ||
|
|
514389681c | ||
|
|
f5475db6e1 | ||
|
|
9316961219 | ||
|
|
304ed67982 | ||
|
|
09714a4f11 | ||
|
|
f871186da3 | ||
|
|
fd2e2ac34f | ||
|
|
07bfb7cac9 | ||
|
|
190f310ed1 | ||
|
|
071dc73954 | ||
|
|
278030ff3e | ||
|
|
ef0db6f034 | ||
|
|
0e191cf70e | ||
|
|
73813c6bac | ||
|
|
c3d2942675 |
@@ -8,6 +8,18 @@ stages:
|
||||
- deploy
|
||||
- post_deploy
|
||||
|
||||
# pipelines will not be created in such two cases:
|
||||
# 1. MR push
|
||||
# 2. push not on "master/release" branches, and not tagged
|
||||
# This behavior could be changed after the `rules: changes` feature is implemented
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
when: never
|
||||
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_PIPELINE_SOURCE == "push"'
|
||||
when: never
|
||||
- when: always
|
||||
|
||||
variables:
|
||||
# System environment
|
||||
|
||||
|
||||
@@ -87,9 +87,8 @@ class OtatoolTarget():
|
||||
seq = bytearray(self.otadata[start:start + 4])
|
||||
crc = bytearray(self.otadata[start + 28:start + 32])
|
||||
|
||||
seq = struct.unpack('>I', seq)
|
||||
crc = struct.unpack('>I', crc)
|
||||
|
||||
seq = struct.unpack('I', seq)
|
||||
crc = struct.unpack('I', crc)
|
||||
info.append(otadata_info(seq[0], crc[0]))
|
||||
|
||||
return info
|
||||
@@ -108,7 +107,7 @@ class OtatoolTarget():
|
||||
|
||||
def is_otadata_info_valid(status):
|
||||
seq = status.seq % (1 << 32)
|
||||
crc = hex(binascii.crc32(struct.pack("I", seq), 0xFFFFFFFF) % (1 << 32))
|
||||
crc = binascii.crc32(struct.pack('I', seq), 0xFFFFFFFF) % (1 << 32)
|
||||
return seq < (int('0xFFFFFFFF', 16) % (1 << 32)) and status.crc == crc
|
||||
|
||||
partition_table = self.target.partition_table
|
||||
@@ -219,8 +218,8 @@ def _read_otadata(target):
|
||||
|
||||
otadata_info = target._get_otadata_info()
|
||||
|
||||
print(" {:8s} \t {:8s} | \t {:8s} \t {:8s}".format("OTA_SEQ", "CRC", "OTA_SEQ", "CRC"))
|
||||
print("Firmware: 0x{:8x} \t0x{:8x} | \t0x{:8x} \t 0x{:8x}".format(otadata_info[0].seq, otadata_info[0].crc,
|
||||
print(' {:8s} \t {:8s} | \t {:8s} \t {:8s}'.format('OTA_SEQ', 'CRC', 'OTA_SEQ', 'CRC'))
|
||||
print('Firmware: 0x{:08x} \t0x{:08x} | \t0x{:08x} \t 0x{:08x}'.format(otadata_info[0].seq, otadata_info[0].crc,
|
||||
otadata_info[1].seq, otadata_info[1].crc))
|
||||
|
||||
|
||||
@@ -249,6 +248,10 @@ def _erase_ota_partition(target, ota_id):
|
||||
|
||||
|
||||
def main():
|
||||
if sys.version_info[0] < 3:
|
||||
print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.", file=sys.stderr)
|
||||
elif sys.version_info[0] == 3 and sys.version_info[1] < 6:
|
||||
print("WARNING: Python 3 versions older than 3.6 are not supported.", file=sys.stderr)
|
||||
global quiet
|
||||
|
||||
parser = argparse.ArgumentParser("ESP-IDF OTA Partitions Tool")
|
||||
|
||||
@@ -334,6 +334,16 @@ menu "Security features"
|
||||
select MBEDTLS_ECDSA_C
|
||||
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
|
||||
|
||||
config SECURE_BOOT_SUPPORTS_RSA
|
||||
bool
|
||||
default y
|
||||
depends on ESP32_REV_MIN_3 || IDF_TARGET_ESP32S2
|
||||
|
||||
config SECURE_TARGET_HAS_SECURE_ROM_DL_MODE
|
||||
bool
|
||||
default y
|
||||
depends on IDF_TARGET_ESP32S2
|
||||
|
||||
|
||||
config SECURE_SIGNED_APPS_NO_SECURE_BOOT
|
||||
bool "Require signed app images"
|
||||
@@ -369,7 +379,7 @@ menu "Security features"
|
||||
|
||||
config SECURE_SIGNED_APPS_RSA_SCHEME
|
||||
bool "RSA"
|
||||
depends on (ESP32_REV_MIN_3 || IDF_TARGET_ESP32S2) && SECURE_BOOT_V2_ENABLED
|
||||
depends on SECURE_BOOT_SUPPORTS_RSA && SECURE_BOOT_V2_ENABLED
|
||||
help
|
||||
Appends the RSA-3072 based Signature block to the application.
|
||||
Refer to <Secure Boot Version 2 documentation link> before enabling.
|
||||
@@ -433,8 +443,8 @@ menu "Security features"
|
||||
|
||||
config SECURE_BOOT_V2_ENABLED
|
||||
bool "Enable Secure Boot version 2"
|
||||
depends on ESP32_REV_MIN_3 || IDF_TARGET_ESP32S2
|
||||
select SECURE_ENABLE_SECURE_ROM_DL_MODE if IDF_TARGET_ESP32S2 && !SECURE_INSECURE_ALLOW_DL_MODE
|
||||
depends on SECURE_BOOT_SUPPORTS_RSA
|
||||
select SECURE_ENABLE_SECURE_ROM_DL_MODE if !IDF_TARGET_ESP32 && !SECURE_INSECURE_ALLOW_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE # NOERROR
|
||||
select SECURE_DISABLE_ROM_DL_MODE if ESP32_REV_MIN_3 && !SECURE_INSECURE_ALLOW_DL_MODE
|
||||
help
|
||||
Build a bootloader which enables Secure Boot version 2 on first boot.
|
||||
@@ -555,6 +565,7 @@ menu "Security features"
|
||||
config SECURE_FLASH_ENC_ENABLED
|
||||
bool "Enable flash encryption on boot (READ DOCS FIRST)"
|
||||
default N
|
||||
select SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE
|
||||
help
|
||||
If this option is set, flash contents will be encrypted by the bootloader on first boot.
|
||||
|
||||
@@ -603,7 +614,8 @@ menu "Security features"
|
||||
|
||||
config SECURE_FLASH_ENCRYPTION_MODE_RELEASE
|
||||
bool "Release"
|
||||
select SECURE_ENABLE_SECURE_ROM_DL_MODE
|
||||
select SECURE_ENABLE_SECURE_ROM_DL_MODE if SECURE_TARGET_HAS_SECURE_ROM_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE # NOERROR
|
||||
select PARTITION_TABLE_MD5 if !ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -748,7 +760,7 @@ menu "Security features"
|
||||
|
||||
config SECURE_ENABLE_SECURE_ROM_DL_MODE
|
||||
bool "Permanently switch to ROM UART Secure Download mode"
|
||||
depends on IDF_TARGET_ESP32S2 && !SECURE_DISABLE_ROM_DL_MODE
|
||||
depends on SECURE_TARGET_HAS_SECURE_ROM_DL_MODE && !SECURE_DISABLE_ROM_DL_MODE
|
||||
help
|
||||
If set, during startup the app will burn an eFuse bit to permanently switch the UART ROM
|
||||
Download Mode into a separate Secure Download mode. This option can only work if
|
||||
|
||||
@@ -28,6 +28,14 @@ extern "C" {
|
||||
*/
|
||||
void bootloader_flash_update_id(void);
|
||||
|
||||
/**
|
||||
* @brief Update the flash size in g_rom_flashchip (global esp_rom_spiflash_chip_t structure).
|
||||
*
|
||||
* @param size The size to store, in bytes.
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_update_size(uint32_t size);
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
*
|
||||
|
||||
@@ -42,6 +42,9 @@ extern "C" {
|
||||
|
||||
#define PART_FLAG_ENCRYPTED (1<<0)
|
||||
|
||||
/* The md5sum value is found this many bytes after the ESP_PARTITION_MAGIC_MD5 offset */
|
||||
#define ESP_PARTITION_MD5_OFFSET 16
|
||||
|
||||
/* Pre-partition table fixed flash offsets */
|
||||
#define ESP_BOOTLOADER_DIGEST_OFFSET 0x0
|
||||
#define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */
|
||||
|
||||
@@ -169,6 +169,14 @@ esp_err_t esp_image_verify_bootloader(uint32_t *length);
|
||||
*/
|
||||
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
|
||||
|
||||
/**
|
||||
* @brief Get the flash size of the image
|
||||
*
|
||||
* @param app_flash_size The value configured in the image header
|
||||
* @return Actual size, in bytes.
|
||||
*/
|
||||
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size);
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t drom_addr;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "sys/param.h"
|
||||
@@ -295,7 +296,18 @@ RESET_REASON bootloader_common_get_reset_reason(int cpu_no)
|
||||
|
||||
#if defined( CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP ) || defined( CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC )
|
||||
|
||||
rtc_retain_mem_t *const rtc_retain_mem = (rtc_retain_mem_t *)(SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t));
|
||||
#define RTC_RETAIN_MEM_ADDR (SOC_RTC_DRAM_HIGH - sizeof(rtc_retain_mem_t))
|
||||
|
||||
rtc_retain_mem_t *const rtc_retain_mem = (rtc_retain_mem_t *)RTC_RETAIN_MEM_ADDR;
|
||||
|
||||
#if !IS_BOOTLOADER_BUILD
|
||||
/* The app needs to be told this memory is reserved, important if configured to use RTC memory as heap.
|
||||
|
||||
Note that keeping this macro here only works when other symbols in this file are referenced by the app, as
|
||||
this feature is otherwise 100% part of the bootloader. However this seems to happen in all apps.
|
||||
*/
|
||||
SOC_RESERVE_MEMORY_REGION(RTC_RETAIN_MEM_ADDR, RTC_RETAIN_MEM_ADDR + sizeof(rtc_retain_mem_t), rtc_retain_mem);
|
||||
#endif
|
||||
|
||||
static bool check_rtc_retain_mem(void)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,11 @@ void bootloader_flash_update_id(void)
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void bootloader_flash_update_size(uint32_t size)
|
||||
{
|
||||
g_rom_flashchip.chip_size = size;
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config(void)
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
|
||||
@@ -39,6 +39,11 @@ void bootloader_flash_update_id()
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void bootloader_flash_update_size(uint32_t size)
|
||||
{
|
||||
g_rom_flashchip.chip_size = size;
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_MEM_USER_REG(0), SPI_MEM_CS_HOLD_M | SPI_MEM_CS_SETUP_M);
|
||||
|
||||
@@ -252,9 +252,7 @@ static esp_err_t encrypt_bootloader(void)
|
||||
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
|
||||
|
||||
#if CONFIG_SECURE_BOOT_V2_ENABLED
|
||||
// Account for the signature sector after the bootloader
|
||||
image_length = (image_length + FLASH_SECTOR_SIZE - 1) & ~(FLASH_SECTOR_SIZE - 1);
|
||||
image_length += FLASH_SECTOR_SIZE;
|
||||
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
|
||||
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
|
||||
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
|
||||
@@ -319,16 +319,26 @@ esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *imag
|
||||
uint32_t dis_reg = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool efuse_key_read_protected = dis_reg & EFUSE_RD_DIS_BLK2;
|
||||
bool efuse_key_write_protected = dis_reg & EFUSE_WR_DIS_BLK2;
|
||||
uint32_t efuse_blk2_r0, efuse_blk2_r1, efuse_blk2_r2, efuse_blk2_r3, efuse_blk2_r4, efuse_blk2_r5, efuse_blk2_r6, efuse_blk2_r7;
|
||||
efuse_blk2_r0 = REG_READ(EFUSE_BLK2_RDATA0_REG);
|
||||
efuse_blk2_r1 = REG_READ(EFUSE_BLK2_RDATA1_REG);
|
||||
efuse_blk2_r2 = REG_READ(EFUSE_BLK2_RDATA2_REG);
|
||||
efuse_blk2_r3 = REG_READ(EFUSE_BLK2_RDATA3_REG);
|
||||
efuse_blk2_r4 = REG_READ(EFUSE_BLK2_RDATA4_REG);
|
||||
efuse_blk2_r5 = REG_READ(EFUSE_BLK2_RDATA5_REG);
|
||||
efuse_blk2_r6 = REG_READ(EFUSE_BLK2_RDATA6_REG);
|
||||
efuse_blk2_r7 = REG_READ(EFUSE_BLK2_RDATA7_REG);
|
||||
|
||||
if (efuse_key_read_protected == true) {
|
||||
ESP_LOGE(TAG, "Secure Boot v2 digest(BLK2) read protected, aborting....");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (efuse_key_write_protected == false
|
||||
&& efuse_key_read_protected == false
|
||||
&& REG_READ(EFUSE_BLK2_RDATA0_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA1_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA2_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA3_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA4_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA5_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA6_REG) == 0
|
||||
&& REG_READ(EFUSE_BLK2_RDATA7_REG) == 0) {
|
||||
&& efuse_blk2_r0 == 0 && efuse_blk2_r1 == 0
|
||||
&& efuse_blk2_r2 == 0 && efuse_blk2_r3 == 0
|
||||
&& efuse_blk2_r4 == 0 && efuse_blk2_r5 == 0
|
||||
&& efuse_blk2_r6 == 0 && efuse_blk2_r7 == 0) {
|
||||
/* Verifies the signature block appended to the image matches with the signature block of the app to be loaded */
|
||||
ret = secure_boot_v2_digest_generate(bootloader_data.start_addr, bootloader_data.image_len - SIG_BLOCK_PADDING, boot_pub_key_digest);
|
||||
if (ret != ESP_OK) {
|
||||
@@ -343,14 +353,26 @@ esp_err_t esp_secure_boot_v2_permanently_enable(const esp_image_metadata_t *imag
|
||||
ESP_LOGD(TAG, "EFUSE_BLKx_WDATA%d_REG = 0x%08x", i, boot_public_key_digest_ptr[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Write protecting public key digest...");
|
||||
new_wdata0 |= EFUSE_WR_DIS_BLK2;
|
||||
efuse_key_write_protected = true;
|
||||
efuse_key_read_protected = false;
|
||||
} else {
|
||||
uint32_t efuse_blk2_digest[8];
|
||||
efuse_blk2_digest[0] = efuse_blk2_r0;
|
||||
efuse_blk2_digest[1] = efuse_blk2_r1;
|
||||
efuse_blk2_digest[2] = efuse_blk2_r2;
|
||||
efuse_blk2_digest[3] = efuse_blk2_r3;
|
||||
efuse_blk2_digest[4] = efuse_blk2_r4;
|
||||
efuse_blk2_digest[5] = efuse_blk2_r5;
|
||||
efuse_blk2_digest[6] = efuse_blk2_r6;
|
||||
efuse_blk2_digest[7] = efuse_blk2_r7;
|
||||
memcpy(boot_pub_key_digest, efuse_blk2_digest, DIGEST_LEN);
|
||||
ESP_LOGW(TAG, "Using pre-loaded secure boot v2 public key digest in EFUSE block 2");
|
||||
}
|
||||
|
||||
if (efuse_key_write_protected == false) {
|
||||
ESP_LOGI(TAG, "Write protecting public key digest...");
|
||||
new_wdata0 |= EFUSE_WR_DIS_BLK2; // delay burning until second half of this function
|
||||
efuse_key_write_protected = true;
|
||||
}
|
||||
|
||||
uint8_t app_pub_key_digest[DIGEST_LEN];
|
||||
ret = secure_boot_v2_digest_generate(image_data->start_addr, image_data->image_len - SIG_BLOCK_PADDING, app_pub_key_digest);
|
||||
if (ret != ESP_OK) {
|
||||
|
||||
@@ -286,9 +286,7 @@ static esp_err_t encrypt_bootloader(void)
|
||||
ESP_LOGD(TAG, "bootloader is plaintext. Encrypting...");
|
||||
|
||||
#if CONFIG_SECURE_BOOT_V2_ENABLED
|
||||
// Account for the signature sector after the bootloader
|
||||
image_length = (image_length + FLASH_SECTOR_SIZE - 1) & ~(FLASH_SECTOR_SIZE - 1);
|
||||
image_length += FLASH_SECTOR_SIZE;
|
||||
/* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */
|
||||
if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) {
|
||||
ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET);
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
|
||||
@@ -229,6 +229,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
if (true) {
|
||||
#endif // end checking for JTAG
|
||||
err = verify_secure_boot_signature(sha_handle, data, image_digest, verified_digest);
|
||||
sha_handle = NULL; // verify_secure_boot_signature finishes sha_handle
|
||||
}
|
||||
#else // SECURE_BOOT_CHECK_SIGNATURE
|
||||
// No secure boot, but SHA-256 can be appended for basic corruption detection
|
||||
@@ -850,3 +851,21 @@ static esp_err_t verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_i
|
||||
bootloader_munmap(hash);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size)
|
||||
{
|
||||
switch (app_flash_size) {
|
||||
case ESP_IMAGE_FLASH_SIZE_1MB:
|
||||
return 1 * 1024 * 1024;
|
||||
case ESP_IMAGE_FLASH_SIZE_2MB:
|
||||
return 2 * 1024 * 1024;
|
||||
case ESP_IMAGE_FLASH_SIZE_4MB:
|
||||
return 4 * 1024 * 1024;
|
||||
case ESP_IMAGE_FLASH_SIZE_8MB:
|
||||
return 8 * 1024 * 1024;
|
||||
case ESP_IMAGE_FLASH_SIZE_16MB:
|
||||
return 16 * 1024 * 1024;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table
|
||||
MD5Update(&context, (unsigned char *) partition_table, num_parts * sizeof(esp_partition_info_t));
|
||||
MD5Final(digest, &context);
|
||||
|
||||
unsigned char *md5sum = ((unsigned char *) part) + 16; // skip the 2B magic number and the 14B fillup bytes
|
||||
unsigned char *md5sum = ((unsigned char *) part) + ESP_PARTITION_MD5_OFFSET;
|
||||
|
||||
if (memcmp(md5sum, digest, sizeof(digest)) != 0) {
|
||||
if (log_errors) {
|
||||
|
||||
@@ -312,8 +312,8 @@ esp_err_t esp_secure_boot_verify_rsa_signature_block(const ets_secure_boot_signa
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = mbedtls_rsa_rsassa_pss_verify( &pk, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, DIGEST_LEN,
|
||||
sig_block->block[i].image_digest, sig_be);
|
||||
ret = mbedtls_rsa_rsassa_pss_verify( &pk, mbedtls_ctr_drbg_random, &ctr_drbg, MBEDTLS_RSA_PUBLIC, MBEDTLS_MD_SHA256, DIGEST_LEN,
|
||||
image_digest, sig_be);
|
||||
if (ret != 0) {
|
||||
ESP_LOGE(TAG, "Failed mbedtls_rsa_rsassa_pss_verify, err: %d", ret);
|
||||
} else {
|
||||
|
||||
@@ -96,6 +96,7 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/bluedroid/bta/dm/bta_dm_main.c"
|
||||
"host/bluedroid/bta/dm/bta_dm_pm.c"
|
||||
"host/bluedroid/bta/dm/bta_dm_sco.c"
|
||||
"host/bluedroid/bta/dm/bta_dm_qos.c"
|
||||
"host/bluedroid/bta/gatt/bta_gatt_common.c"
|
||||
"host/bluedroid/bta/gatt/bta_gattc_act.c"
|
||||
"host/bluedroid/bta/gatt/bta_gattc_api.c"
|
||||
@@ -340,6 +341,7 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c"
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c"
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_ble.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_config_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_generic_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_health_model.c"
|
||||
@@ -389,7 +391,9 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/mesh_core/provisioner_prov.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_client.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_server.c"
|
||||
"esp_ble_mesh/mesh_core/settings_uid.c"
|
||||
"esp_ble_mesh/mesh_core/settings.c"
|
||||
"esp_ble_mesh/mesh_core/scan.c"
|
||||
"esp_ble_mesh/mesh_core/test.c"
|
||||
"esp_ble_mesh/mesh_core/transport.c"
|
||||
"esp_ble_mesh/mesh_models/common/device_property.c"
|
||||
@@ -569,6 +573,6 @@ idf_component_register(SRCS "${srcs}"
|
||||
if(CONFIG_BT_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-implicit-fallthrough -Wno-unused-const-variable)
|
||||
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib")
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L${CMAKE_CURRENT_LIST_DIR}/controller/lib/esp32")
|
||||
target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app)
|
||||
endif()
|
||||
|
||||
@@ -428,21 +428,6 @@ menu "Bluetooth"
|
||||
If you set `BTDM_BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
menuconfig BTDM_COEX_BT_OPTIONS
|
||||
bool "Coexistence Bluetooth Side Options"
|
||||
depends on ESP32_WIFI_SW_COEXIST_ENABLE
|
||||
default n
|
||||
help
|
||||
Options of Bluetooth Side of WiFi and bluetooth coexistence.
|
||||
|
||||
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
|
||||
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
|
||||
depends on BTDM_COEX_BT_OPTIONS
|
||||
default n
|
||||
help
|
||||
Improve BLE ADV coexistence priority to make it better performance.
|
||||
For example, BLE mesh need to enable this option to improve BLE adv performance.
|
||||
|
||||
endmenu
|
||||
|
||||
choice BT_HOST
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#endif
|
||||
|
||||
#if CONFIG_BLE_MESH
|
||||
#include "btc_ble_mesh_ble.h"
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
@@ -93,9 +94,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
[BTC_PID_BLE_HID] = {NULL, NULL},
|
||||
[BTC_PID_SPPLIKE] = {NULL, NULL},
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
|
||||
#endif
|
||||
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
|
||||
@@ -124,18 +125,43 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#if CONFIG_BLE_MESH
|
||||
[BTC_PID_PROV] = {btc_ble_mesh_prov_call_handler, btc_ble_mesh_prov_cb_handler },
|
||||
[BTC_PID_MODEL] = {btc_ble_mesh_model_call_handler, btc_ble_mesh_model_cb_handler },
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
[BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
[BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
[BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
[BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
[BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
#if CONFIG_BLE_MESH_GENERIC_SERVER
|
||||
[BTC_PID_GENERIC_SERVER] = {NULL, btc_ble_mesh_generic_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_SERVER
|
||||
[BTC_PID_LIGHTING_SERVER] = {NULL, btc_ble_mesh_lighting_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
#if CONFIG_BLE_MESH_SENSOR_SERVER
|
||||
[BTC_PID_SENSOR_SERVER] = {NULL, btc_ble_mesh_sensor_server_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
||||
[BTC_PID_BLE_MESH_BLE_COEX] = {btc_ble_mesh_ble_call_handler, btc_ble_mesh_ble_cb_handler },
|
||||
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
||||
#endif /* #if CONFIG_BLE_MESH */
|
||||
};
|
||||
|
||||
@@ -281,12 +307,13 @@ static void btc_deinit_mem(void) {
|
||||
osi_free(btc_creat_tab_env_ptr);
|
||||
btc_creat_tab_env_ptr = NULL;
|
||||
}
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
if (blufi_env_ptr) {
|
||||
osi_free(blufi_env_ptr);
|
||||
blufi_env_ptr = NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if (hf_client_local_param_ptr) {
|
||||
@@ -335,12 +362,13 @@ static bt_status_t btc_init_mem(void) {
|
||||
goto error_exit;
|
||||
}
|
||||
memset((void *)btc_creat_tab_env_ptr, 0, sizeof(esp_btc_creat_tab_t));
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
if ((blufi_env_ptr = (tBLUFI_ENV *)osi_malloc(sizeof(tBLUFI_ENV))) == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
memset((void *)blufi_env_ptr, 0, sizeof(tBLUFI_ENV));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
|
||||
if ((hf_client_local_param_ptr = (hf_client_local_param_t *)osi_malloc(sizeof(hf_client_local_param_t))) == NULL) {
|
||||
|
||||
@@ -53,7 +53,9 @@ typedef enum {
|
||||
BTC_PID_GAP_BLE,
|
||||
BTC_PID_BLE_HID,
|
||||
BTC_PID_SPPLIKE,
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
BTC_PID_BLUFI,
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
BTC_PID_DM_SEC,
|
||||
BTC_PID_ALARM,
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
@@ -85,6 +87,7 @@ typedef enum {
|
||||
BTC_PID_LIGHTING_SERVER,
|
||||
BTC_PID_SENSOR_SERVER,
|
||||
BTC_PID_TIME_SCENE_SERVER,
|
||||
BTC_PID_BLE_MESH_BLE_COEX,
|
||||
#endif /* CONFIG_BLE_MESH */
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
||||
@@ -9,11 +9,11 @@ COMPONENT_ADD_INCLUDEDIRS := include
|
||||
|
||||
LIBS := btdm_app
|
||||
|
||||
COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib \
|
||||
COMPONENT_ADD_LDFLAGS := -lbt -L $(COMPONENT_PATH)/controller/lib/esp32 \
|
||||
$(addprefix -l,$(LIBS))
|
||||
|
||||
# re-link program if BT binary libs change
|
||||
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/lib%.a,$(LIBS))
|
||||
COMPONENT_ADD_LINKER_DEPS := $(patsubst %,$(COMPONENT_PATH)/controller/lib/esp32/lib%.a,$(LIBS))
|
||||
|
||||
COMPONENT_SUBMODULES += controller/lib
|
||||
|
||||
|
||||
@@ -174,6 +174,14 @@ struct osi_funcs_t {
|
||||
int (* _coex_register_bt_cb)(coex_func_cb_t cb);
|
||||
uint32_t (* _coex_bb_reset_lock)(void);
|
||||
void (* _coex_bb_reset_unlock)(uint32_t restore);
|
||||
int (* _coex_schm_register_btdm_callback)(void *callback);
|
||||
void (* _coex_schm_status_bit_clear)(uint32_t type, uint32_t status);
|
||||
void (* _coex_schm_status_bit_set)(uint32_t type, uint32_t status);
|
||||
uint32_t (* _coex_schm_interval_get)(void);
|
||||
uint8_t (* _coex_schm_curr_period_get)(void);
|
||||
void *(* _coex_schm_curr_phase_get)(void);
|
||||
int (* _coex_wifi_channel_get)(uint8_t *primary, uint8_t *secondary);
|
||||
int (* _coex_register_wifi_channel_change_callback)(void *cb);
|
||||
uint32_t _magic;
|
||||
};
|
||||
|
||||
@@ -217,12 +225,19 @@ extern int bredr_txpwr_get(int *min_power_level, int *max_power_level);
|
||||
extern void bredr_sco_datapath_set(uint8_t data_path);
|
||||
extern void btdm_controller_scan_duplicate_list_clear(void);
|
||||
/* Coexistence */
|
||||
extern int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
extern int coex_bt_release_wrapper(uint32_t event);
|
||||
extern int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
|
||||
extern uint32_t coex_bb_reset_lock_wrapper(void);
|
||||
extern void coex_bb_reset_unlock_wrapper(uint32_t restore);
|
||||
extern void coex_ble_adv_priority_high_set(bool high);
|
||||
extern int coex_bt_request(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
extern int coex_bt_release(uint32_t event);
|
||||
extern int coex_register_bt_cb(coex_func_cb_t cb);
|
||||
extern uint32_t coex_bb_reset_lock(void);
|
||||
extern void coex_bb_reset_unlock(uint32_t restore);
|
||||
extern int coex_schm_register_btdm_callback(void *callback);
|
||||
extern void coex_schm_status_bit_clear(uint32_t type, uint32_t status);
|
||||
extern void coex_schm_status_bit_set(uint32_t type, uint32_t status);
|
||||
extern uint32_t coex_schm_interval_get(void);
|
||||
extern uint8_t coex_schm_curr_period_get(void);
|
||||
extern void * coex_schm_curr_phase_get(void);
|
||||
extern int coex_wifi_channel_get(uint8_t *primary, uint8_t *secondary);
|
||||
extern int coex_register_wifi_channel_change_callback(void *cb);
|
||||
|
||||
extern char _bss_start_btdm;
|
||||
extern char _bss_end_btdm;
|
||||
@@ -287,6 +302,19 @@ static void btdm_sleep_enter_phase2_wrapper(void);
|
||||
static void btdm_sleep_exit_phase3_wrapper(void);
|
||||
static bool coex_bt_wakeup_request(void);
|
||||
static void coex_bt_wakeup_request_end(void);
|
||||
static int coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
static int coex_bt_release_wrapper(uint32_t event);
|
||||
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb);
|
||||
static uint32_t coex_bb_reset_lock_wrapper(void);
|
||||
static void coex_bb_reset_unlock_wrapper(uint32_t restore);
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback);
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status);
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status);
|
||||
static uint32_t coex_schm_interval_get_wrapper(void);
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void);
|
||||
static void * coex_schm_curr_phase_get_wrapper(void);
|
||||
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary);
|
||||
static int coex_register_wifi_channel_change_callback_wrapper(void *cb);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@@ -341,6 +369,14 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._coex_register_bt_cb = coex_register_bt_cb_wrapper,
|
||||
._coex_bb_reset_lock = coex_bb_reset_lock_wrapper,
|
||||
._coex_bb_reset_unlock = coex_bb_reset_unlock_wrapper,
|
||||
._coex_schm_register_btdm_callback = coex_schm_register_btdm_callback_wrapper,
|
||||
._coex_schm_status_bit_clear = coex_schm_status_bit_clear_wrapper,
|
||||
._coex_schm_status_bit_set = coex_schm_status_bit_set_wrapper,
|
||||
._coex_schm_interval_get = coex_schm_interval_get_wrapper,
|
||||
._coex_schm_curr_period_get = coex_schm_curr_period_get_wrapper,
|
||||
._coex_schm_curr_phase_get = coex_schm_curr_phase_get_wrapper,
|
||||
._coex_wifi_channel_get = coex_wifi_channel_get_wrapper,
|
||||
._coex_register_wifi_channel_change_callback = coex_register_wifi_channel_change_callback_wrapper,
|
||||
._magic = OSI_MAGIC_VALUE,
|
||||
};
|
||||
|
||||
@@ -996,6 +1032,117 @@ static void coex_bt_wakeup_request_end(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static int IRAM_ATTR coex_bt_request_wrapper(uint32_t event, uint32_t latency, uint32_t duration)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_bt_request(event, latency, duration);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int IRAM_ATTR coex_bt_release_wrapper(uint32_t event)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_bt_release(event);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_register_bt_cb_wrapper(coex_func_cb_t cb)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_register_bt_cb(cb);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t IRAM_ATTR coex_bb_reset_lock_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_bb_reset_lock();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_bb_reset_unlock(restore);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_schm_register_btdm_callback_wrapper(void *callback)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_register_btdm_callback(callback);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_clear_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_clear(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void coex_schm_status_bit_set_wrapper(uint32_t type, uint32_t status)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_schm_status_bit_set(type, status);
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint32_t coex_schm_interval_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_interval_get();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static uint8_t coex_schm_curr_period_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_period_get();
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void * coex_schm_curr_phase_get_wrapper(void)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_schm_curr_phase_get();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_wifi_channel_get_wrapper(uint8_t *primary, uint8_t *secondary)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_wifi_channel_get(primary, secondary);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int coex_register_wifi_channel_change_callback_wrapper(void *cb)
|
||||
{
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
return coex_register_wifi_channel_change_callback(cb);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
{
|
||||
return API_vhci_host_check_send_available();
|
||||
@@ -1180,7 +1327,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
if (btdm_dram_available_region[0].mode == ESP_BT_MODE_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
|
||||
osi_funcs_p = (struct osi_funcs_t *)malloc_internal_wrapper(sizeof(struct osi_funcs_t));
|
||||
if (osi_funcs_p == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
@@ -1313,12 +1460,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BTDM_COEX_BLE_ADV_HIGH_PRIORITY
|
||||
coex_ble_adv_priority_high_set(true);
|
||||
#else
|
||||
coex_ble_adv_priority_high_set(false);
|
||||
#endif
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
return ESP_OK;
|
||||
@@ -1387,6 +1528,19 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static void bt_shutdown(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
ESP_LOGD(BTDM_LOG_TAG, "stop Bluetooth");
|
||||
|
||||
ret = esp_bt_controller_disable();
|
||||
if (ESP_OK != ret) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "controller disable ret=%d", ret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
{
|
||||
int ret;
|
||||
@@ -1450,6 +1604,10 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
}
|
||||
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_ENABLED;
|
||||
ret = esp_register_shutdown_handler(bt_shutdown);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "Register shutdown handler failed, ret = 0x%x", ret);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1480,6 +1638,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
}
|
||||
esp_phy_rf_deinit(PHY_BT_MODULE);
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
esp_unregister_shutdown_handler(bt_shutdown);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
@@ -1496,7 +1655,6 @@ esp_bt_controller_status_t esp_bt_controller_get_status(void)
|
||||
return btdm_controller_status;
|
||||
}
|
||||
|
||||
|
||||
/* extra functions */
|
||||
esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_t power_level)
|
||||
{
|
||||
|
||||
Submodule components/bt/controller/lib updated: 0ba611fc0d...1f7e45e2f6
@@ -95,6 +95,42 @@ if BLE_MESH
|
||||
|
||||
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_DEINIT
|
||||
bool "Support de-initialize BLE Mesh stack"
|
||||
default y
|
||||
help
|
||||
If enabled, users can use the function esp_ble_mesh_deinit() to de-initialize
|
||||
the whole BLE Mesh stack.
|
||||
|
||||
menu "BLE Mesh and BLE coexistence support"
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_ADV
|
||||
bool "Support sending normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can send normal BLE advertising packets
|
||||
with specific API.
|
||||
|
||||
if BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_BLE_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers for BLE advertising packets"
|
||||
default 3
|
||||
range 1 255
|
||||
help
|
||||
Number of advertising buffers for BLE packets available.
|
||||
|
||||
endif # BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_SCAN
|
||||
bool "Support scanning normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can register a callback and receive normal BLE
|
||||
advertising packets in the application layer.
|
||||
|
||||
endmenu # BLE Mesh and BLE coexistence support
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
select BLE_MESH_NODE
|
||||
@@ -188,6 +224,28 @@ if BLE_MESH
|
||||
This option specifies how many application keys the Provisioner can have.
|
||||
Indeed, this value decides the number of the application keys which can be added by a Provisioner.
|
||||
|
||||
config BLE_MESH_PROVISIONER_RECV_HB
|
||||
bool "Support receiving Heartbeat messages"
|
||||
default n
|
||||
help
|
||||
When this option is enabled, Provisioner can call specific functions to enable
|
||||
or disable receiving Heartbeat messages and notify them to the application layer.
|
||||
|
||||
if BLE_MESH_PROVISIONER_RECV_HB
|
||||
|
||||
config BLE_MESH_PROVISIONER_RECV_HB_FILTER_SIZE
|
||||
int "Maximum number of filter entries for receiving Heartbeat messages"
|
||||
default 3
|
||||
range 1 1000
|
||||
help
|
||||
This option specifies how many heartbeat filter entries Provisioner supports.
|
||||
The heartbeat filter (acceptlist or rejectlist) entries are used to store a
|
||||
list of SRC and DST which can be used to decide if a heartbeat message will
|
||||
be processed and notified to the application layer by Provisioner.
|
||||
Note: The filter is an empty rejectlist by default.
|
||||
|
||||
endif # BLE_MESH_PROVISIONER_RECV_HB
|
||||
|
||||
endif # BLE_MESH_PROVISIONER
|
||||
|
||||
# Virtual option enabled whenever Generic Provisioning layer is needed
|
||||
@@ -291,28 +349,6 @@ if BLE_MESH
|
||||
|
||||
if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SPECIFIC_PARTITION
|
||||
bool "Use a specific NVS partition for BLE Mesh"
|
||||
default n
|
||||
help
|
||||
When selected, the mesh stack will use a specified NVS partition instead of
|
||||
default NVS partition. Note that the specified partition must be registered
|
||||
with NVS using nvs_flash_init_partition() API, and the partition must exists
|
||||
in the csv file.
|
||||
When Provisioner needs to store a large amount of nodes' information in the
|
||||
flash (e.g. more than 20), this option is recommended to be enabled.
|
||||
|
||||
if BLE_MESH_SPECIFIC_PARTITION
|
||||
|
||||
config BLE_MESH_PARTITION_NAME
|
||||
string "Name of the NVS partition for BLE Mesh"
|
||||
default "ble_mesh"
|
||||
help
|
||||
This value defines the name of the specified NVS partition used by the
|
||||
mesh stack.
|
||||
|
||||
endif # BLE_MESH_SPECIFIC_PARTITION
|
||||
|
||||
config BLE_MESH_STORE_TIMEOUT
|
||||
int "Delay (in seconds) before storing anything persistently"
|
||||
range 0 1000000
|
||||
@@ -327,7 +363,7 @@ if BLE_MESH
|
||||
config BLE_MESH_SEQ_STORE_RATE
|
||||
int "How often the sequence number gets updated in storage"
|
||||
range 0 1000000
|
||||
default 6
|
||||
default 0
|
||||
help
|
||||
This value defines how often the local sequence number gets updated in
|
||||
persistent storage (i.e. flash). e.g. a value of 100 means that the
|
||||
@@ -342,7 +378,7 @@ if BLE_MESH
|
||||
config BLE_MESH_RPL_STORE_TIMEOUT
|
||||
int "Minimum frequency that the RPL gets updated in storage"
|
||||
range 0 1000000
|
||||
default 5
|
||||
default 0
|
||||
help
|
||||
This value defines in seconds how soon the RPL (Replay Protection List)
|
||||
gets written to persistent storage after a change occurs. If the node
|
||||
@@ -378,6 +414,50 @@ if BLE_MESH
|
||||
in advance before recovering node information and make sure the node
|
||||
information recovering could work as expected.
|
||||
|
||||
config BLE_MESH_SPECIFIC_PARTITION
|
||||
bool "Use a specific NVS partition for BLE Mesh"
|
||||
default n
|
||||
help
|
||||
When selected, the mesh stack will use a specified NVS partition instead of
|
||||
default NVS partition. Note that the specified partition must be registered
|
||||
with NVS using nvs_flash_init_partition() API, and the partition must exists
|
||||
in the csv file.
|
||||
When Provisioner needs to store a large amount of nodes' information in the
|
||||
flash (e.g. more than 20), this option is recommended to be enabled.
|
||||
|
||||
config BLE_MESH_PARTITION_NAME
|
||||
string "Name of the NVS partition for BLE Mesh"
|
||||
depends on BLE_MESH_SPECIFIC_PARTITION
|
||||
default "ble_mesh"
|
||||
help
|
||||
This value defines the name of the specified NVS partition used by the
|
||||
mesh stack.
|
||||
|
||||
config BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
bool "Support using multiple NVS namespaces by Provisioner"
|
||||
depends on BLE_MESH_PROVISIONER
|
||||
default n
|
||||
help
|
||||
When selected, Provisioner can use different NVS namespaces to store
|
||||
different instances of mesh information.
|
||||
For example, if in the first room, Provisioner uses NetKey A, AppKey
|
||||
A and provisions three devices, these information will be treated as
|
||||
mesh information instance A. When the Provisioner moves to the second
|
||||
room, it uses NetKey B, AppKey B and provisions two devices, then the
|
||||
information will be treated as mesh information instance B.
|
||||
Here instance A and instance B will be stored in different namespaces.
|
||||
With this option enabled, Provisioner needs to use specific functions
|
||||
to open the corresponding NVS namespace, restore the mesh information,
|
||||
release the mesh information or erase the mesh information.
|
||||
|
||||
config BLE_MESH_MAX_NVS_NAMESPACE
|
||||
int "Maximum number of NVS namespaces"
|
||||
depends on BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
default 2
|
||||
range 1 255
|
||||
help
|
||||
This option specifies the maximum NVS namespaces supported by Provisioner.
|
||||
|
||||
endif # if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SUBNET_COUNT
|
||||
@@ -459,24 +539,6 @@ if BLE_MESH
|
||||
SDU size is 60 bytes, which leaves 56 bytes for application layer data
|
||||
using a 4-byte MIC, or 52 bytes using an 8-byte MIC.
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_ADV
|
||||
bool "Support sending normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can send normal BLE advertising packets
|
||||
with specific API.
|
||||
|
||||
if BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_BLE_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers for BLE advertising packets"
|
||||
default 3
|
||||
range 1 255
|
||||
help
|
||||
Number of advertising buffers for BLE packets available.
|
||||
|
||||
endif # BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_IVU_DIVIDER
|
||||
int "Divider for IV Update state refresh timer"
|
||||
default 4
|
||||
@@ -871,104 +933,138 @@ if BLE_MESH
|
||||
uses 0 as the timeout value when sending acknowledged messages, then
|
||||
the default value will be used which is four seconds.
|
||||
|
||||
menu "Support for BLE Mesh Client Models"
|
||||
menu "Support for BLE Mesh Foundation models"
|
||||
|
||||
config BLE_MESH_CFG_CLI
|
||||
bool "Configuration Client Model"
|
||||
bool "Configuration Client model"
|
||||
help
|
||||
Enable support for Configuration client model.
|
||||
Enable support for Configuration Client model.
|
||||
|
||||
config BLE_MESH_HEALTH_CLI
|
||||
bool "Health Client Model"
|
||||
bool "Health Client model"
|
||||
help
|
||||
Enable support for Health client model.
|
||||
Enable support for Health Client model.
|
||||
|
||||
config BLE_MESH_HEALTH_SRV
|
||||
bool "Health Server model"
|
||||
default y
|
||||
help
|
||||
Enable support for Health Server model.
|
||||
|
||||
endmenu #Support for BLE Mesh Foundation models
|
||||
|
||||
menu "Support for BLE Mesh Client/Server models"
|
||||
|
||||
config BLE_MESH_GENERIC_ONOFF_CLI
|
||||
bool "Generic OnOff Client Model"
|
||||
bool "Generic OnOff Client model"
|
||||
help
|
||||
Enable support for Generic OnOff client model.
|
||||
Enable support for Generic OnOff Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_LEVEL_CLI
|
||||
bool "Generic Level Client Model"
|
||||
bool "Generic Level Client model"
|
||||
help
|
||||
Enable support for Generic Level client model.
|
||||
Enable support for Generic Level Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI
|
||||
bool "Generic Default Transition Time Client Model"
|
||||
bool "Generic Default Transition Time Client model"
|
||||
help
|
||||
Enable support for Generic Default Transition Time client model.
|
||||
Enable support for Generic Default Transition Time Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_POWER_ONOFF_CLI
|
||||
bool "Generic Power OnOff Client Model"
|
||||
bool "Generic Power OnOff Client model"
|
||||
help
|
||||
Enable support for Generic Power OnOff client model.
|
||||
Enable support for Generic Power OnOff Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_POWER_LEVEL_CLI
|
||||
bool "Generic Power Level Client Model"
|
||||
bool "Generic Power Level Client model"
|
||||
help
|
||||
Enable support for Generic Power Level client model.
|
||||
Enable support for Generic Power Level Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_BATTERY_CLI
|
||||
bool "Generic Battery Client Model"
|
||||
bool "Generic Battery Client model"
|
||||
help
|
||||
Enable support for Generic Battery client model.
|
||||
Enable support for Generic Battery Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_LOCATION_CLI
|
||||
bool "Generic Location Client Model"
|
||||
bool "Generic Location Client model"
|
||||
help
|
||||
Enable support for Generic Location client model.
|
||||
Enable support for Generic Location Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_PROPERTY_CLI
|
||||
bool "Generic Property Client Model"
|
||||
bool "Generic Property Client model"
|
||||
help
|
||||
Enable support for Generic Property client model.
|
||||
Enable support for Generic Property Client model.
|
||||
|
||||
config BLE_MESH_SENSOR_CLI
|
||||
bool "Sensor Client Model"
|
||||
bool "Sensor Client model"
|
||||
help
|
||||
Enable support for Sensor client model.
|
||||
Enable support for Sensor Client model.
|
||||
|
||||
config BLE_MESH_TIME_CLI
|
||||
bool "Time Client Model"
|
||||
bool "Time Client model"
|
||||
help
|
||||
Enable support for Time client model.
|
||||
Enable support for Time Client model.
|
||||
|
||||
config BLE_MESH_SCENE_CLI
|
||||
bool "Scene Client Model"
|
||||
bool "Scene Client model"
|
||||
help
|
||||
Enable support for Scene client model.
|
||||
Enable support for Scene Client model.
|
||||
|
||||
config BLE_MESH_SCHEDULER_CLI
|
||||
bool "Scheduler Client Model"
|
||||
bool "Scheduler Client model"
|
||||
help
|
||||
Enable support for Scheduler client model.
|
||||
Enable support for Scheduler Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_LIGHTNESS_CLI
|
||||
bool "Light Lightness Client Model"
|
||||
bool "Light Lightness Client model"
|
||||
help
|
||||
Enable support for Light Lightness client model.
|
||||
Enable support for Light Lightness Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_CTL_CLI
|
||||
bool "Light CTL Client Model"
|
||||
bool "Light CTL Client model"
|
||||
help
|
||||
Enable support for Light CTL client model.
|
||||
Enable support for Light CTL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_HSL_CLI
|
||||
bool "Light HSL Client Model"
|
||||
bool "Light HSL Client model"
|
||||
help
|
||||
Enable support for Light HSL client model.
|
||||
Enable support for Light HSL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_XYL_CLI
|
||||
bool "Light XYL Client Model"
|
||||
bool "Light XYL Client model"
|
||||
help
|
||||
Enable support for Light XYL client model.
|
||||
Enable support for Light XYL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_LC_CLI
|
||||
bool "Light LC Client Model"
|
||||
bool "Light LC Client model"
|
||||
help
|
||||
Enable support for Light LC client model.
|
||||
Enable support for Light LC Client model.
|
||||
|
||||
endmenu
|
||||
config BLE_MESH_GENERIC_SERVER
|
||||
bool "Generic server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Generic server models.
|
||||
|
||||
config BLE_MESH_SENSOR_SERVER
|
||||
bool "Sensor server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Sensor server models.
|
||||
|
||||
config BLE_MESH_TIME_SCENE_SERVER
|
||||
bool "Time and Scenes server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Time and Scenes server models.
|
||||
|
||||
config BLE_MESH_LIGHTING_SERVER
|
||||
bool "Lighting server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Lighting server models.
|
||||
|
||||
endmenu #Support for BLE Mesh Client/Server models
|
||||
|
||||
config BLE_MESH_IV_UPDATE_TEST
|
||||
bool "Test the IV Update Procedure"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -15,19 +15,25 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
#include "btc_ble_mesh_ble.h"
|
||||
#include "esp_ble_mesh_ble_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
||||
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_BLE_MESH_BLE_COEX, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t *param,
|
||||
const esp_ble_mesh_ble_adv_data_t *data)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_ble_mesh_ble_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (param == NULL) {
|
||||
@@ -37,21 +43,21 @@ esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADVERTISING;
|
||||
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
||||
msg.act = BTC_BLE_MESH_ACT_START_BLE_ADV;
|
||||
|
||||
memcpy(&arg.start_ble_advertising.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
|
||||
memcpy(&arg.start_ble_adv.param, param, sizeof(esp_ble_mesh_ble_adv_param_t));
|
||||
if (data) {
|
||||
memcpy(&arg.start_ble_advertising.data, data, sizeof(esp_ble_mesh_ble_adv_data_t));
|
||||
memcpy(&arg.start_ble_adv.data, data, sizeof(esp_ble_mesh_ble_adv_data_t));
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_ble_mesh_ble_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
|
||||
@@ -61,13 +67,44 @@ esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index)
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADVERTISING;
|
||||
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
||||
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_ADV;
|
||||
|
||||
arg.stop_ble_advertising.index = index;
|
||||
arg.stop_ble_adv.index = index;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
||||
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param)
|
||||
{
|
||||
btc_ble_mesh_ble_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
||||
msg.act = BTC_BLE_MESH_ACT_START_BLE_SCAN;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
esp_err_t esp_ble_mesh_stop_ble_scanning(void)
|
||||
{
|
||||
btc_ble_mesh_ble_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
||||
msg.act = BTC_BLE_MESH_ACT_STOP_BLE_SCAN;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_ble_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|
||||
|
||||
@@ -69,6 +69,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
@@ -89,4 +90,4 @@ esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
@@ -128,3 +129,87 @@ esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint1
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
|
||||
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx)
|
||||
{
|
||||
return btc_ble_mesh_node_get_local_net_key(net_idx);
|
||||
}
|
||||
|
||||
const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx)
|
||||
{
|
||||
return btc_ble_mesh_node_get_local_app_key(app_idx);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (net_key == NULL || net_idx > 0xFFF) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY;
|
||||
|
||||
arg.node_add_local_net_key.net_idx = net_idx;
|
||||
memcpy(arg.node_add_local_net_key.net_key, net_key, 16);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (app_key == NULL || net_idx > 0xFFF || app_idx > 0xFFF) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY;
|
||||
|
||||
arg.node_add_local_app_key.net_idx = net_idx;
|
||||
arg.node_add_local_app_key.app_idx = app_idx;
|
||||
memcpy(arg.node_add_local_app_key.app_key, app_key, 16);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t app_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) || app_idx > 0xFFF) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL;
|
||||
|
||||
arg.node_local_mod_app_bind.element_addr = element_addr;
|
||||
arg.node_local_mod_app_bind.model_id = model_id;
|
||||
arg.node_local_mod_app_bind.company_id = company_id;
|
||||
arg.node_local_mod_app_bind.app_idx = app_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
@@ -164,6 +164,7 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
|
||||
return btc_ble_mesh_client_model_init(model);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
if (model == NULL) {
|
||||
@@ -174,6 +175,7 @@ esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
||||
|
||||
return btc_ble_mesh_client_model_deinit(model);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
@@ -220,6 +222,7 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
|
||||
length, data, 0, false, device_role);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_SERVER_MODEL
|
||||
esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
esp_ble_mesh_server_state_value_t *value)
|
||||
@@ -244,6 +247,7 @@ esp_err_t esp_ble_mesh_server_model_update_state(esp_ble_mesh_model_t *model,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_model_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
|
||||
|
||||
esp_err_t esp_ble_mesh_node_local_reset(void)
|
||||
{
|
||||
@@ -524,6 +528,246 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx)
|
||||
{
|
||||
return bt_mesh_provisioner_local_net_key_get(net_idx);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
|
||||
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV;
|
||||
|
||||
arg.enable_heartbeat_recv.enable = enable;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (type > ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE;
|
||||
|
||||
arg.set_heartbeat_filter_type.type = type;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (op > ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE || info == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_src) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(info->hb_dst) &&
|
||||
!ESP_BLE_MESH_ADDR_IS_GROUP(info->hb_dst)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO;
|
||||
|
||||
arg.set_heartbeat_filter_info.op = op;
|
||||
arg.set_heartbeat_filter_info.hb_src = info->hb_src;
|
||||
arg.set_heartbeat_filter_info.hb_dst = info->hb_dst;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER_RECV_HB */
|
||||
|
||||
#if CONFIG_BLE_MESH_SETTINGS
|
||||
esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SETTINGS */
|
||||
|
||||
#if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX;
|
||||
|
||||
arg.open_settings_with_index.index = index;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID;
|
||||
|
||||
strncpy(arg.open_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX;
|
||||
|
||||
arg.close_settings_with_index.index = index;
|
||||
arg.close_settings_with_index.erase = erase;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID;
|
||||
|
||||
strncpy(arg.close_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
|
||||
arg.close_settings_with_uid.erase = erase;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX;
|
||||
|
||||
arg.delete_settings_with_index.index = index;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID;
|
||||
|
||||
strncpy(arg.delete_settings_with_uid.uid, uid, ESP_BLE_MESH_SETTINGS_UID_SIZE);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index)
|
||||
{
|
||||
if (index >= CONFIG_BLE_MESH_MAX_NVS_NAMESPACE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_settings_uid(index);
|
||||
}
|
||||
|
||||
uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid)
|
||||
{
|
||||
if (!uid || strlen(uid) > ESP_BLE_MESH_SETTINGS_UID_SIZE) {
|
||||
return ESP_BLE_MESH_INVALID_SETTINGS_IDX;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_settings_index(uid);
|
||||
}
|
||||
|
||||
uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_free_settings_count();
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE */
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2017-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@@ -21,6 +21,106 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This enum value is the event of BLE operations */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */
|
||||
ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */
|
||||
ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT, /*!< Start BLE scanning completion event */
|
||||
ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT, /*!< Stop BLE scanning completion event */
|
||||
ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT, /*!< Scanning BLE advertising packets event */
|
||||
ESP_BLE_MESH_BLE_EVT_MAX,
|
||||
} esp_ble_mesh_ble_cb_event_t;
|
||||
|
||||
/** BLE operation callback parameters */
|
||||
typedef union {
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of starting BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} start_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of stopping BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} stop_ble_advertising_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of starting BLE scanning */
|
||||
} start_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of stopping BLE scanning */
|
||||
} stop_ble_scan_comp; /*!< Event parameters of ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT
|
||||
*/
|
||||
struct {
|
||||
uint8_t addr[6]; /*!< Device address */
|
||||
uint8_t addr_type; /*!< Device address type */
|
||||
uint8_t adv_type; /*!< Advertising data type */
|
||||
uint8_t *data; /*!< Advertising data */
|
||||
uint16_t length; /*!< Advertising data length */
|
||||
int8_t rssi; /*!< RSSI of the advertising packet */
|
||||
} scan_ble_adv_pkt; /*!< Event parameters of ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT */
|
||||
} esp_ble_mesh_ble_cb_param_t;
|
||||
|
||||
/**
|
||||
* @brief BLE scanning callback function type
|
||||
*
|
||||
* @param event: BLE scanning callback event type
|
||||
* @param param: BLE scanning callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_ble_cb_t)(esp_ble_mesh_ble_cb_event_t event,
|
||||
esp_ble_mesh_ble_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE scanning callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the BLE scaning callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_ble_callback(esp_ble_mesh_ble_cb_t callback);
|
||||
|
||||
/** Count for sending BLE advertising packet infinitely */
|
||||
#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF
|
||||
|
||||
/*!< This enum value is the priority of BLE advertising packet */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_LOW,
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
|
||||
} esp_ble_mesh_ble_adv_priority_t;
|
||||
|
||||
/** Context of BLE advertising parameters. */
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< BLE advertising interval */
|
||||
uint8_t adv_type; /*!< BLE advertising type */
|
||||
uint8_t own_addr_type; /*!< Own address type */
|
||||
uint8_t peer_addr_type; /*!< Peer address type */
|
||||
uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */
|
||||
uint16_t duration; /*!< Duration is milliseconds */
|
||||
uint16_t period; /*!< Period in milliseconds */
|
||||
uint16_t count; /*!< Number of advertising duration */
|
||||
uint8_t priority:2; /*!< Priority of BLE advertising packet */
|
||||
} esp_ble_mesh_ble_adv_param_t;
|
||||
|
||||
/** Context of BLE advertising data. */
|
||||
typedef struct {
|
||||
uint8_t adv_data_len; /*!< Advertising data length */
|
||||
uint8_t adv_data[31]; /*!< Advertising data */
|
||||
uint8_t scan_rsp_data_len; /*!< Scan response data length */
|
||||
uint8_t scan_rsp_data[31]; /*!< Scan response data */
|
||||
} esp_ble_mesh_ble_adv_data_t;
|
||||
|
||||
/**
|
||||
* @brief This function is called to start BLE advertising with the corresponding data
|
||||
* and parameters while BLE Mesh is working at the same time.
|
||||
@@ -58,6 +158,31 @@ esp_err_t esp_ble_mesh_start_ble_advertising(const esp_ble_mesh_ble_adv_param_t
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index);
|
||||
|
||||
/** Context of BLE scanning parameters. */
|
||||
typedef struct {
|
||||
uint32_t duration; /*!< Duration used to scan normal BLE advertising packets */
|
||||
} esp_ble_mesh_ble_scan_param_t;
|
||||
|
||||
/**
|
||||
* @brief This function is called to start scanning normal BLE advertising packets
|
||||
* and notifying the packets to the application layer.
|
||||
*
|
||||
* @param[in] param: Pointer to the BLE scanning parameters
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_start_ble_scanning(esp_ble_mesh_ble_scan_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop notifying normal BLE advertising packets
|
||||
* to the application layer.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_stop_ble_scanning(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -142,6 +142,72 @@ esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_
|
||||
esp_err_t esp_ble_mesh_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to get the local NetKey.
|
||||
*
|
||||
* @param[in] net_idx: NetKey index.
|
||||
*
|
||||
* @return NetKey on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_node_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to get the local AppKey.
|
||||
*
|
||||
* @param[in] app_idx: AppKey index.
|
||||
*
|
||||
* @return AppKey on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_node_get_local_app_key(uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to add a local NetKey.
|
||||
*
|
||||
* @param[in] net_key: NetKey to be added.
|
||||
* @param[in] net_idx: NetKey Index.
|
||||
*
|
||||
* @note This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to add a local AppKey.
|
||||
*
|
||||
* @param[in] app_key: AppKey to be added.
|
||||
* @param[in] net_idx: NetKey Index.
|
||||
* @param[in] app_idx: AppKey Index.
|
||||
*
|
||||
* @note The net_idx must be an existing one.
|
||||
* This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Node to bind AppKey to model locally.
|
||||
*
|
||||
* @param[in] element_addr: Node local element address
|
||||
* @param[in] company_id: Node local company id
|
||||
* @param[in] model_id: Node local model id
|
||||
* @param[in] app_idx: Node local appkey index
|
||||
*
|
||||
* @note If going to bind app_key with local vendor model, the company_id
|
||||
* shall be set to 0xFFFF.
|
||||
* This function can only be called after the device is provisioned.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_bind_app_key_to_local_model(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t app_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -413,6 +413,231 @@ esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to enable or disable receiving
|
||||
* heartbeat messages.
|
||||
*
|
||||
* @note If enabling receiving heartbeat message successfully, the filter will
|
||||
* be an empty rejectlist by default, which means all heartbeat messages
|
||||
* received by the Provisioner will be reported to the application layer.
|
||||
*
|
||||
* @param[in] enable: Enable or disable receiving heartbeat messages.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_recv_heartbeat(bool enable);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set the heartbeat filter type.
|
||||
*
|
||||
* @note 1. If the filter type is not the same with the current value, then all the
|
||||
* filter entries will be cleaned.
|
||||
* 2. If the previous type is rejectlist, and changed to acceptlist, then the
|
||||
* filter will be an empty acceptlist, which means no heartbeat messages
|
||||
* will be reported. Users need to add SRC or DST into the filter entry,
|
||||
* then heartbeat messages from the SRC or to the DST will be reported.
|
||||
*
|
||||
* @param[in] type: Heartbeat filter type (acceptlist or rejectlist).
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_type(uint8_t type);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to add or remove a heartbeat filter entry.
|
||||
*
|
||||
* @note 1. If the operation is "ADD", the "hb_src" can be set to the SRC (can only be a
|
||||
* unicast address) of heartbeat messages, and the "hb_dst" can be set to the
|
||||
* DST (unicast address or group address), at least one of them needs to be set.
|
||||
* - If only one of them is set, the filter entry will only use the configured
|
||||
* SRC or DST to filter heartbeat messages.
|
||||
* - If both of them are set, the SRC and DST will both be used to decide if a
|
||||
* heartbeat message will be handled.
|
||||
* - If SRC or DST already exists in some filter entry, then the corresponding
|
||||
* entry will be cleaned firstly, then a new entry will be allocated to store
|
||||
* the information.
|
||||
* 2. If the operation is "REMOVE", the "hb_src" can be set to the SRC (can only be
|
||||
* a unicast address) of heartbeat messages, and the "hb_dst" can be set to the
|
||||
* DST (unicast address or group address), at least one of them needs to be set.
|
||||
* - The filter entry with the same SRC or DST will be removed.
|
||||
*
|
||||
* @param[in] op: Add or REMOVE
|
||||
* @param[in] info: Heartbeat filter entry information, including:
|
||||
* hb_src - Heartbeat source address;
|
||||
* hb_dst - Heartbeat destination address;
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_heartbeat_filter_info(uint8_t op, esp_ble_mesh_heartbeat_filter_info_t *info);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to directly erase the mesh
|
||||
* information from nvs namespace.
|
||||
*
|
||||
* @note This function can be invoked when the mesh stack is not initialized
|
||||
* or has been de-initialized.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_direct_erase_settings(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to open a nvs namespace
|
||||
* for storing mesh information.
|
||||
*
|
||||
* @note Before open another nvs namespace, the previously opened nvs
|
||||
* namespace must be closed firstly.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_index(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to open a nvs namespace
|
||||
* for storing mesh information.
|
||||
*
|
||||
* @note Before open another nvs namespace, the previously opened nvs
|
||||
* namespace must be closed firstly.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_open_settings_with_uid(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to close a nvs namespace
|
||||
* which is opened previously for storing mesh information.
|
||||
*
|
||||
* @note 1. Before closing the nvs namespace, it must be open.
|
||||
* 2. When the function is invoked, the Provisioner functionality
|
||||
* will be disabled firstly, and:
|
||||
* a) If the "erase" flag is set to false, the mesh information
|
||||
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
|
||||
* from the mesh stack.
|
||||
* b) If the "erase" flag is set to true, the mesh information
|
||||
* stored in the nvs namespace will also be erased besides
|
||||
* been cleaned from the mesh stack.
|
||||
* 3. If Provisioner tries to work properly again, we can invoke the
|
||||
* open function to open a new nvs namespace or a previously added
|
||||
* one, and restore the mesh information from it if not erased.
|
||||
* 4. The working process shall be as following:
|
||||
* a) Open settings A
|
||||
* b) Start to provision and control nodes
|
||||
* c) Close settings A
|
||||
* d) Open settings B
|
||||
* e) Start to provision and control other nodes
|
||||
* f) Close settings B
|
||||
* g) ......
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
* @param[in] erase: Indicate if erasing mesh information.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_index(uint8_t index, bool erase);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to close a nvs namespace
|
||||
* which is opened previously for storing mesh information.
|
||||
*
|
||||
* @note 1. Before closing the nvs namespace, it must be open.
|
||||
* 2. When the function is invoked, the Provisioner functionality
|
||||
* will be disabled firstly, and:
|
||||
* a) If the "erase" flag is set to false, the mesh information
|
||||
* will be cleaned (e.g. removing NetKey, AppKey, nodes, etc)
|
||||
* from the mesh stack.
|
||||
* b) If the "erase" flag is set to true, the mesh information
|
||||
* stored in the nvs namespace will also be erased besides
|
||||
* been cleaned from the mesh stack.
|
||||
* 3. If Provisioner tries to work properly again, we can invoke the
|
||||
* open function to open a new nvs namespace or a previously added
|
||||
* one, and restore the mesh information from it if not erased.
|
||||
* 4. The working process shall be as following:
|
||||
* a) Open settings A
|
||||
* b) Start to provision and control nodes
|
||||
* c) Close settings A
|
||||
* d) Open settings B
|
||||
* e) Start to provision and control other nodes
|
||||
* f) Close settings B
|
||||
* g) ......
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
* @param[in] erase: Indicate if erasing mesh information.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_close_settings_with_uid(const char *uid, bool erase);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to erase the mesh information
|
||||
* and settings user id from a nvs namespace.
|
||||
*
|
||||
* @note When this function is called, the nvs namespace must not be open.
|
||||
* This function is used to erase the mesh information and settings
|
||||
* user id which are not used currently.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_index(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to erase the mesh information
|
||||
* and settings user id from a nvs namespace.
|
||||
*
|
||||
* @note When this function is called, the nvs namespace must not be open.
|
||||
* This function is used to erase the mesh information and settings
|
||||
* user id which are not used currently.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_settings_with_uid(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get settings user id.
|
||||
*
|
||||
* @param[in] index: Settings index.
|
||||
*
|
||||
* @return Setting user id on success or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const char *esp_ble_mesh_provisioner_get_settings_uid(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get settings index.
|
||||
*
|
||||
* @param[in] uid: Settings user id.
|
||||
*
|
||||
* @return Settings index.
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ble_mesh_provisioner_get_settings_index(const char *uid);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the number of free
|
||||
* settings user id.
|
||||
*
|
||||
* @return Number of free settings user id.
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ble_mesh_provisioner_get_free_settings_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get fast provisioning application key.
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_common.h"
|
||||
#include "proxy_server.h"
|
||||
#include "provisioner_main.h"
|
||||
@@ -50,6 +51,12 @@ extern "C" {
|
||||
/*!< The maximum length of a BLE Mesh unprovisioned device name */
|
||||
#define ESP_BLE_MESH_DEVICE_NAME_MAX_LEN DEVICE_NAME_SIZE
|
||||
|
||||
/*!< The maximum length of settings user id */
|
||||
#define ESP_BLE_MESH_SETTINGS_UID_SIZE 20
|
||||
|
||||
/*!< Invalid settings index */
|
||||
#define ESP_BLE_MESH_INVALID_SETTINGS_IDX 0xFF
|
||||
|
||||
/*!< Define the BLE Mesh octet 16 bytes size */
|
||||
#define ESP_BLE_MESH_OCTET16_LEN 16
|
||||
typedef uint8_t esp_ble_mesh_octet16_t[ESP_BLE_MESH_OCTET16_LEN];
|
||||
@@ -468,8 +475,10 @@ typedef struct {
|
||||
/** Callback used during model initialization. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t init_cb;
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
/** Callback used during model deinitialization. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t deinit_cb;
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
} esp_ble_mesh_model_cbs_t;
|
||||
|
||||
/** Abstraction that describes a Mesh Model instance.
|
||||
@@ -768,35 +777,19 @@ typedef enum {
|
||||
PROXY_FILTER_BLACKLIST,
|
||||
} esp_ble_mesh_proxy_filter_type_t;
|
||||
|
||||
/** Count for sending BLE advertising packet infinitely */
|
||||
#define ESP_BLE_MESH_BLE_ADV_INFINITE 0xFFFF
|
||||
/*!< Provisioner heartbeat filter type */
|
||||
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ACCEPTLIST 0x00
|
||||
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REJECTLIST 0x01
|
||||
|
||||
/*!< This enum value is the priority of BLE advertising packet */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_LOW,
|
||||
ESP_BLE_MESH_BLE_ADV_PRIO_HIGH,
|
||||
} esp_ble_mesh_ble_adv_priority_t;
|
||||
/*!< Provisioner heartbeat filter operation */
|
||||
#define ESP_BLE_MESH_HEARTBEAT_FILTER_ADD 0x00
|
||||
#define ESP_BLE_MESH_HEARTBEAT_FILTER_REMOVE 0x01
|
||||
|
||||
/** Context of BLE advertising parameters. */
|
||||
/** Context of Provisioner heartbeat filter information to be set */
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< BLE advertising interval */
|
||||
uint8_t adv_type; /*!< BLE advertising type */
|
||||
uint8_t own_addr_type; /*!< Own address type */
|
||||
uint8_t peer_addr_type; /*!< Peer address type */
|
||||
uint8_t peer_addr[BD_ADDR_LEN]; /*!< Peer address */
|
||||
uint16_t duration; /*!< Duration is milliseconds */
|
||||
uint16_t period; /*!< Period in milliseconds */
|
||||
uint16_t count; /*!< Number of advertising duration */
|
||||
uint8_t priority:2; /*!< Priority of BLE advertising packet */
|
||||
} esp_ble_mesh_ble_adv_param_t;
|
||||
|
||||
/** Context of BLE advertising data. */
|
||||
typedef struct {
|
||||
uint8_t adv_data_len; /*!< Advertising data length */
|
||||
uint8_t adv_data[31]; /*!< Advertising data */
|
||||
uint8_t scan_rsp_data_len; /*!< Scan response data length */
|
||||
uint8_t scan_rsp_data[31]; /*!< Scan response data */
|
||||
} esp_ble_mesh_ble_adv_data_t;
|
||||
uint16_t hb_src; /*!< Heartbeat source address (unicast address) */
|
||||
uint16_t hb_dst; /*!< Heartbeat destination address (unicast address or group address) */
|
||||
} esp_ble_mesh_heartbeat_filter_info_t;
|
||||
|
||||
/*!< This enum value is the event of node/provisioner/fast provisioning */
|
||||
typedef enum {
|
||||
@@ -818,6 +811,9 @@ typedef enum {
|
||||
ESP_BLE_MESH_NODE_PROXY_IDENTITY_ENABLE_COMP_EVT, /*!< Enable BLE Mesh Proxy Identity advertising completion event */
|
||||
ESP_BLE_MESH_NODE_PROXY_GATT_ENABLE_COMP_EVT, /*!< Enable BLE Mesh GATT Proxy Service completion event */
|
||||
ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT, /*!< Disable BLE Mesh GATT Proxy Service completion event */
|
||||
ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT, /*!< Node add NetKey locally completion event */
|
||||
ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT, /*!< Node add AppKey locally completion event */
|
||||
ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT, /*!< Node bind AppKey to model locally completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT, /*!< Provisioner enable provisioning functionality completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_PROV_DISABLE_COMP_EVT, /*!< Provisioner disable provisioning functionality completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT, /*!< Provisioner receives unprovisioned device beacon event */
|
||||
@@ -846,6 +842,17 @@ typedef enum {
|
||||
ESP_BLE_MESH_PROVISIONER_STORE_NODE_COMP_DATA_COMP_EVT, /*!< Provisioner store node composition data completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_UUID_COMP_EVT, /*!< Provisioner delete node with uuid completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT, /*!< Provisioner delete node with unicast address completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT, /*!< Provisioner start to receive heartbeat message completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT, /*!< Provisioner set the heartbeat filter type completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT, /*!< Provisioner set the heartbeat filter information completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT, /*!< Provisioner receive heartbeat message event */
|
||||
ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT, /*!< Provisioner directly erase settings completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner open settings with index completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner open settings with user id completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner close settings with index completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner close settings with user id completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT, /*!< Provisioner delete settings with index completion event */
|
||||
ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT, /*!< Provisioner delete settings with user id completion event */
|
||||
ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT, /*!< Set fast provisioning information (e.g. unicast address range, net_idx, etc.) completion event */
|
||||
ESP_BLE_MESH_SET_FAST_PROV_ACTION_COMP_EVT, /*!< Set fast provisioning action completion event */
|
||||
ESP_BLE_MESH_HEARTBEAT_MESSAGE_RECV_EVT, /*!< Receive Heartbeat message event */
|
||||
@@ -865,8 +872,6 @@ typedef enum {
|
||||
ESP_BLE_MESH_PROXY_CLIENT_SET_FILTER_TYPE_COMP_EVT, /*!< Proxy Client set filter type completion event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_ADD_FILTER_ADDR_COMP_EVT, /*!< Proxy Client add filter address completion event */
|
||||
ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT, /*!< Proxy Client remove filter address completion event */
|
||||
ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT, /*!< Start BLE advertising completion event */
|
||||
ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT, /*!< Stop BLE advertising completion event */
|
||||
ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model subscribes group address completion event */
|
||||
ESP_BLE_MESH_MODEL_UNSUBSCRIBE_GROUP_ADDR_COMP_EVT, /*!< Local model unsubscribes group address completion event */
|
||||
ESP_BLE_MESH_DEINIT_MESH_COMP_EVT, /*!< De-initialize BLE Mesh stack completion event */
|
||||
@@ -985,6 +990,31 @@ typedef union {
|
||||
struct ble_mesh_proxy_gatt_disable_comp_param {
|
||||
int err_code; /*!< Indicate the result of disabling Mesh Proxy Service */
|
||||
} node_proxy_gatt_disable_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_PROXY_GATT_DISABLE_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_node_add_local_net_key_comp_param {
|
||||
int err_code; /*!< Indicate the result of adding local NetKey by the node */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} node_add_net_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_node_add_local_app_key_comp_param {
|
||||
int err_code; /*!< Indicate the result of adding local AppKey by the node */
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
} node_add_app_key_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_node_bind_local_mod_app_comp_param {
|
||||
int err_code; /*!< Indicate the result of binding AppKey with model by the node */
|
||||
uint16_t element_addr; /*!< Element address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} node_bind_app_key_to_model_comp; /*!< Event parameter of ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT
|
||||
*/
|
||||
@@ -1188,6 +1218,92 @@ typedef union {
|
||||
int err_code; /*!< Indicate the result of deleting node with unicast address by the Provisioner */
|
||||
uint16_t unicast_addr; /*!< Node unicast address */
|
||||
} provisioner_delete_node_with_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_NODE_WITH_ADDR_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of enabling/disabling to receive heartbeat messages by the Provisioner */
|
||||
bool enable; /*!< Indicate enabling or disabling receiving heartbeat messages */
|
||||
} provisioner_enable_heartbeat_recv_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of setting the heartbeat filter type by the Provisioner */
|
||||
uint8_t type; /*!< Type of the filter used for receiving heartbeat messages */
|
||||
} provisioner_set_heartbeat_filter_type_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of setting the heartbeat filter address by the Provisioner */
|
||||
uint8_t op; /*!< Operation (add, remove, clean) */
|
||||
uint16_t hb_src; /*!< Heartbeat source address */
|
||||
uint16_t hb_dst; /*!< Heartbeat destination address */
|
||||
} provisioner_set_heartbeat_filter_info_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT
|
||||
*/
|
||||
struct {
|
||||
uint16_t hb_src; /*!< Heartbeat source address */
|
||||
uint16_t hb_dst; /*!< Heartbeat destination address */
|
||||
uint8_t init_ttl; /*!< Heartbeat InitTTL */
|
||||
uint8_t rx_ttl; /*!< Heartbeat RxTTL */
|
||||
uint8_t hops; /*!< Heartbeat hops (InitTTL - RxTTL + 1) */
|
||||
uint16_t feature; /*!< Bit field of currently active features of the node */
|
||||
int8_t rssi; /*!< RSSI of the heartbeat message */
|
||||
} provisioner_recv_heartbeat; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of directly erasing settings by the Provisioner */
|
||||
} provisioner_direct_erase_settings_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of opening settings with index by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
} provisioner_open_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of opening settings with user id by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
|
||||
} provisioner_open_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of closing settings with index by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
} provisioner_close_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of closing settings with user id by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
|
||||
} provisioner_close_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of deleting settings with index by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
} provisioner_delete_settings_with_index_comp; /*!< Event parameter of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT
|
||||
*/
|
||||
struct {
|
||||
int err_code; /*!< Indicate the result of deleting settings with user id by the Provisioner */
|
||||
uint8_t index; /*!< Index of Provisioner settings */
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1]; /*!< Provisioner settings user id */
|
||||
} provisioner_delete_settings_with_uid_comp; /*!< Event parameters of ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_SET_FAST_PROV_INFO_COMP_EVT
|
||||
*/
|
||||
@@ -1338,20 +1454,6 @@ typedef union {
|
||||
uint8_t conn_handle; /*!< Proxy connection handle */
|
||||
uint16_t net_idx; /*!< Corresponding NetKey Index */
|
||||
} proxy_client_remove_filter_addr_comp; /*!< Event parameter of ESP_BLE_MESH_PROXY_CLIENT_REMOVE_FILTER_ADDR_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_start_ble_advertising_comp_param {
|
||||
int err_code; /*!< Indicate the result of starting BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} start_ble_advertising_comp; /*!< Event parameter of ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT
|
||||
*/
|
||||
struct ble_mesh_stop_ble_advertising_comp_param {
|
||||
int err_code; /*!< Indicate the result of stopping BLE advertising */
|
||||
uint8_t index; /*!< Index of the BLE advertising */
|
||||
} stop_ble_advertising_comp; /*!< Event parameter of ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT */
|
||||
/**
|
||||
* @brief ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT
|
||||
*/
|
||||
@@ -1975,8 +2077,8 @@ typedef struct {
|
||||
int64_t timestamp; /*!< Time when the last message is received */
|
||||
} esp_ble_mesh_last_msg_info_t;
|
||||
|
||||
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response will be sent internally */
|
||||
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response need to be sent in the application */
|
||||
#define ESP_BLE_MESH_SERVER_RSP_BY_APP 0 /*!< Response need to be sent in the application */
|
||||
#define ESP_BLE_MESH_SERVER_AUTO_RSP 1 /*!< Response will be sent internally */
|
||||
|
||||
/** Parameters of the Server Model response control */
|
||||
typedef struct {
|
||||
@@ -2029,6 +2131,11 @@ typedef union {
|
||||
uint16_t temperature; /*!< The value of the Light CTL Temperature state */
|
||||
int16_t delta_uv; /*!< The value of the Light CTL Delta UV state */
|
||||
} light_ctl_temp_delta_uv; /*!< The Light CTL Temperature & Delta UV states */
|
||||
struct {
|
||||
uint16_t lightness; /*!< The value of the Light HSL Lightness state */
|
||||
uint16_t hue; /*!< The value of the Light HSL Hue state */
|
||||
uint16_t saturation; /*!< The value of the Light HSL Saturation state */
|
||||
} light_hsl; /*!< The Light HSL composite state */
|
||||
struct {
|
||||
uint16_t lightness; /*!< The value of the Light HSL Lightness state */
|
||||
} light_hsl_lightness; /*!< The Light HSL Lightness state */
|
||||
@@ -2056,6 +2163,7 @@ typedef enum {
|
||||
ESP_BLE_MESH_LIGHT_LIGHTNESS_LINEAR_STATE,
|
||||
ESP_BLE_MESH_LIGHT_CTL_LIGHTNESS_STATE,
|
||||
ESP_BLE_MESH_LIGHT_CTL_TEMP_DELTA_UV_STATE,
|
||||
ESP_BLE_MESH_LIGHT_HSL_STATE,
|
||||
ESP_BLE_MESH_LIGHT_HSL_LIGHTNESS_STATE,
|
||||
ESP_BLE_MESH_LIGHT_HSL_HUE_STATE,
|
||||
ESP_BLE_MESH_LIGHT_HSL_SATURATION_STATE,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -26,13 +27,6 @@ esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_c
|
||||
return (btc_profile_cb_set(BTC_PID_CONFIG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool config_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
@@ -101,3 +95,11 @@ esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_config_client_args_t), btc_ble_mesh_config_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
|
||||
esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_CONFIG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_generic_model.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -89,10 +90,13 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_generic_client_args_t), btc_ble_mesh_generic_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_GENERIC_SERVER
|
||||
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_GENERIC_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -26,13 +27,6 @@ esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_clien
|
||||
return (btc_profile_cb_set(BTC_PID_HEALTH_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state)
|
||||
{
|
||||
@@ -83,6 +77,15 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_client_args_t), btc_ble_mesh_health_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_HEALTH_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
|
||||
{
|
||||
@@ -103,3 +106,4 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_lighting_model.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -76,10 +77,13 @@ esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_lighting_client_args_t), btc_ble_mesh_lighting_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_LIGHTING_SERVER
|
||||
esp_err_t esp_ble_mesh_register_lighting_server_callback(esp_ble_mesh_lighting_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_LIGHTING_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_sensor_model.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -75,12 +76,13 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_sensor_client_args_t), btc_ble_mesh_sensor_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SENSOR_SERVER
|
||||
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SENSOR_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "btc_ble_mesh_time_scene_model.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
@@ -76,11 +77,13 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_time_scene_client_args_t), btc_ble_mesh_time_scene_client_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback)
|
||||
{
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
|
||||
@@ -367,10 +367,10 @@ typedef struct {
|
||||
|
||||
/** Parameters of Generic Battery Status. */
|
||||
typedef struct {
|
||||
u32_t battery_level : 8; /*!< Value of Generic Battery Level state */
|
||||
u32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
|
||||
u32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */
|
||||
u32_t flags : 8; /*!< Value of Generic Battery Flags state */
|
||||
uint32_t battery_level : 8; /*!< Value of Generic Battery Level state */
|
||||
uint32_t time_to_discharge : 24; /*!< Value of Generic Battery Time to Discharge state */
|
||||
uint32_t time_to_charge : 24; /*!< Value of Generic Battery Time to Charge state */
|
||||
uint32_t flags : 8; /*!< Value of Generic Battery Flags state */
|
||||
} esp_ble_mesh_gen_battery_status_cb_t;
|
||||
|
||||
/** Parameters of Generic Location Global Status. */
|
||||
|
||||
203
components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c
Normal file
203
components/bt/esp_ble_mesh/btc/btc_ble_mesh_ble.c
Normal file
@@ -0,0 +1,203 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "btc_ble_mesh_ble.h"
|
||||
#include "adv.h"
|
||||
#include "scan.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "esp_ble_mesh_ble_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_BLE_COEX_SUPPORT
|
||||
|
||||
static void btc_ble_mesh_ble_copy_req_data(btc_msg_t *msg, void *p_dst, void *p_src)
|
||||
{
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
||||
esp_ble_mesh_ble_cb_param_t *p_dst_data = (esp_ble_mesh_ble_cb_param_t *)p_dst;
|
||||
esp_ble_mesh_ble_cb_param_t *p_src_data = (esp_ble_mesh_ble_cb_param_t *)p_src;
|
||||
|
||||
if (!msg || !p_src_data || !p_dst_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
|
||||
if (p_src_data->scan_ble_adv_pkt.data && p_src_data->scan_ble_adv_pkt.length) {
|
||||
p_dst_data->scan_ble_adv_pkt.length = p_src_data->scan_ble_adv_pkt.length;
|
||||
p_dst_data->scan_ble_adv_pkt.data = bt_mesh_calloc(p_src_data->scan_ble_adv_pkt.length);
|
||||
if (p_dst_data->scan_ble_adv_pkt.data) {
|
||||
memcpy(p_dst_data->scan_ble_adv_pkt.data, p_src_data->scan_ble_adv_pkt.data,
|
||||
p_src_data->scan_ble_adv_pkt.length);
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_ble_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
||||
esp_ble_mesh_ble_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT:
|
||||
if (arg->scan_ble_adv_pkt.data) {
|
||||
bt_mesh_free(arg->scan_ble_adv_pkt.data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_ble_callback(esp_ble_mesh_ble_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLE_MESH_BLE_COEX;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_ble_cb_param_t),
|
||||
btc_ble_mesh_ble_copy_req_data);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
||||
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
|
||||
uint8_t adv_type, uint8_t data[],
|
||||
uint16_t length, int8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_ble_cb_param_t param = {0};
|
||||
|
||||
if (addr == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(param.scan_ble_adv_pkt.addr, addr->val, sizeof(addr->val));
|
||||
param.scan_ble_adv_pkt.addr_type = addr->type;
|
||||
if (data && length) {
|
||||
param.scan_ble_adv_pkt.data = data;
|
||||
param.scan_ble_adv_pkt.length = length;
|
||||
}
|
||||
param.scan_ble_adv_pkt.adv_type = adv_type;
|
||||
param.scan_ble_adv_pkt.rssi = rssi;
|
||||
|
||||
btc_ble_mesh_ble_callback(¶m, ESP_BLE_MESH_SCAN_BLE_ADVERTISING_PKT_EVT);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|
||||
|
||||
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_ble_cb_param_t param = {0};
|
||||
btc_ble_mesh_ble_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_ble_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
case BTC_BLE_MESH_ACT_START_BLE_ADV: {
|
||||
struct bt_mesh_ble_adv_param *set = (struct bt_mesh_ble_adv_param *)&arg->start_ble_adv.param;
|
||||
struct bt_mesh_ble_adv_data *data = NULL;
|
||||
if (arg->start_ble_adv.data.adv_data_len || arg->start_ble_adv.data.scan_rsp_data_len) {
|
||||
data = (struct bt_mesh_ble_adv_data *)&arg->start_ble_adv.data;
|
||||
}
|
||||
|
||||
param.start_ble_advertising_comp.err_code =
|
||||
bt_mesh_start_ble_advertising(set, data, ¶m.start_ble_advertising_comp.index);
|
||||
|
||||
btc_ble_mesh_ble_callback(¶m, ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT);
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_STOP_BLE_ADV:
|
||||
param.stop_ble_advertising_comp.index = arg->stop_ble_adv.index;
|
||||
param.stop_ble_advertising_comp.err_code =
|
||||
bt_mesh_stop_ble_advertising(arg->stop_ble_adv.index);
|
||||
|
||||
btc_ble_mesh_ble_callback(¶m, ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_SCAN
|
||||
case BTC_BLE_MESH_ACT_START_BLE_SCAN:
|
||||
param.start_ble_scan_comp.err_code =
|
||||
bt_mesh_start_ble_scan((struct bt_mesh_ble_scan_param *)&arg->start_ble_scan.param);
|
||||
btc_ble_mesh_ble_callback(¶m, ESP_BLE_MESH_START_BLE_SCANNING_COMP_EVT);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_STOP_BLE_SCAN:
|
||||
param.stop_ble_scan_comp.err_code = bt_mesh_stop_ble_scan();
|
||||
btc_ble_mesh_ble_callback(¶m, ESP_BLE_MESH_STOP_BLE_SCANNING_COMP_EVT);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_SCAN */
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_ble_cb_to_app(esp_ble_mesh_ble_cb_event_t event,
|
||||
esp_ble_mesh_ble_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_ble_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_ble_cb_t)btc_profile_cb_get(BTC_PID_BLE_MESH_BLE_COEX);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_ble_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_ble_cb_param_t *)msg->arg;
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_BLE_EVT_MAX) {
|
||||
btc_ble_mesh_ble_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_ble_free_req_data(msg);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_BLE_COEX_SUPPORT */
|
||||
@@ -17,9 +17,11 @@
|
||||
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
#include "foundation.h"
|
||||
#include "cfg_cli.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
#include "cfg_cli.h"
|
||||
|
||||
/* Configuration Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_config_client_cb_to_app(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
@@ -126,7 +128,7 @@ static void btc_ble_mesh_config_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
{
|
||||
esp_ble_mesh_cfg_client_cb_param_t *p_dest_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_cfg_client_cb_param_t *p_src_data = (esp_ble_mesh_cfg_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -308,10 +310,10 @@ static void btc_ble_mesh_config_client_callback(esp_ble_mesh_cfg_client_cb_param
|
||||
btc_ble_mesh_config_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_cfg_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -362,7 +364,7 @@ void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -679,6 +681,8 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
|
||||
/* Configuration Server Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_config_server_cb_to_app(esp_ble_mesh_cfg_server_cb_event_t event,
|
||||
@@ -709,9 +713,9 @@ static void btc_ble_mesh_config_server_callback(esp_ble_mesh_cfg_server_cb_param
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_cfg_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_cfg_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_generic_model.h"
|
||||
#include "generic_client.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
#include "generic_client.h"
|
||||
|
||||
/* Generic Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_generic_client_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
|
||||
@@ -35,7 +37,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t *dst = (btc_ble_mesh_generic_client_args_t *)p_dest;
|
||||
btc_ble_mesh_generic_client_args_t *src = (btc_ble_mesh_generic_client_args_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -162,7 +164,7 @@ static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_de
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t *p_dest_data = (esp_ble_mesh_generic_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_generic_client_cb_param_t *p_src_data = (esp_ble_mesh_generic_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -378,10 +380,10 @@ static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_
|
||||
btc_ble_mesh_generic_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -432,7 +434,7 @@ void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -530,6 +532,10 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_GENERIC_SERVER
|
||||
|
||||
/* Generic Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_generic_server_cb_to_app(esp_ble_mesh_generic_server_cb_event_t event,
|
||||
@@ -546,7 +552,7 @@ static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_de
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t *p_dest_data = (esp_ble_mesh_generic_server_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_generic_server_cb_param_t *p_src_data = (esp_ble_mesh_generic_server_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -691,9 +697,9 @@ static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_
|
||||
btc_ble_mesh_generic_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
@@ -756,3 +762,5 @@ void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "foundation.h"
|
||||
#include "health_srv.h"
|
||||
#include "health_cli.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
#include "health_cli.h"
|
||||
|
||||
/* Health Client Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_health_client_cb_to_app(esp_ble_mesh_health_client_cb_event_t event,
|
||||
@@ -120,7 +121,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t *p_dest_data = (esp_ble_mesh_health_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_health_client_cb_param_t *p_src_data = (esp_ble_mesh_health_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -242,10 +243,10 @@ static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_pa
|
||||
btc_ble_mesh_health_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len)
|
||||
const uint8_t *val, uint16_t len)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -296,7 +297,7 @@ void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -457,6 +458,11 @@ void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
#include "health_srv.h"
|
||||
|
||||
/* Health Server Model related functions */
|
||||
|
||||
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
|
||||
@@ -596,7 +602,7 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id)
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
@@ -607,7 +613,7 @@ void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t c
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id)
|
||||
uint8_t test_id, uint16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
@@ -618,7 +624,7 @@ void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time)
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
@@ -636,3 +642,4 @@ void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
|
||||
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_lighting_model.h"
|
||||
#include "lighting_client.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
#include "lighting_client.h"
|
||||
|
||||
/* Lighting Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lighting_client_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
|
||||
@@ -118,7 +120,7 @@ static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_d
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t *p_dest_data = (esp_ble_mesh_light_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_light_client_cb_param_t *p_src_data = (esp_ble_mesh_light_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -222,10 +224,10 @@ static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_p
|
||||
btc_ble_mesh_lighting_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -276,7 +278,7 @@ void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -374,6 +376,10 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_LIGHTING_SERVER
|
||||
|
||||
/* Lighting Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_lighting_server_cb_to_app(esp_ble_mesh_lighting_server_cb_event_t event,
|
||||
@@ -390,7 +396,7 @@ static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_d
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t *p_dest_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_lighting_server_cb_param_t *p_src_data = (esp_ble_mesh_lighting_server_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -503,9 +509,9 @@ static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_c
|
||||
btc_ble_mesh_lighting_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
@@ -570,4 +576,6 @@ void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
|
||||
@@ -29,19 +29,34 @@
|
||||
#include "mesh.h"
|
||||
#include "access.h"
|
||||
#include "prov.h"
|
||||
#include "settings_uid.h"
|
||||
#include "proxy_server.h"
|
||||
#include "proxy_client.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "provisioner_main.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
#include "cfg_cli.h"
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
#include "health_cli.h"
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
#include "cfg_srv.h"
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
#include "health_srv.h"
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
#include "generic_client.h"
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
#include "lighting_client.h"
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
#include "sensor_client.h"
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
#include "time_scene_client.h"
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
#include "client_common.h"
|
||||
#include "state_binding.h"
|
||||
#include "local_operation.h"
|
||||
@@ -452,7 +467,7 @@ static void btc_ble_mesh_client_model_timeout_cb(struct k_work *work)
|
||||
|
||||
static void btc_ble_mesh_model_send_comp_cb(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
u32_t opcode, int err)
|
||||
uint32_t opcode, int err)
|
||||
{
|
||||
esp_ble_mesh_model_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -489,6 +504,7 @@ static int btc_ble_mesh_model_publish_update(struct bt_mesh_model *mod)
|
||||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_SERVER_MODEL
|
||||
static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_server_state_type_t type,
|
||||
int err)
|
||||
@@ -502,6 +518,7 @@ static void btc_ble_mesh_server_model_update_state_comp_cb(esp_ble_mesh_model_t
|
||||
btc_ble_mesh_model_callback(&mesh_param, ESP_BLE_MESH_SERVER_MODEL_UPDATE_STATE_COMP_EVT);
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
|
||||
|
||||
static bt_status_t btc_ble_mesh_prov_callback(esp_ble_mesh_prov_cb_param_t *param, uint8_t act)
|
||||
{
|
||||
@@ -535,7 +552,7 @@ static void btc_ble_mesh_oob_pub_key_cb(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, u32_t num)
|
||||
static int btc_ble_mesh_output_number_cb(bt_mesh_output_action_t act, uint32_t num)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||
@@ -563,7 +580,7 @@ static int btc_ble_mesh_output_string_cb(const char *str)
|
||||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_input_cb(bt_mesh_input_action_t act, u8_t size)
|
||||
static int btc_ble_mesh_input_cb(bt_mesh_input_action_t act, uint8_t size)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||
@@ -601,8 +618,8 @@ static void btc_ble_mesh_link_close_cb(bt_mesh_prov_bearer_t bearer)
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_complete_cb(u16_t net_idx, const u8_t net_key[16],
|
||||
u16_t addr, u8_t flags, u32_t iv_index)
|
||||
static void btc_ble_mesh_complete_cb(uint16_t net_idx, const uint8_t net_key[16],
|
||||
uint16_t addr, uint8_t flags, uint32_t iv_index)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -625,6 +642,16 @@ static void btc_ble_mesh_reset_cb(void)
|
||||
btc_ble_mesh_prov_callback(NULL, ESP_BLE_MESH_NODE_PROV_RESET_EVT);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t *btc_ble_mesh_node_get_local_net_key(uint16_t net_idx)
|
||||
{
|
||||
return bt_mesh_node_get_local_net_key(net_idx);
|
||||
}
|
||||
|
||||
const uint8_t *btc_ble_mesh_node_get_local_app_key(uint16_t app_idx)
|
||||
{
|
||||
return bt_mesh_node_get_local_app_key(app_idx);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
static void btc_ble_mesh_prov_register_complete_cb(int err_code)
|
||||
@@ -648,10 +675,10 @@ static void btc_ble_mesh_prov_set_complete_cb(esp_ble_mesh_prov_cb_param_t *para
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6], const u8_t addr_type,
|
||||
const u8_t adv_type, const u8_t dev_uuid[16],
|
||||
u16_t oob_info, bt_mesh_prov_bearer_t bearer,
|
||||
s8_t rssi)
|
||||
static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const uint8_t addr[6], const uint8_t addr_type,
|
||||
const uint8_t adv_type, const uint8_t dev_uuid[16],
|
||||
uint16_t oob_info, bt_mesh_prov_bearer_t bearer,
|
||||
int8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -675,7 +702,7 @@ static void btc_ble_mesh_provisioner_recv_unprov_adv_pkt_cb(const u8_t addr[6],
|
||||
return;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx)
|
||||
static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(uint8_t link_idx)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||
@@ -688,8 +715,8 @@ static int btc_ble_mesh_provisioner_prov_read_oob_pub_key_cb(u8_t link_idx)
|
||||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, bt_mesh_output_action_t act,
|
||||
u8_t size, u8_t link_idx)
|
||||
static int btc_ble_mesh_provisioner_prov_input_cb(uint8_t method, bt_mesh_output_action_t act,
|
||||
uint8_t size, uint8_t link_idx)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||
@@ -705,8 +732,8 @@ static int btc_ble_mesh_provisioner_prov_input_cb(u8_t method, bt_mesh_output_ac
|
||||
return (ret == BT_STATUS_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, bt_mesh_input_action_t act,
|
||||
void *data, u8_t size, u8_t link_idx)
|
||||
static int btc_ble_mesh_provisioner_prov_output_cb(uint8_t method, bt_mesh_input_action_t act,
|
||||
void *data, uint8_t size, uint8_t link_idx)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
bt_status_t ret = BT_STATUS_SUCCESS;
|
||||
@@ -720,7 +747,7 @@ static int btc_ble_mesh_provisioner_prov_output_cb(u8_t method, bt_mesh_input_ac
|
||||
if (act == BLE_MESH_ENTER_STRING) {
|
||||
strncpy(mesh_param.provisioner_prov_output.string, (char *)data, size);
|
||||
} else {
|
||||
mesh_param.provisioner_prov_output.number = sys_get_le32((u8_t *)data);
|
||||
mesh_param.provisioner_prov_output.number = sys_get_le32((uint8_t *)data);
|
||||
}
|
||||
|
||||
ret = btc_ble_mesh_prov_callback(&mesh_param, ESP_BLE_MESH_PROVISIONER_PROV_OUTPUT_EVT);
|
||||
@@ -739,7 +766,7 @@ static void btc_ble_mesh_provisioner_link_open_cb(bt_mesh_prov_bearer_t bearer)
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, u8_t reason)
|
||||
static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer, uint8_t reason)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -752,9 +779,9 @@ static void btc_ble_mesh_provisioner_link_close_cb(bt_mesh_prov_bearer_t bearer,
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_provisioner_prov_complete_cb(u16_t node_idx, const u8_t device_uuid[16],
|
||||
u16_t unicast_addr, u8_t element_num,
|
||||
u16_t netkey_idx)
|
||||
static void btc_ble_mesh_provisioner_prov_complete_cb(uint16_t node_idx, const uint8_t device_uuid[16],
|
||||
uint16_t unicast_addr, uint8_t element_num,
|
||||
uint16_t netkey_idx)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -785,7 +812,7 @@ esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *nam
|
||||
return (esp_ble_mesh_node_t *)bt_mesh_provisioner_get_node_with_name(name);
|
||||
}
|
||||
|
||||
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
{
|
||||
return bt_mesh_provisioner_get_node_count();
|
||||
}
|
||||
@@ -794,9 +821,46 @@ const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void)
|
||||
{
|
||||
return (const esp_ble_mesh_node_t **)bt_mesh_provisioner_get_node_table_entry();
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
|
||||
static void btc_ble_mesh_provisioner_recv_heartbeat_cb(uint16_t hb_src, uint16_t hb_dst,
|
||||
uint8_t init_ttl, uint8_t rx_ttl,
|
||||
uint8_t hops, uint16_t feat, int8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
mesh_param.provisioner_recv_heartbeat.hb_src = hb_src;
|
||||
mesh_param.provisioner_recv_heartbeat.hb_dst = hb_dst;
|
||||
mesh_param.provisioner_recv_heartbeat.init_ttl = init_ttl;
|
||||
mesh_param.provisioner_recv_heartbeat.rx_ttl = rx_ttl;
|
||||
mesh_param.provisioner_recv_heartbeat.hops = hops;
|
||||
mesh_param.provisioner_recv_heartbeat.feature = feat;
|
||||
mesh_param.provisioner_recv_heartbeat.rssi = rssi;
|
||||
|
||||
btc_ble_mesh_prov_callback(&mesh_param, ESP_BLE_MESH_PROVISIONER_RECV_HEARTBEAT_MESSAGE_EVT);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER_RECV_HB */
|
||||
|
||||
#if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index)
|
||||
{
|
||||
return bt_mesh_provisioner_get_settings_uid(index);
|
||||
}
|
||||
|
||||
uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid)
|
||||
{
|
||||
return bt_mesh_provisioner_get_settings_index(uid);
|
||||
}
|
||||
|
||||
uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void)
|
||||
{
|
||||
return bt_mesh_provisioner_get_free_settings_count();
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE */
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
static void btc_ble_mesh_heartbeat_msg_recv_cb(u8_t hops, u16_t feature)
|
||||
static void btc_ble_mesh_node_recv_heartbeat_cb(uint8_t hops, uint16_t feature)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -810,10 +874,10 @@ static void btc_ble_mesh_heartbeat_msg_recv_cb(u8_t hops, u16_t feature)
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_LOW_POWER
|
||||
static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established)
|
||||
static void btc_ble_mesh_lpn_cb(uint16_t friend_addr, bool established)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
u8_t act = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
@@ -831,10 +895,10 @@ static void btc_ble_mesh_lpn_cb(u16_t friend_addr, bool established)
|
||||
#endif /* CONFIG_BLE_MESH_LOW_POWER */
|
||||
|
||||
#if CONFIG_BLE_MESH_FRIEND
|
||||
void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason)
|
||||
void btc_ble_mesh_friend_cb(bool establish, uint16_t lpn_addr, uint8_t reason)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
u8_t act = 0U;
|
||||
uint8_t act = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
@@ -858,8 +922,8 @@ void btc_ble_mesh_friend_cb(bool establish, u16_t lpn_addr, u8_t reason)
|
||||
#endif /* CONFIG_BLE_MESH_FRIEND */
|
||||
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8_t type,
|
||||
bt_mesh_proxy_adv_ctx_t *ctx, s8_t rssi)
|
||||
static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, uint8_t type,
|
||||
bt_mesh_proxy_adv_ctx_t *ctx, int8_t rssi)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -881,7 +945,7 @@ static void btc_ble_mesh_proxy_client_adv_recv_cb(const bt_mesh_addr_t *addr, u8
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr,
|
||||
u8_t conn_handle, u16_t net_idx)
|
||||
uint8_t conn_handle, uint16_t net_idx)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -901,8 +965,8 @@ static void btc_ble_mesh_proxy_client_connect_cb(const bt_mesh_addr_t *addr,
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, u8_t conn_handle,
|
||||
u16_t net_idx, u8_t reason)
|
||||
static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr, uint8_t conn_handle,
|
||||
uint16_t net_idx, uint8_t reason)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -923,8 +987,8 @@ static void btc_ble_mesh_proxy_client_disconnect_cb(const bt_mesh_addr_t *addr,
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_proxy_client_filter_status_recv_cb(u8_t conn_handle, u16_t src, u16_t net_idx,
|
||||
u8_t filter_type, u16_t list_size)
|
||||
static void btc_ble_mesh_proxy_client_filter_status_recv_cb(uint8_t conn_handle, uint16_t src, uint16_t net_idx,
|
||||
uint8_t filter_type, uint16_t list_size)
|
||||
{
|
||||
esp_ble_mesh_prov_cb_param_t mesh_param = {0};
|
||||
|
||||
@@ -962,10 +1026,12 @@ int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
|
||||
return bt_mesh_client_init((struct bt_mesh_model *)model);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
return bt_mesh_client_deinit((struct bt_mesh_model *)model);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod)
|
||||
{
|
||||
@@ -982,7 +1048,7 @@ uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr
|
||||
return bt_mesh_model_find_group((struct bt_mesh_model *)mod, addr);
|
||||
}
|
||||
|
||||
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr)
|
||||
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr)
|
||||
{
|
||||
return (esp_ble_mesh_elem_t *)bt_mesh_elem_find(addr);
|
||||
}
|
||||
@@ -1010,15 +1076,24 @@ const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void)
|
||||
|
||||
/* Configuration Models */
|
||||
extern const struct bt_mesh_model_op bt_mesh_cfg_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb;
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
extern const struct bt_mesh_model_op bt_mesh_cfg_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
|
||||
/* Health Models */
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
extern const struct bt_mesh_model_op bt_mesh_health_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_health_srv_cb;
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
extern const struct bt_mesh_model_op bt_mesh_health_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
|
||||
/* Generic Client Models */
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_onoff_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_level_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_cli_op[];
|
||||
@@ -1028,22 +1103,34 @@ extern const struct bt_mesh_model_op bt_mesh_gen_battery_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_location_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_property_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_generic_client_cb;
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
|
||||
/* Lighting Client Models */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lightness_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_ctl_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_hsl_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_xyl_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lc_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_lighting_client_cb;
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
|
||||
/* Sensor Client Models */
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
extern const struct bt_mesh_model_op bt_mesh_sensor_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_sensor_client_cb;
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
|
||||
/* Time and Scenes Client Models */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
extern const struct bt_mesh_model_op bt_mesh_time_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_scene_cli_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_scheduler_cli_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_time_scene_client_cb;
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
|
||||
/* Generic Server Models */
|
||||
#if CONFIG_BLE_MESH_GENERIC_SERVER
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_onoff_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_level_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_gen_def_trans_time_srv_op[];
|
||||
@@ -1072,7 +1159,10 @@ extern const struct bt_mesh_model_cb bt_mesh_gen_user_prop_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_gen_admin_prop_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_gen_manu_prop_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_gen_client_prop_srv_cb;
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
|
||||
/* Lighting Server Models */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_SERVER
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lightness_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lightness_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_ctl_srv_op[];
|
||||
@@ -1084,8 +1174,6 @@ extern const struct bt_mesh_model_op bt_mesh_light_hsl_sat_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_hsl_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_xyl_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_xyl_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_lightness_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_lightness_setup_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_ctl_srv_cb;
|
||||
@@ -1097,9 +1185,14 @@ extern const struct bt_mesh_model_cb bt_mesh_light_hsl_sat_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_hsl_setup_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_xyl_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_xyl_setup_srv_cb;
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lc_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_light_lc_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_lc_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_light_lc_setup_srv_cb;
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
|
||||
/* Time and Scenes Server Models */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
extern const struct bt_mesh_model_op bt_mesh_time_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_time_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_scene_srv_op[];
|
||||
@@ -1112,11 +1205,15 @@ extern const struct bt_mesh_model_cb bt_mesh_scene_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_scene_setup_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_scheduler_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_scheduler_setup_srv_cb;
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
|
||||
/* Sensor Server Models */
|
||||
#if CONFIG_BLE_MESH_SENSOR_SERVER
|
||||
extern const struct bt_mesh_model_op bt_mesh_sensor_srv_op[];
|
||||
extern const struct bt_mesh_model_op bt_mesh_sensor_setup_srv_op[];
|
||||
extern const struct bt_mesh_model_cb bt_mesh_sensor_srv_cb;
|
||||
extern const struct bt_mesh_model_cb bt_mesh_sensor_setup_srv_cb;
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
|
||||
static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
@@ -1138,10 +1235,11 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_srv_cb;
|
||||
struct bt_mesh_cfg_srv *srv = (struct bt_mesh_cfg_srv *)model->user_data;
|
||||
if (srv) {
|
||||
srv->hb_sub.func = btc_ble_mesh_heartbeat_msg_recv_cb;
|
||||
srv->hb_sub.func = btc_ble_mesh_node_recv_heartbeat_cb;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
case BLE_MESH_MODEL_ID_CFG_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_cfg_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_cfg_cli_cb;
|
||||
@@ -1151,6 +1249,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
case BLE_MESH_MODEL_ID_HEALTH_SRV: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_srv_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_srv_cb;
|
||||
@@ -1163,6 +1263,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
case BLE_MESH_MODEL_ID_HEALTH_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_health_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_health_cli_cb;
|
||||
@@ -1172,6 +1274,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
#if CONFIG_BLE_MESH_GENERIC_CLIENT
|
||||
case BLE_MESH_MODEL_ID_GEN_ONOFF_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_generic_client_cb;
|
||||
@@ -1244,6 +1348,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_CLIENT */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_CLIENT
|
||||
case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_lighting_client_cb;
|
||||
@@ -1289,6 +1395,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_CLIENT */
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
case BLE_MESH_MODEL_ID_SENSOR_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_client_cb;
|
||||
@@ -1298,6 +1406,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
case BLE_MESH_MODEL_ID_TIME_CLI: {
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_cli_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_scene_client_cb;
|
||||
@@ -1325,6 +1435,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
#if CONFIG_BLE_MESH_GENERIC_SERVER
|
||||
case BLE_MESH_MODEL_ID_GEN_ONOFF_SRV:
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_gen_onoff_srv_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_gen_onoff_srv_cb;
|
||||
@@ -1423,6 +1535,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_GENERIC_SERVER */
|
||||
#if CONFIG_BLE_MESH_LIGHTING_SERVER
|
||||
case BLE_MESH_MODEL_ID_LIGHT_LIGHTNESS_SRV:
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_light_lightness_srv_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_light_lightness_srv_cb;
|
||||
@@ -1514,6 +1628,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_LIGHTING_SERVER */
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
case BLE_MESH_MODEL_ID_TIME_SRV:
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_time_srv_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_time_srv_cb;
|
||||
@@ -1558,6 +1674,8 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
#if CONFIG_BLE_MESH_SENSOR_SERVER
|
||||
case BLE_MESH_MODEL_ID_SENSOR_SRV:
|
||||
model->op = (esp_ble_mesh_model_op_t *)bt_mesh_sensor_srv_op;
|
||||
model->cb = (esp_ble_mesh_model_cbs_t *)&bt_mesh_sensor_srv_cb;
|
||||
@@ -1572,6 +1690,7 @@ static void btc_ble_mesh_model_op_set(esp_ble_mesh_model_t *model)
|
||||
model->pub->update = (esp_ble_mesh_cb_t)btc_ble_mesh_model_publish_update;
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
default:
|
||||
goto set_vnd_op;
|
||||
}
|
||||
@@ -1692,6 +1811,34 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
act = ESP_BLE_MESH_NODE_PROV_INPUT_STRING_COMP_EVT;
|
||||
param.node_prov_input_str_comp.err_code = bt_mesh_input_string(arg->input_string.string);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY:
|
||||
act = ESP_BLE_MESH_NODE_ADD_LOCAL_NET_KEY_COMP_EVT;
|
||||
param.node_add_net_key_comp.net_idx = arg->node_add_local_net_key.net_idx;
|
||||
param.node_add_net_key_comp.err_code =
|
||||
bt_mesh_node_local_net_key_add(arg->node_add_local_net_key.net_idx,
|
||||
arg->node_add_local_net_key.net_key);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY:
|
||||
act = ESP_BLE_MESH_NODE_ADD_LOCAL_APP_KEY_COMP_EVT;
|
||||
param.node_add_app_key_comp.net_idx = arg->node_add_local_app_key.net_idx;
|
||||
param.node_add_app_key_comp.app_idx = arg->node_add_local_app_key.app_idx;
|
||||
param.node_add_app_key_comp.err_code =
|
||||
bt_mesh_node_local_app_key_add(arg->node_add_local_app_key.net_idx,
|
||||
arg->node_add_local_app_key.app_idx,
|
||||
arg->node_add_local_app_key.app_key);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL:
|
||||
act = ESP_BLE_MESH_NODE_BIND_APP_KEY_TO_MODEL_COMP_EVT;
|
||||
param.node_bind_app_key_to_model_comp.element_addr = arg->node_local_mod_app_bind.element_addr;
|
||||
param.node_bind_app_key_to_model_comp.model_id = arg->node_local_mod_app_bind.model_id;
|
||||
param.node_bind_app_key_to_model_comp.company_id = arg->node_local_mod_app_bind.company_id;
|
||||
param.node_bind_app_key_to_model_comp.app_idx = arg->node_local_mod_app_bind.app_idx;
|
||||
param.node_bind_app_key_to_model_comp.err_code =
|
||||
bt_mesh_node_bind_app_key_to_model(arg->node_local_mod_app_bind.element_addr,
|
||||
arg->node_local_mod_app_bind.model_id,
|
||||
arg->node_local_mod_app_bind.company_id,
|
||||
arg->node_local_mod_app_bind.app_idx);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
@@ -1726,13 +1873,15 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_STRING_COMP_EVT;
|
||||
param.provisioner_prov_input_str_comp.err_code =
|
||||
bt_mesh_provisioner_set_oob_input_data(arg->provisioner_input_str.link_idx,
|
||||
(const u8_t *)&arg->provisioner_input_str.string, false);
|
||||
(const uint8_t *)&arg->provisioner_input_str.string,
|
||||
false);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM:
|
||||
act = ESP_BLE_MESH_PROVISIONER_PROV_INPUT_NUMBER_COMP_EVT;
|
||||
param.provisioner_prov_input_num_comp.err_code =
|
||||
bt_mesh_provisioner_set_oob_input_data(arg->provisioner_input_num.link_idx,
|
||||
(const u8_t *)&arg->provisioner_input_num.number, true);
|
||||
(const uint8_t *)&arg->provisioner_input_num.number,
|
||||
true);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_ENABLE:
|
||||
act = ESP_BLE_MESH_PROVISIONER_PROV_ENABLE_COMP_EVT;
|
||||
@@ -1817,8 +1966,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
bt_mesh_provisioner_set_node_name(arg->set_node_name.index, arg->set_node_name.name);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY: {
|
||||
const u8_t *app_key = NULL;
|
||||
const u8_t zero[16] = {0};
|
||||
const uint8_t *app_key = NULL;
|
||||
const uint8_t zero[16] = {0};
|
||||
if (memcmp(arg->add_local_app_key.app_key, zero, 16)) {
|
||||
app_key = arg->add_local_app_key.app_key;
|
||||
}
|
||||
@@ -1851,8 +2000,8 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
arg->local_mod_app_bind.app_idx);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY: {
|
||||
const u8_t *net_key = NULL;
|
||||
const u8_t zero[16] = {0};
|
||||
const uint8_t *net_key = NULL;
|
||||
const uint8_t zero[16] = {0};
|
||||
if (memcmp(arg->add_local_net_key.net_key, zero, 16)) {
|
||||
net_key = arg->add_local_net_key.net_key;
|
||||
}
|
||||
@@ -1888,6 +2037,83 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
param.provisioner_delete_node_with_addr_comp.err_code =
|
||||
bt_mesh_provisioner_delete_node_with_node_addr(arg->delete_node_with_addr.unicast_addr);
|
||||
break;
|
||||
#if CONFIG_BLE_MESH_PROVISIONER_RECV_HB
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV:
|
||||
act = ESP_BLE_MESH_PROVISIONER_ENABLE_HEARTBEAT_RECV_COMP_EVT;
|
||||
param.provisioner_enable_heartbeat_recv_comp.enable = arg->enable_heartbeat_recv.enable;
|
||||
param.provisioner_enable_heartbeat_recv_comp.err_code =
|
||||
bt_mesh_provisioner_recv_heartbeat(arg->enable_heartbeat_recv.enable ?
|
||||
btc_ble_mesh_provisioner_recv_heartbeat_cb : NULL);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE:
|
||||
act = ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE_COMP_EVT;
|
||||
param.provisioner_set_heartbeat_filter_type_comp.type = arg->set_heartbeat_filter_type.type;
|
||||
param.provisioner_set_heartbeat_filter_type_comp.err_code =
|
||||
bt_mesh_provisioner_set_heartbeat_filter_type(arg->set_heartbeat_filter_type.type);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO:
|
||||
act = ESP_BLE_MESH_PROVISIONER_SET_HEARTBEAT_FILTER_INFO_COMP_EVT;
|
||||
param.provisioner_set_heartbeat_filter_info_comp.op = arg->set_heartbeat_filter_info.op;
|
||||
param.provisioner_set_heartbeat_filter_info_comp.hb_src = arg->set_heartbeat_filter_info.hb_src;
|
||||
param.provisioner_set_heartbeat_filter_info_comp.hb_dst = arg->set_heartbeat_filter_info.hb_dst;
|
||||
param.provisioner_set_heartbeat_filter_info_comp.err_code =
|
||||
bt_mesh_provisioner_set_heartbeat_filter_info(arg->set_heartbeat_filter_info.op,
|
||||
arg->set_heartbeat_filter_info.hb_src,
|
||||
arg->set_heartbeat_filter_info.hb_dst);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER_RECV_HB */
|
||||
#if CONFIG_BLE_MESH_SETTINGS
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS:
|
||||
act = ESP_BLE_MESH_PROVISIONER_DRIECT_ERASE_SETTINGS_COMP_EVT;
|
||||
param.provisioner_direct_erase_settings_comp.err_code = bt_mesh_provisioner_direct_erase_settings();
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SETTINGS */
|
||||
#if CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX:
|
||||
act = ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_INDEX_COMP_EVT;
|
||||
param.provisioner_open_settings_with_index_comp.index = arg->open_settings_with_index.index;
|
||||
param.provisioner_open_settings_with_index_comp.err_code =
|
||||
bt_mesh_provisioner_open_settings_with_index(arg->open_settings_with_index.index);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID:
|
||||
act = ESP_BLE_MESH_PROVISIONER_OPEN_SETTINGS_WITH_UID_COMP_EVT;
|
||||
strncpy(param.provisioner_open_settings_with_uid_comp.uid,
|
||||
arg->open_settings_with_uid.uid, ESP_BLE_MESH_SETTINGS_UID_SIZE + 1);
|
||||
param.provisioner_open_settings_with_uid_comp.err_code =
|
||||
bt_mesh_provisioner_open_settings_with_uid(arg->open_settings_with_uid.uid,
|
||||
¶m.provisioner_open_settings_with_uid_comp.index);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX:
|
||||
act = ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX_COMP_EVT;
|
||||
param.provisioner_close_settings_with_index_comp.index = arg->close_settings_with_index.index;
|
||||
param.provisioner_close_settings_with_index_comp.err_code =
|
||||
bt_mesh_provisioner_close_settings_with_index(arg->close_settings_with_index.index,
|
||||
arg->close_settings_with_index.erase);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID:
|
||||
act = ESP_BLE_MESH_PROVISIONER_CLOSE_SETTINGS_WITH_UID_COMP_EVT;
|
||||
strncpy(param.provisioner_close_settings_with_uid_comp.uid,
|
||||
arg->close_settings_with_uid.uid, ESP_BLE_MESH_SETTINGS_UID_SIZE + 1);
|
||||
param.provisioner_close_settings_with_uid_comp.err_code =
|
||||
bt_mesh_provisioner_close_settings_with_uid(arg->close_settings_with_uid.uid,
|
||||
arg->close_settings_with_uid.erase,
|
||||
¶m.provisioner_close_settings_with_uid_comp.index);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX:
|
||||
act = ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_INDEX_COMP_EVT;
|
||||
param.provisioner_delete_settings_with_index_comp.index = arg->delete_settings_with_index.index;
|
||||
param.provisioner_delete_settings_with_index_comp.err_code =
|
||||
bt_mesh_provisioner_delete_settings_with_index(arg->delete_settings_with_index.index);
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID:
|
||||
act = ESP_BLE_MESH_PROVISIONER_DELETE_SETTINGS_WITH_UID_COMP_EVT;
|
||||
strncpy(param.provisioner_delete_settings_with_uid_comp.uid,
|
||||
arg->delete_settings_with_uid.uid, ESP_BLE_MESH_SETTINGS_UID_SIZE + 1);
|
||||
param.provisioner_delete_settings_with_uid_comp.err_code =
|
||||
bt_mesh_provisioner_delete_settings_with_uid(arg->delete_settings_with_uid.uid,
|
||||
¶m.provisioner_delete_settings_with_uid_comp.index);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_USE_MULTIPLE_NAMESPACE */
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
#if CONFIG_BLE_MESH_FAST_PROV
|
||||
case BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO:
|
||||
@@ -1983,26 +2209,6 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_GATT_PROXY_CLIENT */
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
case BTC_BLE_MESH_ACT_START_BLE_ADVERTISING: {
|
||||
struct bt_mesh_ble_adv_param *set = (struct bt_mesh_ble_adv_param *)&arg->start_ble_advertising.param;
|
||||
struct bt_mesh_ble_adv_data *data = NULL;
|
||||
if (arg->start_ble_advertising.data.adv_data_len ||
|
||||
arg->start_ble_advertising.data.scan_rsp_data_len) {
|
||||
data = (struct bt_mesh_ble_adv_data *)&arg->start_ble_advertising.data;
|
||||
}
|
||||
act = ESP_BLE_MESH_START_BLE_ADVERTISING_COMP_EVT;
|
||||
param.start_ble_advertising_comp.err_code =
|
||||
bt_mesh_start_ble_advertising(set, data, ¶m.start_ble_advertising_comp.index);
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_STOP_BLE_ADVERTISING:
|
||||
act = ESP_BLE_MESH_STOP_BLE_ADVERTISING_COMP_EVT;
|
||||
param.stop_ble_advertising_comp.index = arg->stop_ble_advertising.index;
|
||||
param.stop_ble_advertising_comp.err_code =
|
||||
bt_mesh_stop_ble_advertising(arg->stop_ble_advertising.index);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
case BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR:
|
||||
act = ESP_BLE_MESH_MODEL_SUBSCRIBE_GROUP_ADDR_COMP_EVT;
|
||||
param.model_sub_group_addr_comp.element_addr = arg->model_sub_group_addr.element_addr;
|
||||
@@ -2027,10 +2233,12 @@ void btc_ble_mesh_prov_call_handler(btc_msg_t *msg)
|
||||
arg->model_unsub_group_addr.model_id,
|
||||
arg->model_unsub_group_addr.group_addr);
|
||||
break;
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
case BTC_BLE_MESH_ACT_DEINIT_MESH:
|
||||
act = ESP_BLE_MESH_DEINIT_MESH_COMP_EVT;
|
||||
param.deinit_mesh_comp.err_code = bt_mesh_deinit((struct bt_mesh_deinit_param *)&arg->mesh_deinit.param);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
default:
|
||||
BT_WARN("%s, Unknown act %d", __func__, msg->act);
|
||||
return;
|
||||
@@ -2142,6 +2350,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
arg->model_send.opcode, err);
|
||||
break;
|
||||
}
|
||||
#if CONFIG_BLE_MESH_SERVER_MODEL
|
||||
case BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE:
|
||||
err = bt_mesh_update_binding_state(
|
||||
(struct bt_mesh_model *)arg->model_update_state.model, arg->model_update_state.type,
|
||||
@@ -2149,6 +2358,7 @@ void btc_ble_mesh_model_call_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_server_model_update_state_comp_cb(arg->model_update_state.model,
|
||||
arg->model_update_state.type, err);
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_SERVER_MODEL */
|
||||
default:
|
||||
BT_WARN("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_sensor_model.h"
|
||||
#include "sensor_client.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_SENSOR_CLI
|
||||
#include "sensor_client.h"
|
||||
|
||||
/* Sensor Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sensor_client_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
@@ -35,7 +37,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t *dst = (btc_ble_mesh_sensor_client_args_t *)p_dest;
|
||||
btc_ble_mesh_sensor_client_args_t *src = (btc_ble_mesh_sensor_client_args_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -246,7 +248,7 @@ static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_sensor_client_cb_param_t *p_src_data = (esp_ble_mesh_sensor_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -460,10 +462,10 @@ static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_pa
|
||||
btc_ble_mesh_sensor_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -514,7 +516,7 @@ void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -612,6 +614,10 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_CLI */
|
||||
|
||||
#if CONFIG_BLE_MESH_SENSOR_SERVER
|
||||
|
||||
/* Sensor Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_sensor_server_cb_to_app(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
@@ -628,7 +634,7 @@ static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t *p_dest_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_sensor_server_cb_param_t *p_src_data = (esp_ble_mesh_sensor_server_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -823,9 +829,9 @@ static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_pa
|
||||
btc_ble_mesh_sensor_server_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
@@ -888,3 +894,5 @@ void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_SENSOR_SERVER */
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc_ble_mesh_time_scene_model.h"
|
||||
#include "time_scene_client.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_CLIENT
|
||||
#include "time_scene_client.h"
|
||||
|
||||
/* Time and Scenes Client Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_time_scene_client_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
@@ -118,7 +120,7 @@ static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *p_dest_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_dest;
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *p_src_data = (esp_ble_mesh_time_scene_client_cb_param_t *)p_src;
|
||||
u16_t length = 0U;
|
||||
uint16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -224,10 +226,10 @@ static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_clie
|
||||
btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
@@ -278,7 +280,7 @@ void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
@@ -376,6 +378,10 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_CLIENT */
|
||||
|
||||
#if CONFIG_BLE_MESH_TIME_SCENE_SERVER
|
||||
|
||||
/* Time and Scenes Server Models related functions */
|
||||
|
||||
static inline void btc_ble_mesh_time_scene_server_cb_to_app(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
@@ -406,9 +412,9 @@ static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_serv
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_server_cb_param_t), NULL);
|
||||
}
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
const uint8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
@@ -474,3 +480,4 @@ void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_TIME_SCENE_SERVER */
|
||||
|
||||
62
components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h
Normal file
62
components/bt/esp_ble_mesh/btc/include/btc_ble_mesh_ble.h
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _BTC_BLE_MESH_BLE_H_
|
||||
#define _BTC_BLE_MESH_BLE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_manage.h"
|
||||
#include "mesh_bearer_adapt.h"
|
||||
#include "esp_ble_mesh_ble_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
esp_ble_mesh_ble_adv_param_t param;
|
||||
esp_ble_mesh_ble_adv_data_t data;
|
||||
} start_ble_adv;
|
||||
struct {
|
||||
uint8_t index;
|
||||
} stop_ble_adv;
|
||||
struct {
|
||||
esp_ble_mesh_ble_scan_param_t param;
|
||||
} start_ble_scan;
|
||||
struct {
|
||||
/* RFU */
|
||||
} stop_ble_scan;
|
||||
} btc_ble_mesh_ble_args_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_START_BLE_ADV,
|
||||
BTC_BLE_MESH_ACT_STOP_BLE_ADV,
|
||||
BTC_BLE_MESH_ACT_START_BLE_SCAN,
|
||||
BTC_BLE_MESH_ACT_STOP_BLE_SCAN,
|
||||
} btc_ble_mesh_ble_act_t;
|
||||
|
||||
void bt_mesh_ble_scan_cb_evt_to_btc(const bt_mesh_addr_t *addr,
|
||||
uint8_t adv_type, uint8_t data[],
|
||||
uint16_t length, int8_t rssi);
|
||||
|
||||
void btc_ble_mesh_ble_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_ble_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_BLE_H_ */
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_config_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_config_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_config_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
@@ -69,9 +69,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
|
||||
} btc_ble_mesh_config_server_evt_t;
|
||||
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_config_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_generic_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
|
||||
@@ -69,9 +69,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_MAX,
|
||||
} btc_ble_mesh_generic_server_evt_t;
|
||||
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_generic_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_health_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_health_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len);
|
||||
const uint8_t *val, uint16_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
|
||||
@@ -79,12 +79,12 @@ void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, uint16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id);
|
||||
uint8_t test_id, uint16_t company_id);
|
||||
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, uint8_t time);
|
||||
|
||||
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model);
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_lighting_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
|
||||
@@ -70,9 +70,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_MAX,
|
||||
} btc_ble_mesh_lighting_server_evt_t;
|
||||
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_lighting_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_main.h"
|
||||
#include "fast_prov.h"
|
||||
#include "provisioner_prov.h"
|
||||
@@ -38,6 +39,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROXY_IDENTITY_ENABLE,
|
||||
BTC_BLE_MESH_ACT_PROXY_GATT_ENABLE,
|
||||
BTC_BLE_MESH_ACT_PROXY_GATT_DISABLE,
|
||||
BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_NET_KEY,
|
||||
BTC_BLE_MESH_ACT_NODE_ADD_LOCAL_APP_KEY,
|
||||
BTC_BLE_MESH_ACT_NODE_BIND_APP_KEY_TO_MODEL,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_READ_OOB_PUB_KEY,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_STR,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_INPUT_NUM,
|
||||
@@ -59,6 +63,16 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_UUID,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_NODE_WITH_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE_HEARTBEAT_RECV,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_TYPE,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_HEARTBEAT_FILTER_INFO,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DIRECT_ERASE_SETTINGS,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_INDEX,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_OPEN_SETTINGS_WITH_UID,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_INDEX,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_CLOSE_SETTINGS_WITH_UID,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_INDEX,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DELETE_SETTINGS_WITH_UID,
|
||||
BTC_BLE_MESH_ACT_SET_FAST_PROV_INFO,
|
||||
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
|
||||
BTC_BLE_MESH_ACT_LPN_ENABLE,
|
||||
@@ -69,8 +83,6 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_SET_FILTER_TYPE,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_ADD_FILTER_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_REMOVE_FILTER_ADDR,
|
||||
BTC_BLE_MESH_ACT_START_BLE_ADVERTISING,
|
||||
BTC_BLE_MESH_ACT_STOP_BLE_ADVERTISING,
|
||||
BTC_BLE_MESH_ACT_MODEL_SUBSCRIBE_GROUP_ADDR,
|
||||
BTC_BLE_MESH_ACT_MODEL_UNSUBSCRIBE_GROUP_ADDR,
|
||||
BTC_BLE_MESH_ACT_DEINIT_MESH,
|
||||
@@ -109,6 +121,21 @@ typedef union {
|
||||
struct ble_mesh_set_device_name_args {
|
||||
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1];
|
||||
} set_device_name;
|
||||
struct ble_mesh_node_add_local_net_key_args {
|
||||
uint8_t net_key[16];
|
||||
uint16_t net_idx;
|
||||
} node_add_local_net_key;
|
||||
struct ble_mesh_node_add_local_app_key_args {
|
||||
uint8_t app_key[16];
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
} node_add_local_app_key;
|
||||
struct ble_mesh_node_bind_local_mod_app_args {
|
||||
uint16_t element_addr;
|
||||
uint16_t company_id;
|
||||
uint16_t model_id;
|
||||
uint16_t app_idx;
|
||||
} node_local_mod_app_bind;
|
||||
struct ble_mesh_provisioner_read_oob_pub_key_args {
|
||||
uint8_t link_idx;
|
||||
uint8_t pub_key_x[32];
|
||||
@@ -198,6 +225,37 @@ typedef union {
|
||||
struct ble_mesh_provisioner_delete_node_with_addr_args {
|
||||
uint16_t unicast_addr;
|
||||
} delete_node_with_addr;
|
||||
struct {
|
||||
bool enable;
|
||||
} enable_heartbeat_recv;
|
||||
struct {
|
||||
uint8_t type;
|
||||
} set_heartbeat_filter_type;
|
||||
struct {
|
||||
uint8_t op;
|
||||
uint16_t hb_src;
|
||||
uint16_t hb_dst;
|
||||
} set_heartbeat_filter_info;
|
||||
struct {
|
||||
uint8_t index;
|
||||
} open_settings_with_index;
|
||||
struct {
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
|
||||
} open_settings_with_uid;
|
||||
struct {
|
||||
uint8_t index;
|
||||
bool erase;
|
||||
} close_settings_with_index;
|
||||
struct {
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
|
||||
bool erase;
|
||||
} close_settings_with_uid;
|
||||
struct {
|
||||
uint8_t index;
|
||||
} delete_settings_with_index;
|
||||
struct {
|
||||
char uid[ESP_BLE_MESH_SETTINGS_UID_SIZE + 1];
|
||||
} delete_settings_with_uid;
|
||||
struct ble_mesh_set_fast_prov_info_args {
|
||||
uint16_t unicast_min;
|
||||
uint16_t unicast_max;
|
||||
@@ -245,13 +303,6 @@ typedef union {
|
||||
uint16_t addr_num;
|
||||
uint16_t *addr;
|
||||
} proxy_client_remove_filter_addr;
|
||||
struct ble_mesh_start_ble_advertising_args {
|
||||
esp_ble_mesh_ble_adv_param_t param;
|
||||
esp_ble_mesh_ble_adv_data_t data;
|
||||
} start_ble_advertising;
|
||||
struct ble_mesh_stop_ble_advertising_args {
|
||||
uint8_t index;
|
||||
} stop_ble_advertising;
|
||||
struct ble_mesh_model_sub_group_addr_args {
|
||||
uint16_t element_addr;
|
||||
uint16_t company_id;
|
||||
@@ -295,13 +346,17 @@ void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
const uint8_t *btc_ble_mesh_node_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
const uint8_t *btc_ble_mesh_node_get_local_app_key(uint16_t app_idx);
|
||||
|
||||
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
|
||||
|
||||
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
esp_ble_mesh_node_t *btc_ble_mesh_provisioner_get_node_with_name(const char *name);
|
||||
|
||||
u16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
uint16_t btc_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
@@ -315,7 +370,7 @@ uint16_t btc_ble_mesh_get_primary_addr(void);
|
||||
|
||||
uint16_t *btc_ble_mesh_model_find_group(esp_ble_mesh_model_t *mod, uint16_t addr);
|
||||
|
||||
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
|
||||
esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(uint16_t addr);
|
||||
|
||||
uint8_t btc_ble_mesh_elem_count(void);
|
||||
|
||||
@@ -326,6 +381,12 @@ esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, u
|
||||
|
||||
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
|
||||
|
||||
const char *btc_ble_mesh_provisioner_get_settings_uid(uint8_t index);
|
||||
|
||||
uint8_t btc_ble_mesh_provisioner_get_settings_index(const char *uid);
|
||||
|
||||
uint8_t btc_ble_mesh_provisioner_get_free_settings_count(void);
|
||||
|
||||
void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_sensor_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
|
||||
@@ -69,9 +69,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_MAX,
|
||||
} btc_ble_mesh_sensor_server_evt_t;
|
||||
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_sensor_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(uint32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(uint32_t opcode, uint8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
|
||||
@@ -70,9 +70,9 @@ typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_MAX,
|
||||
} btc_ble_mesh_time_scene_server_evt_t;
|
||||
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
void bt_mesh_time_scene_server_cb_evt_to_btc(uint8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
const uint8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#ifndef _BLE_MESH_BUF_H_
|
||||
#define _BLE_MESH_BUF_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_compiler.h"
|
||||
|
||||
@@ -51,7 +52,7 @@ __extension__ ({ \
|
||||
* @param _size Maximum data storage for the buffer.
|
||||
*/
|
||||
#define NET_BUF_SIMPLE_DEFINE(_name, _size) \
|
||||
u8_t net_buf_data_##_name[_size]; \
|
||||
uint8_t net_buf_data_##_name[_size]; \
|
||||
struct net_buf_simple _name = { \
|
||||
.data = net_buf_data_##_name, \
|
||||
.len = 0, \
|
||||
@@ -70,7 +71,7 @@ __extension__ ({ \
|
||||
* @param _size Maximum data storage for the buffer.
|
||||
*/
|
||||
#define NET_BUF_SIMPLE_DEFINE_STATIC(_name, _size) \
|
||||
static u8_t net_buf_data_##_name[_size]; \
|
||||
static uint8_t net_buf_data_##_name[_size]; \
|
||||
static struct net_buf_simple _name = { \
|
||||
.data = net_buf_data_##_name, \
|
||||
.len = 0, \
|
||||
@@ -93,18 +94,18 @@ __extension__ ({ \
|
||||
*/
|
||||
struct net_buf_simple {
|
||||
/** Pointer to the start of data in the buffer. */
|
||||
u8_t *data;
|
||||
uint8_t *data;
|
||||
|
||||
/** Length of the data behind the data pointer. */
|
||||
u16_t len;
|
||||
uint16_t len;
|
||||
|
||||
/** Amount of data that this buffer can store. */
|
||||
u16_t size;
|
||||
uint16_t size;
|
||||
|
||||
/** Start of the data storage. Not to be accessed directly
|
||||
* (the data pointer should be used instead).
|
||||
*/
|
||||
u8_t *__buf;
|
||||
uint8_t *__buf;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -123,13 +124,13 @@ struct net_buf_simple {
|
||||
*
|
||||
* @return Pointer to stack-allocated net_buf_simple object.
|
||||
*/
|
||||
#define NET_BUF_SIMPLE(_size) \
|
||||
((struct net_buf_simple *)(&(struct { \
|
||||
struct net_buf_simple buf; \
|
||||
u8_t data[_size] __net_buf_align; \
|
||||
}) { \
|
||||
.buf.size = _size, \
|
||||
.buf.__buf = NULL, \
|
||||
#define NET_BUF_SIMPLE(_size) \
|
||||
((struct net_buf_simple *)(&(struct { \
|
||||
struct net_buf_simple buf; \
|
||||
uint8_t data[_size] __net_buf_align; \
|
||||
}) { \
|
||||
.buf.size = _size, \
|
||||
.buf.__buf = NULL, \
|
||||
}))
|
||||
|
||||
/**
|
||||
@@ -145,7 +146,7 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
|
||||
size_t reserve_head)
|
||||
{
|
||||
if (!buf->__buf) {
|
||||
buf->__buf = (u8_t *)buf + sizeof(*buf);
|
||||
buf->__buf = (uint8_t *)buf + sizeof(*buf);
|
||||
}
|
||||
|
||||
buf->data = buf->__buf + reserve_head;
|
||||
@@ -229,7 +230,7 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
|
||||
*
|
||||
* @return Pointer to the value added
|
||||
*/
|
||||
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val);
|
||||
uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 16-bit value at the end of the buffer
|
||||
@@ -241,7 +242,7 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 16-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
|
||||
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 16-bit value at the end of the buffer
|
||||
@@ -253,7 +254,7 @@ void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 16-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
|
||||
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
@@ -265,7 +266,7 @@ void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
@@ -277,7 +278,7 @@ void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 32-bit value at the end of the buffer
|
||||
@@ -289,7 +290,7 @@ void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 32-bit value at the end of the buffer
|
||||
@@ -301,7 +302,7 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
@@ -313,7 +314,7 @@ void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
@@ -325,7 +326,7 @@ void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
@@ -337,7 +338,7 @@ void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
@@ -349,7 +350,7 @@ void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be added.
|
||||
*/
|
||||
void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Push data to the beginning of the buffer.
|
||||
@@ -373,7 +374,7 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 16-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val);
|
||||
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 16-bit value to the beginning of the buffer
|
||||
@@ -384,7 +385,7 @@ void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 16-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
|
||||
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 8-bit value to the beginning of the buffer
|
||||
@@ -394,7 +395,7 @@ void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 8-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
|
||||
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
@@ -405,7 +406,7 @@ void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
@@ -416,7 +417,7 @@ void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
@@ -427,7 +428,7 @@ void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
@@ -438,7 +439,7 @@ void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val);
|
||||
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
@@ -449,7 +450,7 @@ void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
@@ -460,7 +461,7 @@ void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
@@ -471,7 +472,7 @@ void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
@@ -482,7 +483,7 @@ void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val);
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be pushed to the buffer.
|
||||
*/
|
||||
void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val);
|
||||
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val);
|
||||
|
||||
/**
|
||||
* @brief Remove data from the beginning of the buffer.
|
||||
@@ -520,7 +521,7 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len);
|
||||
*
|
||||
* @return The 8-bit removed value
|
||||
*/
|
||||
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
|
||||
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 16 bits from the beginning of the buffer.
|
||||
@@ -532,7 +533,7 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 16-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
|
||||
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 16 bits from the beginning of the buffer.
|
||||
@@ -544,7 +545,7 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 16-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
|
||||
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
@@ -556,7 +557,7 @@ u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 24-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
|
||||
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
@@ -568,7 +569,7 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 24-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
|
||||
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 32 bits from the beginning of the buffer.
|
||||
@@ -580,7 +581,7 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 32-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
|
||||
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 32 bits from the beginning of the buffer.
|
||||
@@ -592,7 +593,7 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 32-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
|
||||
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
@@ -604,7 +605,7 @@ u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 48-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
|
||||
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
@@ -616,7 +617,7 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 48-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
|
||||
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
@@ -628,7 +629,7 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 64-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
|
||||
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
@@ -640,7 +641,7 @@ u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 64-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
|
||||
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Get the tail pointer for a buffer.
|
||||
@@ -651,7 +652,7 @@ u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return Tail pointer for the buffer.
|
||||
*/
|
||||
static inline u8_t *net_buf_simple_tail(struct net_buf_simple *buf)
|
||||
static inline uint8_t *net_buf_simple_tail(struct net_buf_simple *buf)
|
||||
{
|
||||
return buf->data + buf->len;
|
||||
}
|
||||
@@ -687,9 +688,9 @@ size_t net_buf_simple_tailroom(struct net_buf_simple *buf);
|
||||
*/
|
||||
struct net_buf_simple_state {
|
||||
/** Offset of the data pointer from the beginning of the storage */
|
||||
u16_t offset;
|
||||
uint16_t offset;
|
||||
/** Length of data */
|
||||
u16_t len;
|
||||
uint16_t len;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -717,7 +718,7 @@ static inline void net_buf_simple_save(struct net_buf_simple *buf,
|
||||
* @param state Stored state.
|
||||
*/
|
||||
static inline void net_buf_simple_restore(struct net_buf_simple *buf,
|
||||
struct net_buf_simple_state *state)
|
||||
struct net_buf_simple_state *state)
|
||||
{
|
||||
buf->data = buf->__buf + state->offset;
|
||||
buf->len = state->len;
|
||||
@@ -760,10 +761,10 @@ struct net_buf {
|
||||
};
|
||||
|
||||
/** Reference count. */
|
||||
u8_t ref;
|
||||
uint8_t ref;
|
||||
|
||||
/** Bit-field of buffer flags. */
|
||||
u8_t flags;
|
||||
uint8_t flags;
|
||||
|
||||
/** Where the buffer should go when freed up. */
|
||||
struct net_buf_pool *pool;
|
||||
@@ -775,32 +776,32 @@ struct net_buf {
|
||||
/* The ABI of this struct must match net_buf_simple */
|
||||
struct {
|
||||
/** Pointer to the start of data in the buffer. */
|
||||
u8_t *data;
|
||||
uint8_t *data;
|
||||
|
||||
/** Length of the data behind the data pointer. */
|
||||
u16_t len;
|
||||
uint16_t len;
|
||||
|
||||
/** Amount of data that this buffer can store. */
|
||||
u16_t size;
|
||||
uint16_t size;
|
||||
|
||||
/** Start of the data storage. Not to be accessed
|
||||
* directly (the data pointer should be used
|
||||
* instead).
|
||||
*/
|
||||
u8_t *__buf;
|
||||
uint8_t *__buf;
|
||||
};
|
||||
|
||||
struct net_buf_simple b;
|
||||
};
|
||||
|
||||
/** System metadata for this buffer. */
|
||||
u8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align;
|
||||
uint8_t user_data[BLE_MESH_NET_BUF_USER_DATA_SIZE] __net_buf_align;
|
||||
};
|
||||
|
||||
struct net_buf_data_cb {
|
||||
u8_t *(*alloc)(struct net_buf *buf, size_t *size, s32_t timeout);
|
||||
u8_t *(*ref)(struct net_buf *buf, u8_t *data);
|
||||
void (*unref)(struct net_buf *buf, u8_t *data);
|
||||
uint8_t *(*alloc)(struct net_buf *buf, size_t *size, int32_t timeout);
|
||||
uint8_t *(*ref)(struct net_buf *buf, uint8_t *data);
|
||||
void (*unref)(struct net_buf *buf, uint8_t *data);
|
||||
};
|
||||
|
||||
struct net_buf_data_alloc {
|
||||
@@ -810,17 +811,17 @@ struct net_buf_data_alloc {
|
||||
|
||||
struct net_buf_pool {
|
||||
/** Number of buffers in pool */
|
||||
const u16_t buf_count;
|
||||
const uint16_t buf_count;
|
||||
|
||||
/** Number of uninitialized buffers */
|
||||
u16_t uninit_count;
|
||||
uint16_t uninit_count;
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_POOL_USAGE)
|
||||
/** Amount of available buffers in the pool. */
|
||||
s16_t avail_count;
|
||||
int16_t avail_count;
|
||||
|
||||
/** Total size of the pool. */
|
||||
const u16_t pool_size;
|
||||
const uint16_t pool_size;
|
||||
|
||||
/** Name of the pool. Used when printing pool information. */
|
||||
const char *name;
|
||||
@@ -860,7 +861,7 @@ struct net_buf_pool {
|
||||
|
||||
struct net_buf_pool_fixed {
|
||||
size_t data_size;
|
||||
u8_t *data_pool;
|
||||
uint8_t *data_pool;
|
||||
};
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
@@ -895,10 +896,10 @@ extern const struct net_buf_data_cb net_buf_fixed_cb;
|
||||
*/
|
||||
#define NET_BUF_POOL_FIXED_DEFINE(_name, _count, _data_size, _destroy) \
|
||||
static struct net_buf net_buf_##_name[_count]; \
|
||||
static u8_t net_buf_data_##_name[_count][_data_size]; \
|
||||
static uint8_t net_buf_data_##_name[_count][_data_size]; \
|
||||
static const struct net_buf_pool_fixed net_buf_fixed_##_name = { \
|
||||
.data_size = _data_size, \
|
||||
.data_pool = (u8_t *)net_buf_data_##_name, \
|
||||
.data_pool = (uint8_t *)net_buf_data_##_name, \
|
||||
}; \
|
||||
static const struct net_buf_data_alloc net_buf_fixed_alloc_##_name = { \
|
||||
.cb = &net_buf_fixed_cb, \
|
||||
@@ -962,12 +963,12 @@ int net_buf_id(struct net_buf *buf);
|
||||
* @return New buffer or NULL if out of buffers.
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, s32_t timeout,
|
||||
const char *func, int line);
|
||||
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool, int32_t timeout,
|
||||
const char *func, int line);
|
||||
#define net_buf_alloc_fixed(_pool, _timeout) \
|
||||
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
|
||||
#else
|
||||
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout);
|
||||
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout);
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -1631,8 +1632,8 @@ struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
|
||||
*/
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_frag_del_debug(struct net_buf *parent,
|
||||
struct net_buf *frag,
|
||||
const char *func, int line);
|
||||
struct net_buf *frag,
|
||||
const char *func, int line);
|
||||
#define net_buf_frag_del(_parent, _frag) \
|
||||
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
|
||||
#else
|
||||
@@ -1655,7 +1656,7 @@ struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
|
||||
* @return number of bytes actually copied
|
||||
*/
|
||||
size_t net_buf_linearize(void *dst, size_t dst_len,
|
||||
struct net_buf *src, size_t offset, size_t len);
|
||||
struct net_buf *src, size_t offset, size_t len);
|
||||
|
||||
/**
|
||||
* @typedef net_buf_allocator_cb
|
||||
@@ -1671,7 +1672,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len,
|
||||
* @param user_data The user data given in net_buf_append_bytes call.
|
||||
* @return pointer to allocated net_buf or NULL on error.
|
||||
*/
|
||||
typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
|
||||
typedef struct net_buf *(*net_buf_allocator_cb)(int32_t timeout, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Append data to a list of net_buf
|
||||
@@ -1694,8 +1695,8 @@ typedef struct net_buf *(*net_buf_allocator_cb)(s32_t timeout, void *user_data);
|
||||
* were no free fragments in a pool to accommodate all data.
|
||||
*/
|
||||
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
|
||||
const void *value, s32_t timeout,
|
||||
net_buf_allocator_cb allocate_cb, void *user_data);
|
||||
const void *value, int32_t timeout,
|
||||
net_buf_allocator_cb allocate_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Skip N number of bytes in a net_buf
|
||||
|
||||
@@ -16,40 +16,40 @@ extern "C" {
|
||||
|
||||
/* Internal helpers only used by the sys_* APIs further below */
|
||||
#ifndef __bswap_16
|
||||
#define __bswap_16(x) ((u16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
|
||||
#define __bswap_16(x) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
|
||||
#endif
|
||||
|
||||
#ifndef __bswap_24
|
||||
#define __bswap_24(x) ((u32_t) ((((x) >> 16) & 0xff) | \
|
||||
(((x)) & 0xff00) | \
|
||||
(((x) & 0xff) << 16)))
|
||||
#define __bswap_24(x) ((uint32_t) ((((x) >> 16) & 0xff) | \
|
||||
(((x)) & 0xff00) | \
|
||||
(((x) & 0xff) << 16)))
|
||||
#endif
|
||||
|
||||
#ifndef __bswap_32
|
||||
#define __bswap_32(x) ((u32_t) ((((x) >> 24) & 0xff) | \
|
||||
(((x) >> 8) & 0xff00) | \
|
||||
(((x) & 0xff00) << 8) | \
|
||||
(((x) & 0xff) << 24)))
|
||||
#define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) | \
|
||||
(((x) >> 8) & 0xff00) | \
|
||||
(((x) & 0xff00) << 8) | \
|
||||
(((x) & 0xff) << 24)))
|
||||
#endif
|
||||
|
||||
#ifndef __bswap_48
|
||||
#define __bswap_48(x) ((u64_t) ((((x) >> 40) & 0xff) | \
|
||||
(((x) >> 24) & 0xff00) | \
|
||||
(((x) >> 8) & 0xff0000) | \
|
||||
(((x) & 0xff0000) << 8) | \
|
||||
(((x) & 0xff00) << 24) | \
|
||||
(((x) & 0xff) << 40)))
|
||||
#define __bswap_48(x) ((uint64_t) ((((x) >> 40) & 0xff) | \
|
||||
(((x) >> 24) & 0xff00) | \
|
||||
(((x) >> 8) & 0xff0000) | \
|
||||
(((x) & 0xff0000) << 8) | \
|
||||
(((x) & 0xff00) << 24) | \
|
||||
(((x) & 0xff) << 40)))
|
||||
#endif
|
||||
|
||||
#ifndef __bswap_64
|
||||
#define __bswap_64(x) ((u64_t) ((((x) >> 56) & 0xff) | \
|
||||
(((x) >> 40) & 0xff00) | \
|
||||
(((x) >> 24) & 0xff0000) | \
|
||||
(((x) >> 8) & 0xff000000) | \
|
||||
(((x) & 0xff000000) << 8) | \
|
||||
(((x) & 0xff0000) << 24) | \
|
||||
(((x) & 0xff00) << 40) | \
|
||||
(((x) & 0xff) << 56)))
|
||||
#define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) | \
|
||||
(((x) >> 40) & 0xff00) | \
|
||||
(((x) >> 24) & 0xff0000) | \
|
||||
(((x) >> 8) & 0xff000000) | \
|
||||
(((x) & 0xff000000) << 8) | \
|
||||
(((x) & 0xff0000) << 24) | \
|
||||
(((x) & 0xff00) << 40) | \
|
||||
(((x) & 0xff) << 56)))
|
||||
#endif
|
||||
|
||||
/** @def sys_le16_to_cpu
|
||||
@@ -250,7 +250,7 @@ extern "C" {
|
||||
* @param val 16-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_be16(u16_t val, u8_t dst[2])
|
||||
static inline void sys_put_be16(uint16_t val, uint8_t dst[2])
|
||||
{
|
||||
dst[0] = val >> 8;
|
||||
dst[1] = val;
|
||||
@@ -265,7 +265,7 @@ static inline void sys_put_be16(u16_t val, u8_t dst[2])
|
||||
* @param val 24-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_be24(u32_t val, u8_t dst[3])
|
||||
static inline void sys_put_be24(uint32_t val, uint8_t dst[3])
|
||||
{
|
||||
dst[0] = val >> 16;
|
||||
sys_put_be16(val, &dst[1]);
|
||||
@@ -280,7 +280,7 @@ static inline void sys_put_be24(u32_t val, u8_t dst[3])
|
||||
* @param val 32-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_be32(u32_t val, u8_t dst[4])
|
||||
static inline void sys_put_be32(uint32_t val, uint8_t dst[4])
|
||||
{
|
||||
sys_put_be16(val >> 16, dst);
|
||||
sys_put_be16(val, &dst[2]);
|
||||
@@ -295,7 +295,7 @@ static inline void sys_put_be32(u32_t val, u8_t dst[4])
|
||||
* @param val 48-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_be48(u64_t val, u8_t dst[6])
|
||||
static inline void sys_put_be48(uint64_t val, uint8_t dst[6])
|
||||
{
|
||||
sys_put_be16(val >> 32, dst);
|
||||
sys_put_be32(val, &dst[2]);
|
||||
@@ -310,7 +310,7 @@ static inline void sys_put_be48(u64_t val, u8_t dst[6])
|
||||
* @param val 64-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_be64(u64_t val, u8_t dst[8])
|
||||
static inline void sys_put_be64(uint64_t val, uint8_t dst[8])
|
||||
{
|
||||
sys_put_be32(val >> 32, dst);
|
||||
sys_put_be32(val, &dst[4]);
|
||||
@@ -325,7 +325,7 @@ static inline void sys_put_be64(u64_t val, u8_t dst[8])
|
||||
* @param val 16-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_le16(u16_t val, u8_t dst[2])
|
||||
static inline void sys_put_le16(uint16_t val, uint8_t dst[2])
|
||||
{
|
||||
dst[0] = val;
|
||||
dst[1] = val >> 8;
|
||||
@@ -340,7 +340,7 @@ static inline void sys_put_le16(u16_t val, u8_t dst[2])
|
||||
* @param val 24-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_le24(u32_t val, u8_t dst[3])
|
||||
static inline void sys_put_le24(uint32_t val, uint8_t dst[3])
|
||||
{
|
||||
sys_put_le16(val, dst);
|
||||
dst[2] = val >> 16;
|
||||
@@ -355,7 +355,7 @@ static inline void sys_put_le24(u32_t val, u8_t dst[3])
|
||||
* @param val 32-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_le32(u32_t val, u8_t dst[4])
|
||||
static inline void sys_put_le32(uint32_t val, uint8_t dst[4])
|
||||
{
|
||||
sys_put_le16(val, dst);
|
||||
sys_put_le16(val >> 16, &dst[2]);
|
||||
@@ -370,7 +370,7 @@ static inline void sys_put_le32(u32_t val, u8_t dst[4])
|
||||
* @param val 48-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_le48(u64_t val, u8_t dst[6])
|
||||
static inline void sys_put_le48(uint64_t val, uint8_t dst[6])
|
||||
{
|
||||
sys_put_le32(val, dst);
|
||||
sys_put_le16(val >> 32, &dst[4]);
|
||||
@@ -385,7 +385,7 @@ static inline void sys_put_le48(u64_t val, u8_t dst[6])
|
||||
* @param val 64-bit integer in host endianness.
|
||||
* @param dst Destination memory address to store the result.
|
||||
*/
|
||||
static inline void sys_put_le64(u64_t val, u8_t dst[8])
|
||||
static inline void sys_put_le64(uint64_t val, uint8_t dst[8])
|
||||
{
|
||||
sys_put_le32(val, dst);
|
||||
sys_put_le32(val >> 32, &dst[4]);
|
||||
@@ -401,9 +401,9 @@ static inline void sys_put_le64(u64_t val, u8_t dst[8])
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
static inline u16_t sys_get_be16(const u8_t src[2])
|
||||
static inline uint16_t sys_get_be16(const uint8_t src[2])
|
||||
{
|
||||
return ((u16_t)src[0] << 8) | src[1];
|
||||
return ((uint16_t)src[0] << 8) | src[1];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,9 +416,9 @@ static inline u16_t sys_get_be16(const u8_t src[2])
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_be24(const u8_t src[3])
|
||||
static inline uint32_t sys_get_be24(const uint8_t src[3])
|
||||
{
|
||||
return ((u32_t)src[0] << 16) | sys_get_be16(&src[1]);
|
||||
return ((uint32_t)src[0] << 16) | sys_get_be16(&src[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,9 +431,9 @@ static inline u32_t sys_get_be24(const u8_t src[3])
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_be32(const u8_t src[4])
|
||||
static inline uint32_t sys_get_be32(const uint8_t src[4])
|
||||
{
|
||||
return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
|
||||
return ((uint32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,9 +446,9 @@ static inline u32_t sys_get_be32(const u8_t src[4])
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_be48(const u8_t src[6])
|
||||
static inline uint64_t sys_get_be48(const uint8_t src[6])
|
||||
{
|
||||
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
|
||||
return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,9 +461,9 @@ static inline u64_t sys_get_be48(const u8_t src[6])
|
||||
*
|
||||
* @return 64-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_be64(const u8_t src[8])
|
||||
static inline uint64_t sys_get_be64(const uint8_t src[8])
|
||||
{
|
||||
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
|
||||
return ((uint64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,9 +476,9 @@ static inline u64_t sys_get_be64(const u8_t src[8])
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
static inline u16_t sys_get_le16(const u8_t src[2])
|
||||
static inline uint16_t sys_get_le16(const uint8_t src[2])
|
||||
{
|
||||
return ((u16_t)src[1] << 8) | src[0];
|
||||
return ((uint16_t)src[1] << 8) | src[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -491,9 +491,9 @@ static inline u16_t sys_get_le16(const u8_t src[2])
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_le24(const u8_t src[3])
|
||||
static inline uint32_t sys_get_le24(const uint8_t src[3])
|
||||
{
|
||||
return ((u32_t)src[2] << 16) | sys_get_le16(&src[0]);
|
||||
return ((uint32_t)src[2] << 16) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,9 +506,9 @@ static inline u32_t sys_get_le24(const u8_t src[3])
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_le32(const u8_t src[4])
|
||||
static inline uint32_t sys_get_le32(const uint8_t src[4])
|
||||
{
|
||||
return ((u32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
|
||||
return ((uint32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,9 +521,9 @@ static inline u32_t sys_get_le32(const u8_t src[4])
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_le48(const u8_t src[6])
|
||||
static inline uint64_t sys_get_le48(const uint8_t src[6])
|
||||
{
|
||||
return ((u64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
|
||||
return ((uint64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,9 +536,9 @@ static inline u64_t sys_get_le48(const u8_t src[6])
|
||||
*
|
||||
* @return 64-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_le64(const u8_t src[8])
|
||||
static inline uint64_t sys_get_le64(const uint8_t src[8])
|
||||
{
|
||||
return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
|
||||
return ((uint64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -556,8 +556,8 @@ static inline u64_t sys_get_le64(const u8_t src[8])
|
||||
*/
|
||||
static inline void sys_memcpy_swap(void *dst, const void *src, size_t length)
|
||||
{
|
||||
u8_t *pdst = (u8_t *)dst;
|
||||
const u8_t *psrc = (const u8_t *)src;
|
||||
uint8_t *pdst = (uint8_t *)dst;
|
||||
const uint8_t *psrc = (const uint8_t *)src;
|
||||
|
||||
__ASSERT(((psrc < pdst && (psrc + length) <= pdst) ||
|
||||
(psrc > pdst && (pdst + length) <= psrc)),
|
||||
@@ -585,10 +585,10 @@ static inline void sys_mem_swap(void *buf, size_t length)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < (length / 2); i++) {
|
||||
u8_t tmp = ((u8_t *)buf)[i];
|
||||
uint8_t tmp = ((uint8_t *)buf)[i];
|
||||
|
||||
((u8_t *)buf)[i] = ((u8_t *)buf)[length - 1 - i];
|
||||
((u8_t *)buf)[length - 1 - i] = tmp;
|
||||
((uint8_t *)buf)[i] = ((uint8_t *)buf)[length - 1 - i];
|
||||
((uint8_t *)buf)[length - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ IRAM_ATTR void bt_mesh_free(void *ptr);
|
||||
*
|
||||
* @return NULL-fail, pointer of a net_buf_simple structure-success
|
||||
*/
|
||||
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size);
|
||||
struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief This function releases the memory allocated for the outgoing message.
|
||||
@@ -71,7 +71,9 @@ void bt_mesh_free_buf(struct net_buf_simple *buf);
|
||||
*
|
||||
* @return 0 - Node, 1 - Provisioner
|
||||
*/
|
||||
u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
|
||||
uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
55
components/bt/esp_ble_mesh/mesh_common/include/mesh_config.h
Normal file
55
components/bt/esp_ble_mesh/mesh_common/include/mesh_config.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// Copyright 2020-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef _BLE_MESH_CONFIG_H_
|
||||
#define _BLE_MESH_CONFIG_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CONFIG_BLE_MESH_GENERIC_CLIENT (CONFIG_BLE_MESH_GENERIC_ONOFF_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_LEVEL_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_POWER_ONOFF_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_POWER_LEVEL_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_BATTERY_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_LOCATION_CLI || \
|
||||
CONFIG_BLE_MESH_GENERIC_PROPERTY_CLI)
|
||||
|
||||
#define CONFIG_BLE_MESH_TIME_SCENE_CLIENT (CONFIG_BLE_MESH_TIME_CLI || \
|
||||
CONFIG_BLE_MESH_SCENE_CLI || \
|
||||
CONFIG_BLE_MESH_SCHEDULER_CLI)
|
||||
|
||||
#define CONFIG_BLE_MESH_LIGHTING_CLIENT (CONFIG_BLE_MESH_LIGHT_LIGHTNESS_CLI || \
|
||||
CONFIG_BLE_MESH_LIGHT_CTL_CLI || \
|
||||
CONFIG_BLE_MESH_LIGHT_HSL_CLI || \
|
||||
CONFIG_BLE_MESH_LIGHT_XYL_CLI || \
|
||||
CONFIG_BLE_MESH_LIGHT_LC_CLI)
|
||||
|
||||
#define CONFIG_BLE_MESH_SERVER_MODEL (CONFIG_BLE_MESH_GENERIC_SERVER || \
|
||||
CONFIG_BLE_MESH_SENSOR_SERVER || \
|
||||
CONFIG_BLE_MESH_TIME_SCENE_SERVER || \
|
||||
CONFIG_BLE_MESH_LIGHTING_SERVER)
|
||||
|
||||
#define CONFIG_BLE_MESH_BLE_COEX_SUPPORT (CONFIG_BLE_MESH_SUPPORT_BLE_ADV || \
|
||||
CONFIG_BLE_MESH_SUPPORT_BLE_SCAN)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_CONFIG_H_ */
|
||||
@@ -291,7 +291,7 @@ static inline sys_dnode_t *sys_dlist_peek_head_not_empty(sys_dlist_t *list)
|
||||
*/
|
||||
|
||||
static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
|
||||
sys_dnode_t *node)
|
||||
sys_dnode_t *node)
|
||||
{
|
||||
return (node == list->tail) ? NULL : node->next;
|
||||
}
|
||||
@@ -307,7 +307,7 @@ static inline sys_dnode_t *sys_dlist_peek_next_no_check(sys_dlist_t *list,
|
||||
*/
|
||||
|
||||
static inline sys_dnode_t *sys_dlist_peek_next(sys_dlist_t *list,
|
||||
sys_dnode_t *node)
|
||||
sys_dnode_t *node)
|
||||
{
|
||||
return node ? sys_dlist_peek_next_no_check(list, node) : NULL;
|
||||
}
|
||||
@@ -379,7 +379,8 @@ static inline void sys_dlist_prepend(sys_dlist_t *list, sys_dnode_t *node)
|
||||
*/
|
||||
|
||||
static inline void sys_dlist_insert_after(sys_dlist_t *list,
|
||||
sys_dnode_t *insert_point, sys_dnode_t *node)
|
||||
sys_dnode_t *insert_point,
|
||||
sys_dnode_t *node)
|
||||
{
|
||||
if (!insert_point) {
|
||||
sys_dlist_prepend(list, node);
|
||||
@@ -405,7 +406,8 @@ static inline void sys_dlist_insert_after(sys_dlist_t *list,
|
||||
*/
|
||||
|
||||
static inline void sys_dlist_insert_before(sys_dlist_t *list,
|
||||
sys_dnode_t *insert_point, sys_dnode_t *node)
|
||||
sys_dnode_t *insert_point,
|
||||
sys_dnode_t *node)
|
||||
{
|
||||
if (!insert_point) {
|
||||
sys_dlist_append(list, node);
|
||||
|
||||
@@ -27,7 +27,7 @@ extern "C" {
|
||||
* @return most significant bit set, 0 if @a op is 0
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
|
||||
static ALWAYS_INLINE unsigned int find_msb_set(uint32_t op)
|
||||
{
|
||||
if (op == 0) {
|
||||
return 0;
|
||||
@@ -48,7 +48,7 @@ static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
|
||||
* @return least significant bit set, 0 if @a op is 0
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
|
||||
static ALWAYS_INLINE unsigned int find_lsb_set(uint32_t op)
|
||||
{
|
||||
return __builtin_ffs(op);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
void k_sleep(s32_t duration);
|
||||
void k_sleep(int32_t duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ static inline void sys_slist_append(sys_slist_t *list,
|
||||
* @param tail A pointer to the last element of the list to append
|
||||
*/
|
||||
static inline void sys_slist_append_list(sys_slist_t *list,
|
||||
void *head, void *tail)
|
||||
void *head, void *tail)
|
||||
{
|
||||
if (!list->tail) {
|
||||
list->head = (sys_snode_t *)head;
|
||||
@@ -333,7 +333,7 @@ static inline void sys_slist_append_list(sys_slist_t *list,
|
||||
* @param list_to_append A pointer to the list to append.
|
||||
*/
|
||||
static inline void sys_slist_merge_slist(sys_slist_t *list,
|
||||
sys_slist_t *list_to_append)
|
||||
sys_slist_t *list_to_append)
|
||||
{
|
||||
sys_slist_append_list(list, list_to_append->head,
|
||||
list_to_append->tail);
|
||||
@@ -443,7 +443,7 @@ static inline void sys_slist_remove(sys_slist_t *list,
|
||||
* @return true if node was removed
|
||||
*/
|
||||
static inline bool sys_slist_find_and_remove(sys_slist_t *list,
|
||||
sys_snode_t *node)
|
||||
sys_snode_t *node)
|
||||
{
|
||||
sys_snode_t *prev = NULL;
|
||||
sys_snode_t *test;
|
||||
|
||||
@@ -142,7 +142,7 @@ struct k_work {
|
||||
*
|
||||
* @return Current uptime.
|
||||
*/
|
||||
u32_t k_uptime_get_32(void);
|
||||
uint32_t k_uptime_get_32(void);
|
||||
|
||||
struct k_delayed_work {
|
||||
struct k_work work;
|
||||
@@ -180,9 +180,9 @@ struct k_delayed_work {
|
||||
* @retval -EINVAL Work item is being processed or has completed its work.
|
||||
* @retval -EADDRINUSE Work item is pending on a different workqueue.
|
||||
*/
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay);
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay);
|
||||
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period);
|
||||
|
||||
/**
|
||||
* @brief Get time remaining before a delayed work gets scheduled.
|
||||
@@ -195,7 +195,7 @@ int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
|
||||
*
|
||||
* @return Remaining time (in milliseconds).
|
||||
*/
|
||||
s32_t k_delayed_work_remaining_get(struct k_delayed_work *work);
|
||||
int32_t k_delayed_work_remaining_get(struct k_delayed_work *work);
|
||||
|
||||
/**
|
||||
* @brief Submit a work item to the system workqueue.
|
||||
@@ -254,7 +254,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
|
||||
*
|
||||
* @return Current uptime.
|
||||
*/
|
||||
s64_t k_uptime_get(void);
|
||||
int64_t k_uptime_get(void);
|
||||
|
||||
void bt_mesh_timer_init(void);
|
||||
void bt_mesh_timer_deinit(void);
|
||||
|
||||
@@ -17,39 +17,39 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Define common tracing for all */
|
||||
#ifndef LOG_LEVEL_ERROR
|
||||
#define LOG_LEVEL_ERROR 1
|
||||
#endif /* LOG_LEVEL_ERROR */
|
||||
#ifndef BLE_MESH_LOG_LEVEL_ERROR
|
||||
#define BLE_MESH_LOG_LEVEL_ERROR 1
|
||||
#endif /* BLE_MESH_LOG_LEVEL_ERROR */
|
||||
|
||||
#ifndef LOG_LEVEL_WARN
|
||||
#define LOG_LEVEL_WARN 2
|
||||
#endif /* LOG_LEVEL_WARN */
|
||||
#ifndef BLE_MESH_LOG_LEVEL_WARN
|
||||
#define BLE_MESH_LOG_LEVEL_WARN 2
|
||||
#endif /* BLE_MESH_LOG_LEVEL_WARN */
|
||||
|
||||
#ifndef LOG_LEVEL_INFO
|
||||
#define LOG_LEVEL_INFO 3
|
||||
#endif /* LOG_LEVEL_INFO */
|
||||
#ifndef BLE_MESH_LOG_LEVEL_INFO
|
||||
#define BLE_MESH_LOG_LEVEL_INFO 3
|
||||
#endif /* BLE_MESH_LOG_LEVEL_INFO */
|
||||
|
||||
#ifndef LOG_LEVEL_DEBUG
|
||||
#define LOG_LEVEL_DEBUG 4
|
||||
#endif /* LOG_LEVEL_DEBUG */
|
||||
#ifndef BLE_MESH_LOG_LEVEL_DEBUG
|
||||
#define BLE_MESH_LOG_LEVEL_DEBUG 4
|
||||
#endif /* BLE_MESH_LOG_LEVEL_DEBUG */
|
||||
|
||||
#ifndef LOG_LEVEL_VERBOSE
|
||||
#define LOG_LEVEL_VERBOSE 5
|
||||
#endif /*LOG_LEVEL_VERBOSE */
|
||||
#ifndef BLE_MESH_LOG_LEVEL_VERBOSE
|
||||
#define BLE_MESH_LOG_LEVEL_VERBOSE 5
|
||||
#endif /*BLE_MESH_LOG_LEVEL_VERBOSE */
|
||||
|
||||
#ifdef CONFIG_BLE_MESH_STACK_TRACE_LEVEL
|
||||
#define MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL
|
||||
#define BLE_MESH_LOG_LEVEL CONFIG_BLE_MESH_STACK_TRACE_LEVEL
|
||||
#else
|
||||
#define MESH_LOG_LEVEL LOG_LEVEL_WARN
|
||||
#define BLE_MESH_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
|
||||
#define NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
|
||||
#define BLE_MESH_NET_BUF_LOG_LEVEL CONFIG_BLE_MESH_NET_BUF_TRACE_LEVEL
|
||||
#else
|
||||
#define NET_BUF_LOG_LEVEL LOG_LEVEL_WARN
|
||||
#define BLE_MESH_NET_BUF_LOG_LEVEL BLE_MESH_LOG_LEVEL_WARN
|
||||
#endif
|
||||
|
||||
#define MESH_TRACE_TAG "BLE_MESH"
|
||||
#define BLE_MESH_TRACE_TAG "BLE_MESH"
|
||||
|
||||
#if (LOG_LOCAL_LEVEL >= 4)
|
||||
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING (LOG_LOCAL_LEVEL + 1)
|
||||
@@ -57,13 +57,13 @@ extern "C" {
|
||||
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
|
||||
#endif
|
||||
|
||||
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= LOG_LEVEL_##LEVEL)
|
||||
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= BLE_MESH_LOG_LEVEL_##LEVEL)
|
||||
|
||||
#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_E(tag, format, ...) {esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_W(tag, format, ...) {esp_log_write(ESP_LOG_WARN, tag, LOG_FORMAT(W, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_I(tag, format, ...) {esp_log_write(ESP_LOG_INFO, tag, LOG_FORMAT(I, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_D(tag, format, ...) {esp_log_write(ESP_LOG_DEBUG, tag, LOG_FORMAT(D, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
#define BLE_MESH_PRINT_V(tag, format, ...) {esp_log_write(ESP_LOG_VERBOSE, tag, LOG_FORMAT(V, format), esp_log_timestamp(), tag, ##__VA_ARGS__); }
|
||||
|
||||
#define printk ets_printf
|
||||
|
||||
@@ -85,14 +85,14 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __ASSERT_NO_MSG
|
||||
#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0)
|
||||
#define __ASSERT_NO_MSG(x) do { if (!(x)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, "error %s %u", __FILE__, __LINE__); } while (0)
|
||||
#endif
|
||||
|
||||
#if !CONFIG_BLE_MESH_NO_LOG
|
||||
#define BT_ERR(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(MESH, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_WARN(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(MESH, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_INFO(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(MESH, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_DBG(fmt, args...) do {if ((MESH_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(MESH, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_ERR(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_WARN(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_INFO(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define BT_DBG(fmt, args...) do {if ((BLE_MESH_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#else
|
||||
#define BT_ERR(fmt, args...)
|
||||
#define BT_WARN(fmt, args...)
|
||||
@@ -101,10 +101,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
|
||||
#define NET_BUF_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_ASSERT(cond) __ASSERT_NO_MSG(cond)
|
||||
#else
|
||||
#define NET_BUF_ERR(fmt, args...)
|
||||
@@ -115,10 +115,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_SIMPLE_LOG) && (!CONFIG_BLE_MESH_NO_LOG)
|
||||
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, ERROR)) BLE_MESH_PRINT_E(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, WARN)) BLE_MESH_PRINT_W(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, INFO)) BLE_MESH_PRINT_I(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((NET_BUF_LOG_LEVEL >= LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(NET_BUF, DEBUG)) BLE_MESH_PRINT_D(MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_ERR(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_ERROR) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, ERROR)) BLE_MESH_PRINT_E(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_WARN(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_WARN) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, WARN)) BLE_MESH_PRINT_W(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_INFO(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_INFO) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, INFO)) BLE_MESH_PRINT_I(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_DBG(fmt, args...) do {if ((BLE_MESH_NET_BUF_LOG_LEVEL >= BLE_MESH_LOG_LEVEL_DEBUG) && BLE_MESH_LOG_LEVEL_CHECK(BLE_MESH_NET_BUF, DEBUG)) BLE_MESH_PRINT_D(BLE_MESH_TRACE_TAG, fmt, ## args);} while(0)
|
||||
#define NET_BUF_SIMPLE_ASSERT(cond) __ASSERT_NO_MSG(cond)
|
||||
#else
|
||||
#define NET_BUF_SIMPLE_ERR(fmt, args...)
|
||||
|
||||
@@ -16,16 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef signed char s8_t;
|
||||
typedef signed short s16_t;
|
||||
typedef signed int s32_t;
|
||||
typedef signed long long s64_t;
|
||||
|
||||
typedef unsigned char u8_t;
|
||||
typedef unsigned short u16_t;
|
||||
typedef unsigned int u32_t;
|
||||
typedef unsigned long long u64_t;
|
||||
|
||||
typedef int bt_mesh_atomic_t;
|
||||
|
||||
#ifndef PRIu64
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define _BLE_MESH_UTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "esp_bit_defs.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -25,13 +26,13 @@ extern "C" {
|
||||
* Those are available for 32 bits architectures:
|
||||
*/
|
||||
#ifndef POINTER_TO_UINT
|
||||
#define POINTER_TO_UINT(x) ((u32_t) (x))
|
||||
#define POINTER_TO_UINT(x) ((uint32_t) (x))
|
||||
#endif
|
||||
#ifndef UINT_TO_POINTER
|
||||
#define UINT_TO_POINTER(x) ((void *) (x))
|
||||
#endif
|
||||
#ifndef POINTER_TO_INT
|
||||
#define POINTER_TO_INT(x) ((s32_t) (x))
|
||||
#define POINTER_TO_INT(x) ((int32_t) (x))
|
||||
#endif
|
||||
#ifndef INT_TO_POINTER
|
||||
#define INT_TO_POINTER(x) ((void *) (x))
|
||||
@@ -56,9 +57,7 @@ extern "C" {
|
||||
* an array (e.g. pointer)
|
||||
*/
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(array) \
|
||||
((unsigned long) (IS_ARRAY(array) + \
|
||||
(sizeof(array) / sizeof((array)[0]))))
|
||||
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
#endif
|
||||
|
||||
/* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if
|
||||
@@ -183,7 +182,7 @@ extern "C" {
|
||||
|
||||
const char *bt_hex(const void *buf, size_t len);
|
||||
|
||||
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
|
||||
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ int net_buf_id(struct net_buf *buf)
|
||||
}
|
||||
|
||||
static inline struct net_buf *pool_get_uninit(struct net_buf_pool *pool,
|
||||
u16_t uninit_count)
|
||||
uint16_t uninit_count)
|
||||
{
|
||||
struct net_buf *buf = NULL;
|
||||
|
||||
@@ -35,7 +35,7 @@ void net_buf_simple_clone(const struct net_buf_simple *original,
|
||||
|
||||
void *net_buf_simple_add(struct net_buf_simple *buf, size_t len)
|
||||
{
|
||||
u8_t *tail = net_buf_simple_tail(buf);
|
||||
uint8_t *tail = net_buf_simple_tail(buf);
|
||||
|
||||
NET_BUF_SIMPLE_DBG("buf %p len %u", buf, len);
|
||||
|
||||
@@ -53,9 +53,9 @@ void *net_buf_simple_add_mem(struct net_buf_simple *buf, const void *mem,
|
||||
return memcpy(net_buf_simple_add(buf, len), mem, len);
|
||||
}
|
||||
|
||||
u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
|
||||
uint8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, uint8_t val)
|
||||
{
|
||||
u8_t *u8 = NULL;
|
||||
uint8_t *u8 = NULL;
|
||||
|
||||
NET_BUF_SIMPLE_DBG("buf %p val 0x%02x", buf, val);
|
||||
|
||||
@@ -65,70 +65,70 @@ u8_t *net_buf_simple_add_u8(struct net_buf_simple *buf, u8_t val)
|
||||
return u8;
|
||||
}
|
||||
|
||||
void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val)
|
||||
void net_buf_simple_add_le16(struct net_buf_simple *buf, uint16_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le16(val, net_buf_simple_add(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val)
|
||||
void net_buf_simple_add_be16(struct net_buf_simple *buf, uint16_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be16(val, net_buf_simple_add(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_le24(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_add_le24(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le24(val, net_buf_simple_add(buf, 3));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_be24(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_add_be24(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be24(val, net_buf_simple_add(buf, 3));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_add_le32(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le32(val, net_buf_simple_add(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be32(val, net_buf_simple_add(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_le48(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_add_le48(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_le48(val, net_buf_simple_add(buf, 6));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_be48(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_add_be48(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_be48(val, net_buf_simple_add(buf, 6));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_le64(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_add_le64(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_le64(val, net_buf_simple_add(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_add_be64(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_add_be64(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
@@ -146,77 +146,77 @@ void *net_buf_simple_push(struct net_buf_simple *buf, size_t len)
|
||||
return buf->data;
|
||||
}
|
||||
|
||||
void net_buf_simple_push_le16(struct net_buf_simple *buf, u16_t val)
|
||||
void net_buf_simple_push_le16(struct net_buf_simple *buf, uint16_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le16(val, net_buf_simple_push(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val)
|
||||
void net_buf_simple_push_be16(struct net_buf_simple *buf, uint16_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be16(val, net_buf_simple_push(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val)
|
||||
void net_buf_simple_push_u8(struct net_buf_simple *buf, uint8_t val)
|
||||
{
|
||||
u8_t *data = net_buf_simple_push(buf, 1);
|
||||
uint8_t *data = net_buf_simple_push(buf, 1);
|
||||
|
||||
*data = val;
|
||||
}
|
||||
|
||||
void net_buf_simple_push_le24(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_push_le24(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le24(val, net_buf_simple_push(buf, 3));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_be24(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_push_be24(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be24(val, net_buf_simple_push(buf, 3));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_le32(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_push_le32(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_le32(val, net_buf_simple_push(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_be32(struct net_buf_simple *buf, u32_t val)
|
||||
void net_buf_simple_push_be32(struct net_buf_simple *buf, uint32_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %u", buf, val);
|
||||
|
||||
sys_put_be32(val, net_buf_simple_push(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_le48(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_push_le48(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_le48(val, net_buf_simple_push(buf, 6));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_be48(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_push_be48(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_be48(val, net_buf_simple_push(buf, 6));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_le64(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_push_le64(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
sys_put_le64(val, net_buf_simple_push(buf, sizeof(val)));
|
||||
}
|
||||
|
||||
void net_buf_simple_push_be64(struct net_buf_simple *buf, u64_t val)
|
||||
void net_buf_simple_push_be64(struct net_buf_simple *buf, uint64_t val)
|
||||
{
|
||||
NET_BUF_SIMPLE_DBG("buf %p val %" PRIu64, buf, val);
|
||||
|
||||
@@ -247,9 +247,9 @@ void *net_buf_simple_pull_mem(struct net_buf_simple *buf, size_t len)
|
||||
return data;
|
||||
}
|
||||
|
||||
u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
|
||||
uint8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t val = 0U;
|
||||
uint8_t val = 0U;
|
||||
|
||||
val = buf->data[0];
|
||||
net_buf_simple_pull(buf, 1);
|
||||
@@ -257,30 +257,30 @@ u8_t net_buf_simple_pull_u8(struct net_buf_simple *buf)
|
||||
return val;
|
||||
}
|
||||
|
||||
u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
|
||||
uint16_t net_buf_simple_pull_le16(struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t val = 0U;
|
||||
uint16_t val = 0U;
|
||||
|
||||
val = UNALIGNED_GET((u16_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint16_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_le16_to_cpu(val);
|
||||
}
|
||||
|
||||
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
|
||||
uint16_t net_buf_simple_pull_be16(struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t val = 0U;
|
||||
uint16_t val = 0U;
|
||||
|
||||
val = UNALIGNED_GET((u16_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint16_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_be16_to_cpu(val);
|
||||
}
|
||||
|
||||
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
|
||||
uint32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint24 {
|
||||
u32_t u24:24;
|
||||
uint32_t u24:24;
|
||||
} __packed val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint24 *)buf->data);
|
||||
@@ -289,10 +289,10 @@ u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf)
|
||||
return sys_le24_to_cpu(val.u24);
|
||||
}
|
||||
|
||||
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
|
||||
uint32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint24 {
|
||||
u32_t u24:24;
|
||||
uint32_t u24:24;
|
||||
} __packed val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint24 *)buf->data);
|
||||
@@ -301,30 +301,30 @@ u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf)
|
||||
return sys_be24_to_cpu(val.u24);
|
||||
}
|
||||
|
||||
u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
|
||||
uint32_t net_buf_simple_pull_le32(struct net_buf_simple *buf)
|
||||
{
|
||||
u32_t val = 0U;
|
||||
uint32_t val = 0U;
|
||||
|
||||
val = UNALIGNED_GET((u32_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint32_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_le32_to_cpu(val);
|
||||
}
|
||||
|
||||
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
|
||||
uint32_t net_buf_simple_pull_be32(struct net_buf_simple *buf)
|
||||
{
|
||||
u32_t val = 0U;
|
||||
uint32_t val = 0U;
|
||||
|
||||
val = UNALIGNED_GET((u32_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint32_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_be32_to_cpu(val);
|
||||
}
|
||||
|
||||
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
|
||||
uint64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint48 {
|
||||
u64_t u48:48;
|
||||
uint64_t u48:48;
|
||||
} __packed val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint48 *)buf->data);
|
||||
@@ -333,10 +333,10 @@ u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf)
|
||||
return sys_le48_to_cpu(val.u48);
|
||||
}
|
||||
|
||||
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
|
||||
uint64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
|
||||
{
|
||||
struct uint48 {
|
||||
u64_t u48:48;
|
||||
uint64_t u48:48;
|
||||
} __packed val;
|
||||
|
||||
val = UNALIGNED_GET((struct uint48 *)buf->data);
|
||||
@@ -345,21 +345,21 @@ u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf)
|
||||
return sys_be48_to_cpu(val.u48);
|
||||
}
|
||||
|
||||
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
|
||||
uint64_t net_buf_simple_pull_le64(struct net_buf_simple *buf)
|
||||
{
|
||||
u64_t val;
|
||||
uint64_t val;
|
||||
|
||||
val = UNALIGNED_GET((u64_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint64_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_le64_to_cpu(val);
|
||||
}
|
||||
|
||||
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
|
||||
uint64_t net_buf_simple_pull_be64(struct net_buf_simple *buf)
|
||||
{
|
||||
u64_t val;
|
||||
uint64_t val;
|
||||
|
||||
val = UNALIGNED_GET((u64_t *)buf->data);
|
||||
val = UNALIGNED_GET((uint64_t *)buf->data);
|
||||
net_buf_simple_pull(buf, sizeof(val));
|
||||
|
||||
return sys_be64_to_cpu(val);
|
||||
@@ -506,7 +506,7 @@ void net_buf_unref(struct net_buf *buf)
|
||||
}
|
||||
}
|
||||
|
||||
static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
|
||||
static uint8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, int32_t timeout)
|
||||
{
|
||||
struct net_buf_pool *pool = buf->pool;
|
||||
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
|
||||
@@ -516,7 +516,7 @@ static u8_t *fixed_data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
|
||||
return fixed->data_pool + fixed->data_size * net_buf_id(buf);
|
||||
}
|
||||
|
||||
static void fixed_data_unref(struct net_buf *buf, u8_t *data)
|
||||
static void fixed_data_unref(struct net_buf *buf, uint8_t *data)
|
||||
{
|
||||
/* Nothing needed for fixed-size data pools */
|
||||
}
|
||||
@@ -526,7 +526,7 @@ const struct net_buf_data_cb net_buf_fixed_cb = {
|
||||
.unref = fixed_data_unref,
|
||||
};
|
||||
|
||||
static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
|
||||
static uint8_t *data_alloc(struct net_buf *buf, size_t *size, int32_t timeout)
|
||||
{
|
||||
struct net_buf_pool *pool = buf->pool;
|
||||
|
||||
@@ -535,10 +535,10 @@ static u8_t *data_alloc(struct net_buf *buf, size_t *size, s32_t timeout)
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_alloc_len_debug(struct net_buf_pool *pool, size_t size,
|
||||
s32_t timeout, const char *func, int line)
|
||||
int32_t timeout, const char *func, int line)
|
||||
#else
|
||||
struct net_buf *net_buf_alloc_len(struct net_buf_pool *pool, size_t size,
|
||||
s32_t timeout)
|
||||
int32_t timeout)
|
||||
#endif
|
||||
{
|
||||
struct net_buf *buf = NULL;
|
||||
@@ -604,15 +604,15 @@ success:
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_NET_BUF_LOG)
|
||||
struct net_buf *net_buf_alloc_fixed_debug(struct net_buf_pool *pool,
|
||||
s32_t timeout, const char *func,
|
||||
int line)
|
||||
int32_t timeout, const char *func,
|
||||
int line)
|
||||
{
|
||||
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
|
||||
|
||||
return net_buf_alloc_len_debug(pool, fixed->data_size, timeout, func, line);
|
||||
}
|
||||
#else
|
||||
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, s32_t timeout)
|
||||
struct net_buf *net_buf_alloc_fixed(struct net_buf_pool *pool, int32_t timeout)
|
||||
{
|
||||
const struct net_buf_pool_fixed *fixed = pool->alloc->alloc_data;
|
||||
|
||||
@@ -708,7 +708,7 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
|
||||
copied = 0;
|
||||
while (frag && len > 0) {
|
||||
to_copy = MIN(len, frag->len - offset);
|
||||
memcpy((u8_t *)dst + copied, frag->data + offset, to_copy);
|
||||
memcpy((uint8_t *)dst + copied, frag->data + offset, to_copy);
|
||||
|
||||
copied += to_copy;
|
||||
|
||||
@@ -728,15 +728,15 @@ size_t net_buf_linearize(void *dst, size_t dst_len, struct net_buf *src,
|
||||
* the buffer. It assumes that the buffer has at least one fragment.
|
||||
*/
|
||||
size_t net_buf_append_bytes(struct net_buf *buf, size_t len,
|
||||
const void *value, s32_t timeout,
|
||||
net_buf_allocator_cb allocate_cb, void *user_data)
|
||||
const void *value, int32_t timeout,
|
||||
net_buf_allocator_cb allocate_cb, void *user_data)
|
||||
{
|
||||
struct net_buf *frag = net_buf_frag_last(buf);
|
||||
size_t added_len = 0U;
|
||||
const u8_t *value8 = value;
|
||||
const uint8_t *value8 = value;
|
||||
|
||||
do {
|
||||
u16_t count = MIN(len, net_buf_tailroom(frag));
|
||||
uint16_t count = MIN(len, net_buf_tailroom(frag));
|
||||
|
||||
net_buf_add_mem(frag, value8, count);
|
||||
len -= count;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "esp_system.h"
|
||||
|
||||
#include "mesh_main.h"
|
||||
#include "client_common.h"
|
||||
#include "mesh_common.h"
|
||||
@@ -50,10 +52,10 @@ IRAM_ATTR void bt_mesh_free(void *ptr)
|
||||
heap_caps_free(ptr);
|
||||
}
|
||||
|
||||
struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
|
||||
struct net_buf_simple *bt_mesh_alloc_buf(uint16_t size)
|
||||
{
|
||||
struct net_buf_simple *buf = NULL;
|
||||
u8_t *data = NULL;
|
||||
uint8_t *data = NULL;
|
||||
|
||||
buf = (struct net_buf_simple *)bt_mesh_calloc(sizeof(struct net_buf_simple) + size);
|
||||
if (!buf) {
|
||||
@@ -61,7 +63,7 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (u8_t *)buf + sizeof(struct net_buf_simple);
|
||||
data = (uint8_t *)buf + sizeof(struct net_buf_simple);
|
||||
|
||||
buf->data = data;
|
||||
buf->len = 0;
|
||||
@@ -78,7 +80,7 @@ void bt_mesh_free_buf(struct net_buf_simple *buf)
|
||||
}
|
||||
}
|
||||
|
||||
u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
||||
uint8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
||||
{
|
||||
bt_mesh_client_user_data_t *client = NULL;
|
||||
|
||||
@@ -96,3 +98,17 @@ u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send)
|
||||
|
||||
return client->msg_role;
|
||||
}
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len)
|
||||
{
|
||||
if (buf == NULL || len == 0) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
esp_fill_random(buf, len);
|
||||
|
||||
BT_DBG("Random %s", bt_hex(buf, len));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
|
||||
void k_sleep(s32_t duration)
|
||||
void k_sleep(int32_t duration)
|
||||
{
|
||||
vTaskDelay(duration / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
@@ -82,18 +82,13 @@ void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex)
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_alarm_mutex_new(void)
|
||||
static inline void bt_mesh_alarm_mutex_new(void)
|
||||
{
|
||||
if (!alarm_lock.mutex) {
|
||||
bt_mesh_mutex_create(&alarm_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_alarm_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&alarm_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_alarm_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&alarm_lock);
|
||||
@@ -104,18 +99,13 @@ void bt_mesh_alarm_unlock(void)
|
||||
bt_mesh_mutex_unlock(&alarm_lock);
|
||||
}
|
||||
|
||||
static void bt_mesh_list_mutex_new(void)
|
||||
static inline void bt_mesh_list_mutex_new(void)
|
||||
{
|
||||
if (!list_lock.mutex) {
|
||||
bt_mesh_mutex_create(&list_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_list_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&list_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_list_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&list_lock);
|
||||
@@ -126,18 +116,13 @@ void bt_mesh_list_unlock(void)
|
||||
bt_mesh_mutex_unlock(&list_lock);
|
||||
}
|
||||
|
||||
static void bt_mesh_buf_mutex_new(void)
|
||||
static inline void bt_mesh_buf_mutex_new(void)
|
||||
{
|
||||
if (!buf_lock.mutex) {
|
||||
bt_mesh_mutex_create(&buf_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_buf_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&buf_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_buf_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&buf_lock);
|
||||
@@ -148,18 +133,13 @@ void bt_mesh_buf_unlock(void)
|
||||
bt_mesh_mutex_unlock(&buf_lock);
|
||||
}
|
||||
|
||||
static void bt_mesh_atomic_mutex_new(void)
|
||||
static inline void bt_mesh_atomic_mutex_new(void)
|
||||
{
|
||||
if (!atomic_lock.mutex) {
|
||||
bt_mesh_mutex_create(&atomic_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_atomic_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&atomic_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_atomic_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&atomic_lock);
|
||||
@@ -178,6 +158,27 @@ void bt_mesh_mutex_init(void)
|
||||
bt_mesh_atomic_mutex_new();
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static inline void bt_mesh_alarm_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&alarm_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_list_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&list_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_buf_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&buf_lock);
|
||||
}
|
||||
|
||||
static inline void bt_mesh_atomic_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&atomic_lock);
|
||||
}
|
||||
|
||||
void bt_mesh_mutex_deinit(void)
|
||||
{
|
||||
bt_mesh_alarm_mutex_free();
|
||||
@@ -185,3 +186,4 @@ void bt_mesh_mutex_deinit(void)
|
||||
bt_mesh_buf_mutex_free();
|
||||
bt_mesh_atomic_mutex_free();
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
@@ -27,20 +27,20 @@ typedef struct alarm_t {
|
||||
int64_t deadline_us;
|
||||
} osi_alarm_t;
|
||||
|
||||
s64_t k_uptime_get(void)
|
||||
int64_t k_uptime_get(void)
|
||||
{
|
||||
/** k_uptime_get_32 is in in milliseconds,
|
||||
/* k_uptime_get_32 is in in milliseconds,
|
||||
* but esp_timer_get_time is in microseconds
|
||||
*/
|
||||
return (esp_timer_get_time() / 1000);
|
||||
}
|
||||
|
||||
u32_t k_uptime_get_32(void)
|
||||
uint32_t k_uptime_get_32(void)
|
||||
{
|
||||
/** k_uptime_get_32 is in in milliseconds,
|
||||
/* k_uptime_get_32 is in in milliseconds,
|
||||
* but esp_timer_get_time is in microseconds
|
||||
*/
|
||||
return (u32_t)(esp_timer_get_time() / 1000);
|
||||
return (uint32_t)(esp_timer_get_time() / 1000);
|
||||
}
|
||||
|
||||
void bt_mesh_timer_init(void)
|
||||
@@ -51,6 +51,7 @@ void bt_mesh_timer_init(void)
|
||||
__ASSERT(bm_alarm_hash_map, "Failed to create hash map");
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
void bt_mesh_timer_deinit(void)
|
||||
{
|
||||
if (bm_alarm_hash_map) {
|
||||
@@ -58,6 +59,7 @@ void bt_mesh_timer_deinit(void)
|
||||
bm_alarm_hash_map = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
||||
{
|
||||
@@ -98,7 +100,7 @@ int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay)
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, int32_t delay)
|
||||
{
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -120,7 +122,7 @@ int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period)
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, int32_t period)
|
||||
{
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -184,9 +186,9 @@ int k_delayed_work_free(struct k_delayed_work *work)
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
int32_t k_delayed_work_remaining_get(struct k_delayed_work *work)
|
||||
{
|
||||
s32_t time = 0;
|
||||
int32_t time = 0;
|
||||
|
||||
if (!work || !bm_alarm_hash_map) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
|
||||
@@ -15,8 +15,8 @@ const char *bt_hex(const void *buf, size_t len)
|
||||
{
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
static char hexbufs[2][129];
|
||||
static u8_t curbuf;
|
||||
const u8_t *b = buf;
|
||||
static uint8_t curbuf;
|
||||
const uint8_t *b = buf;
|
||||
char *str = NULL;
|
||||
int i;
|
||||
|
||||
@@ -35,7 +35,7 @@ const char *bt_hex(const void *buf, size_t len)
|
||||
return str;
|
||||
}
|
||||
|
||||
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len)
|
||||
void mem_rcopy(uint8_t *dst, uint8_t const *src, uint16_t len)
|
||||
{
|
||||
src += len;
|
||||
while (len--) {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ACCESS)
|
||||
|
||||
#include "mesh.h"
|
||||
#include "adv.h"
|
||||
#include "transport.h"
|
||||
@@ -25,7 +23,7 @@
|
||||
#define BLE_MESH_SDU_MAX_LEN 384
|
||||
|
||||
static const struct bt_mesh_comp *dev_comp;
|
||||
static u16_t dev_primary_addr;
|
||||
static uint16_t dev_primary_addr;
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem,
|
||||
@@ -57,7 +55,7 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
}
|
||||
}
|
||||
|
||||
s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
||||
int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
||||
{
|
||||
int period = 0;
|
||||
|
||||
@@ -95,10 +93,10 @@ s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod)
|
||||
}
|
||||
}
|
||||
|
||||
static s32_t next_period(struct bt_mesh_model *mod)
|
||||
static int32_t next_period(struct bt_mesh_model *mod)
|
||||
{
|
||||
struct bt_mesh_model_pub *pub = mod->pub;
|
||||
u32_t elapsed = 0U, period = 0U;
|
||||
uint32_t elapsed = 0U, period = 0U;
|
||||
|
||||
if (!pub) {
|
||||
BT_ERR("Model has no publication support");
|
||||
@@ -126,7 +124,7 @@ static s32_t next_period(struct bt_mesh_model *mod)
|
||||
static void publish_sent(int err, void *user_data)
|
||||
{
|
||||
struct bt_mesh_model *mod = user_data;
|
||||
s32_t delay = 0;
|
||||
int32_t delay = 0;
|
||||
|
||||
BT_DBG("err %d", err);
|
||||
|
||||
@@ -147,7 +145,7 @@ static void publish_sent(int err, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
static void publish_start(u16_t duration, int err, void *user_data)
|
||||
static void publish_start(uint16_t duration, int err, void *user_data)
|
||||
{
|
||||
struct bt_mesh_model *mod = user_data;
|
||||
struct bt_mesh_model_pub *pub = mod->pub;
|
||||
@@ -236,7 +234,7 @@ static void mod_publish(struct k_work *work)
|
||||
struct bt_mesh_model_pub *pub = CONTAINER_OF(work,
|
||||
struct bt_mesh_model_pub,
|
||||
timer.work);
|
||||
s32_t period_ms = 0;
|
||||
int32_t period_ms = 0;
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
@@ -287,7 +285,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod)
|
||||
return &dev_comp->elem[mod->elem_idx];
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx)
|
||||
struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx)
|
||||
{
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
@@ -364,6 +362,23 @@ static void mod_init(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/* There must be at least one element */
|
||||
if (!comp->elem_count) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_comp = comp;
|
||||
|
||||
bt_mesh_model_foreach(mod_init, &err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
@@ -404,22 +419,6 @@ static void mod_deinit(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
/* There must be at least one element */
|
||||
if (!comp->elem_count) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_comp = comp;
|
||||
|
||||
bt_mesh_model_foreach(mod_init, &err);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_comp_deregister(void)
|
||||
{
|
||||
int err = 0;
|
||||
@@ -434,8 +433,9 @@ int bt_mesh_comp_deregister(void)
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
void bt_mesh_comp_provision(u16_t addr)
|
||||
void bt_mesh_comp_provision(uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -460,12 +460,12 @@ void bt_mesh_comp_unprovision(void)
|
||||
dev_primary_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
}
|
||||
|
||||
u16_t bt_mesh_primary_addr(void)
|
||||
uint16_t bt_mesh_primary_addr(void)
|
||||
{
|
||||
return dev_primary_addr;
|
||||
}
|
||||
|
||||
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
|
||||
uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -479,10 +479,10 @@ u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr)
|
||||
}
|
||||
|
||||
static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
|
||||
u16_t group_addr)
|
||||
uint16_t group_addr)
|
||||
{
|
||||
struct bt_mesh_model *model = NULL;
|
||||
u16_t *match = NULL;
|
||||
uint16_t *match = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < elem->model_count; i++) {
|
||||
@@ -506,9 +506,9 @@ static struct bt_mesh_model *bt_mesh_elem_find_group(struct bt_mesh_elem *elem,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr)
|
||||
{
|
||||
u16_t index = 0U;
|
||||
uint16_t index = 0U;
|
||||
|
||||
if (BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
index = (addr - dev_comp->elem[0].addr);
|
||||
@@ -530,12 +530,12 @@ struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_elem_count(void)
|
||||
uint8_t bt_mesh_elem_count(void)
|
||||
{
|
||||
return dev_comp->elem_count;
|
||||
}
|
||||
|
||||
static bool model_has_key(struct bt_mesh_model *mod, u16_t key)
|
||||
static bool model_has_key(struct bt_mesh_model *mod, uint16_t key)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -548,7 +548,7 @@ static bool model_has_key(struct bt_mesh_model *mod, u16_t key)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool model_has_dst(struct bt_mesh_model *model, u16_t dst)
|
||||
static bool model_has_dst(struct bt_mesh_model *model, uint16_t dst)
|
||||
{
|
||||
if (BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
return (dev_comp->elem[model->elem_idx].addr == dst);
|
||||
@@ -560,7 +560,7 @@ static bool model_has_dst(struct bt_mesh_model *model, u16_t dst)
|
||||
}
|
||||
|
||||
static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models,
|
||||
u8_t model_count, u32_t opcode,
|
||||
uint8_t model_count, uint32_t opcode,
|
||||
struct bt_mesh_model **model)
|
||||
{
|
||||
int i;
|
||||
@@ -581,7 +581,7 @@ static const struct bt_mesh_model_op *find_op(struct bt_mesh_model *models,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
||||
static int get_opcode(struct net_buf_simple *buf, uint32_t *opcode)
|
||||
{
|
||||
switch (buf->data[0] >> 6) {
|
||||
case 0x00:
|
||||
@@ -619,7 +619,7 @@ static int get_opcode(struct net_buf_simple *buf, u32_t *opcode)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bool bt_mesh_fixed_group_match(u16_t addr)
|
||||
bool bt_mesh_fixed_group_match(uint16_t addr)
|
||||
{
|
||||
/* Check for fixed group addresses */
|
||||
switch (addr) {
|
||||
@@ -640,8 +640,8 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_model *models = NULL, *model = NULL;
|
||||
const struct bt_mesh_model_op *op = NULL;
|
||||
u32_t opcode = 0U;
|
||||
u8_t count = 0U;
|
||||
uint32_t opcode = 0U;
|
||||
uint8_t count = 0U;
|
||||
int i;
|
||||
|
||||
BT_INFO("recv, app_idx 0x%04x src 0x%04x dst 0x%04x", rx->ctx.app_idx,
|
||||
@@ -712,7 +712,7 @@ void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode)
|
||||
void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode)
|
||||
{
|
||||
net_buf_simple_init(msg, 0);
|
||||
|
||||
@@ -737,7 +737,7 @@ void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode)
|
||||
}
|
||||
}
|
||||
|
||||
static bool ready_to_send(u8_t role, u16_t dst)
|
||||
static bool ready_to_send(uint8_t role, uint16_t dst)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
return true;
|
||||
@@ -759,7 +759,7 @@ static int model_send(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *msg,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||
{
|
||||
u8_t role = 0U;
|
||||
uint8_t role = 0U;
|
||||
|
||||
role = bt_mesh_get_device_role(model, tx->ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
@@ -800,7 +800,7 @@ int bt_mesh_model_send(struct bt_mesh_model *model,
|
||||
const struct bt_mesh_send_cb *cb, void *cb_data)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u8_t role = 0U;
|
||||
uint8_t role = 0U;
|
||||
|
||||
role = bt_mesh_get_device_role(model, ctx->srv_send);
|
||||
if (role == ROLE_NVAL) {
|
||||
@@ -909,7 +909,7 @@ int bt_mesh_model_publish(struct bt_mesh_model *model)
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
u16_t company, u16_t id)
|
||||
uint16_t company, uint16_t id)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -923,7 +923,7 @@ struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id)
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -942,7 +942,7 @@ const struct bt_mesh_comp *bt_mesh_comp_get(void)
|
||||
}
|
||||
|
||||
/* APIs used by messages encryption in upper transport layer & network layer */
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx)
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
@@ -957,9 +957,9 @@ struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx)
|
||||
return sub;
|
||||
}
|
||||
|
||||
const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst)
|
||||
const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst)
|
||||
{
|
||||
const u8_t *key = NULL;
|
||||
const uint8_t *key = NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_provisioned() && role == NODE) {
|
||||
key = bt_mesh.dev_key;
|
||||
@@ -972,7 +972,7 @@ const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst)
|
||||
return key;
|
||||
}
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(u8_t role, u16_t app_idx)
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
|
||||
@@ -1067,9 +1067,9 @@ size_t bt_mesh_rx_devkey_size(void)
|
||||
return size;
|
||||
}
|
||||
|
||||
const u8_t *bt_mesh_rx_devkey_get(size_t index, u16_t src)
|
||||
const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src)
|
||||
{
|
||||
const u8_t *key = NULL;
|
||||
const uint8_t *key = NULL;
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE && !CONFIG_BLE_MESH_PROVISIONER
|
||||
if (bt_mesh_is_provisioned()) {
|
||||
|
||||
@@ -22,16 +22,16 @@ enum {
|
||||
BLE_MESH_MOD_PUB_PENDING = BIT(2),
|
||||
};
|
||||
|
||||
void bt_mesh_elem_register(struct bt_mesh_elem *elem, u8_t count);
|
||||
void bt_mesh_elem_register(struct bt_mesh_elem *elem, uint8_t count);
|
||||
|
||||
u8_t bt_mesh_elem_count(void);
|
||||
uint8_t bt_mesh_elem_count(void);
|
||||
|
||||
/* Find local element based on unicast or group address */
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(u16_t addr);
|
||||
struct bt_mesh_elem *bt_mesh_elem_find(uint16_t addr);
|
||||
|
||||
u16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, u16_t addr);
|
||||
uint16_t *bt_mesh_model_find_group(struct bt_mesh_model *mod, uint16_t addr);
|
||||
|
||||
bool bt_mesh_fixed_group_match(u16_t addr);
|
||||
bool bt_mesh_fixed_group_match(uint16_t addr);
|
||||
|
||||
void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem,
|
||||
@@ -39,27 +39,27 @@ void bt_mesh_model_foreach(void (*func)(struct bt_mesh_model *mod,
|
||||
void *user_data),
|
||||
void *user_data);
|
||||
|
||||
s32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod);
|
||||
int32_t bt_mesh_model_pub_period_get(struct bt_mesh_model *mod);
|
||||
|
||||
void bt_mesh_comp_provision(u16_t addr);
|
||||
void bt_mesh_comp_provision(uint16_t addr);
|
||||
void bt_mesh_comp_unprovision(void);
|
||||
|
||||
u16_t bt_mesh_primary_addr(void);
|
||||
uint16_t bt_mesh_primary_addr(void);
|
||||
|
||||
const struct bt_mesh_comp *bt_mesh_comp_get(void);
|
||||
|
||||
struct bt_mesh_model *bt_mesh_model_get(bool vnd, u8_t elem_idx, u8_t mod_idx);
|
||||
struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx);
|
||||
|
||||
void bt_mesh_model_recv(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
|
||||
|
||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
|
||||
int bt_mesh_comp_deregister(void);
|
||||
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(u8_t role, u16_t net_idx);
|
||||
struct bt_mesh_subnet *bt_mesh_tx_netkey_get(uint8_t role, uint16_t net_idx);
|
||||
|
||||
const u8_t *bt_mesh_tx_devkey_get(u8_t role, u16_t dst);
|
||||
const uint8_t *bt_mesh_tx_devkey_get(uint8_t role, uint16_t dst);
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(u8_t role, u16_t app_idx);
|
||||
struct bt_mesh_app_key *bt_mesh_tx_appkey_get(uint8_t role, uint16_t app_idx);
|
||||
|
||||
size_t bt_mesh_rx_netkey_size(void);
|
||||
|
||||
@@ -67,7 +67,7 @@ struct bt_mesh_subnet *bt_mesh_rx_netkey_get(size_t index);
|
||||
|
||||
size_t bt_mesh_rx_devkey_size(void);
|
||||
|
||||
const u8_t *bt_mesh_rx_devkey_get(size_t index, u16_t src);
|
||||
const uint8_t *bt_mesh_rx_devkey_get(size_t index, uint16_t src);
|
||||
|
||||
size_t bt_mesh_rx_appkey_size(void);
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_ADV)
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh.h"
|
||||
#include "mesh_hci.h"
|
||||
@@ -31,19 +29,13 @@
|
||||
/* Convert from 0.625ms units to interval(ms) */
|
||||
#define ADV_SCAN_INT(val) ((val) * 5 / 8)
|
||||
|
||||
/* Window and Interval are equal for continuous scanning */
|
||||
#define MESH_SCAN_INTERVAL 0x20
|
||||
#define MESH_SCAN_WINDOW 0x20
|
||||
|
||||
/* Pre-5.0 controllers enforce a minimum interval of 100ms
|
||||
* whereas 5.0+ controllers can go down to 20ms.
|
||||
*/
|
||||
#define ADV_INT_DEFAULT_MS 100
|
||||
#define ADV_INT_FAST_MS 20
|
||||
|
||||
static const bt_mesh_addr_t *dev_addr;
|
||||
|
||||
static const u8_t adv_type[] = {
|
||||
static const uint8_t adv_type[] = {
|
||||
[BLE_MESH_ADV_PROV] = BLE_MESH_DATA_MESH_PROV,
|
||||
[BLE_MESH_ADV_DATA] = BLE_MESH_DATA_MESH_MESSAGE,
|
||||
[BLE_MESH_ADV_BEACON] = BLE_MESH_DATA_MESH_BEACON,
|
||||
@@ -59,7 +51,7 @@ struct bt_mesh_queue {
|
||||
QueueHandle_t handle;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
StaticQueue_t *buffer;
|
||||
u8_t *storage;
|
||||
uint8_t *storage;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -86,7 +78,7 @@ static QueueSetHandle_t mesh_queue_set;
|
||||
#define BLE_MESH_RELAY_TIME_INTERVAL K_SECONDS(6)
|
||||
#define BLE_MESH_MAX_TIME_INTERVAL 0xFFFFFFFF
|
||||
|
||||
static bool ignore_relay_packet(u32_t timestamp);
|
||||
static bool ignore_relay_packet(uint32_t timestamp);
|
||||
#endif /* defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
@@ -110,7 +102,9 @@ static struct ble_adv_tx {
|
||||
|
||||
#define SEND_BLE_ADV_INFINITE 0xFFFF
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static void bt_mesh_ble_adv_deinit(void);
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
|
||||
struct bt_mesh_adv_task {
|
||||
@@ -130,7 +124,7 @@ static struct bt_mesh_adv *adv_alloc(int id)
|
||||
return &adv_pool[id];
|
||||
}
|
||||
|
||||
static inline void adv_send_start(u16_t duration, int err,
|
||||
static inline void adv_send_start(uint16_t duration, int err,
|
||||
const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data)
|
||||
{
|
||||
@@ -149,12 +143,12 @@ static inline void adv_send_end(int err, const struct bt_mesh_send_cb *cb,
|
||||
|
||||
static inline int adv_send(struct net_buf *buf)
|
||||
{
|
||||
const s32_t adv_int_min = ((bt_mesh_dev.hci_version >= BLE_MESH_HCI_VERSION_5_0) ?
|
||||
ADV_INT_FAST_MS : ADV_INT_DEFAULT_MS);
|
||||
const int32_t adv_int_min = ((bt_mesh_dev.hci_version >= BLE_MESH_HCI_VERSION_5_0) ?
|
||||
ADV_INT_FAST_MS : ADV_INT_DEFAULT_MS);
|
||||
const struct bt_mesh_send_cb *cb = BLE_MESH_ADV(buf)->cb;
|
||||
void *cb_data = BLE_MESH_ADV(buf)->cb_data;
|
||||
struct bt_mesh_adv_param param = {0};
|
||||
u16_t duration = 0U, adv_int = 0U;
|
||||
uint16_t duration = 0U, adv_int = 0U;
|
||||
struct bt_mesh_adv_data ad = {0};
|
||||
int err = 0;
|
||||
|
||||
@@ -237,6 +231,11 @@ static inline int adv_send(struct net_buf *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline TickType_t K_WAIT(int32_t val)
|
||||
{
|
||||
return (val == K_FOREVER) ? portMAX_DELAY : (val / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
static void adv_thread(void *p)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
@@ -256,11 +255,11 @@ static void adv_thread(void *p)
|
||||
CONFIG_BLE_MESH_GATT_PROXY_SERVER
|
||||
xQueueReceive(adv_queue.handle, &msg, K_NO_WAIT);
|
||||
while (!(*buf)) {
|
||||
s32_t timeout;
|
||||
int32_t timeout = 0;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
xQueueReceive(adv_queue.handle, &msg, timeout);
|
||||
xQueueReceive(adv_queue.handle, &msg, K_WAIT(timeout));
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
}
|
||||
@@ -279,11 +278,11 @@ static void adv_thread(void *p)
|
||||
}
|
||||
} else {
|
||||
while (!(*buf)) {
|
||||
s32_t timeout = 0;
|
||||
int32_t timeout = 0;
|
||||
BT_DBG("Mesh Proxy Advertising start");
|
||||
timeout = bt_mesh_proxy_server_adv_start();
|
||||
BT_DBG("Mesh Proxy Advertising up to %d ms", timeout);
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, timeout);
|
||||
handle = xQueueSelectFromSet(mesh_queue_set, K_WAIT(timeout));
|
||||
BT_DBG("Mesh Proxy Advertising stop");
|
||||
bt_mesh_proxy_server_adv_stop();
|
||||
if (handle) {
|
||||
@@ -344,7 +343,7 @@ static void adv_thread(void *p)
|
||||
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
bt_mesh_adv_alloc_t get_id,
|
||||
enum bt_mesh_adv_type type,
|
||||
u8_t xmit, s32_t timeout)
|
||||
uint8_t xmit, int32_t timeout)
|
||||
{
|
||||
struct bt_mesh_adv *adv = NULL;
|
||||
struct net_buf *buf = NULL;
|
||||
@@ -367,8 +366,8 @@ struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
|
||||
(void)memset(adv, 0, sizeof(*adv));
|
||||
|
||||
adv->type = type;
|
||||
adv->xmit = xmit;
|
||||
adv->type = type;
|
||||
adv->xmit = xmit;
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -391,15 +390,15 @@ void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool)
|
||||
}
|
||||
}
|
||||
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout)
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&adv_buf_pool, adv_alloc, type,
|
||||
xmit, timeout);
|
||||
}
|
||||
|
||||
void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
|
||||
u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag)
|
||||
uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag)
|
||||
{
|
||||
if (buf == NULL || func == NULL || flag >= BLE_MESH_BUF_REF_MAX) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -493,10 +492,10 @@ void bt_mesh_adv_update(void)
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF)
|
||||
static bool ignore_relay_packet(u32_t timestamp)
|
||||
static bool ignore_relay_packet(uint32_t timestamp)
|
||||
{
|
||||
u32_t now = k_uptime_get_32();
|
||||
u32_t interval = 0U;
|
||||
uint32_t now = k_uptime_get_32();
|
||||
uint32_t interval = 0U;
|
||||
|
||||
if (now >= timestamp) {
|
||||
interval = now - timestamp;
|
||||
@@ -512,8 +511,8 @@ static struct bt_mesh_adv *relay_adv_alloc(int id)
|
||||
return &relay_adv_pool[id];
|
||||
}
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout)
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&relay_adv_buf_pool, relay_adv_alloc, type,
|
||||
xmit, timeout);
|
||||
@@ -544,7 +543,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
BT_INFO("Full queue, remove the oldest relay packet");
|
||||
/* Remove the oldest relay packet from queue */
|
||||
if (xQueueReceive(relay_queue.handle, &old_msg, K_NO_WAIT) != pdTRUE) {
|
||||
BT_ERR("Failed to remove item from queue");
|
||||
BT_ERR("Failed to remove item from relay queue");
|
||||
bt_mesh_unref_buf(msg);
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +562,7 @@ static void ble_mesh_relay_task_post(bt_mesh_msg_t *msg, uint32_t timeout)
|
||||
}
|
||||
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data, u16_t src, u16_t dst)
|
||||
void *cb_data, uint16_t src, uint16_t dst)
|
||||
{
|
||||
bt_mesh_msg_t msg = {
|
||||
.relay = true,
|
||||
@@ -584,213 +583,12 @@ void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *c
|
||||
ble_mesh_relay_task_post(&msg, K_NO_WAIT);
|
||||
}
|
||||
|
||||
u16_t bt_mesh_get_stored_relay_count(void)
|
||||
uint16_t bt_mesh_get_stored_relay_count(void)
|
||||
{
|
||||
return (u16_t)uxQueueMessagesWaiting(relay_queue.handle);
|
||||
return (uint16_t)uxQueueMessagesWaiting(relay_queue.handle);
|
||||
}
|
||||
#endif /* #if defined(CONFIG_BLE_MESH_RELAY_ADV_BUF) */
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void)
|
||||
{
|
||||
return dev_addr;
|
||||
}
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
static bool adv_flags_valid(struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t flags = 0U;
|
||||
|
||||
if (buf->len != 1U) {
|
||||
BT_DBG("Unexpected adv flags length %d", buf->len);
|
||||
return false;
|
||||
}
|
||||
|
||||
flags = net_buf_simple_pull_u8(buf);
|
||||
|
||||
BT_DBG("Received adv pkt with flags: 0x%02x", flags);
|
||||
|
||||
/* Flags context will not be checked currently */
|
||||
((void) flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool adv_service_uuid_valid(struct net_buf_simple *buf, u16_t *uuid)
|
||||
{
|
||||
if (buf->len != 2U) {
|
||||
BT_DBG("Length not match mesh service uuid");
|
||||
return false;
|
||||
}
|
||||
|
||||
*uuid = net_buf_simple_pull_le16(buf);
|
||||
|
||||
BT_DBG("Received adv pkt with service UUID: %d", *uuid);
|
||||
|
||||
if (*uuid != BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
*uuid != BLE_MESH_UUID_MESH_PROXY_VAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*uuid == BLE_MESH_UUID_MESH_PROV_VAL &&
|
||||
bt_mesh_is_provisioner_en() == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (*uuid == BLE_MESH_UUID_MESH_PROXY_VAL &&
|
||||
!IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_CLIENT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define BLE_MESH_PROV_SRV_DATA_LEN 0x12
|
||||
#define BLE_MESH_PROXY_SRV_DATA_LEN1 0x09
|
||||
#define BLE_MESH_PROXY_SRV_DATA_LEN2 0x11
|
||||
|
||||
static void handle_adv_service_data(struct net_buf_simple *buf,
|
||||
const bt_mesh_addr_t *addr,
|
||||
u16_t uuid, s8_t rssi)
|
||||
{
|
||||
u16_t type = 0U;
|
||||
|
||||
if (!buf || !addr) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
type = net_buf_simple_pull_le16(buf);
|
||||
if (type != uuid) {
|
||||
BT_DBG("Invalid Mesh Service Data UUID 0x%04x", type);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
#if CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT
|
||||
case BLE_MESH_UUID_MESH_PROV_VAL:
|
||||
if (bt_mesh_is_provisioner_en()) {
|
||||
if (buf->len != BLE_MESH_PROV_SRV_DATA_LEN) {
|
||||
BT_WARN("Invalid Mesh Prov Service Data length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Prov Service Data");
|
||||
bt_mesh_provisioner_prov_adv_recv(buf, addr, rssi);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
case BLE_MESH_UUID_MESH_PROXY_VAL:
|
||||
if (buf->len != BLE_MESH_PROXY_SRV_DATA_LEN1 &&
|
||||
buf->len != BLE_MESH_PROXY_SRV_DATA_LEN2) {
|
||||
BT_WARN("Invalid Mesh Proxy Service Data length %d", buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("Start to handle Mesh Proxy Service Data");
|
||||
bt_mesh_proxy_client_gatt_adv_recv(buf, addr, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void bt_mesh_scan_cb(const bt_mesh_addr_t *addr, s8_t rssi,
|
||||
u8_t adv_type, struct net_buf_simple *buf)
|
||||
{
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
u16_t uuid = 0U;
|
||||
#endif
|
||||
|
||||
if (adv_type != BLE_MESH_ADV_NONCONN_IND && adv_type != BLE_MESH_ADV_IND) {
|
||||
return;
|
||||
}
|
||||
|
||||
BT_DBG("scan, len %u: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
dev_addr = addr;
|
||||
|
||||
while (buf->len > 1) {
|
||||
struct net_buf_simple_state state;
|
||||
u8_t len, type;
|
||||
|
||||
len = net_buf_simple_pull_u8(buf);
|
||||
/* Check for early termination */
|
||||
if (len == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (len > buf->len) {
|
||||
BT_WARN("AD malformed");
|
||||
return;
|
||||
}
|
||||
|
||||
net_buf_simple_save(buf, &state);
|
||||
|
||||
type = net_buf_simple_pull_u8(buf);
|
||||
|
||||
buf->len = len - 1;
|
||||
|
||||
#if 0
|
||||
/* TODO: Check with BLE Mesh BQB test cases */
|
||||
if ((type == BLE_MESH_DATA_MESH_PROV || type == BLE_MESH_DATA_MESH_MESSAGE ||
|
||||
type == BLE_MESH_DATA_MESH_BEACON) && (adv_type != BLE_MESH_ADV_NONCONN_IND)) {
|
||||
BT_DBG("%s, ignore BLE Mesh packet (type 0x%02x) with adv_type 0x%02x",
|
||||
__func__, type, adv_type);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (type) {
|
||||
case BLE_MESH_DATA_MESH_MESSAGE:
|
||||
bt_mesh_net_recv(buf, rssi, BLE_MESH_NET_IF_ADV);
|
||||
break;
|
||||
#if CONFIG_BLE_MESH_PB_ADV
|
||||
case BLE_MESH_DATA_MESH_PROV:
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_NODE) && bt_mesh_is_node()) {
|
||||
bt_mesh_pb_adv_recv(buf);
|
||||
}
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_PROVISIONER) && bt_mesh_is_provisioner_en()) {
|
||||
bt_mesh_provisioner_pb_adv_recv(buf);
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_BLE_MESH_PB_ADV */
|
||||
case BLE_MESH_DATA_MESH_BEACON:
|
||||
bt_mesh_beacon_recv(buf, rssi);
|
||||
break;
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
CONFIG_BLE_MESH_GATT_PROXY_CLIENT
|
||||
case BLE_MESH_DATA_FLAGS:
|
||||
if (!adv_flags_valid(buf)) {
|
||||
BT_DBG("Adv Flags mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_UUID16_ALL:
|
||||
if (!adv_service_uuid_valid(buf, &uuid)) {
|
||||
BT_DBG("Adv Service UUID mismatch, ignore this adv pkt");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BLE_MESH_DATA_SVC_DATA16:
|
||||
handle_adv_service_data(buf, addr, uuid, rssi);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
net_buf_simple_restore(buf, &state);
|
||||
net_buf_simple_pull(buf, len);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void bt_mesh_adv_init(void)
|
||||
{
|
||||
#if !CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
@@ -857,6 +655,7 @@ void bt_mesh_adv_init(void)
|
||||
#endif /* CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL && CONFIG_SPIRAM_CACHE_WORKAROUND && CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY */
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
void bt_mesh_adv_deinit(void)
|
||||
{
|
||||
if (adv_queue.handle == NULL) {
|
||||
@@ -910,77 +709,7 @@ void bt_mesh_adv_deinit(void)
|
||||
bt_mesh_ble_adv_deinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
int bt_mesh_scan_enable(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
struct bt_mesh_scan_param scan_param = {
|
||||
.type = BLE_MESH_SCAN_PASSIVE,
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_ENABLE,
|
||||
#else
|
||||
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_DISABLE,
|
||||
#endif
|
||||
.interval = MESH_SCAN_INTERVAL,
|
||||
.window = MESH_SCAN_WINDOW,
|
||||
.scan_fil_policy = BLE_MESH_SP_ADV_ALL,
|
||||
};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
err = bt_le_scan_start(&scan_param, bt_mesh_scan_cb);
|
||||
if (err && err != -EALREADY) {
|
||||
BT_ERR("starting scan failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_scan_disable(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
err = bt_le_scan_stop();
|
||||
if (err && err != -EALREADY) {
|
||||
BT_ERR("stopping scan failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_TEST_USE_WHITE_LIST
|
||||
int bt_mesh_scan_with_wl_enable(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
struct bt_mesh_scan_param scan_param = {
|
||||
.type = BLE_MESH_SCAN_PASSIVE,
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_ENABLE,
|
||||
#else
|
||||
.filter_dup = BLE_MESH_SCAN_FILTER_DUP_DISABLE,
|
||||
#endif
|
||||
.interval = MESH_SCAN_INTERVAL,
|
||||
.window = MESH_SCAN_WINDOW,
|
||||
.scan_fil_policy = BLE_MESH_SP_ADV_WL,
|
||||
};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
err = bt_le_scan_start(&scan_param, bt_mesh_scan_cb);
|
||||
if (err && err != -EALREADY) {
|
||||
BT_ERR("starting scan failed (err %d)", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_TEST_USE_WHITE_LIST */
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
static struct bt_mesh_adv *ble_adv_alloc(int id)
|
||||
@@ -988,7 +717,7 @@ static struct bt_mesh_adv *ble_adv_alloc(int id)
|
||||
return &ble_adv_pool[id];
|
||||
}
|
||||
|
||||
static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, u8_t xmit, s32_t timeout)
|
||||
static struct net_buf *bt_mesh_ble_adv_create(enum bt_mesh_adv_type type, uint8_t xmit, int32_t timeout)
|
||||
{
|
||||
return bt_mesh_adv_create_from_pool(&ble_adv_buf_pool, ble_adv_alloc, type,
|
||||
xmit, timeout);
|
||||
@@ -1032,7 +761,7 @@ static void ble_adv_tx_reset(struct ble_adv_tx *tx, bool unref)
|
||||
tx->buf = NULL;
|
||||
}
|
||||
|
||||
static void ble_adv_send_start(u16_t duration, int err, void *cb_data)
|
||||
static void ble_adv_send_start(uint16_t duration, int err, void *cb_data)
|
||||
{
|
||||
struct ble_adv_tx *tx = cb_data;
|
||||
|
||||
@@ -1098,7 +827,7 @@ static void ble_adv_resend(struct k_work *work)
|
||||
}
|
||||
|
||||
int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
||||
const struct bt_mesh_ble_adv_data *data, u8_t *index)
|
||||
const struct bt_mesh_ble_adv_data *data, uint8_t *index)
|
||||
{
|
||||
struct ble_adv_tx *tx = NULL;
|
||||
struct net_buf *buf = NULL;
|
||||
@@ -1152,7 +881,7 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
||||
|
||||
buf = bt_mesh_ble_adv_create(BLE_MESH_ADV_BLE, 0U, K_NO_WAIT);
|
||||
if (!buf) {
|
||||
BT_ERR("Unable to allocate buffer");
|
||||
BT_ERR("No empty ble adv buffer");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
@@ -1196,7 +925,7 @@ int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_stop_ble_advertising(u8_t index)
|
||||
int bt_mesh_stop_ble_advertising(uint8_t index)
|
||||
{
|
||||
struct ble_adv_tx *tx = NULL;
|
||||
bool unref = true;
|
||||
@@ -1225,6 +954,7 @@ int bt_mesh_stop_ble_advertising(u8_t index)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static void bt_mesh_ble_adv_deinit(void)
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(ble_adv_tx); i++) {
|
||||
@@ -1234,4 +964,5 @@ static void bt_mesh_ble_adv_deinit(void)
|
||||
bt_mesh_unref_buf_from_pool(&ble_adv_buf_pool);
|
||||
memset(ble_adv_pool, 0, sizeof(ble_adv_pool));
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
|
||||
@@ -28,9 +28,9 @@ extern "C" {
|
||||
typedef struct bt_mesh_msg {
|
||||
bool relay; /* Flag indicates if the packet is a relayed one */
|
||||
void *arg; /* Pointer to the struct net_buf */
|
||||
u16_t src; /* Source address for relay packets */
|
||||
u16_t dst; /* Destination address for relay packets */
|
||||
u32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */
|
||||
uint16_t src; /* Source address for relay packets */
|
||||
uint16_t dst; /* Destination address for relay packets */
|
||||
uint32_t timestamp; /* Timestamp recorded when the relay packet is posted to queue */
|
||||
} bt_mesh_msg_t;
|
||||
|
||||
enum bt_mesh_adv_type {
|
||||
@@ -41,23 +41,20 @@ enum bt_mesh_adv_type {
|
||||
BLE_MESH_ADV_BLE,
|
||||
};
|
||||
|
||||
typedef void (*bt_mesh_adv_func_t)(struct net_buf *buf, u16_t duration,
|
||||
int err, void *user_data);
|
||||
|
||||
struct bt_mesh_adv {
|
||||
const struct bt_mesh_send_cb *cb;
|
||||
void *cb_data;
|
||||
|
||||
u8_t type:3,
|
||||
busy:1;
|
||||
u8_t xmit;
|
||||
uint8_t type:3,
|
||||
busy:1;
|
||||
uint8_t xmit;
|
||||
};
|
||||
|
||||
typedef struct bt_mesh_adv *(*bt_mesh_adv_alloc_t)(int id);
|
||||
|
||||
/* xmit_count: Number of retransmissions, i.e. 0 == 1 transmission */
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout);
|
||||
struct net_buf *bt_mesh_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout);
|
||||
|
||||
typedef enum {
|
||||
BLE_MESH_BUF_REF_EQUAL,
|
||||
@@ -66,44 +63,36 @@ typedef enum {
|
||||
} bt_mesh_buf_ref_flag_t;
|
||||
|
||||
void bt_mesh_adv_buf_ref_debug(const char *func, struct net_buf *buf,
|
||||
u8_t ref_cmp, bt_mesh_buf_ref_flag_t flag);
|
||||
uint8_t ref_cmp, bt_mesh_buf_ref_flag_t flag);
|
||||
|
||||
struct net_buf *bt_mesh_adv_create_from_pool(struct net_buf_pool *pool,
|
||||
bt_mesh_adv_alloc_t get_id,
|
||||
enum bt_mesh_adv_type type,
|
||||
u8_t xmit, s32_t timeout);
|
||||
uint8_t xmit, int32_t timeout);
|
||||
|
||||
void bt_mesh_unref_buf_from_pool(struct net_buf_pool *pool);
|
||||
|
||||
void bt_mesh_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data);
|
||||
|
||||
const bt_mesh_addr_t *bt_mesh_get_unprov_dev_addr(void);
|
||||
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, u8_t xmit,
|
||||
s32_t timeout);
|
||||
struct net_buf *bt_mesh_relay_adv_create(enum bt_mesh_adv_type type, uint8_t xmit,
|
||||
int32_t timeout);
|
||||
|
||||
void bt_mesh_relay_adv_send(struct net_buf *buf, const struct bt_mesh_send_cb *cb,
|
||||
void *cb_data, u16_t src, u16_t dst);
|
||||
void *cb_data, uint16_t src, uint16_t dst);
|
||||
|
||||
u16_t bt_mesh_get_stored_relay_count(void);
|
||||
uint16_t bt_mesh_get_stored_relay_count(void);
|
||||
|
||||
void bt_mesh_adv_update(void);
|
||||
|
||||
void bt_mesh_adv_init(void);
|
||||
void bt_mesh_adv_deinit(void);
|
||||
|
||||
int bt_mesh_scan_enable(void);
|
||||
|
||||
int bt_mesh_scan_disable(void);
|
||||
|
||||
int bt_mesh_scan_with_wl_enable(void);
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
int bt_mesh_start_ble_advertising(const struct bt_mesh_ble_adv_param *param,
|
||||
const struct bt_mesh_ble_adv_data *data, u8_t *index);
|
||||
const struct bt_mesh_ble_adv_data *data, uint8_t *index);
|
||||
|
||||
int bt_mesh_stop_ble_advertising(u8_t index);
|
||||
int bt_mesh_stop_ble_advertising(uint8_t index);
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_BEACON)
|
||||
|
||||
#include "adv.h"
|
||||
#include "mesh.h"
|
||||
#include "prov.h"
|
||||
@@ -40,12 +38,12 @@
|
||||
/* 1 transmission, 20ms interval */
|
||||
#define PROV_XMIT BLE_MESH_TRANSMIT(0, 20)
|
||||
|
||||
#define SNB_NET_IDX_SET(_val) ((void *)((u32_t)(_val)))
|
||||
#define SNB_NET_IDX_GET(_ptr) ((u32_t)(_ptr))
|
||||
#define SNB_NET_IDX_SET(_val) ((void *)((uint32_t)(_val)))
|
||||
#define SNB_NET_IDX_GET(_ptr) ((uint32_t)(_ptr))
|
||||
|
||||
static struct k_delayed_work beacon_timer;
|
||||
|
||||
static struct bt_mesh_subnet *cache_check(u8_t data[21])
|
||||
static struct bt_mesh_subnet *cache_check(uint8_t data[21])
|
||||
{
|
||||
size_t subnet_size = 0U;
|
||||
int i = 0;
|
||||
@@ -67,7 +65,7 @@ static struct bt_mesh_subnet *cache_check(u8_t data[21])
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void cache_add(u8_t data[21], struct bt_mesh_subnet *sub)
|
||||
static void cache_add(uint8_t data[21], struct bt_mesh_subnet *sub)
|
||||
{
|
||||
memcpy(sub->beacon_cache, data, 21);
|
||||
}
|
||||
@@ -75,11 +73,11 @@ static void cache_add(u8_t data[21], struct bt_mesh_subnet *sub)
|
||||
static void beacon_complete(int err, void *user_data)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t net_idx = BLE_MESH_KEY_UNUSED;
|
||||
uint16_t net_idx = BLE_MESH_KEY_UNUSED;
|
||||
|
||||
BT_DBG("err %d", err);
|
||||
|
||||
net_idx = (u16_t)SNB_NET_IDX_GET(user_data);
|
||||
net_idx = (uint16_t)SNB_NET_IDX_GET(user_data);
|
||||
|
||||
/* For node, directly updating the "beacon_sent" timestamp is fine,
|
||||
* since the subnet is pre-allocated.
|
||||
@@ -103,7 +101,7 @@ static void beacon_complete(int err, void *user_data)
|
||||
void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t flags = bt_mesh_net_flags(sub);
|
||||
uint8_t flags = bt_mesh_net_flags(sub);
|
||||
struct bt_mesh_subnet_keys *keys = NULL;
|
||||
|
||||
net_buf_simple_add_u8(buf, BEACON_TYPE_SECURE);
|
||||
@@ -131,15 +129,14 @@ void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
|
||||
}
|
||||
|
||||
/* If the interval has passed or is within 5 seconds from now send a beacon */
|
||||
#define BEACON_THRESHOLD(sub) (K_SECONDS(10 * ((sub)->beacons_last + 1)) - \
|
||||
K_SECONDS(5))
|
||||
#define BEACON_THRESHOLD(sub) (K_SECONDS(10 * ((sub)->beacons_last + 1)) - K_SECONDS(5))
|
||||
|
||||
static int secure_beacon_send(void)
|
||||
{
|
||||
static const struct bt_mesh_send_cb send_cb = {
|
||||
.end = beacon_complete,
|
||||
};
|
||||
u32_t now = k_uptime_get_32();
|
||||
uint32_t now = k_uptime_get_32();
|
||||
size_t subnet_size = 0U;
|
||||
int i = 0;
|
||||
|
||||
@@ -150,7 +147,7 @@ static int secure_beacon_send(void)
|
||||
for (i = 0; i < subnet_size; i++) {
|
||||
struct bt_mesh_subnet *sub = bt_mesh_rx_netkey_get(i);
|
||||
struct net_buf *buf;
|
||||
u32_t time_diff;
|
||||
uint32_t time_diff;
|
||||
|
||||
if (sub == NULL || sub->net_idx == BLE_MESH_KEY_UNUSED) {
|
||||
continue;
|
||||
@@ -205,9 +202,9 @@ static int unprovisioned_beacon_send(void)
|
||||
{
|
||||
#if defined(CONFIG_BLE_MESH_PB_ADV)
|
||||
const struct bt_mesh_prov *prov = NULL;
|
||||
u8_t uri_hash[16] = { 0 };
|
||||
uint8_t uri_hash[16] = { 0 };
|
||||
struct net_buf *buf = NULL;
|
||||
u16_t oob_info = 0U;
|
||||
uint16_t oob_info = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
@@ -334,11 +331,13 @@ static void beacon_send(struct k_work *work)
|
||||
|
||||
static void secure_beacon_recv(struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t *data = NULL, *net_id = NULL, *auth = NULL;
|
||||
uint8_t *data = NULL, *net_id = NULL, *auth = NULL;
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u32_t iv_index = 0U;
|
||||
bool new_key = false, kr_change = false, iv_change = false;
|
||||
u8_t flags = 0U;
|
||||
uint32_t iv_index = 0U;
|
||||
bool kr_change = false;
|
||||
bool iv_change = false;
|
||||
bool new_key = false;
|
||||
uint8_t flags = 0U;
|
||||
|
||||
if (buf->len < 21) {
|
||||
BT_ERR("Too short secure beacon (len %u)", buf->len);
|
||||
@@ -413,9 +412,9 @@ update_stats:
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi)
|
||||
void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi)
|
||||
{
|
||||
u8_t type = 0U;
|
||||
uint8_t type = 0U;
|
||||
|
||||
BT_DBG("%u bytes: %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
|
||||
@@ -447,10 +446,12 @@ void bt_mesh_beacon_init(void)
|
||||
k_delayed_work_init(&beacon_timer, beacon_send);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
void bt_mesh_beacon_deinit(void)
|
||||
{
|
||||
k_delayed_work_free(&beacon_timer);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
void bt_mesh_beacon_ivu_initiator(bool enable)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ void bt_mesh_beacon_disable(void);
|
||||
|
||||
void bt_mesh_beacon_ivu_initiator(bool enable);
|
||||
|
||||
void bt_mesh_beacon_recv(struct net_buf_simple *buf, s8_t rssi);
|
||||
void bt_mesh_beacon_recv(struct net_buf_simple *buf, int8_t rssi);
|
||||
|
||||
void bt_mesh_beacon_create(struct bt_mesh_subnet *sub,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
@@ -38,8 +38,8 @@ struct bt_mesh_dev bt_mesh_dev;
|
||||
} \
|
||||
} while(0);
|
||||
|
||||
#define BLE_MESH_GATT_GET_CONN_ID(conn_id) (((u16_t)(conn_id)) >> 8)
|
||||
#define BLE_MESH_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((u16_t)((((u8_t)(conn_id)) << 8) | ((u8_t)(gatt_if))))
|
||||
#define BLE_MESH_GATT_GET_CONN_ID(conn_id) (((uint16_t)(conn_id)) >> 8)
|
||||
#define BLE_MESH_GATT_CREATE_CONN_ID(gatt_if, conn_id) ((uint16_t)((((uint8_t)(conn_id)) << 8) | ((uint8_t)(gatt_if))))
|
||||
|
||||
/* We don't need to manage the BLE_MESH_DEV_ADVERTISING flags in the version of Bluedroid,
|
||||
* it will manage it in the BTM layer.
|
||||
@@ -47,7 +47,7 @@ struct bt_mesh_dev bt_mesh_dev;
|
||||
#define BLE_MESH_DEV 0
|
||||
|
||||
/* P-256 Variables */
|
||||
static u8_t bt_mesh_public_key[64];
|
||||
static uint8_t bt_mesh_public_key[64];
|
||||
static BT_OCTET32 bt_mesh_private_key;
|
||||
|
||||
/* Scan related functions */
|
||||
@@ -66,11 +66,11 @@ static struct bt_mesh_conn bt_mesh_gatts_conn[BLE_MESH_MAX_CONN];
|
||||
static struct bt_mesh_conn_cb *bt_mesh_gatts_conn_cb;
|
||||
static tBTA_GATTS_IF bt_mesh_gatts_if;
|
||||
static BD_ADDR bt_mesh_gatts_addr;
|
||||
static u16_t svc_handle, char_handle;
|
||||
static uint16_t svc_handle, char_handle;
|
||||
static future_t *future_mesh;
|
||||
|
||||
/* Static Functions */
|
||||
static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle);
|
||||
static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle);
|
||||
#endif
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
@@ -81,14 +81,14 @@ static struct gattc_prov_info {
|
||||
/* Service to be found depends on the type of adv pkt received */
|
||||
struct bt_mesh_conn conn;
|
||||
bt_mesh_addr_t addr;
|
||||
u16_t service_uuid;
|
||||
u16_t mtu;
|
||||
bool wr_desc_done; /* Indicate if write char descriptor event is received */
|
||||
u16_t start_handle; /* Service attribute start handle */
|
||||
u16_t end_handle; /* Service attribute end handle */
|
||||
u16_t data_in_handle; /* Data In Characteristic attribute handle */
|
||||
u16_t data_out_handle; /* Data Out Characteristic attribute handle */
|
||||
u16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */
|
||||
uint16_t service_uuid;
|
||||
uint16_t mtu;
|
||||
bool wr_desc_done; /* Indicate if write char descriptor event is received */
|
||||
uint16_t start_handle; /* Service attribute start handle */
|
||||
uint16_t end_handle; /* Service attribute end handle */
|
||||
uint16_t data_in_handle; /* Data In Characteristic attribute handle */
|
||||
uint16_t data_out_handle; /* Data Out Characteristic attribute handle */
|
||||
uint16_t ccc_handle; /* Data Out Characteristic CCC attribute handle */
|
||||
} bt_mesh_gattc_info[BLE_MESH_MAX_CONN];
|
||||
static struct bt_mesh_prov_conn_cb *bt_mesh_gattc_conn_cb;
|
||||
static tBTA_GATTC_IF bt_mesh_gattc_if;
|
||||
@@ -128,7 +128,7 @@ void bt_mesh_hci_init(void)
|
||||
bt_mesh_dev.le.states = (states_sh << 32) | states_fh;
|
||||
}
|
||||
|
||||
static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir,
|
||||
static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, uint8_t *p_eir,
|
||||
tBTA_DM_SEARCH_CBACK *p_scan_cback)
|
||||
{
|
||||
tBTM_INQ_INFO *p_inq_info = NULL;
|
||||
@@ -166,7 +166,7 @@ static void bt_mesh_scan_results_change_2_bta(tBTM_INQ_RESULTS *p_inq, u8_t *p_e
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_scan_results_cb(tBTM_INQ_RESULTS *p_inq, u8_t *p_eir)
|
||||
static void bt_mesh_scan_results_cb(tBTM_INQ_RESULTS *p_inq, uint8_t *p_eir)
|
||||
{
|
||||
bt_mesh_scan_results_change_2_bta(p_inq, p_eir, bt_mesh_scan_result_callback);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ static bool valid_adv_param(const struct bt_mesh_adv_param *param)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int set_adv_data(u16_t hci_op, const struct bt_mesh_adv_data *ad, size_t ad_len)
|
||||
static int set_adv_data(uint16_t hci_op, const struct bt_mesh_adv_data *ad, size_t ad_len)
|
||||
{
|
||||
struct bt_mesh_hci_cp_set_adv_data param = {0};
|
||||
int i;
|
||||
@@ -222,7 +222,7 @@ static int set_adv_data(u16_t hci_op, const struct bt_mesh_adv_data *ad, size_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void start_adv_completed_cb(u8_t status)
|
||||
static void start_adv_completed_cb(uint8_t status)
|
||||
{
|
||||
#if BLE_MESH_DEV
|
||||
if (!status) {
|
||||
@@ -258,8 +258,8 @@ static bool valid_scan_param(const struct bt_mesh_scan_param *param)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window,
|
||||
u8_t filter_dup, u8_t scan_fil_policy)
|
||||
static int start_le_scan(uint8_t scan_type, uint16_t interval, uint16_t window,
|
||||
uint8_t filter_dup, uint8_t scan_fil_policy)
|
||||
{
|
||||
UINT8 addr_type_own = BLE_MESH_ADDR_PUBLIC; /* Currently only support Public Address */
|
||||
tGATT_IF client_if = 0xFF; /* Default GATT interface id */
|
||||
@@ -284,31 +284,21 @@ static int start_le_scan(u8_t scan_type, u16_t interval, u16_t window,
|
||||
|
||||
static void bt_mesh_scan_result_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
{
|
||||
struct net_buf_simple buf = {0};
|
||||
bt_mesh_addr_t addr = {0};
|
||||
u8_t adv_type = 0U;
|
||||
s8_t rssi = 0;
|
||||
|
||||
BT_DBG("%s, event %d", __func__, event);
|
||||
|
||||
if (event == BTA_DM_INQ_RES_EVT) {
|
||||
/* TODO: How to process scan response here? */
|
||||
/* TODO: How to process scan response here? PS: p_data->inq_res.scan_rsp_len */
|
||||
addr.type = p_data->inq_res.ble_addr_type;
|
||||
memcpy(addr.val, p_data->inq_res.bd_addr, BLE_MESH_ADDR_LEN);
|
||||
rssi = p_data->inq_res.rssi;
|
||||
adv_type = p_data->inq_res.ble_evt_type;
|
||||
|
||||
/* scan rsp len: p_data->inq_res.scan_rsp_len */
|
||||
struct net_buf_simple *buf = bt_mesh_alloc_buf(p_data->inq_res.adv_data_len);
|
||||
if (!buf) {
|
||||
BT_ERR("%s, Out of memory", __func__);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len);
|
||||
net_buf_simple_init_with_data(&buf, p_data->inq_res.p_eir, p_data->inq_res.adv_data_len);
|
||||
|
||||
if (bt_mesh_scan_dev_found_cb != NULL) {
|
||||
bt_mesh_scan_dev_found_cb(&addr, rssi, adv_type, buf);
|
||||
if (bt_mesh_scan_dev_found_cb) {
|
||||
bt_mesh_scan_dev_found_cb(&addr, p_data->inq_res.rssi, p_data->inq_res.ble_evt_type, &buf);
|
||||
}
|
||||
bt_mesh_free(buf);
|
||||
} else if (event == BTA_DM_INQ_CMPL_EVT) {
|
||||
BT_INFO("Scan completed, number of scan response %d", p_data->inq_cmpl.num_resps);
|
||||
} else {
|
||||
@@ -326,7 +316,7 @@ int bt_le_adv_start(const struct bt_mesh_adv_param *param,
|
||||
tBLE_ADDR_TYPE addr_type_own = 0U;
|
||||
tBLE_BD_ADDR p_dir_bda = {0};
|
||||
tBTM_BLE_AFP adv_fil_pol = 0U;
|
||||
u8_t adv_type = 0U;
|
||||
uint8_t adv_type = 0U;
|
||||
int err = 0;
|
||||
|
||||
#if BLE_MESH_DEV
|
||||
@@ -532,10 +522,10 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT: {
|
||||
struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(p_data->req_data.p_data->read_req.handle);
|
||||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
tBTA_GATTS_RSP rsp = {0};
|
||||
u8_t buf[100] = {0};
|
||||
u16_t len = 0;
|
||||
uint8_t buf[100] = {0};
|
||||
uint16_t len = 0;
|
||||
|
||||
BT_DBG("gatts read, handle %d", p_data->req_data.p_data->read_req.handle);
|
||||
|
||||
@@ -556,8 +546,8 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
}
|
||||
case BTA_GATTS_WRITE_EVT: {
|
||||
struct bt_mesh_gatt_attr *attr = bt_mesh_gatts_find_attr_by_handle(p_data->req_data.p_data->write_req.handle);
|
||||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
u16_t len = 0;
|
||||
uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->req_data.conn_id);
|
||||
uint16_t len = 0;
|
||||
|
||||
BT_DBG("gatts write, handle %d, len %d, data %s", p_data->req_data.p_data->write_req.handle,
|
||||
p_data->req_data.p_data->write_req.len,
|
||||
@@ -620,7 +610,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING);
|
||||
#endif
|
||||
if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->connected != NULL) {
|
||||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
if (index < BLE_MESH_MAX_CONN) {
|
||||
bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
(bt_mesh_gatts_conn_cb->connected)(&bt_mesh_gatts_conn[index], 0);
|
||||
@@ -639,7 +629,7 @@ static void bt_mesh_bta_gatts_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
bt_mesh_atomic_test_and_clear_bit(bt_mesh_dev.flags, BLE_MESH_DEV_ADVERTISING);
|
||||
#endif
|
||||
if (bt_mesh_gatts_conn_cb != NULL && bt_mesh_gatts_conn_cb->disconnected != NULL) {
|
||||
u8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
uint8_t index = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
if (index < BLE_MESH_MAX_CONN) {
|
||||
bt_mesh_gatts_conn[index].handle = BLE_MESH_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
(bt_mesh_gatts_conn_cb->disconnected)(&bt_mesh_gatts_conn[index], p_data->conn.reason);
|
||||
@@ -664,7 +654,7 @@ void bt_mesh_gatts_conn_cb_deregister(void)
|
||||
bt_mesh_gatts_conn_cb = NULL;
|
||||
}
|
||||
|
||||
static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle)
|
||||
static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(uint16_t handle)
|
||||
{
|
||||
struct bt_mesh_gatt_service *svc = NULL;
|
||||
struct bt_mesh_gatt_attr *attr = NULL;
|
||||
@@ -684,7 +674,7 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_find_attr_by_handle(u16_t handle)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle,
|
||||
static void bt_mesh_gatts_foreach_attr(uint16_t start_handle, uint16_t end_handle,
|
||||
bt_mesh_gatt_attr_func_t func, void *user_data)
|
||||
{
|
||||
struct bt_mesh_gatt_service *svc = NULL;
|
||||
@@ -708,7 +698,7 @@ static void bt_mesh_gatts_foreach_attr(u16_t start_handle, u16_t end_handle,
|
||||
}
|
||||
}
|
||||
|
||||
static u8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data)
|
||||
static uint8_t find_next(const struct bt_mesh_gatt_attr *attr, void *user_data)
|
||||
{
|
||||
struct bt_mesh_gatt_attr **next = user_data;
|
||||
|
||||
@@ -728,10 +718,10 @@ static struct bt_mesh_gatt_attr *bt_mesh_gatts_attr_next(const struct bt_mesh_ga
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len)
|
||||
void *buf, uint16_t buf_len, uint16_t offset,
|
||||
const void *value, uint16_t value_len)
|
||||
{
|
||||
u16_t len = 0U;
|
||||
uint16_t len = 0U;
|
||||
|
||||
if (offset > value_len) {
|
||||
return BLE_MESH_GATT_ERR(BLE_MESH_ATT_ERR_INVALID_OFFSET);
|
||||
@@ -747,19 +737,19 @@ ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
}
|
||||
|
||||
struct gatts_incl {
|
||||
u16_t start_handle;
|
||||
u16_t end_handle;
|
||||
u16_t uuid16;
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
uint16_t uuid16;
|
||||
} __packed;
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
void *buf, uint16_t len, uint16_t offset)
|
||||
{
|
||||
struct bt_mesh_gatt_attr *incl = attr->user_data;
|
||||
struct bt_mesh_uuid *uuid = incl->user_data;
|
||||
struct gatts_incl pdu = {0};
|
||||
u8_t value_len = 0U;
|
||||
uint8_t value_len = 0U;
|
||||
|
||||
/* First attr points to the start handle */
|
||||
pdu.start_handle = sys_cpu_to_le16(incl->handle);
|
||||
@@ -779,12 +769,12 @@ ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
void *buf, uint16_t len, uint16_t offset)
|
||||
{
|
||||
struct bt_mesh_uuid *uuid = attr->user_data;
|
||||
|
||||
if (uuid->type == BLE_MESH_UUID_TYPE_16) {
|
||||
u16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val);
|
||||
uint16_t uuid16 = sys_cpu_to_le16(BLE_MESH_UUID_16(uuid)->val);
|
||||
|
||||
return bt_mesh_gatts_attr_read(conn, attr, buf, len, offset, &uuid16, 2);
|
||||
}
|
||||
@@ -794,22 +784,22 @@ ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn,
|
||||
}
|
||||
|
||||
struct gatts_chrc {
|
||||
u8_t properties;
|
||||
u16_t value_handle;
|
||||
uint8_t properties;
|
||||
uint16_t value_handle;
|
||||
union {
|
||||
u16_t uuid16;
|
||||
u8_t uuid[16];
|
||||
uint16_t uuid16;
|
||||
uint8_t uuid[16];
|
||||
};
|
||||
} __packed;
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset)
|
||||
void *buf, uint16_t len, uint16_t offset)
|
||||
{
|
||||
struct bt_mesh_gatt_char *chrc = attr->user_data;
|
||||
const struct bt_mesh_gatt_attr *next = NULL;
|
||||
struct gatts_chrc pdu = {0};
|
||||
u8_t value_len = 0U;
|
||||
uint8_t value_len = 0U;
|
||||
|
||||
pdu.properties = chrc->properties;
|
||||
/* BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part G] page 534:
|
||||
@@ -862,7 +852,7 @@ static void bta_uuid_to_bt_mesh_uuid(tBT_UUID *bta_uuid, const struct bt_mesh_uu
|
||||
static int gatts_register(struct bt_mesh_gatt_service *svc)
|
||||
{
|
||||
struct bt_mesh_gatt_service *last = NULL;
|
||||
u16_t handle = 0U;
|
||||
uint16_t handle = 0U;
|
||||
|
||||
if (sys_slist_is_empty(&bt_mesh_gatts_db)) {
|
||||
handle = 0;
|
||||
@@ -890,7 +880,7 @@ static int gatts_deregister(struct bt_mesh_gatt_service *svc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static tBTA_GATT_PERM bt_mesh_perm_to_bta_perm(u8_t perm)
|
||||
static tBTA_GATT_PERM bt_mesh_perm_to_bta_perm(uint8_t perm)
|
||||
{
|
||||
tBTA_GATT_PERM bta_perm = 0;
|
||||
|
||||
@@ -1025,10 +1015,10 @@ int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason)
|
||||
int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason)
|
||||
{
|
||||
UNUSED(reason);
|
||||
u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
BTA_GATTS_Close(conn_id);
|
||||
return 0;
|
||||
}
|
||||
@@ -1043,14 +1033,14 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc)
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
const void *data, uint16_t len)
|
||||
{
|
||||
u16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
BTA_GATTS_HandleValueIndication(conn_id, attr->handle, len, (u8_t *)data, false);
|
||||
uint16_t conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gatts_if, conn->handle);
|
||||
BTA_GATTS_HandleValueIndication(conn_id, attr->handle, len, (uint8_t *)data, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn)
|
||||
uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn)
|
||||
{
|
||||
return BTA_GATT_GetLocalMTU();
|
||||
}
|
||||
@@ -1101,7 +1091,7 @@ int bt_mesh_gatts_service_start(struct bt_mesh_gatt_service *svc)
|
||||
|
||||
int bt_mesh_gatts_set_local_device_name(const char *name)
|
||||
{
|
||||
BLE_MESH_BTM_CHECK_STATUS(BTM_SetLocalDeviceName((char *)name));
|
||||
BTM_SetLocalDeviceName((char *)name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1120,9 +1110,9 @@ void bt_mesh_gattc_conn_cb_deregister(void)
|
||||
bt_mesh_gattc_conn_cb = NULL;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_gattc_get_free_conn_count(void)
|
||||
uint8_t bt_mesh_gattc_get_free_conn_count(void)
|
||||
{
|
||||
u8_t count = 0U;
|
||||
uint8_t count = 0U;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
@@ -1135,7 +1125,7 @@ u8_t bt_mesh_gattc_get_free_conn_count(void)
|
||||
return count;
|
||||
}
|
||||
|
||||
u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
||||
uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1159,9 +1149,9 @@ u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn)
|
||||
* 6. Set the Notification bit of CCC
|
||||
*/
|
||||
|
||||
int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
||||
int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid)
|
||||
{
|
||||
u8_t zero[6] = {0};
|
||||
uint8_t zero[6] = {0};
|
||||
int i;
|
||||
|
||||
if (!addr || !memcmp(addr->val, zero, BLE_MESH_ADDR_LEN) ||
|
||||
@@ -1209,33 +1199,33 @@ int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid)
|
||||
|
||||
BT_DBG("Create conn with %s", bt_hex(addr->val, BLE_MESH_ADDR_LEN));
|
||||
|
||||
/* Min_interval: 250ms
|
||||
* Max_interval: 250ms
|
||||
/* Min_interval: 15ms
|
||||
* Max_interval: 15ms
|
||||
* Slave_latency: 0x0
|
||||
* Supervision_timeout: 32 sec
|
||||
* Supervision_timeout: 1s
|
||||
*/
|
||||
BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0xC8, 0xC8, 0x00, 0xC80);
|
||||
BTA_DmSetBlePrefConnParams(bt_mesh_gattc_info[i].addr.val, 0x18, 0x18, 0x00, 0x64);
|
||||
|
||||
BTA_GATTC_Open(bt_mesh_gattc_if, bt_mesh_gattc_info[i].addr.val,
|
||||
bt_mesh_gattc_info[i].addr.type, true, BTA_GATT_TRANSPORT_LE);
|
||||
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_gattc_exchange_mtu(u8_t index)
|
||||
void bt_mesh_gattc_exchange_mtu(uint8_t index)
|
||||
{
|
||||
/** Set local MTU and exchange with GATT server.
|
||||
* ATT_MTU >= 69 for Mesh GATT Prov Service
|
||||
* ATT_NTU >= 33 for Mesh GATT Proxy Service
|
||||
*/
|
||||
u16_t conn_id = 0U;
|
||||
uint16_t conn_id = 0U;
|
||||
|
||||
conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gattc_if, bt_mesh_gattc_info[index].conn.handle);
|
||||
|
||||
BTA_GATTC_ConfigureMTU(conn_id);
|
||||
}
|
||||
|
||||
u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
||||
uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1250,9 +1240,9 @@ u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn)
|
||||
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len)
|
||||
const void *data, uint16_t len)
|
||||
{
|
||||
u16_t conn_id = 0U;
|
||||
uint16_t conn_id = 0U;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
@@ -1260,7 +1250,7 @@ int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn,
|
||||
conn_id = BLE_MESH_GATT_CREATE_CONN_ID(bt_mesh_gattc_if, bt_mesh_gattc_info[i].conn.handle);
|
||||
BTA_GATTC_WriteCharValue(conn_id, bt_mesh_gattc_info[i].data_in_handle,
|
||||
BTA_GATTC_TYPE_WRITE_NO_RSP, len,
|
||||
(u8_t *)data, BTA_GATT_AUTH_REQ_NONE);
|
||||
(uint8_t *)data, BTA_GATT_AUTH_REQ_NONE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1279,7 +1269,7 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
||||
* when proxy_disconnected callback comes, the proxy server
|
||||
* information and prov_link information should be cleared.
|
||||
*/
|
||||
u16_t conn_id = 0U;
|
||||
uint16_t conn_id = 0U;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh_gattc_info); i++) {
|
||||
@@ -1304,14 +1294,14 @@ void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn)
|
||||
static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
{
|
||||
struct bt_mesh_conn *conn = NULL;
|
||||
u16_t handle = 0U;
|
||||
uint16_t handle = 0U;
|
||||
ssize_t len = 0;
|
||||
int i = 0;
|
||||
|
||||
switch (event) {
|
||||
case BTA_GATTC_REG_EVT:
|
||||
if (p_data->reg_oper.status == BTA_GATT_OK) {
|
||||
u8_t uuid[16] = { [0 ... 15] = BLE_MESH_GATTC_APP_UUID_BYTE };
|
||||
uint8_t uuid[16] = { [0 ... 15] = BLE_MESH_GATTC_APP_UUID_BYTE };
|
||||
|
||||
BT_DBG("BTA_GATTC_REG_EVT");
|
||||
|
||||
@@ -1386,13 +1376,13 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
u16_t notify_en = BLE_MESH_GATT_CCC_NOTIFY;
|
||||
uint16_t notify_en = BLE_MESH_GATT_CCC_NOTIFY;
|
||||
btgatt_db_element_t *result = NULL;
|
||||
tBT_UUID char_uuid = {0};
|
||||
tBTA_GATT_STATUS status = 0U;
|
||||
tBTA_GATT_UNFMT write = {0};
|
||||
u16_t count = 0U;
|
||||
u16_t num = 0;
|
||||
uint16_t count = 0U;
|
||||
uint16_t num = 0;
|
||||
|
||||
/* Get the characteristic num within Mesh Provisioning/Proxy Service */
|
||||
BTA_GATTC_GetDBSizeByType(p_data->search_cmpl.conn_id, BTGATT_DB_CHARACTERISTIC,
|
||||
@@ -1490,7 +1480,7 @@ static void bt_mesh_bta_gattc_cb(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
* Characteristic Descriptor.
|
||||
*/
|
||||
write.len = sizeof(notify_en);
|
||||
write.p_value = (u8_t *)¬ify_en;
|
||||
write.p_value = (uint8_t *)¬ify_en;
|
||||
BTA_GATTC_WriteCharDescr(p_data->search_cmpl.conn_id, result[0].attribute_handle,
|
||||
BTA_GATTC_TYPE_WRITE, &write, BTA_GATT_AUTH_REQ_NONE);
|
||||
|
||||
@@ -1749,6 +1739,7 @@ void bt_mesh_gatt_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
void bt_mesh_gatt_deinit(void)
|
||||
{
|
||||
#if (CONFIG_BLE_MESH_NODE && CONFIG_BLE_MESH_PB_GATT) || \
|
||||
@@ -1778,6 +1769,7 @@ void bt_mesh_gatt_deinit(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
void bt_mesh_adapt_init(void)
|
||||
{
|
||||
@@ -1795,30 +1787,12 @@ void bt_mesh_adapt_init(void)
|
||||
bt_mesh_rand(bt_mesh_private_key, sizeof(bt_mesh_private_key));
|
||||
}
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (buf == NULL || len == 0) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(len / sizeof(u32_t)); i++) {
|
||||
u32_t rand = esp_random();
|
||||
memcpy(buf + i * sizeof(u32_t), &rand, sizeof(u32_t));
|
||||
}
|
||||
|
||||
BT_DBG("Rand %s", bt_hex(buf, len));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_set_private_key(const u8_t pri_key[32])
|
||||
void bt_mesh_set_private_key(const uint8_t pri_key[32])
|
||||
{
|
||||
memcpy(bt_mesh_private_key, pri_key, 32);
|
||||
}
|
||||
|
||||
const u8_t *bt_mesh_pub_key_get(void)
|
||||
const uint8_t *bt_mesh_pub_key_get(void)
|
||||
{
|
||||
BT_OCTET32 private_key = {0};
|
||||
Point public_key = {0};
|
||||
@@ -1854,11 +1828,11 @@ const u8_t *bt_mesh_pub_key_get(void)
|
||||
return bt_mesh_public_key;
|
||||
}
|
||||
|
||||
bool bt_mesh_check_public_key(const u8_t key[64])
|
||||
bool bt_mesh_check_public_key(const uint8_t key[64])
|
||||
{
|
||||
struct p256_pub_key {
|
||||
u8_t x[32];
|
||||
u8_t y[32];
|
||||
uint8_t x[32];
|
||||
uint8_t y[32];
|
||||
} check = {0};
|
||||
|
||||
sys_memcpy_swap(check.x, key, 32);
|
||||
@@ -1867,7 +1841,7 @@ bool bt_mesh_check_public_key(const u8_t key[64])
|
||||
return ECC_CheckPointIsInElliCur_P256((Point *)&check);
|
||||
}
|
||||
|
||||
int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx)
|
||||
int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx)
|
||||
{
|
||||
BT_OCTET32 private_key = {0};
|
||||
Point peer_pub_key = {0};
|
||||
@@ -1888,65 +1862,42 @@ int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u
|
||||
BT_DBG("new public key y = %s", bt_hex(new_pub_key.y, 32));
|
||||
|
||||
if (cb != NULL) {
|
||||
cb((const u8_t *)new_pub_key.x, idx);
|
||||
cb((const uint8_t *)new_pub_key.x, idx);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
static void ecb_encrypt(u8_t const *const key_le, u8_t const *const clear_text_le,
|
||||
u8_t *const cipher_text_le, u8_t *const cipher_text_be)
|
||||
int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
uint8_t enc_data[16])
|
||||
{
|
||||
struct bt_mesh_ecb_param ecb = {0};
|
||||
mbedtls_aes_context aes_ctx = {0};
|
||||
uint8_t tmp[16] = {0};
|
||||
|
||||
aes_ctx.key_bytes = 16;
|
||||
mem_rcopy(&aes_ctx.key[0], key_le, 16);
|
||||
mem_rcopy(&ecb.clear_text[0], clear_text_le, sizeof(ecb.clear_text));
|
||||
mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, &ecb.clear_text[0], &ecb.cipher_text[0]);
|
||||
|
||||
if (cipher_text_le) {
|
||||
mem_rcopy(cipher_text_le, &ecb.cipher_text[0],
|
||||
sizeof(ecb.cipher_text));
|
||||
}
|
||||
|
||||
if (cipher_text_be) {
|
||||
memcpy(cipher_text_be, &ecb.cipher_text[0],
|
||||
sizeof(ecb.cipher_text));
|
||||
}
|
||||
}
|
||||
|
||||
static void ecb_encrypt_be(u8_t const *const key_be, u8_t const *const clear_text_be,
|
||||
u8_t *const cipher_text_be)
|
||||
{
|
||||
struct bt_mesh_ecb_param ecb = {0};
|
||||
mbedtls_aes_context aes_ctx = {0};
|
||||
|
||||
aes_ctx.key_bytes = 16;
|
||||
memcpy(&aes_ctx.key[0], key_be, 16);
|
||||
memcpy(&ecb.clear_text[0], clear_text_be, sizeof(ecb.clear_text));
|
||||
mbedtls_aes_crypt_ecb(&aes_ctx, MBEDTLS_AES_ENCRYPT, &ecb.clear_text[0], &ecb.cipher_text[0]);
|
||||
|
||||
memcpy(cipher_text_be, &ecb.cipher_text[0], sizeof(ecb.cipher_text));
|
||||
}
|
||||
#endif /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
|
||||
int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
|
||||
u8_t enc_data[16])
|
||||
{
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
|
||||
|
||||
ecb_encrypt(key, plaintext, enc_data, NULL);
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
mbedtls_aes_context ctx = {0};
|
||||
|
||||
BT_DBG("enc_data %s", bt_hex(enc_data, 16));
|
||||
return 0;
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
sys_memcpy_swap(tmp, key, 16);
|
||||
|
||||
if (mbedtls_aes_setkey_enc(&ctx, tmp, 128) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sys_memcpy_swap(tmp, plaintext, 16);
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT,
|
||||
tmp, enc_data) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&ctx);
|
||||
#else /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
struct tc_aes_key_sched_struct s = {0};
|
||||
u8_t tmp[16] = {0};
|
||||
|
||||
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
|
||||
|
||||
sys_memcpy_swap(tmp, key, 16);
|
||||
|
||||
@@ -1959,31 +1910,40 @@ int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
|
||||
if (tc_aes_encrypt(enc_data, tmp, &s) == TC_CRYPTO_FAIL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
|
||||
sys_mem_swap(enc_data, 16);
|
||||
|
||||
BT_DBG("enc_data %s", bt_hex(enc_data, 16));
|
||||
|
||||
return 0;
|
||||
#endif /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
}
|
||||
|
||||
int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
|
||||
u8_t enc_data[16])
|
||||
int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
uint8_t enc_data[16])
|
||||
{
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
|
||||
|
||||
ecb_encrypt_be(key, plaintext, enc_data);
|
||||
#if CONFIG_MBEDTLS_HARDWARE_AES
|
||||
mbedtls_aes_context ctx = {0};
|
||||
|
||||
BT_DBG("enc_data %s", bt_hex(enc_data, 16));
|
||||
mbedtls_aes_init(&ctx);
|
||||
|
||||
return 0;
|
||||
if (mbedtls_aes_setkey_enc(&ctx, key, 128) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT,
|
||||
plaintext, enc_data) != 0) {
|
||||
mbedtls_aes_free(&ctx);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&ctx);
|
||||
#else /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
struct tc_aes_key_sched_struct s = {0};
|
||||
|
||||
BT_DBG("key %s plaintext %s", bt_hex(key, 16), bt_hex(plaintext, 16));
|
||||
|
||||
if (tc_aes128_set_encrypt_key(&s, key) == TC_CRYPTO_FAIL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -1991,15 +1951,15 @@ int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
|
||||
if (tc_aes_encrypt(enc_data, plaintext, &s) == TC_CRYPTO_FAIL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
|
||||
BT_DBG("enc_data %s", bt_hex(enc_data, 16));
|
||||
|
||||
return 0;
|
||||
#endif /* CONFIG_MBEDTLS_HARDWARE_AES */
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_USE_DUPLICATE_SCAN)
|
||||
int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info)
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info)
|
||||
{
|
||||
BD_ADDR value = {0};
|
||||
|
||||
@@ -2014,7 +1974,7 @@ int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info)
|
||||
BT_ERR("Invalid Provisioning Link ID");
|
||||
return -EINVAL;
|
||||
}
|
||||
sys_memcpy_swap(value, info, sizeof(u32_t));
|
||||
sys_memcpy_swap(value, info, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
BT_DBG("%s exceptional list, type 0x%02x", sub_code ? "Remove" : "Add", type);
|
||||
|
||||
@@ -11,15 +11,16 @@
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
|
||||
#include "mesh.h"
|
||||
#include "mesh_config.h"
|
||||
#include "foundation.h"
|
||||
#include "mesh_common.h"
|
||||
#include "cfg_cli.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_CFG_CLI
|
||||
|
||||
static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
|
||||
{ OP_BEACON_GET, OP_BEACON_STATUS },
|
||||
{ OP_BEACON_SET, OP_BEACON_STATUS },
|
||||
@@ -72,24 +73,26 @@ static const bt_mesh_client_op_pair_t cfg_op_pair[] = {
|
||||
|
||||
static bt_mesh_mutex_t cfg_client_lock;
|
||||
|
||||
static void bt_mesh_cfg_client_mutex_new(void)
|
||||
static inline void bt_mesh_cfg_client_mutex_new(void)
|
||||
{
|
||||
if (!cfg_client_lock.mutex) {
|
||||
bt_mesh_mutex_create(&cfg_client_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_cfg_client_mutex_free(void)
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static inline void bt_mesh_cfg_client_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&cfg_client_lock);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
static void bt_mesh_cfg_client_lock(void)
|
||||
static inline void bt_mesh_cfg_client_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&cfg_client_lock);
|
||||
}
|
||||
|
||||
static void bt_mesh_cfg_client_unlock(void)
|
||||
static inline void bt_mesh_cfg_client_unlock(void)
|
||||
{
|
||||
bt_mesh_mutex_unlock(&cfg_client_lock);
|
||||
}
|
||||
@@ -99,7 +102,7 @@ static void timeout_handler(struct k_work *work)
|
||||
struct k_delayed_work *timer = NULL;
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
u32_t opcode = 0U;
|
||||
uint32_t opcode = 0U;
|
||||
|
||||
BT_WARN("Receive configuration status message timeout");
|
||||
|
||||
@@ -129,7 +132,7 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
{
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
struct net_buf_simple buf = {0};
|
||||
u8_t evt_type = 0xFF;
|
||||
uint8_t evt_type = 0xFF;
|
||||
|
||||
if (!model || !ctx) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -137,8 +140,8 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
/* If it is a publish message, sent to the user directly. */
|
||||
buf.data = (u8_t *)status;
|
||||
buf.len = (u16_t)len;
|
||||
buf.data = (uint8_t *)status;
|
||||
buf.len = (uint16_t)len;
|
||||
|
||||
bt_mesh_cfg_client_lock();
|
||||
|
||||
@@ -203,10 +206,10 @@ static void cfg_client_recv_status(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
u32_t opcode = node->opcode;
|
||||
uint32_t opcode = node->opcode;
|
||||
bt_mesh_client_free_node(node);
|
||||
bt_mesh_config_client_cb_evt_to_btc(
|
||||
opcode, evt_type, model, ctx, (const u8_t *)status, len);
|
||||
opcode, evt_type, model, ctx, (const uint8_t *)status, len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +274,7 @@ static void state_status_u8(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t status = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -279,7 +282,7 @@ static void state_status_u8(struct bt_mesh_model *model,
|
||||
|
||||
status = net_buf_simple_pull_u8(buf);
|
||||
|
||||
cfg_client_recv_status(model, ctx, &status, sizeof(u8_t));
|
||||
cfg_client_recv_status(model, ctx, &status, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
static void beacon_status(struct bt_mesh_model *model,
|
||||
@@ -673,7 +676,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_cli_op[] = {
|
||||
BLE_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
static int send_msg_with_none(bt_mesh_client_common_param_t *param, u32_t op)
|
||||
static int send_msg_with_none(bt_mesh_client_common_param_t *param, uint32_t op)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 0);
|
||||
|
||||
@@ -682,7 +685,7 @@ static int send_msg_with_none(bt_mesh_client_common_param_t *param, u32_t op)
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
static int send_msg_with_u8(bt_mesh_client_common_param_t *param, u32_t op, u8_t val)
|
||||
static int send_msg_with_u8(bt_mesh_client_common_param_t *param, uint32_t op, uint8_t val)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 1);
|
||||
|
||||
@@ -692,7 +695,7 @@ static int send_msg_with_u8(bt_mesh_client_common_param_t *param, u32_t op, u8_t
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
static int send_msg_with_le16(bt_mesh_client_common_param_t *param, u32_t op, u16_t val)
|
||||
static int send_msg_with_le16(bt_mesh_client_common_param_t *param, uint32_t op, uint16_t val)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 2);
|
||||
|
||||
@@ -702,7 +705,7 @@ static int send_msg_with_le16(bt_mesh_client_common_param_t *param, u32_t op, u1
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page)
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_DEV_COMP_DATA_GET, page);
|
||||
}
|
||||
@@ -712,7 +715,7 @@ int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param)
|
||||
return send_msg_with_none(param, OP_BEACON_GET);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val)
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val)
|
||||
{
|
||||
if (val > 0x01) {
|
||||
BT_ERR("Invalid beacon state 0x%02x", val);
|
||||
@@ -726,7 +729,7 @@ int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param)
|
||||
return send_msg_with_none(param, OP_DEFAULT_TTL_GET);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val)
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_DEFAULT_TTL_SET, val);
|
||||
}
|
||||
@@ -736,7 +739,7 @@ int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param)
|
||||
return send_msg_with_none(param, OP_FRIEND_GET);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val)
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_FRIEND_SET, val);
|
||||
}
|
||||
@@ -746,7 +749,7 @@ int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param)
|
||||
return send_msg_with_none(param, OP_GATT_PROXY_GET);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val)
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_GATT_PROXY_SET, val);
|
||||
}
|
||||
@@ -757,7 +760,7 @@ int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param)
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t relay, u8_t retransmit)
|
||||
uint8_t relay, uint8_t retransmit)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_RELAY_SET, 2);
|
||||
|
||||
@@ -769,7 +772,7 @@ int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16])
|
||||
uint16_t net_idx, const uint8_t net_key[16])
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_ADD, 18);
|
||||
|
||||
@@ -786,8 +789,8 @@ int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16])
|
||||
uint16_t net_idx, uint16_t app_idx,
|
||||
const uint8_t app_key[16])
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_ADD, 19);
|
||||
|
||||
@@ -804,8 +807,8 @@ int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_BIND, 8);
|
||||
|
||||
@@ -820,9 +823,9 @@ int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
static int mod_sub(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid)
|
||||
static int mod_sub(bt_mesh_client_common_param_t *param, uint32_t op,
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 8);
|
||||
|
||||
@@ -838,29 +841,29 @@ static int mod_sub(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub(param, OP_MOD_SUB_ADD, elem_addr, sub_addr, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub(param, OP_MOD_SUB_DEL, elem_addr, sub_addr, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub(param, OP_MOD_SUB_OVERWRITE, elem_addr, sub_addr, mod_id, cid);
|
||||
}
|
||||
|
||||
static int mod_sub_va(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid)
|
||||
static int mod_sub_va(bt_mesh_client_common_param_t *param, uint32_t op,
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 22);
|
||||
|
||||
@@ -884,28 +887,28 @@ static int mod_sub_va(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub_va(param, OP_MOD_SUB_VA_ADD, elem_addr, label, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub_va(param, OP_MOD_SUB_VA_DEL, elem_addr, label, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
return mod_sub_va(param, OP_MOD_SUB_VA_OVERWRITE, elem_addr, label, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_GET, 6);
|
||||
|
||||
@@ -920,7 +923,7 @@ int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid,
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
|
||||
struct bt_mesh_cfg_mod_pub *pub)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_SET, 13);
|
||||
@@ -1000,8 +1003,8 @@ int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param)
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id,
|
||||
u16_t cid, const u8_t label[16],
|
||||
uint16_t elem_addr, uint16_t mod_id,
|
||||
uint16_t cid, const uint8_t label[16],
|
||||
struct bt_mesh_cfg_mod_pub *pub)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_VA_SET, 27);
|
||||
@@ -1027,7 +1030,7 @@ int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_DEL_ALL, 6);
|
||||
|
||||
@@ -1041,8 +1044,8 @@ int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
static int mod_sub_get(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
static int mod_sub_get(bt_mesh_client_common_param_t *param, uint32_t op,
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6);
|
||||
|
||||
@@ -1057,13 +1060,13 @@ static int mod_sub_get(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id)
|
||||
uint16_t elem_addr, uint16_t mod_id)
|
||||
{
|
||||
return mod_sub_get(param, OP_MOD_SUB_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
if (cid == BLE_MESH_CID_NVAL) {
|
||||
BT_ERR("Invalid company id");
|
||||
@@ -1073,7 +1076,7 @@ int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16])
|
||||
uint16_t net_idx, const uint8_t net_key[16])
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_UPDATE, 18);
|
||||
|
||||
@@ -1089,7 +1092,7 @@ int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx)
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx)
|
||||
{
|
||||
return send_msg_with_le16(param, OP_NET_KEY_DEL, net_idx);
|
||||
}
|
||||
@@ -1100,8 +1103,8 @@ int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param)
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16])
|
||||
uint16_t net_idx, uint16_t app_idx,
|
||||
const uint8_t app_key[16])
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_UPDATE, 19);
|
||||
|
||||
@@ -1118,7 +1121,7 @@ int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx)
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_DEL, 3);
|
||||
|
||||
@@ -1128,18 +1131,18 @@ int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx)
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx)
|
||||
{
|
||||
return send_msg_with_le16(param, OP_APP_KEY_GET, net_idx);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx)
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx)
|
||||
{
|
||||
return send_msg_with_le16(param, OP_NODE_IDENTITY_GET, net_idx);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t identity)
|
||||
uint16_t net_idx, uint8_t identity)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_SET, 3);
|
||||
|
||||
@@ -1156,8 +1159,8 @@ int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_UNBIND, 8);
|
||||
|
||||
@@ -1172,8 +1175,8 @@ int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
static int mod_app_get(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
static int mod_app_get(bt_mesh_client_common_param_t *param, uint32_t op,
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, op, 6);
|
||||
|
||||
@@ -1188,13 +1191,13 @@ static int mod_app_get(bt_mesh_client_common_param_t *param, u32_t op,
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id)
|
||||
uint16_t elem_addr, uint16_t mod_id)
|
||||
{
|
||||
return mod_app_get(param, OP_SIG_MOD_APP_GET, elem_addr, mod_id, BLE_MESH_CID_NVAL);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid)
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid)
|
||||
{
|
||||
if (cid == BLE_MESH_CID_NVAL) {
|
||||
BT_ERR("Invalid company id");
|
||||
@@ -1203,13 +1206,13 @@ int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
return mod_app_get(param, OP_VND_MOD_APP_GET, elem_addr, mod_id, cid);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx)
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx)
|
||||
{
|
||||
return send_msg_with_le16(param, OP_KRP_GET, net_idx);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t transition)
|
||||
uint16_t net_idx, uint8_t transition)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_KRP_SET, 3);
|
||||
|
||||
@@ -1225,7 +1228,7 @@ int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, true, timeout_handler);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr)
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr)
|
||||
{
|
||||
return send_msg_with_le16(param, OP_LPN_TIMEOUT_GET, lpn_addr);
|
||||
}
|
||||
@@ -1235,7 +1238,7 @@ int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param)
|
||||
return send_msg_with_none(param, OP_NET_TRANSMIT_GET);
|
||||
}
|
||||
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit)
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit)
|
||||
{
|
||||
return send_msg_with_u8(param, OP_NET_TRANSMIT_SET, transmit);
|
||||
}
|
||||
@@ -1286,6 +1289,7 @@ static int cfg_cli_init(struct bt_mesh_model *model)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static int cfg_cli_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
bt_mesh_config_client_t *client = NULL;
|
||||
@@ -1319,8 +1323,13 @@ static int cfg_cli_deinit(struct bt_mesh_model *model)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb = {
|
||||
.init = cfg_cli_init,
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
.deinit = cfg_cli_deinit,
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
};
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_CFG_CLI */
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
|
||||
#include "mesh.h"
|
||||
@@ -75,8 +73,8 @@ static int comp_add_elem(struct net_buf_simple *buf, struct bt_mesh_elem *elem,
|
||||
|
||||
static int comp_get_page_0(struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t feat = 0U;
|
||||
const struct bt_mesh_comp *comp = NULL;
|
||||
uint16_t feat = 0U;
|
||||
int i;
|
||||
|
||||
comp = bt_mesh_comp_get();
|
||||
@@ -120,7 +118,7 @@ static void dev_comp_data_get(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct net_buf_simple *sdu = NULL;
|
||||
u8_t page = 0U;
|
||||
uint8_t page = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -159,7 +157,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
struct net_buf_simple *buf, bool *vnd)
|
||||
{
|
||||
if (buf->len < 4) {
|
||||
u16_t id = 0U;
|
||||
uint16_t id = 0U;
|
||||
|
||||
id = net_buf_simple_pull_le16(buf);
|
||||
|
||||
@@ -169,7 +167,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
|
||||
return bt_mesh_model_find(elem, id);
|
||||
} else {
|
||||
u16_t company = 0U, id = 0U;
|
||||
uint16_t company = 0U, id = 0U;
|
||||
|
||||
company = net_buf_simple_pull_le16(buf);
|
||||
id = net_buf_simple_pull_le16(buf);
|
||||
@@ -183,7 +181,7 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
}
|
||||
}
|
||||
|
||||
static bool app_key_is_valid(u16_t app_idx)
|
||||
static bool app_key_is_valid(uint16_t app_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -199,9 +197,9 @@ static bool app_key_is_valid(u16_t app_idx)
|
||||
return false;
|
||||
}
|
||||
|
||||
static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr,
|
||||
u16_t app_idx, u8_t cred_flag, u8_t ttl, u8_t period,
|
||||
u8_t retransmit, bool store)
|
||||
static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr,
|
||||
uint16_t app_idx, uint8_t cred_flag, uint8_t ttl, uint8_t period,
|
||||
uint8_t retransmit, bool store)
|
||||
{
|
||||
if (!model->pub) {
|
||||
return STATUS_NVAL_PUB_PARAM;
|
||||
@@ -251,7 +249,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr,
|
||||
model->pub->retransmit = retransmit;
|
||||
|
||||
if (model->pub->update) {
|
||||
s32_t period_ms;
|
||||
int32_t period_ms;
|
||||
|
||||
period_ms = bt_mesh_model_pub_period_get(model);
|
||||
BT_DBG("period %u ms", period_ms);
|
||||
@@ -270,7 +268,7 @@ static u8_t _mod_pub_set(struct bt_mesh_model *model, u16_t pub_addr,
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx)
|
||||
static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -302,7 +300,7 @@ static u8_t mod_bind(struct bt_mesh_model *model, u16_t key_idx)
|
||||
return STATUS_INSUFF_RESOURCES;
|
||||
}
|
||||
|
||||
static u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store)
|
||||
static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -332,7 +330,7 @@ static u8_t mod_unbind(struct bt_mesh_model *model, u16_t key_idx, bool store)
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx)
|
||||
struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -347,8 +345,8 @@ struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static u8_t app_key_set(u16_t net_idx, u16_t app_idx, const u8_t val[16],
|
||||
bool update)
|
||||
static uint8_t app_key_set(uint16_t net_idx, uint16_t app_idx, const uint8_t val[16],
|
||||
bool update)
|
||||
{
|
||||
struct bt_mesh_app_keys *keys = NULL;
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
@@ -441,8 +439,8 @@ static void app_key_add(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
||||
u16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
u8_t status = 0U;
|
||||
uint16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
||||
|
||||
@@ -467,7 +465,7 @@ static void app_key_add(struct bt_mesh_model *model,
|
||||
change.cfg_appkey_add.app_idx = key_app_idx;
|
||||
memcpy(change.cfg_appkey_add.app_key, buf->data, 16);
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,8 +474,8 @@ static void app_key_update(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
||||
u16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
u8_t status = 0U;
|
||||
uint16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
||||
|
||||
@@ -501,12 +499,12 @@ static void app_key_update(struct bt_mesh_model *model,
|
||||
change.cfg_appkey_update.app_idx = key_app_idx;
|
||||
memcpy(change.cfg_appkey_update.app_key, buf->data, 16);
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
struct unbind_data {
|
||||
u16_t app_idx;
|
||||
uint16_t app_idx;
|
||||
bool store;
|
||||
};
|
||||
|
||||
@@ -539,9 +537,9 @@ static void app_key_del(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_STATUS, 4);
|
||||
u16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
uint16_t key_net_idx = 0U, key_app_idx = 0U;
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
key_idx_unpack(buf, &key_net_idx, &key_app_idx);
|
||||
|
||||
@@ -585,7 +583,7 @@ send_status:
|
||||
change.cfg_appkey_delete.net_idx = key_net_idx;
|
||||
change.cfg_appkey_delete.app_idx = key_app_idx;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,8 +596,8 @@ static void app_key_get(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_APP_KEY_LIST,
|
||||
3 + IDX_LEN(CONFIG_BLE_MESH_APP_KEY_COUNT));
|
||||
u16_t get_idx = 0U, i = 0U, prev = 0U;
|
||||
u8_t status = 0U;
|
||||
uint16_t get_idx = 0U, i = 0U, prev = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
get_idx = net_buf_simple_pull_le16(buf);
|
||||
if (get_idx > 0xfff) {
|
||||
@@ -953,9 +951,9 @@ static void relay_set(struct bt_mesh_model *model,
|
||||
|
||||
static void send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
u16_t elem_addr, u16_t pub_addr,
|
||||
uint16_t elem_addr, uint16_t pub_addr,
|
||||
bool vnd, struct bt_mesh_model *mod,
|
||||
u8_t status, u8_t *mod_id)
|
||||
uint8_t status, uint8_t *mod_id)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_STATUS, 14);
|
||||
|
||||
@@ -967,11 +965,11 @@ static void send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
||||
if (status != STATUS_SUCCESS) {
|
||||
(void)memset(net_buf_simple_add(&msg, 7), 0, 7);
|
||||
} else {
|
||||
u16_t idx_cred;
|
||||
uint16_t idx_cred;
|
||||
|
||||
net_buf_simple_add_le16(&msg, pub_addr);
|
||||
|
||||
idx_cred = mod->pub->key | (u16_t)mod->pub->cred << 12;
|
||||
idx_cred = mod->pub->key | (uint16_t)mod->pub->cred << 12;
|
||||
net_buf_simple_add_le16(&msg, idx_cred);
|
||||
net_buf_simple_add_u8(&msg, mod->pub->ttl);
|
||||
net_buf_simple_add_u8(&msg, mod->pub->period);
|
||||
@@ -993,10 +991,10 @@ static void mod_pub_get(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, pub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, pub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL, status = 0U;
|
||||
uint8_t *mod_id = NULL, status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1040,11 +1038,11 @@ static void mod_pub_set(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
||||
u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
||||
uint8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
||||
uint16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
uint8_t *mod_id = NULL;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1109,11 +1107,11 @@ send_status:
|
||||
change.cfg_mod_pub_set.cid = vnd ? mod->vnd.company : 0xFFFF;
|
||||
change.cfg_mod_pub_set.mod_id = vnd ? mod->vnd.id : mod->id;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
struct label *get_label(u16_t index)
|
||||
struct label *get_label(uint16_t index)
|
||||
{
|
||||
if (index >= ARRAY_SIZE(labels)) {
|
||||
return NULL;
|
||||
@@ -1131,7 +1129,7 @@ static inline void va_store(struct label *store)
|
||||
}
|
||||
}
|
||||
|
||||
static struct label *va_find(const u8_t *label_uuid,
|
||||
static struct label *va_find(const uint8_t *label_uuid,
|
||||
struct label **free_slot)
|
||||
{
|
||||
struct label *match = NULL;
|
||||
@@ -1157,7 +1155,7 @@ static struct label *va_find(const u8_t *label_uuid,
|
||||
return match;
|
||||
}
|
||||
|
||||
static u8_t va_add(u8_t *label_uuid, u16_t *addr)
|
||||
static uint8_t va_add(uint8_t *label_uuid, uint16_t *addr)
|
||||
{
|
||||
struct label *update = NULL, *free_slot = NULL;
|
||||
|
||||
@@ -1184,7 +1182,7 @@ static u8_t va_add(u8_t *label_uuid, u16_t *addr)
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static u8_t va_del(u8_t *label_uuid, u16_t *addr)
|
||||
static uint8_t va_del(uint8_t *label_uuid, uint16_t *addr)
|
||||
{
|
||||
struct label *update = NULL;
|
||||
|
||||
@@ -1209,7 +1207,7 @@ static u8_t va_del(u8_t *label_uuid, u16_t *addr)
|
||||
|
||||
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
||||
{
|
||||
u8_t *label_uuid = NULL;
|
||||
uint8_t *label_uuid = NULL;
|
||||
size_t clear_count = 0U;
|
||||
int i;
|
||||
|
||||
@@ -1243,12 +1241,12 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
||||
u16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
||||
uint8_t retransmit = 0U, status = 0U, pub_ttl = 0U, pub_period = 0U, cred_flag = 0U;
|
||||
uint16_t elem_addr = 0U, pub_addr = 0U, pub_app_idx = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *label_uuid = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
uint8_t *label_uuid = NULL;
|
||||
uint8_t *mod_id = NULL;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1325,10 +1323,10 @@ static void mod_pub_va_set(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t *mod_id = NULL, status = 0U;
|
||||
uint8_t *mod_id = NULL, status = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t elem_addr = 0U, pub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, pub_addr = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1371,8 +1369,8 @@ send_status:
|
||||
#endif /* CONFIG_BLE_MESH_LABEL_COUNT > 0 */
|
||||
|
||||
static void send_mod_sub_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, u8_t status,
|
||||
u16_t elem_addr, u16_t sub_addr, u8_t *mod_id,
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status,
|
||||
uint16_t elem_addr, uint16_t sub_addr, uint8_t *mod_id,
|
||||
bool vnd)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_SUB_STATUS, 9);
|
||||
@@ -1401,11 +1399,11 @@ static void mod_sub_add(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, sub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
int i;
|
||||
|
||||
@@ -1479,7 +1477,7 @@ send_status:
|
||||
change.cfg_mod_sub_add.cid = vnd ? mod->vnd.company : 0xFFFF;
|
||||
change.cfg_mod_sub_add.mod_id = vnd ? mod->vnd.id : mod->id;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1487,12 +1485,12 @@ static void mod_sub_del(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, sub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u16_t *match = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint16_t *match = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1555,7 +1553,7 @@ send_status:
|
||||
change.cfg_mod_sub_delete.cid = vnd ? mod->vnd.company : 0xFFFF;
|
||||
change.cfg_mod_sub_delete.mod_id = vnd ? mod->vnd.id : mod->id;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1563,11 +1561,11 @@ static void mod_sub_overwrite(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, sub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1634,9 +1632,9 @@ static void mod_sub_del_all(struct bt_mesh_model *model,
|
||||
{
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t elem_addr = 0U;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint16_t elem_addr = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1688,7 +1686,7 @@ static void mod_sub_get(struct bt_mesh_model *model,
|
||||
5 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t addr = 0U, id = 0U;
|
||||
uint16_t addr = 0U, id = 0U;
|
||||
int i;
|
||||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1744,7 +1742,7 @@ static void mod_sub_get_vnd(struct bt_mesh_model *model,
|
||||
7 + CONFIG_BLE_MESH_MODEL_GROUP_COUNT * 2);
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t company = 0U, addr = 0U, id = 0U;
|
||||
uint16_t company = 0U, addr = 0U, id = 0U;
|
||||
int i;
|
||||
|
||||
addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1801,12 +1799,12 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, sub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *label_uuid = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *label_uuid = NULL;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
int i;
|
||||
|
||||
@@ -1878,13 +1876,13 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = 0U;
|
||||
uint16_t elem_addr = 0U, sub_addr = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *label_uuid = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u16_t *match = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *label_uuid = NULL;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint16_t *match = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -1946,12 +1944,12 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
uint16_t elem_addr = 0U, sub_addr = BLE_MESH_ADDR_UNASSIGNED;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *label_uuid = NULL;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint8_t *label_uuid = NULL;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2014,9 +2012,9 @@ static void mod_sub_va_add(struct bt_mesh_model *model,
|
||||
{
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t elem_addr = 0U;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint16_t elem_addr = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2055,9 +2053,9 @@ static void mod_sub_va_del(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t elem_addr = 0U;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint16_t elem_addr = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2094,9 +2092,9 @@ static void mod_sub_va_overwrite(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u16_t elem_addr = 0U;
|
||||
u8_t *mod_id = NULL;
|
||||
u8_t status = 0U;
|
||||
uint16_t elem_addr = 0U;
|
||||
uint8_t *mod_id = NULL;
|
||||
uint8_t status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2131,7 +2129,7 @@ send_status:
|
||||
|
||||
static void send_net_key_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
u16_t idx, u8_t status)
|
||||
uint16_t idx, uint8_t status)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_STATUS, 3);
|
||||
|
||||
@@ -2150,7 +2148,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t idx = 0U;
|
||||
uint16_t idx = 0U;
|
||||
int err = 0;
|
||||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
@@ -2181,7 +2179,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
||||
|
||||
/* Check for already existing subnet */
|
||||
if (sub->net_idx == idx) {
|
||||
u8_t status = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
if (memcmp(buf->data, sub->keys[0].net, 16)) {
|
||||
status = STATUS_IDX_ALREADY_STORED;
|
||||
@@ -2223,7 +2221,7 @@ static void net_key_add(struct bt_mesh_model *model,
|
||||
change.cfg_netkey_add.net_idx = sub->net_idx;
|
||||
memcpy(change.cfg_netkey_add.net_key, sub->keys[0].net, 16);
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
|
||||
static void net_key_update(struct bt_mesh_model *model,
|
||||
@@ -2231,7 +2229,7 @@ static void net_key_update(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t idx = 0U;
|
||||
uint16_t idx = 0U;
|
||||
int err = 0;
|
||||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
@@ -2298,7 +2296,7 @@ static void net_key_update(struct bt_mesh_model *model,
|
||||
change.cfg_netkey_update.net_idx = sub->net_idx;
|
||||
memcpy(change.cfg_netkey_update.net_key, sub->keys[1].net, 16);
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
|
||||
static void hb_pub_disable(struct bt_mesh_cfg_srv *cfg)
|
||||
@@ -2318,8 +2316,8 @@ static void net_key_del(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t del_idx = 0U;
|
||||
u8_t status = 0U;
|
||||
uint16_t del_idx = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
del_idx = net_buf_simple_pull_le16(buf);
|
||||
if (del_idx > 0xfff) {
|
||||
@@ -2356,7 +2354,7 @@ send_status:
|
||||
bt_mesh_cfg_server_state_change_t change = {0};
|
||||
change.cfg_netkey_delete.net_idx = sub->net_idx;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2366,7 +2364,7 @@ static void net_key_get(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NET_KEY_LIST,
|
||||
IDX_LEN(CONFIG_BLE_MESH_SUBNET_COUNT));
|
||||
u16_t prev = 0U, i = 0U;
|
||||
uint16_t prev = 0U, i = 0U;
|
||||
|
||||
bt_mesh_model_msg_init(&msg, OP_NET_KEY_LIST);
|
||||
|
||||
@@ -2402,8 +2400,8 @@ static void node_identity_get(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u8_t node_id = 0U;
|
||||
u16_t idx = 0U;
|
||||
uint8_t node_id = 0U;
|
||||
uint16_t idx = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -2440,8 +2438,8 @@ static void node_identity_set(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_NODE_IDENTITY_STATUS, 4);
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u8_t node_id = 0U;
|
||||
u16_t idx = 0U;
|
||||
uint8_t node_id = 0U;
|
||||
uint16_t idx = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -2488,8 +2486,8 @@ static void node_identity_set(struct bt_mesh_model *model,
|
||||
|
||||
static void create_mod_app_status(struct net_buf_simple *msg,
|
||||
struct bt_mesh_model *mod, bool vnd,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u8_t status, u8_t *mod_id)
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint8_t status, uint8_t *mod_id)
|
||||
{
|
||||
bt_mesh_model_msg_init(msg, OP_MOD_APP_STATUS);
|
||||
|
||||
@@ -2509,10 +2507,10 @@ static void mod_app_bind(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
||||
u16_t elem_addr = 0U, key_app_idx = 0U;
|
||||
uint16_t elem_addr = 0U, key_app_idx = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL, status = 0U;
|
||||
uint8_t *mod_id = NULL, status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2563,7 +2561,7 @@ send_status:
|
||||
change.cfg_mod_app_bind.cid = vnd ? mod->vnd.company : 0xFFFF;
|
||||
change.cfg_mod_app_bind.mod_id = vnd ? mod->vnd.id : mod->id;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2572,10 +2570,10 @@ static void mod_app_unbind(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
||||
u16_t elem_addr = 0U, key_app_idx = 0U;
|
||||
uint16_t elem_addr = 0U, key_app_idx = 0U;
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL, status = 0U;
|
||||
uint8_t *mod_id = NULL, status = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2619,7 +2617,7 @@ send_status:
|
||||
change.cfg_mod_app_unbind.cid = vnd ? mod->vnd.company : 0xFFFF;
|
||||
change.cfg_mod_app_unbind.mod_id = vnd ? mod->vnd.id : mod->id;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2636,8 +2634,8 @@ static void mod_app_get(struct bt_mesh_model *model,
|
||||
9 + KEY_LIST_LEN)));
|
||||
struct bt_mesh_model *mod = NULL;
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
u8_t *mod_id = NULL, status = 0U;
|
||||
u16_t elem_addr = 0U;
|
||||
uint8_t *mod_id = NULL, status = 0U;
|
||||
uint16_t elem_addr = 0U;
|
||||
bool vnd = false;
|
||||
|
||||
elem_addr = net_buf_simple_pull_le16(buf);
|
||||
@@ -2799,8 +2797,8 @@ static void lpn_timeout_get(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_LPN_TIMEOUT_STATUS, 5);
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u16_t lpn_addr = 0U;
|
||||
s32_t timeout = 0;
|
||||
uint16_t lpn_addr = 0U;
|
||||
int32_t timeout = 0;
|
||||
|
||||
lpn_addr = net_buf_simple_pull_le16(buf);
|
||||
|
||||
@@ -2838,7 +2836,7 @@ send_rsp:
|
||||
|
||||
static void send_krp_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
u16_t idx, u8_t phase, u8_t status)
|
||||
uint16_t idx, uint8_t phase, uint8_t status)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_KRP_STATUS, 4);
|
||||
|
||||
@@ -2857,7 +2855,7 @@ static void krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t idx = 0U;
|
||||
uint16_t idx = 0U;
|
||||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
if (idx > 0xfff) {
|
||||
@@ -2880,8 +2878,8 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u8_t phase = 0U;
|
||||
u16_t idx = 0U;
|
||||
uint8_t phase = 0U;
|
||||
uint16_t idx = 0U;
|
||||
|
||||
idx = net_buf_simple_pull_le16(buf);
|
||||
phase = net_buf_simple_pull_u8(buf);
|
||||
@@ -2912,17 +2910,25 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
phase == BLE_MESH_KR_PHASE_2) {
|
||||
sub->kr_phase = BLE_MESH_KR_PHASE_2;
|
||||
sub->kr_flag = 1;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
BT_DBG("Storing kr phase persistently");
|
||||
bt_mesh_store_subnet(sub);
|
||||
}
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
} else if ((sub->kr_phase == BLE_MESH_KR_PHASE_1 ||
|
||||
sub->kr_phase == BLE_MESH_KR_PHASE_2) &&
|
||||
phase == BLE_MESH_KR_PHASE_3) {
|
||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||
sub->kr_flag = 0;
|
||||
bt_mesh_net_revoke_keys(sub);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_LOW_POWER) ||
|
||||
IS_ENABLED(CONFIG_BLE_MESH_FRIEND)) {
|
||||
friend_cred_refresh(ctx->net_idx);
|
||||
}
|
||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||
sub->kr_flag = 0;
|
||||
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
}
|
||||
|
||||
@@ -2932,10 +2938,10 @@ static void krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
change.cfg_kr_phase_set.net_idx = idx;
|
||||
change.cfg_kr_phase_set.kr_phase = phase;
|
||||
bt_mesh_config_server_cb_evt_to_btc(BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
model, ctx, (const u8_t *)&change, sizeof(change));
|
||||
model, ctx, (const uint8_t *)&change, sizeof(change));
|
||||
}
|
||||
|
||||
static u8_t hb_log(u16_t val)
|
||||
static uint8_t hb_log(uint16_t val)
|
||||
{
|
||||
if (!val) {
|
||||
return 0x00;
|
||||
@@ -2946,7 +2952,7 @@ static u8_t hb_log(u16_t val)
|
||||
}
|
||||
}
|
||||
|
||||
static u8_t hb_pub_count_log(u16_t val)
|
||||
static uint8_t hb_pub_count_log(uint16_t val)
|
||||
{
|
||||
if (!val) {
|
||||
return 0x00;
|
||||
@@ -2959,7 +2965,7 @@ static u8_t hb_pub_count_log(u16_t val)
|
||||
}
|
||||
}
|
||||
|
||||
static u16_t hb_pwr2(u8_t val, u8_t sub)
|
||||
static uint16_t hb_pwr2(uint8_t val, uint8_t sub)
|
||||
{
|
||||
if (!val) {
|
||||
return 0x0000;
|
||||
@@ -2971,16 +2977,16 @@ static u16_t hb_pwr2(u8_t val, u8_t sub)
|
||||
}
|
||||
|
||||
struct hb_pub_param {
|
||||
u16_t dst;
|
||||
u8_t count_log;
|
||||
u8_t period_log;
|
||||
u8_t ttl;
|
||||
u16_t feat;
|
||||
u16_t net_idx;
|
||||
uint16_t dst;
|
||||
uint8_t count_log;
|
||||
uint8_t period_log;
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
} __packed;
|
||||
|
||||
static void hb_pub_send_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, u8_t status,
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status,
|
||||
struct hb_pub_param *orig_msg)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_PUB_STATUS, 10);
|
||||
@@ -3026,8 +3032,8 @@ static void heartbeat_pub_set(struct bt_mesh_model *model,
|
||||
{
|
||||
struct hb_pub_param *param = (void *)buf->data;
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
u16_t dst = 0U, feat = 0U, idx = 0U;
|
||||
u8_t status = 0U;
|
||||
uint16_t dst = 0U, feat = 0U, idx = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
BT_DBG("src 0x%04x", ctx->addr);
|
||||
|
||||
@@ -3119,12 +3125,12 @@ failed:
|
||||
}
|
||||
|
||||
static void hb_sub_send_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, u8_t status)
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEARTBEAT_SUB_STATUS, 9);
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
u16_t period = 0U;
|
||||
s64_t uptime = 0;
|
||||
uint16_t period = 0U;
|
||||
int64_t uptime = 0;
|
||||
|
||||
BT_DBG("src 0x%04x status 0x%02x", ctx->addr, status);
|
||||
|
||||
@@ -3164,9 +3170,9 @@ static void heartbeat_sub_set(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
u16_t sub_src = 0U, sub_dst = 0U;
|
||||
u8_t sub_period = 0U;
|
||||
s32_t period_ms = 0;
|
||||
uint16_t sub_src = 0U, sub_dst = 0U;
|
||||
uint8_t sub_period = 0U;
|
||||
int32_t period_ms = 0;
|
||||
|
||||
BT_DBG("src 0x%04x", ctx->addr);
|
||||
|
||||
@@ -3299,7 +3305,7 @@ static void hb_publish(struct k_work *work)
|
||||
struct bt_mesh_cfg_srv,
|
||||
hb_pub.timer.work);
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
u16_t period_ms = 0U;
|
||||
uint16_t period_ms = 0U;
|
||||
|
||||
BT_DBG("hb_pub.count: %u", cfg->hb_pub.count);
|
||||
|
||||
@@ -3389,6 +3395,7 @@ static int cfg_srv_init(struct bt_mesh_model *model)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static int cfg_srv_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = model->user_data;
|
||||
@@ -3403,7 +3410,10 @@ static int cfg_srv_deinit(struct bt_mesh_model *model)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bt_mesh_cfg_reset();
|
||||
/* Use "false" here because if cfg needs to be erased,
|
||||
* it will already be erased in the ble_mesh_deinit().
|
||||
*/
|
||||
bt_mesh_cfg_reset(false);
|
||||
|
||||
k_delayed_work_free(&cfg->hb_pub.timer);
|
||||
cfg->hb_pub.dst = BLE_MESH_ADDR_UNASSIGNED;
|
||||
@@ -3412,15 +3422,19 @@ static int cfg_srv_deinit(struct bt_mesh_model *model)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb = {
|
||||
.init = cfg_srv_init,
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
.deinit = cfg_srv_deinit,
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
};
|
||||
|
||||
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
bool store = *(bool *)user_data;
|
||||
size_t clear_count = 0U;
|
||||
|
||||
/* Clear model state that isn't otherwise cleared. E.g. AppKey
|
||||
@@ -3431,12 +3445,17 @@ static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
|
||||
clear_count = mod_sub_list_clear(mod);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && clear_count) {
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS) && clear_count && store) {
|
||||
bt_mesh_store_mod_sub(mod);
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_cfg_reset(void)
|
||||
void bt_mesh_mod_sub_reset(bool store)
|
||||
{
|
||||
bt_mesh_model_foreach(mod_reset, &store);
|
||||
}
|
||||
|
||||
void bt_mesh_cfg_reset(bool store)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = conf;
|
||||
int i;
|
||||
@@ -3460,16 +3479,16 @@ void bt_mesh_cfg_reset(void)
|
||||
struct bt_mesh_subnet *sub = &bt_mesh.sub[i];
|
||||
|
||||
if (sub->net_idx != BLE_MESH_KEY_UNUSED) {
|
||||
bt_mesh_subnet_del(sub, true);
|
||||
bt_mesh_subnet_del(sub, store);
|
||||
}
|
||||
}
|
||||
|
||||
bt_mesh_model_foreach(mod_reset, NULL);
|
||||
bt_mesh_mod_sub_reset(store);
|
||||
|
||||
(void)memset(labels, 0, sizeof(labels));
|
||||
}
|
||||
|
||||
void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat)
|
||||
void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat)
|
||||
{
|
||||
struct bt_mesh_cfg_srv *cfg = conf;
|
||||
|
||||
@@ -3504,7 +3523,7 @@ void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat)
|
||||
}
|
||||
}
|
||||
|
||||
u8_t bt_mesh_net_transmit_get(void)
|
||||
uint8_t bt_mesh_net_transmit_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->net_transmit;
|
||||
@@ -3513,7 +3532,7 @@ u8_t bt_mesh_net_transmit_get(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_relay_get(void)
|
||||
uint8_t bt_mesh_relay_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->relay;
|
||||
@@ -3522,7 +3541,7 @@ u8_t bt_mesh_relay_get(void)
|
||||
return BLE_MESH_RELAY_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_friend_get(void)
|
||||
uint8_t bt_mesh_friend_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
BT_DBG("conf %p conf->frnd 0x%02x", conf, conf->frnd);
|
||||
@@ -3532,7 +3551,7 @@ u8_t bt_mesh_friend_get(void)
|
||||
return BLE_MESH_FRIEND_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_relay_retransmit_get(void)
|
||||
uint8_t bt_mesh_relay_retransmit_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->relay_retransmit;
|
||||
@@ -3541,7 +3560,7 @@ u8_t bt_mesh_relay_retransmit_get(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_beacon_get(void)
|
||||
uint8_t bt_mesh_beacon_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->beacon;
|
||||
@@ -3550,7 +3569,7 @@ u8_t bt_mesh_beacon_get(void)
|
||||
return BLE_MESH_BEACON_DISABLED;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_gatt_proxy_get(void)
|
||||
uint8_t bt_mesh_gatt_proxy_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->gatt_proxy;
|
||||
@@ -3559,7 +3578,7 @@ u8_t bt_mesh_gatt_proxy_get(void)
|
||||
return BLE_MESH_GATT_PROXY_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_default_ttl_get(void)
|
||||
uint8_t bt_mesh_default_ttl_get(void)
|
||||
{
|
||||
if (conf) {
|
||||
return conf->default_ttl;
|
||||
@@ -3568,7 +3587,7 @@ u8_t bt_mesh_default_ttl_get(void)
|
||||
return DEFAULT_TTL;
|
||||
}
|
||||
|
||||
u8_t *bt_mesh_label_uuid_get(u16_t addr)
|
||||
uint8_t *bt_mesh_label_uuid_get(uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_CRYPTO)
|
||||
|
||||
#include <tinycrypt/aes.h>
|
||||
#include <tinycrypt/constants.h>
|
||||
#include <tinycrypt/cmac_mode.h>
|
||||
@@ -24,8 +22,8 @@
|
||||
#define NET_MIC_LEN(pdu) (((pdu)[1] & 0x80) ? 8 : 4)
|
||||
#define APP_MIC_LEN(aszmic) ((aszmic) ? 8 : 4)
|
||||
|
||||
int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
|
||||
size_t sg_len, u8_t mac[16])
|
||||
int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg,
|
||||
size_t sg_len, uint8_t mac[16])
|
||||
{
|
||||
struct tc_aes_key_sched_struct sched = {0};
|
||||
struct tc_cmac_struct state = {0};
|
||||
@@ -48,8 +46,8 @@ int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
|
||||
const char *info, u8_t okm[16])
|
||||
int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16],
|
||||
const char *info, uint8_t okm[16])
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -61,14 +59,14 @@ int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
|
||||
return bt_mesh_aes_cmac_one(okm, info, strlen(info), okm);
|
||||
}
|
||||
|
||||
int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
|
||||
u8_t net_id[1], u8_t enc_key[16], u8_t priv_key[16])
|
||||
int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len,
|
||||
uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16])
|
||||
{
|
||||
struct bt_mesh_sg sg[3] = {0};
|
||||
u8_t salt[16] = {0};
|
||||
u8_t out[16] = {0};
|
||||
u8_t t[16] = {0};
|
||||
u8_t pad = 0U;
|
||||
uint8_t salt[16] = {0};
|
||||
uint8_t out[16] = {0};
|
||||
uint8_t t[16] = {0};
|
||||
uint8_t pad = 0U;
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("n %s", bt_hex(n, 16));
|
||||
@@ -126,11 +124,11 @@ int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_k3(const u8_t n[16], u8_t out[8])
|
||||
int bt_mesh_k3(const uint8_t n[16], uint8_t out[8])
|
||||
{
|
||||
u8_t id64[] = { 'i', 'd', '6', '4', 0x01 };
|
||||
u8_t tmp[16] = {0};
|
||||
u8_t t[16] = {0};
|
||||
uint8_t id64[] = { 'i', 'd', '6', '4', 0x01 };
|
||||
uint8_t tmp[16] = {0};
|
||||
uint8_t t[16] = {0};
|
||||
int err = 0;
|
||||
|
||||
err = bt_mesh_s1("smk3", tmp);
|
||||
@@ -153,11 +151,11 @@ int bt_mesh_k3(const u8_t n[16], u8_t out[8])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_k4(const u8_t n[16], u8_t out[1])
|
||||
int bt_mesh_k4(const uint8_t n[16], uint8_t out[1])
|
||||
{
|
||||
u8_t id6[] = { 'i', 'd', '6', 0x01 };
|
||||
u8_t tmp[16] = {0};
|
||||
u8_t t[16] = {0};
|
||||
uint8_t id6[] = { 'i', 'd', '6', 0x01 };
|
||||
uint8_t tmp[16] = {0};
|
||||
uint8_t t[16] = {0};
|
||||
int err = 0;
|
||||
|
||||
err = bt_mesh_s1("smk4", tmp);
|
||||
@@ -180,10 +178,10 @@ int bt_mesh_k4(const u8_t n[16], u8_t out[1])
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16])
|
||||
int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16])
|
||||
{
|
||||
const char *id128 = "id128\x01";
|
||||
u8_t salt[16] = {0};
|
||||
uint8_t salt[16] = {0};
|
||||
int err = 0;
|
||||
|
||||
err = bt_mesh_s1(s, salt);
|
||||
@@ -194,14 +192,14 @@ int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16])
|
||||
return bt_mesh_k1(n, 16, salt, id128, out);
|
||||
}
|
||||
|
||||
static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t *enc_msg, size_t msg_len,
|
||||
const u8_t *aad, size_t aad_len,
|
||||
u8_t *out_msg, size_t mic_size)
|
||||
static int bt_mesh_ccm_decrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t *enc_msg, size_t msg_len,
|
||||
const uint8_t *aad, size_t aad_len,
|
||||
uint8_t *out_msg, size_t mic_size)
|
||||
{
|
||||
u8_t msg[16] = {0}, pmsg[16] = {0}, cmic[16] = {0},
|
||||
cmsg[16] = {0}, Xn[16] = {0}, mic[16] = {0};
|
||||
u16_t last_blk = 0U, blk_cnt = 0U;
|
||||
uint8_t msg[16] = {0}, pmsg[16] = {0}, cmic[16] = {0},
|
||||
cmsg[16] = {0}, Xn[16] = {0}, mic[16] = {0};
|
||||
uint16_t last_blk = 0U, blk_cnt = 0U;
|
||||
size_t i = 0U, j = 0U;
|
||||
int err = 0;
|
||||
|
||||
@@ -220,7 +218,7 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
}
|
||||
|
||||
/* X_0 = e(AppKey, 0x09 || nonce || length) */
|
||||
if (mic_size == sizeof(u64_t)) {
|
||||
if (mic_size == sizeof(uint64_t)) {
|
||||
pmsg[0] = 0x19 | (aad_len ? 0x40 : 0x00);
|
||||
} else {
|
||||
pmsg[0] = 0x09 | (aad_len ? 0x40 : 0x00);
|
||||
@@ -238,12 +236,12 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
if (aad_len) {
|
||||
sys_put_be16(aad_len, pmsg);
|
||||
|
||||
for (i = 0; i < sizeof(u16_t); i++) {
|
||||
for (i = 0; i < sizeof(uint16_t); i++) {
|
||||
pmsg[i] = Xn[i] ^ pmsg[i];
|
||||
}
|
||||
|
||||
j = 0;
|
||||
aad_len += sizeof(u16_t);
|
||||
aad_len += sizeof(uint16_t);
|
||||
while (aad_len > 16) {
|
||||
do {
|
||||
pmsg[i] = Xn[i] ^ aad[j];
|
||||
@@ -353,14 +351,14 @@ static int bt_mesh_ccm_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t *msg, size_t msg_len,
|
||||
const u8_t *aad, size_t aad_len,
|
||||
u8_t *out_msg, size_t mic_size)
|
||||
static int bt_mesh_ccm_encrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t *msg, size_t msg_len,
|
||||
const uint8_t *aad, size_t aad_len,
|
||||
uint8_t *out_msg, size_t mic_size)
|
||||
{
|
||||
u8_t pmsg[16] = {0}, cmic[16] = {0}, cmsg[16] = {0},
|
||||
mic[16] = {0}, Xn[16] = {0};
|
||||
u16_t blk_cnt = 0U, last_blk = 0U;
|
||||
uint8_t pmsg[16] = {0}, cmic[16] = {0}, cmsg[16] = {0},
|
||||
mic[16] = {0}, Xn[16] = {0};
|
||||
uint16_t blk_cnt = 0U, last_blk = 0U;
|
||||
size_t i = 0U, j = 0U;
|
||||
int err = 0;
|
||||
|
||||
@@ -385,7 +383,7 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
}
|
||||
|
||||
/* X_0 = e(AppKey, 0x09 || nonce || length) */
|
||||
if (mic_size == sizeof(u64_t)) {
|
||||
if (mic_size == sizeof(uint64_t)) {
|
||||
pmsg[0] = 0x19 | (aad_len ? 0x40 : 0x00);
|
||||
} else {
|
||||
pmsg[0] = 0x09 | (aad_len ? 0x40 : 0x00);
|
||||
@@ -403,12 +401,12 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
if (aad_len) {
|
||||
sys_put_be16(aad_len, pmsg);
|
||||
|
||||
for (i = 0; i < sizeof(u16_t); i++) {
|
||||
for (i = 0; i < sizeof(uint16_t); i++) {
|
||||
pmsg[i] = Xn[i] ^ pmsg[i];
|
||||
}
|
||||
|
||||
j = 0;
|
||||
aad_len += sizeof(u16_t);
|
||||
aad_len += sizeof(uint16_t);
|
||||
while (aad_len > 16) {
|
||||
do {
|
||||
pmsg[i] = Xn[i] ^ aad[j];
|
||||
@@ -515,8 +513,8 @@ static int bt_mesh_ccm_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLE_MESH_PROXY)
|
||||
static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu,
|
||||
u32_t iv_index)
|
||||
static void create_proxy_nonce(uint8_t nonce[13], const uint8_t *pdu,
|
||||
uint32_t iv_index)
|
||||
{
|
||||
/* Nonce Type */
|
||||
nonce[0] = 0x03;
|
||||
@@ -542,8 +540,8 @@ static void create_proxy_nonce(u8_t nonce[13], const u8_t *pdu,
|
||||
}
|
||||
#endif /* PROXY */
|
||||
|
||||
static void create_net_nonce(u8_t nonce[13], const u8_t *pdu,
|
||||
u32_t iv_index)
|
||||
static void create_net_nonce(uint8_t nonce[13], const uint8_t *pdu,
|
||||
uint32_t iv_index)
|
||||
{
|
||||
/* Nonce Type */
|
||||
nonce[0] = 0x00;
|
||||
@@ -568,11 +566,11 @@ static void create_net_nonce(u8_t nonce[13], const u8_t *pdu,
|
||||
sys_put_be32(iv_index, &nonce[9]);
|
||||
}
|
||||
|
||||
int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index,
|
||||
const u8_t privacy_key[16])
|
||||
int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index,
|
||||
const uint8_t privacy_key[16])
|
||||
{
|
||||
u8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, };
|
||||
u8_t tmp[16] = {0};
|
||||
uint8_t priv_rand[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, };
|
||||
uint8_t tmp[16] = {0};
|
||||
int err = 0, i;
|
||||
|
||||
BT_DBG("IVIndex %u, PrivacyKey %s", iv_index, bt_hex(privacy_key, 16));
|
||||
@@ -594,11 +592,11 @@ int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
u32_t iv_index, bool proxy)
|
||||
int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy)
|
||||
{
|
||||
u8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
u8_t nonce[13] = {0};
|
||||
uint8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
uint8_t nonce[13] = {0};
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("IVIndex %u EncKey %s mic_len %u", iv_index, bt_hex(key, 16),
|
||||
@@ -626,11 +624,11 @@ int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
u32_t iv_index, bool proxy)
|
||||
int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy)
|
||||
{
|
||||
u8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
u8_t nonce[13] = {0};
|
||||
uint8_t mic_len = NET_MIC_LEN(buf->data);
|
||||
uint8_t nonce[13] = {0};
|
||||
|
||||
BT_DBG("PDU (%u bytes) %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
BT_DBG("iv_index %u, key %s mic_len %u", iv_index, bt_hex(key, 16),
|
||||
@@ -654,9 +652,9 @@ int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
NULL, 0, &buf->data[7], mic_len);
|
||||
}
|
||||
|
||||
static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic,
|
||||
u16_t src, u16_t dst, u32_t seq_num,
|
||||
u32_t iv_index)
|
||||
static void create_app_nonce(uint8_t nonce[13], bool dev_key, uint8_t aszmic,
|
||||
uint16_t src, uint16_t dst, uint32_t seq_num,
|
||||
uint32_t iv_index)
|
||||
{
|
||||
if (dev_key) {
|
||||
nonce[0] = 0x02;
|
||||
@@ -664,7 +662,7 @@ static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic,
|
||||
nonce[0] = 0x01;
|
||||
}
|
||||
|
||||
sys_put_be32((seq_num | ((u32_t)aszmic << 31)), &nonce[1]);
|
||||
sys_put_be32((seq_num | ((uint32_t)aszmic << 31)), &nonce[1]);
|
||||
|
||||
sys_put_be16(src, &nonce[5]);
|
||||
sys_put_be16(dst, &nonce[7]);
|
||||
@@ -672,11 +670,11 @@ static void create_app_nonce(u8_t nonce[13], bool dev_key, u8_t aszmic,
|
||||
sys_put_be32(iv_index, &nonce[9]);
|
||||
}
|
||||
|
||||
int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
struct net_buf_simple *buf, const u8_t *ad,
|
||||
u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index)
|
||||
int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic,
|
||||
struct net_buf_simple *buf, const uint8_t *ad,
|
||||
uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index)
|
||||
{
|
||||
u8_t nonce[13] = {0};
|
||||
uint8_t nonce[13] = {0};
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("AppKey %s", bt_hex(key, 16));
|
||||
@@ -698,12 +696,12 @@ int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
return err;
|
||||
}
|
||||
|
||||
int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic,
|
||||
struct net_buf_simple *buf, struct net_buf_simple *out,
|
||||
const u8_t *ad, u16_t src, u16_t dst, u32_t seq_num,
|
||||
u32_t iv_index)
|
||||
const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num,
|
||||
uint32_t iv_index)
|
||||
{
|
||||
u8_t nonce[13] = {0};
|
||||
uint8_t nonce[13] = {0};
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("EncData (len %u) %s", buf->len, bt_hex(buf->data, buf->len));
|
||||
@@ -723,7 +721,7 @@ int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
}
|
||||
|
||||
/* reversed, 8-bit, poly=0x07 */
|
||||
static const u8_t crc_table[256] = {
|
||||
static const uint8_t crc_table[256] = {
|
||||
0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75,
|
||||
0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b,
|
||||
0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69,
|
||||
@@ -765,9 +763,9 @@ static const u8_t crc_table[256] = {
|
||||
0xba, 0x2b, 0x59, 0xc8, 0xbd, 0x2c, 0x5e, 0xcf
|
||||
};
|
||||
|
||||
u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len)
|
||||
uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len)
|
||||
{
|
||||
u8_t fcs = 0xff;
|
||||
uint8_t fcs = 0xff;
|
||||
|
||||
while (data_len--) {
|
||||
fcs = crc_table[fcs ^ *data++];
|
||||
@@ -778,11 +776,11 @@ u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len)
|
||||
return 0xff - fcs;
|
||||
}
|
||||
|
||||
bool bt_mesh_fcs_check(struct net_buf_simple *buf, u8_t received_fcs)
|
||||
bool bt_mesh_fcs_check(struct net_buf_simple *buf, uint8_t received_fcs)
|
||||
{
|
||||
const u8_t *data = buf->data;
|
||||
u16_t data_len = buf->len;
|
||||
u8_t fcs = 0xff;
|
||||
const uint8_t *data = buf->data;
|
||||
uint16_t data_len = buf->len;
|
||||
uint8_t fcs = 0xff;
|
||||
|
||||
while (data_len--) {
|
||||
fcs = crc_table[fcs ^ *data++];
|
||||
@@ -791,10 +789,10 @@ bool bt_mesh_fcs_check(struct net_buf_simple *buf, u8_t received_fcs)
|
||||
return crc_table[fcs ^ received_fcs] == 0xcf;
|
||||
}
|
||||
|
||||
int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr)
|
||||
int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr)
|
||||
{
|
||||
u8_t salt[16] = {0};
|
||||
u8_t tmp[16] = {0};
|
||||
uint8_t salt[16] = {0};
|
||||
uint8_t tmp[16] = {0};
|
||||
int err = 0;
|
||||
|
||||
err = bt_mesh_s1("vtad", salt);
|
||||
@@ -812,21 +810,21 @@ int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_prov_conf_salt(const u8_t conf_inputs[145], u8_t salt[16])
|
||||
int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16])
|
||||
{
|
||||
const u8_t conf_salt_key[16] = { 0 };
|
||||
const uint8_t conf_salt_key[16] = { 0 };
|
||||
|
||||
return bt_mesh_aes_cmac_one(conf_salt_key, conf_inputs, 145, salt);
|
||||
}
|
||||
|
||||
int bt_mesh_prov_conf_key(const u8_t dhkey[32], const u8_t conf_salt[16],
|
||||
u8_t conf_key[16])
|
||||
int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16],
|
||||
uint8_t conf_key[16])
|
||||
{
|
||||
return bt_mesh_k1(dhkey, 32, conf_salt, "prck", conf_key);
|
||||
}
|
||||
|
||||
int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16],
|
||||
const u8_t auth[16], u8_t conf[16])
|
||||
int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16],
|
||||
const uint8_t auth[16], uint8_t conf[16])
|
||||
{
|
||||
struct bt_mesh_sg sg[] = { { rand, 16 }, { auth, 16 } };
|
||||
|
||||
@@ -837,25 +835,25 @@ int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16],
|
||||
return bt_mesh_aes_cmac(conf_key, sg, ARRAY_SIZE(sg), conf);
|
||||
}
|
||||
|
||||
int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t data[25 + 8], u8_t out[25])
|
||||
int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t data[25 + 8], uint8_t out[25])
|
||||
{
|
||||
return bt_mesh_ccm_decrypt(key, nonce, data, 25, NULL, 0, out, 8);
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t data[25], u8_t out[33])
|
||||
int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t data[25], uint8_t out[33])
|
||||
{
|
||||
return bt_mesh_ccm_encrypt(key, nonce, data, 25, NULL, 0, out, 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags,
|
||||
const u8_t net_id[8], u32_t iv_index,
|
||||
u8_t auth[8])
|
||||
int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[8], uint32_t iv_index,
|
||||
uint8_t auth[8])
|
||||
{
|
||||
u8_t msg[13] = {0}, tmp[16] = {0};
|
||||
uint8_t msg[13] = {0}, tmp[16] = {0};
|
||||
int err = 0;
|
||||
|
||||
BT_DBG("BeaconKey %s", bt_hex(beacon_key, 16));
|
||||
|
||||
@@ -22,81 +22,81 @@ struct bt_mesh_sg {
|
||||
size_t len;
|
||||
};
|
||||
|
||||
int bt_mesh_aes_cmac(const u8_t key[16], struct bt_mesh_sg *sg,
|
||||
size_t sg_len, u8_t mac[16]);
|
||||
int bt_mesh_aes_cmac(const uint8_t key[16], struct bt_mesh_sg *sg,
|
||||
size_t sg_len, uint8_t mac[16]);
|
||||
|
||||
static inline int bt_mesh_aes_cmac_one(const u8_t key[16], const void *m,
|
||||
size_t len, u8_t mac[16])
|
||||
static inline int bt_mesh_aes_cmac_one(const uint8_t key[16], const void *m,
|
||||
size_t len, uint8_t mac[16])
|
||||
{
|
||||
struct bt_mesh_sg sg = { m, len };
|
||||
|
||||
return bt_mesh_aes_cmac(key, &sg, 1, mac);
|
||||
}
|
||||
|
||||
static inline bool bt_mesh_s1(const char *m, u8_t salt[16])
|
||||
static inline bool bt_mesh_s1(const char *m, uint8_t salt[16])
|
||||
{
|
||||
const u8_t zero[16] = { 0 };
|
||||
const uint8_t zero[16] = { 0 };
|
||||
|
||||
return bt_mesh_aes_cmac_one(zero, m, strlen(m), salt);
|
||||
}
|
||||
|
||||
int bt_mesh_k1(const u8_t *ikm, size_t ikm_len, const u8_t salt[16],
|
||||
const char *info, u8_t okm[16]);
|
||||
int bt_mesh_k1(const uint8_t *ikm, size_t ikm_len, const uint8_t salt[16],
|
||||
const char *info, uint8_t okm[16]);
|
||||
|
||||
#define bt_mesh_k1_str(ikm, ikm_len, salt_str, info, okm) \
|
||||
({ \
|
||||
const u8_t salt[16] = salt_str; \
|
||||
const uint8_t salt[16] = salt_str; \
|
||||
bt_mesh_k1(ikm, ikm_len, salt, info, okm); \
|
||||
})
|
||||
|
||||
int bt_mesh_k2(const u8_t n[16], const u8_t *p, size_t p_len,
|
||||
u8_t net_id[1], u8_t enc_key[16], u8_t priv_key[16]);
|
||||
int bt_mesh_k2(const uint8_t n[16], const uint8_t *p, size_t p_len,
|
||||
uint8_t net_id[1], uint8_t enc_key[16], uint8_t priv_key[16]);
|
||||
|
||||
int bt_mesh_k3(const u8_t n[16], u8_t out[8]);
|
||||
int bt_mesh_k3(const uint8_t n[16], uint8_t out[8]);
|
||||
|
||||
int bt_mesh_k4(const u8_t n[16], u8_t out[1]);
|
||||
int bt_mesh_k4(const uint8_t n[16], uint8_t out[1]);
|
||||
|
||||
int bt_mesh_id128(const u8_t n[16], const char *s, u8_t out[16]);
|
||||
int bt_mesh_id128(const uint8_t n[16], const char *s, uint8_t out[16]);
|
||||
|
||||
static inline int bt_mesh_id_resolving_key(const u8_t net_key[16],
|
||||
u8_t resolving_key[16])
|
||||
static inline int bt_mesh_id_resolving_key(const uint8_t net_key[16],
|
||||
uint8_t resolving_key[16])
|
||||
{
|
||||
return bt_mesh_k1_str(net_key, 16, "smbt", "smbi", resolving_key);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_identity_key(const u8_t net_key[16],
|
||||
u8_t identity_key[16])
|
||||
static inline int bt_mesh_identity_key(const uint8_t net_key[16],
|
||||
uint8_t identity_key[16])
|
||||
{
|
||||
return bt_mesh_id128(net_key, "nkik", identity_key);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_beacon_key(const u8_t net_key[16],
|
||||
u8_t beacon_key[16])
|
||||
static inline int bt_mesh_beacon_key(const uint8_t net_key[16],
|
||||
uint8_t beacon_key[16])
|
||||
{
|
||||
return bt_mesh_id128(net_key, "nkbk", beacon_key);
|
||||
}
|
||||
|
||||
int bt_mesh_beacon_auth(const u8_t beacon_key[16], u8_t flags,
|
||||
const u8_t net_id[16], u32_t iv_index,
|
||||
u8_t auth[8]);
|
||||
int bt_mesh_beacon_auth(const uint8_t beacon_key[16], uint8_t flags,
|
||||
const uint8_t net_id[16], uint32_t iv_index,
|
||||
uint8_t auth[8]);
|
||||
|
||||
static inline int bt_mesh_app_id(const u8_t app_key[16], u8_t app_id[1])
|
||||
static inline int bt_mesh_app_id(const uint8_t app_key[16], uint8_t app_id[1])
|
||||
{
|
||||
return bt_mesh_k4(app_key, app_id);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_session_key(const u8_t dhkey[32],
|
||||
const u8_t prov_salt[16],
|
||||
u8_t session_key[16])
|
||||
static inline int bt_mesh_session_key(const uint8_t dhkey[32],
|
||||
const uint8_t prov_salt[16],
|
||||
uint8_t session_key[16])
|
||||
{
|
||||
return bt_mesh_k1(dhkey, 32, prov_salt, "prsk", session_key);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_prov_nonce(const u8_t dhkey[32],
|
||||
const u8_t prov_salt[16],
|
||||
u8_t nonce[13])
|
||||
static inline int bt_mesh_prov_nonce(const uint8_t dhkey[32],
|
||||
const uint8_t prov_salt[16],
|
||||
uint8_t nonce[13])
|
||||
{
|
||||
u8_t tmp[16];
|
||||
uint8_t tmp[16];
|
||||
int err;
|
||||
|
||||
err = bt_mesh_k1(dhkey, 32, prov_salt, "prsn", tmp);
|
||||
@@ -107,19 +107,19 @@ static inline int bt_mesh_prov_nonce(const u8_t dhkey[32],
|
||||
return err;
|
||||
}
|
||||
|
||||
static inline int bt_mesh_dev_key(const u8_t dhkey[32],
|
||||
const u8_t prov_salt[16],
|
||||
u8_t dev_key[16])
|
||||
static inline int bt_mesh_dev_key(const uint8_t dhkey[32],
|
||||
const uint8_t prov_salt[16],
|
||||
uint8_t dev_key[16])
|
||||
{
|
||||
return bt_mesh_k1(dhkey, 32, prov_salt, "prdk", dev_key);
|
||||
}
|
||||
|
||||
static inline int bt_mesh_prov_salt(const u8_t conf_salt[16],
|
||||
const u8_t prov_rand[16],
|
||||
const u8_t dev_rand[16],
|
||||
u8_t prov_salt[16])
|
||||
static inline int bt_mesh_prov_salt(const uint8_t conf_salt[16],
|
||||
const uint8_t prov_rand[16],
|
||||
const uint8_t dev_rand[16],
|
||||
uint8_t prov_salt[16])
|
||||
{
|
||||
const u8_t prov_salt_key[16] = { 0 };
|
||||
const uint8_t prov_salt_key[16] = { 0 };
|
||||
struct bt_mesh_sg sg[] = {
|
||||
{ conf_salt, 16 },
|
||||
{ prov_rand, 16 },
|
||||
@@ -129,43 +129,43 @@ static inline int bt_mesh_prov_salt(const u8_t conf_salt[16],
|
||||
return bt_mesh_aes_cmac(prov_salt_key, sg, ARRAY_SIZE(sg), prov_salt);
|
||||
}
|
||||
|
||||
int bt_mesh_net_obfuscate(u8_t *pdu, u32_t iv_index,
|
||||
const u8_t privacy_key[16]);
|
||||
int bt_mesh_net_obfuscate(uint8_t *pdu, uint32_t iv_index,
|
||||
const uint8_t privacy_key[16]);
|
||||
|
||||
int bt_mesh_net_encrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
u32_t iv_index, bool proxy);
|
||||
int bt_mesh_net_encrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy);
|
||||
|
||||
int bt_mesh_net_decrypt(const u8_t key[16], struct net_buf_simple *buf,
|
||||
u32_t iv_index, bool proxy);
|
||||
int bt_mesh_net_decrypt(const uint8_t key[16], struct net_buf_simple *buf,
|
||||
uint32_t iv_index, bool proxy);
|
||||
|
||||
int bt_mesh_app_encrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
struct net_buf_simple *buf, const u8_t *ad,
|
||||
u16_t src, u16_t dst, u32_t seq_num, u32_t iv_index);
|
||||
int bt_mesh_app_encrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic,
|
||||
struct net_buf_simple *buf, const uint8_t *ad,
|
||||
uint16_t src, uint16_t dst, uint32_t seq_num, uint32_t iv_index);
|
||||
|
||||
int bt_mesh_app_decrypt(const u8_t key[16], bool dev_key, u8_t aszmic,
|
||||
int bt_mesh_app_decrypt(const uint8_t key[16], bool dev_key, uint8_t aszmic,
|
||||
struct net_buf_simple *buf, struct net_buf_simple *out,
|
||||
const u8_t *ad, u16_t src, u16_t dst, u32_t seq_num,
|
||||
u32_t iv_index);
|
||||
const uint8_t *ad, uint16_t src, uint16_t dst, uint32_t seq_num,
|
||||
uint32_t iv_index);
|
||||
|
||||
u8_t bt_mesh_fcs_calc(const u8_t *data, u8_t data_len);
|
||||
uint8_t bt_mesh_fcs_calc(const uint8_t *data, uint8_t data_len);
|
||||
|
||||
bool bt_mesh_fcs_check(struct net_buf_simple *buf, u8_t received_fcs);
|
||||
bool bt_mesh_fcs_check(struct net_buf_simple *buf, uint8_t received_fcs);
|
||||
|
||||
int bt_mesh_virtual_addr(const u8_t virtual_label[16], u16_t *addr);
|
||||
int bt_mesh_virtual_addr(const uint8_t virtual_label[16], uint16_t *addr);
|
||||
|
||||
int bt_mesh_prov_conf_salt(const u8_t conf_inputs[145], u8_t salt[16]);
|
||||
int bt_mesh_prov_conf_salt(const uint8_t conf_inputs[145], uint8_t salt[16]);
|
||||
|
||||
int bt_mesh_prov_conf_key(const u8_t dhkey[32], const u8_t conf_salt[16],
|
||||
u8_t conf_key[16]);
|
||||
int bt_mesh_prov_conf_key(const uint8_t dhkey[32], const uint8_t conf_salt[16],
|
||||
uint8_t conf_key[16]);
|
||||
|
||||
int bt_mesh_prov_conf(const u8_t conf_key[16], const u8_t rand[16],
|
||||
const u8_t auth[16], u8_t conf[16]);
|
||||
int bt_mesh_prov_conf(const uint8_t conf_key[16], const uint8_t rand[16],
|
||||
const uint8_t auth[16], uint8_t conf[16]);
|
||||
|
||||
int bt_mesh_prov_decrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t data[25 + 8], u8_t out[25]);
|
||||
int bt_mesh_prov_decrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t data[25 + 8], uint8_t out[25]);
|
||||
|
||||
int bt_mesh_prov_encrypt(const u8_t key[16], u8_t nonce[13],
|
||||
const u8_t data[25], u8_t out[33]);
|
||||
int bt_mesh_prov_encrypt(const uint8_t key[16], uint8_t nonce[13],
|
||||
const uint8_t data[25], uint8_t out[33]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define ACTION_SUSPEND 0x02
|
||||
#define ACTION_EXIT 0x03
|
||||
|
||||
const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
|
||||
const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst)
|
||||
{
|
||||
if (!BLE_MESH_ADDR_IS_UNICAST(dst)) {
|
||||
BT_ERR("Invalid unicast address 0x%04x", dst);
|
||||
@@ -44,7 +44,7 @@ const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst)
|
||||
return bt_mesh_provisioner_dev_key_get(dst);
|
||||
}
|
||||
|
||||
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx)
|
||||
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
int i;
|
||||
@@ -66,7 +66,7 @@ struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx)
|
||||
struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
int i;
|
||||
@@ -90,7 +90,7 @@ struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx)
|
||||
uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx)
|
||||
{
|
||||
/* Set net_idx for fast provisioning */
|
||||
bt_mesh_provisioner_set_fast_prov_net_idx(net_idx);
|
||||
@@ -104,9 +104,9 @@ u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx)
|
||||
return 0x0; /* status: Succeed */
|
||||
}
|
||||
|
||||
u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16])
|
||||
uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16])
|
||||
{
|
||||
u16_t net_idx = 0U;
|
||||
uint16_t net_idx = 0U;
|
||||
int err = 0;
|
||||
|
||||
net_idx = bt_mesh_provisioner_get_fast_prov_net_idx();
|
||||
@@ -122,7 +122,7 @@ u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16])
|
||||
return 0x0; /* status: Succeed */
|
||||
}
|
||||
|
||||
const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx)
|
||||
const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
@@ -135,7 +135,7 @@ const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx)
|
||||
return (sub->kr_flag ? sub->keys[1].net : sub->keys[0].net);
|
||||
}
|
||||
|
||||
const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx)
|
||||
const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
|
||||
@@ -148,7 +148,7 @@ const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx)
|
||||
return (key->updated ? key->keys[1].val : key->keys[0].val);
|
||||
}
|
||||
|
||||
u8_t bt_mesh_set_fast_prov_action(u8_t action)
|
||||
uint8_t bt_mesh_set_fast_prov_action(uint8_t action)
|
||||
{
|
||||
if (!action || action > ACTION_EXIT) {
|
||||
return 0x01;
|
||||
|
||||
@@ -21,21 +21,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const u8_t *bt_mesh_fast_prov_dev_key_get(u16_t dst);
|
||||
const uint8_t *bt_mesh_fast_prov_dev_key_get(uint16_t dst);
|
||||
|
||||
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(u16_t net_idx);
|
||||
struct bt_mesh_subnet *bt_mesh_fast_prov_subnet_get(uint16_t net_idx);
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(u16_t app_idx);
|
||||
struct bt_mesh_app_key *bt_mesh_fast_prov_app_key_find(uint16_t app_idx);
|
||||
|
||||
u8_t bt_mesh_set_fast_prov_net_idx(u16_t net_idx);
|
||||
uint8_t bt_mesh_set_fast_prov_net_idx(uint16_t net_idx);
|
||||
|
||||
u8_t bt_mesh_fast_prov_net_key_add(const u8_t net_key[16]);
|
||||
uint8_t bt_mesh_fast_prov_net_key_add(const uint8_t net_key[16]);
|
||||
|
||||
const u8_t *bt_mesh_fast_prov_net_key_get(u16_t net_idx);
|
||||
const uint8_t *bt_mesh_fast_prov_net_key_get(uint16_t net_idx);
|
||||
|
||||
const u8_t *bt_mesh_get_fast_prov_app_key(u16_t net_idx, u16_t app_idx);
|
||||
const uint8_t *bt_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
u8_t bt_mesh_set_fast_prov_action(u8_t action);
|
||||
uint8_t bt_mesh_set_fast_prov_action(uint8_t action);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -126,48 +126,50 @@ enum {
|
||||
};
|
||||
|
||||
struct label {
|
||||
u16_t ref;
|
||||
u16_t addr;
|
||||
u8_t uuid[16];
|
||||
uint16_t ref;
|
||||
uint16_t addr;
|
||||
uint8_t uuid[16];
|
||||
bt_mesh_atomic_t flags[1];
|
||||
};
|
||||
|
||||
void bt_mesh_cfg_reset(void);
|
||||
void bt_mesh_mod_sub_reset(bool store);
|
||||
|
||||
void bt_mesh_heartbeat(u16_t src, u16_t dst, u8_t hops, u16_t feat);
|
||||
void bt_mesh_cfg_reset(bool store);
|
||||
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time);
|
||||
void bt_mesh_heartbeat(uint16_t src, uint16_t dst, uint8_t hops, uint16_t feat);
|
||||
|
||||
struct label *get_label(u16_t index);
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time);
|
||||
|
||||
u8_t *bt_mesh_label_uuid_get(u16_t addr);
|
||||
struct label *get_label(uint16_t index);
|
||||
|
||||
uint8_t *bt_mesh_label_uuid_get(uint16_t addr);
|
||||
|
||||
struct bt_mesh_hb_pub *bt_mesh_hb_pub_get(void);
|
||||
void bt_mesh_hb_pub_disable(void);
|
||||
struct bt_mesh_cfg_srv *bt_mesh_cfg_get(void);
|
||||
|
||||
u8_t bt_mesh_net_transmit_get(void);
|
||||
u8_t bt_mesh_relay_get(void);
|
||||
u8_t bt_mesh_friend_get(void);
|
||||
u8_t bt_mesh_relay_retransmit_get(void);
|
||||
u8_t bt_mesh_beacon_get(void);
|
||||
u8_t bt_mesh_gatt_proxy_get(void);
|
||||
u8_t bt_mesh_default_ttl_get(void);
|
||||
uint8_t bt_mesh_net_transmit_get(void);
|
||||
uint8_t bt_mesh_relay_get(void);
|
||||
uint8_t bt_mesh_friend_get(void);
|
||||
uint8_t bt_mesh_relay_retransmit_get(void);
|
||||
uint8_t bt_mesh_beacon_get(void);
|
||||
uint8_t bt_mesh_gatt_proxy_get(void);
|
||||
uint8_t bt_mesh_default_ttl_get(void);
|
||||
|
||||
void bt_mesh_subnet_del(struct bt_mesh_subnet *sub, bool store);
|
||||
|
||||
struct bt_mesh_app_key *bt_mesh_app_key_alloc(u16_t app_idx);
|
||||
struct bt_mesh_app_key *bt_mesh_app_key_alloc(uint16_t app_idx);
|
||||
void bt_mesh_app_key_del(struct bt_mesh_app_key *key, bool store);
|
||||
|
||||
static inline void key_idx_pack(struct net_buf_simple *buf,
|
||||
u16_t idx1, u16_t idx2)
|
||||
uint16_t idx1, uint16_t idx2)
|
||||
{
|
||||
net_buf_simple_add_le16(buf, idx1 | ((idx2 & 0x00f) << 12));
|
||||
net_buf_simple_add_u8(buf, idx2 >> 4);
|
||||
}
|
||||
|
||||
static inline void key_idx_unpack(struct net_buf_simple *buf,
|
||||
u16_t *idx1, u16_t *idx2)
|
||||
uint16_t *idx1, uint16_t *idx2)
|
||||
{
|
||||
*idx1 = sys_get_le16(&buf->data[0]) & 0xfff;
|
||||
*idx2 = sys_get_le16(&buf->data[1]) >> 4;
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_FRIEND)
|
||||
|
||||
#include "crypto.h"
|
||||
#include "adv.h"
|
||||
#include "mesh.h"
|
||||
@@ -38,15 +36,15 @@
|
||||
#define FRIEND_XMIT BLE_MESH_TRANSMIT(0, 20)
|
||||
|
||||
struct friend_pdu_info {
|
||||
u16_t src;
|
||||
u16_t dst;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
|
||||
u8_t seq[3];
|
||||
uint8_t seq[3];
|
||||
|
||||
u8_t ttl: 7,
|
||||
ctl: 1;
|
||||
uint8_t ttl:7,
|
||||
ctl:1;
|
||||
|
||||
u32_t iv_index;
|
||||
uint32_t iv_index;
|
||||
};
|
||||
|
||||
NET_BUF_POOL_FIXED_DEFINE(friend_buf_pool, FRIEND_BUF_COUNT,
|
||||
@@ -54,7 +52,7 @@ NET_BUF_POOL_FIXED_DEFINE(friend_buf_pool, FRIEND_BUF_COUNT,
|
||||
|
||||
static struct friend_adv {
|
||||
struct bt_mesh_adv adv;
|
||||
u16_t app_idx;
|
||||
uint16_t app_idx;
|
||||
} adv_pool[FRIEND_BUF_COUNT];
|
||||
|
||||
enum {
|
||||
@@ -65,11 +63,11 @@ enum {
|
||||
BLE_MESH_FRIENDSHIP_TERMINATE_DISABLE,
|
||||
};
|
||||
|
||||
static void (*friend_cb)(bool establish, u16_t lpn_addr, u8_t reason);
|
||||
static void (*friend_cb)(bool establish, uint16_t lpn_addr, uint8_t reason);
|
||||
|
||||
static bool friend_init = false;
|
||||
|
||||
static struct bt_mesh_subnet *friend_subnet_get(u16_t net_idx)
|
||||
static struct bt_mesh_subnet *friend_subnet_get(uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
@@ -88,7 +86,7 @@ static struct bt_mesh_adv *adv_alloc(int id)
|
||||
return &adv_pool[id].adv;
|
||||
}
|
||||
|
||||
static bool is_lpn_unicast(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
static bool is_lpn_unicast(struct bt_mesh_friend *frnd, uint16_t addr)
|
||||
{
|
||||
if (frnd->lpn == BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return false;
|
||||
@@ -97,8 +95,8 @@ static bool is_lpn_unicast(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
return (addr >= frnd->lpn && addr < (frnd->lpn + frnd->num_elem));
|
||||
}
|
||||
|
||||
struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr,
|
||||
bool valid, bool established)
|
||||
struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr,
|
||||
bool valid, bool established)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -146,16 +144,16 @@ static void purge_buffers(sys_slist_t *list)
|
||||
* like the PTS, where the receiver might not have sufficiently compensated
|
||||
* for internal latencies required to start scanning.
|
||||
*/
|
||||
static s32_t recv_delay(struct bt_mesh_friend *frnd)
|
||||
static int32_t recv_delay(struct bt_mesh_friend *frnd)
|
||||
{
|
||||
#if CONFIG_BLE_MESH_FRIEND_RECV_WIN > 50
|
||||
return (s32_t)frnd->recv_delay + (CONFIG_BLE_MESH_FRIEND_RECV_WIN / 5);
|
||||
return (int32_t)frnd->recv_delay + (CONFIG_BLE_MESH_FRIEND_RECV_WIN / 5);
|
||||
#else
|
||||
return frnd->recv_delay;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void friend_clear(struct bt_mesh_friend *frnd, u8_t reason)
|
||||
static void friend_clear(struct bt_mesh_friend *frnd, uint8_t reason)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -202,7 +200,7 @@ static void friend_clear(struct bt_mesh_friend *frnd, u8_t reason)
|
||||
(void)memset(frnd->sub_list, 0, sizeof(frnd->sub_list));
|
||||
}
|
||||
|
||||
void bt_mesh_friend_clear_net_idx(u16_t net_idx)
|
||||
void bt_mesh_friend_clear_net_idx(uint16_t net_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -221,7 +219,7 @@ void bt_mesh_friend_clear_net_idx(u16_t net_idx)
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_friend_sec_update(u16_t net_idx)
|
||||
void bt_mesh_friend_sec_update(uint16_t net_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -244,7 +242,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_ctl_friend_clear *msg = (void *)buf->data;
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u16_t lpn_addr = 0U, lpn_counter = 0U;
|
||||
uint16_t lpn_addr = 0U, lpn_counter = 0U;
|
||||
struct bt_mesh_net_tx tx = {
|
||||
.sub = rx->sub,
|
||||
.ctx = &rx->ctx,
|
||||
@@ -294,7 +292,7 @@ int bt_mesh_friend_clear(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
static void friend_sub_add(struct bt_mesh_friend *frnd, uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -308,7 +306,7 @@ static void friend_sub_add(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
BT_WARN("No space in friend subscription list");
|
||||
}
|
||||
|
||||
static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
static void friend_sub_rem(struct bt_mesh_friend *frnd, uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -321,8 +319,8 @@ static void friend_sub_rem(struct bt_mesh_friend *frnd, u16_t addr)
|
||||
}
|
||||
|
||||
static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd,
|
||||
struct friend_pdu_info *info,
|
||||
struct net_buf_simple *sdu)
|
||||
struct friend_pdu_info *info,
|
||||
struct net_buf_simple *sdu)
|
||||
{
|
||||
struct net_buf *buf = NULL;
|
||||
|
||||
@@ -353,19 +351,19 @@ static struct net_buf *create_friend_pdu(struct bt_mesh_friend *frnd,
|
||||
|
||||
struct unseg_app_sdu_meta {
|
||||
struct bt_mesh_net_rx net;
|
||||
const u8_t *key;
|
||||
const uint8_t *key;
|
||||
struct bt_mesh_subnet *subnet;
|
||||
bool is_dev_key;
|
||||
u8_t aid;
|
||||
u8_t *ad;
|
||||
uint8_t aid;
|
||||
uint8_t *ad;
|
||||
};
|
||||
|
||||
static int unseg_app_sdu_unpack(struct bt_mesh_friend *frnd,
|
||||
struct net_buf *buf,
|
||||
struct unseg_app_sdu_meta *meta)
|
||||
{
|
||||
u16_t app_idx = FRIEND_ADV(buf)->app_idx;
|
||||
u8_t role = 0U;
|
||||
uint16_t app_idx = FRIEND_ADV(buf)->app_idx;
|
||||
uint8_t role = 0U;
|
||||
int err = 0;
|
||||
|
||||
meta->subnet = friend_subnet_get(frnd->net_idx);
|
||||
@@ -471,10 +469,10 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf,
|
||||
bool master_cred)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = friend_subnet_get(frnd->net_idx);
|
||||
const u8_t *enc = NULL, *priv = NULL;
|
||||
u32_t iv_index = 0U;
|
||||
u16_t src = 0U;
|
||||
u8_t nid = 0U;
|
||||
const uint8_t *enc = NULL, *priv = NULL;
|
||||
uint32_t iv_index = 0U;
|
||||
uint16_t src = 0U;
|
||||
uint8_t nid = 0U;
|
||||
int err = 0;
|
||||
|
||||
if (!sub) {
|
||||
@@ -496,7 +494,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf,
|
||||
src = sys_get_be16(&buf->data[5]);
|
||||
|
||||
if (bt_mesh_elem_find(src)) {
|
||||
u32_t seq;
|
||||
uint32_t seq;
|
||||
|
||||
if (FRIEND_ADV(buf)->app_idx != BLE_MESH_KEY_UNUSED) {
|
||||
err = unseg_app_sdu_prepare(frnd, buf);
|
||||
@@ -511,7 +509,7 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf,
|
||||
iv_index = BLE_MESH_NET_IVI_TX;
|
||||
FRIEND_ADV(buf)->app_idx = BLE_MESH_KEY_UNUSED;
|
||||
} else {
|
||||
u8_t ivi = (buf->data[0] >> 7);
|
||||
uint8_t ivi = (buf->data[0] >> 7);
|
||||
iv_index = (bt_mesh.iv_index - ((bt_mesh.iv_index & 1) != ivi));
|
||||
}
|
||||
|
||||
@@ -531,8 +529,8 @@ static int encrypt_friend_pdu(struct bt_mesh_friend *frnd, struct net_buf *buf,
|
||||
}
|
||||
|
||||
static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd,
|
||||
u8_t ctl_op,
|
||||
struct net_buf_simple *sdu)
|
||||
uint8_t ctl_op,
|
||||
struct net_buf_simple *sdu)
|
||||
{
|
||||
struct friend_pdu_info info = {0};
|
||||
|
||||
@@ -553,7 +551,7 @@ static struct net_buf *encode_friend_ctl(struct bt_mesh_friend *frnd,
|
||||
return create_friend_pdu(frnd, &info, sdu);
|
||||
}
|
||||
|
||||
static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
|
||||
static struct net_buf *encode_update(struct bt_mesh_friend *frnd, uint8_t md)
|
||||
{
|
||||
struct bt_mesh_ctl_friend_update *upd = NULL;
|
||||
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*upd));
|
||||
@@ -576,7 +574,7 @@ static struct net_buf *encode_update(struct bt_mesh_friend *frnd, u8_t md)
|
||||
return encode_friend_ctl(frnd, TRANS_CTL_OP_FRIEND_UPDATE, &sdu);
|
||||
}
|
||||
|
||||
static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, u8_t xact)
|
||||
static void enqueue_sub_cfm(struct bt_mesh_friend *frnd, uint8_t xact)
|
||||
{
|
||||
struct bt_mesh_ctl_friend_sub_confirm *cfm = NULL;
|
||||
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*cfm));
|
||||
@@ -619,7 +617,7 @@ int bt_mesh_friend_sub_add(struct bt_mesh_net_rx *rx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u8_t xact = 0U;
|
||||
uint8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("Too short Friend Subscription Add (len %d)", buf->len);
|
||||
@@ -654,7 +652,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u8_t xact = 0U;
|
||||
uint8_t xact = 0U;
|
||||
|
||||
if (buf->len < BLE_MESH_FRIEND_SUB_MIN_LEN) {
|
||||
BT_WARN("Too short Friend Subscription Remove (len %d)", buf->len);
|
||||
@@ -691,7 +689,7 @@ static void enqueue_buf(struct bt_mesh_friend *frnd, struct net_buf *buf)
|
||||
frnd->queue_size++;
|
||||
}
|
||||
|
||||
static void enqueue_update(struct bt_mesh_friend *frnd, u8_t md)
|
||||
static void enqueue_update(struct bt_mesh_friend *frnd, uint8_t md)
|
||||
{
|
||||
struct net_buf *buf = NULL;
|
||||
|
||||
@@ -763,7 +761,7 @@ int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bt_mesh_friend *find_clear(u16_t prev_friend)
|
||||
static struct bt_mesh_friend *find_clear(uint16_t prev_friend)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -825,7 +823,7 @@ static void clear_timeout(struct k_work *work)
|
||||
{
|
||||
struct bt_mesh_friend *frnd = CONTAINER_OF(work, struct bt_mesh_friend,
|
||||
clear.timer.work);
|
||||
u32_t duration = 0U;
|
||||
uint32_t duration = 0U;
|
||||
|
||||
BT_DBG("LPN 0x%04x (old) Friend 0x%04x", frnd->lpn, frnd->clear.frnd);
|
||||
|
||||
@@ -854,7 +852,7 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
|
||||
{
|
||||
struct bt_mesh_ctl_friend_clear_confirm *msg = (void *)buf->data;
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u16_t lpn_addr = 0U, lpn_counter = 0U;
|
||||
uint16_t lpn_addr = 0U, lpn_counter = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
@@ -889,7 +887,7 @@ int bt_mesh_friend_clear_cfm(struct bt_mesh_net_rx *rx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
|
||||
static void enqueue_offer(struct bt_mesh_friend *frnd, int8_t rssi)
|
||||
{
|
||||
struct bt_mesh_ctl_friend_offer *off = NULL;
|
||||
NET_BUF_SIMPLE_DEFINE(sdu, 1 + sizeof(*off));
|
||||
@@ -928,26 +926,26 @@ static void enqueue_offer(struct bt_mesh_friend *frnd, s8_t rssi)
|
||||
}
|
||||
|
||||
#define RECV_WIN CONFIG_BLE_MESH_FRIEND_RECV_WIN
|
||||
#define RSSI_FACT(crit) (((crit) >> 5) & (u8_t)BIT_MASK(2))
|
||||
#define RECV_WIN_FACT(crit) (((crit) >> 3) & (u8_t)BIT_MASK(2))
|
||||
#define MIN_QUEUE_SIZE_LOG(crit) ((crit) & (u8_t)BIT_MASK(3))
|
||||
#define MIN_QUEUE_SIZE(crit) ((u32_t)BIT(MIN_QUEUE_SIZE_LOG(crit)))
|
||||
#define RSSI_FACT(crit) (((crit) >> 5) & (uint8_t)BIT_MASK(2))
|
||||
#define RECV_WIN_FACT(crit) (((crit) >> 3) & (uint8_t)BIT_MASK(2))
|
||||
#define MIN_QUEUE_SIZE_LOG(crit) ((crit) & (uint8_t)BIT_MASK(3))
|
||||
#define MIN_QUEUE_SIZE(crit) ((uint32_t)BIT(MIN_QUEUE_SIZE_LOG(crit)))
|
||||
|
||||
static s32_t offer_delay(struct bt_mesh_friend *frnd, s8_t rssi, u8_t crit)
|
||||
static int32_t offer_delay(struct bt_mesh_friend *frnd, int8_t rssi, uint8_t crit)
|
||||
{
|
||||
/* Scaling factors. The actual values are 1, 1.5, 2 & 2.5, but we
|
||||
* want to avoid floating-point arithmetic.
|
||||
*/
|
||||
static const u8_t fact[] = { 10, 15, 20, 25 };
|
||||
s32_t delay = 0;
|
||||
static const uint8_t fact[] = { 10, 15, 20, 25 };
|
||||
int32_t delay = 0;
|
||||
|
||||
BT_INFO("ReceiveWindowFactor %u ReceiveWindow %u RSSIFactor %u RSSI %d",
|
||||
fact[RECV_WIN_FACT(crit)], RECV_WIN,
|
||||
fact[RSSI_FACT(crit)], rssi);
|
||||
|
||||
/* Delay = ReceiveWindowFactor * ReceiveWindow - RSSIFactor * RSSI */
|
||||
delay = (s32_t)fact[RECV_WIN_FACT(crit)] * RECV_WIN;
|
||||
delay -= (s32_t)fact[RSSI_FACT(crit)] * rssi;
|
||||
delay = (int32_t)fact[RECV_WIN_FACT(crit)] * RECV_WIN;
|
||||
delay -= (int32_t)fact[RSSI_FACT(crit)] * rssi;
|
||||
delay /= 10;
|
||||
|
||||
BT_DBG("Local Delay calculated as %d ms", delay);
|
||||
@@ -963,7 +961,7 @@ int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_ctl_friend_req *msg = (void *)buf->data;
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
u32_t poll_to = 0U;
|
||||
uint32_t poll_to = 0U;
|
||||
int i;
|
||||
|
||||
if (buf->len < sizeof(*msg)) {
|
||||
@@ -1061,12 +1059,12 @@ init_friend:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool is_seg(struct bt_mesh_friend_seg *seg, u16_t src, u16_t seq_zero)
|
||||
static bool is_seg(struct bt_mesh_friend_seg *seg, uint16_t src, uint16_t seq_zero)
|
||||
{
|
||||
struct net_buf *buf = (void *)sys_slist_peek_head(&seg->queue);
|
||||
struct net_buf_simple_state state = {0};
|
||||
u16_t buf_seq_zero = 0U;
|
||||
u16_t buf_src = 0U;
|
||||
uint16_t buf_seq_zero = 0U;
|
||||
uint16_t buf_src = 0U;
|
||||
|
||||
if (!buf) {
|
||||
return false;
|
||||
@@ -1083,8 +1081,8 @@ static bool is_seg(struct bt_mesh_friend_seg *seg, u16_t src, u16_t seq_zero)
|
||||
}
|
||||
|
||||
static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd,
|
||||
u16_t src, u16_t seq_zero,
|
||||
u8_t seg_count)
|
||||
uint16_t src, uint16_t seq_zero,
|
||||
uint8_t seg_count)
|
||||
{
|
||||
struct bt_mesh_friend_seg *unassigned = NULL;
|
||||
int i;
|
||||
@@ -1110,7 +1108,7 @@ static struct bt_mesh_friend_seg *get_seg(struct bt_mesh_friend *frnd,
|
||||
|
||||
static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
u16_t src, u8_t seg_count,
|
||||
uint16_t src, uint8_t seg_count,
|
||||
struct net_buf *buf)
|
||||
{
|
||||
struct bt_mesh_friend_seg *seg = NULL;
|
||||
@@ -1126,7 +1124,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
|
||||
return;
|
||||
}
|
||||
|
||||
u16_t seq_zero = (((buf->data[10] << 8 | buf->data[11]) >> 2) & TRANS_SEQ_ZERO_MASK);
|
||||
uint16_t seq_zero = (((buf->data[10] << 8 | buf->data[11]) >> 2) & TRANS_SEQ_ZERO_MASK);
|
||||
|
||||
seg = get_seg(frnd, src, seq_zero, seg_count);
|
||||
if (!seg) {
|
||||
@@ -1152,7 +1150,7 @@ static void enqueue_friend_pdu(struct bt_mesh_friend *frnd,
|
||||
}
|
||||
}
|
||||
|
||||
static void buf_send_start(u16_t duration, int err, void *user_data)
|
||||
static void buf_send_start(uint16_t duration, int err, void *user_data)
|
||||
{
|
||||
struct bt_mesh_friend *frnd = user_data;
|
||||
|
||||
@@ -1242,7 +1240,7 @@ send_last:
|
||||
bt_mesh_adv_send(frnd->last, &buf_sent_cb, frnd);
|
||||
}
|
||||
|
||||
void bt_mesh_friend_set_cb(void (*cb)(bool establish, u16_t lpn_addr, u8_t reason))
|
||||
void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason))
|
||||
{
|
||||
friend_cb = cb;
|
||||
}
|
||||
@@ -1277,6 +1275,7 @@ int bt_mesh_friend_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
int bt_mesh_friend_deinit(void)
|
||||
{
|
||||
int i;
|
||||
@@ -1304,8 +1303,9 @@ int bt_mesh_friend_deinit(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
static bool is_segack(struct net_buf *buf, const u64_t *seqauth, u16_t src)
|
||||
static bool is_segack(struct net_buf *buf, const uint64_t *seqauth, uint16_t src)
|
||||
{
|
||||
struct net_buf_simple_state state = {0};
|
||||
bool found = false;
|
||||
@@ -1330,7 +1330,7 @@ static bool is_segack(struct net_buf *buf, const u64_t *seqauth, u16_t src)
|
||||
|
||||
net_buf_skip(buf, 2); /* skip dst */
|
||||
|
||||
if (TRANS_CTL_OP((u8_t *) net_buf_pull_mem(buf, 1)) != TRANS_CTL_OP_ACK) {
|
||||
if (TRANS_CTL_OP((uint8_t *) net_buf_pull_mem(buf, 1)) != TRANS_CTL_OP_ACK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
@@ -1342,7 +1342,7 @@ end:
|
||||
}
|
||||
|
||||
static void friend_purge_old_ack(struct bt_mesh_friend *frnd,
|
||||
const u64_t *seq_auth, u16_t src)
|
||||
const uint64_t *seq_auth, uint16_t src)
|
||||
{
|
||||
sys_snode_t *cur = NULL, *prev = NULL;
|
||||
|
||||
@@ -1369,7 +1369,7 @@ static void friend_purge_old_ack(struct bt_mesh_friend *frnd,
|
||||
static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
|
||||
struct bt_mesh_net_rx *rx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf)
|
||||
{
|
||||
struct friend_pdu_info info = {0};
|
||||
@@ -1419,7 +1419,7 @@ static void friend_lpn_enqueue_rx(struct bt_mesh_friend *frnd,
|
||||
static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
|
||||
struct bt_mesh_net_tx *tx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf)
|
||||
{
|
||||
struct friend_pdu_info info = {0};
|
||||
@@ -1460,8 +1460,8 @@ static void friend_lpn_enqueue_tx(struct bt_mesh_friend *frnd,
|
||||
BT_DBG("Queued message for LPN 0x%04x", frnd->lpn);
|
||||
}
|
||||
|
||||
static bool friend_lpn_matches(struct bt_mesh_friend *frnd, u16_t net_idx,
|
||||
u16_t addr)
|
||||
static bool friend_lpn_matches(struct bt_mesh_friend *frnd, uint16_t net_idx,
|
||||
uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1486,7 +1486,7 @@ static bool friend_lpn_matches(struct bt_mesh_friend *frnd, u16_t net_idx,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bt_mesh_friend_match(u16_t net_idx, u16_t addr)
|
||||
bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1505,10 +1505,10 @@ bool bt_mesh_friend_match(u16_t net_idx, u16_t addr)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr,
|
||||
const u64_t *seq_auth, u8_t seg_count)
|
||||
static bool friend_queue_has_space(struct bt_mesh_friend *frnd, uint16_t addr,
|
||||
const uint64_t *seq_auth, uint8_t seg_count)
|
||||
{
|
||||
u32_t total = 0U;
|
||||
uint32_t total = 0U;
|
||||
int i;
|
||||
|
||||
if (seg_count > CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE) {
|
||||
@@ -1536,8 +1536,8 @@ static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr,
|
||||
return (CONFIG_BLE_MESH_FRIEND_QUEUE_SIZE - total) > seg_count;
|
||||
}
|
||||
|
||||
bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
|
||||
const u64_t *seq_auth, u8_t seg_count)
|
||||
bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst,
|
||||
const uint64_t *seq_auth, uint8_t seg_count)
|
||||
{
|
||||
bool someone_has_space = false, friend_match = false;
|
||||
int i;
|
||||
@@ -1571,11 +1571,11 @@ bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
|
||||
return someone_has_space;
|
||||
}
|
||||
|
||||
static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, u16_t addr,
|
||||
const u64_t *seq_auth, u8_t seg_count)
|
||||
static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, uint16_t addr,
|
||||
const uint64_t *seq_auth, uint8_t seg_count)
|
||||
{
|
||||
bool pending_segments = false;
|
||||
u8_t avail_space = 0U;
|
||||
uint8_t avail_space = 0U;
|
||||
|
||||
if (!friend_queue_has_space(frnd, addr, seq_auth, seg_count)) {
|
||||
return false;
|
||||
@@ -1609,7 +1609,7 @@ static bool friend_queue_prepare_space(struct bt_mesh_friend *frnd, u16_t addr,
|
||||
|
||||
void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf)
|
||||
{
|
||||
int i;
|
||||
@@ -1644,7 +1644,7 @@ void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx,
|
||||
|
||||
bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf)
|
||||
{
|
||||
bool matched = false;
|
||||
@@ -1679,8 +1679,8 @@ bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx,
|
||||
return matched;
|
||||
}
|
||||
|
||||
void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
|
||||
u16_t dst, const u64_t *seq_auth)
|
||||
void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src,
|
||||
uint16_t dst, const uint64_t *seq_auth)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1710,7 +1710,7 @@ void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
|
||||
}
|
||||
}
|
||||
|
||||
void bt_mesh_friend_remove_lpn(u16_t lpn_addr)
|
||||
void bt_mesh_friend_remove_lpn(uint16_t lpn_addr)
|
||||
{
|
||||
struct bt_mesh_friend *frnd = NULL;
|
||||
|
||||
|
||||
@@ -21,29 +21,29 @@ enum bt_mesh_friend_pdu_type {
|
||||
BLE_MESH_FRIEND_PDU_COMPLETE,
|
||||
};
|
||||
|
||||
bool bt_mesh_friend_match(u16_t net_idx, u16_t addr);
|
||||
bool bt_mesh_friend_match(uint16_t net_idx, uint16_t addr);
|
||||
|
||||
struct bt_mesh_friend *bt_mesh_friend_find(u16_t net_idx, u16_t lpn_addr,
|
||||
bool valid, bool established);
|
||||
struct bt_mesh_friend *bt_mesh_friend_find(uint16_t net_idx, uint16_t lpn_addr,
|
||||
bool valid, bool established);
|
||||
|
||||
bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
|
||||
const u64_t *seq_auth, u8_t seg_count);
|
||||
bool bt_mesh_friend_queue_has_space(uint16_t net_idx, uint16_t src, uint16_t dst,
|
||||
const uint64_t *seq_auth, uint8_t seg_count);
|
||||
|
||||
void bt_mesh_friend_enqueue_rx(struct bt_mesh_net_rx *rx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf);
|
||||
bool bt_mesh_friend_enqueue_tx(struct bt_mesh_net_tx *tx,
|
||||
enum bt_mesh_friend_pdu_type type,
|
||||
const u64_t *seq_auth, u8_t seg_count,
|
||||
const uint64_t *seq_auth, uint8_t seg_count,
|
||||
struct net_buf_simple *sbuf);
|
||||
|
||||
void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, u16_t src,
|
||||
u16_t dst, const u64_t *seq_auth);
|
||||
void bt_mesh_friend_clear_incomplete(struct bt_mesh_subnet *sub, uint16_t src,
|
||||
uint16_t dst, const uint64_t *seq_auth);
|
||||
|
||||
void bt_mesh_friend_sec_update(u16_t net_idx);
|
||||
void bt_mesh_friend_sec_update(uint16_t net_idx);
|
||||
|
||||
void bt_mesh_friend_clear_net_idx(u16_t net_idx);
|
||||
void bt_mesh_friend_clear_net_idx(uint16_t net_idx);
|
||||
|
||||
int bt_mesh_friend_poll(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
|
||||
int bt_mesh_friend_req(struct bt_mesh_net_rx *rx, struct net_buf_simple *buf);
|
||||
@@ -58,7 +58,7 @@ int bt_mesh_friend_sub_rem(struct bt_mesh_net_rx *rx,
|
||||
int bt_mesh_friend_init(void);
|
||||
int bt_mesh_friend_deinit(void);
|
||||
|
||||
void bt_mesh_friend_remove_lpn(u16_t lpn_addr);
|
||||
void bt_mesh_friend_remove_lpn(uint16_t lpn_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -10,12 +10,13 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
|
||||
#include "mesh_config.h"
|
||||
#include "foundation.h"
|
||||
#include "mesh_common.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_CLI
|
||||
#include "health_cli.h"
|
||||
|
||||
static const bt_mesh_client_op_pair_t health_op_pair[] = {
|
||||
@@ -30,24 +31,26 @@ static const bt_mesh_client_op_pair_t health_op_pair[] = {
|
||||
|
||||
static bt_mesh_mutex_t health_client_lock;
|
||||
|
||||
static void bt_mesh_health_client_mutex_new(void)
|
||||
static inline void bt_mesh_health_client_mutex_new(void)
|
||||
{
|
||||
if (!health_client_lock.mutex) {
|
||||
bt_mesh_mutex_create(&health_client_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static void bt_mesh_health_client_mutex_free(void)
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static inline void bt_mesh_health_client_mutex_free(void)
|
||||
{
|
||||
bt_mesh_mutex_free(&health_client_lock);
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
static void bt_mesh_health_client_lock(void)
|
||||
static inline void bt_mesh_health_client_lock(void)
|
||||
{
|
||||
bt_mesh_mutex_lock(&health_client_lock);
|
||||
}
|
||||
|
||||
static void bt_mesh_health_client_unlock(void)
|
||||
static inline void bt_mesh_health_client_unlock(void)
|
||||
{
|
||||
bt_mesh_mutex_unlock(&health_client_lock);
|
||||
}
|
||||
@@ -57,7 +60,7 @@ static void timeout_handler(struct k_work *work)
|
||||
struct k_delayed_work *timer = NULL;
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
u32_t opcode = 0U;
|
||||
uint32_t opcode = 0U;
|
||||
|
||||
BT_WARN("Receive health status message timeout");
|
||||
|
||||
@@ -87,7 +90,7 @@ static void health_client_recv_status(struct bt_mesh_model *model,
|
||||
{
|
||||
bt_mesh_client_node_t *node = NULL;
|
||||
struct net_buf_simple buf = {0};
|
||||
u8_t evt_type = 0xFF;
|
||||
uint8_t evt_type = 0xFF;
|
||||
|
||||
if (!model || !ctx || !status || !len) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
@@ -95,8 +98,8 @@ static void health_client_recv_status(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
/* If it is a publish message, sent to the user directly. */
|
||||
buf.data = (u8_t *)status;
|
||||
buf.len = (u16_t)len;
|
||||
buf.data = (uint8_t *)status;
|
||||
buf.len = (uint16_t)len;
|
||||
|
||||
bt_mesh_health_client_lock();
|
||||
|
||||
@@ -121,10 +124,10 @@ static void health_client_recv_status(struct bt_mesh_model *model,
|
||||
}
|
||||
|
||||
if (!k_delayed_work_free(&node->timer)) {
|
||||
u32_t opcode = node->opcode;
|
||||
uint32_t opcode = node->opcode;
|
||||
bt_mesh_client_free_node(node);
|
||||
bt_mesh_health_client_cb_evt_to_btc(
|
||||
opcode, evt_type, model, ctx, (const u8_t *)status, len);
|
||||
opcode, evt_type, model, ctx, (const uint8_t *)status, len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +199,7 @@ static void health_period_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t status = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -204,14 +207,14 @@ static void health_period_status(struct bt_mesh_model *model,
|
||||
|
||||
status = net_buf_simple_pull_u8(buf);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(u8_t));
|
||||
health_client_recv_status(model, ctx, &status, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
static void health_attention_status(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t status = 0U;
|
||||
uint8_t status = 0U;
|
||||
|
||||
BT_DBG("net_idx 0x%04x app_idx 0x%04x src 0x%04x len %u: %s",
|
||||
ctx->net_idx, ctx->app_idx, ctx->addr, buf->len,
|
||||
@@ -219,7 +222,7 @@ static void health_attention_status(struct bt_mesh_model *model,
|
||||
|
||||
status = net_buf_simple_pull_u8(buf);
|
||||
|
||||
health_client_recv_status(model, ctx, &status, sizeof(u8_t));
|
||||
health_client_recv_status(model, ctx, &status, sizeof(uint8_t));
|
||||
}
|
||||
|
||||
const struct bt_mesh_model_op bt_mesh_health_cli_op[] = {
|
||||
@@ -240,7 +243,7 @@ int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param)
|
||||
}
|
||||
|
||||
int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t attention, bool need_ack)
|
||||
uint8_t attention, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_SET, 1);
|
||||
|
||||
@@ -260,7 +263,7 @@ int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param)
|
||||
}
|
||||
|
||||
int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t divisor, bool need_ack)
|
||||
uint8_t divisor, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_PERIOD_SET, 1);
|
||||
|
||||
@@ -271,7 +274,7 @@ int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, u8_t test_id, bool need_ack)
|
||||
uint16_t cid, uint8_t test_id, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_TEST, 3);
|
||||
|
||||
@@ -283,7 +286,7 @@ int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, bool need_ack)
|
||||
uint16_t cid, bool need_ack)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_CLEAR, 2);
|
||||
|
||||
@@ -293,7 +296,7 @@ int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
return bt_mesh_client_send_msg(param, &msg, need_ack, timeout_handler);
|
||||
}
|
||||
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid)
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid)
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_HEALTH_FAULT_GET, 2);
|
||||
|
||||
@@ -343,6 +346,7 @@ static int health_cli_init(struct bt_mesh_model *model)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static int health_cli_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
bt_mesh_health_client_t *client = NULL;
|
||||
@@ -373,8 +377,13 @@ static int health_cli_deinit(struct bt_mesh_model *model)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_health_cli_cb = {
|
||||
.init = health_cli_init,
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
.deinit = health_cli_deinit,
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
};
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_CLI */
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define BT_DBG_ENABLED IS_ENABLED(CONFIG_BLE_MESH_DEBUG_MODEL)
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
|
||||
#include "access.h"
|
||||
#include "foundation.h"
|
||||
#include "mesh_common.h"
|
||||
|
||||
#if CONFIG_BLE_MESH_HEALTH_SRV
|
||||
#include "health_srv.h"
|
||||
|
||||
#define HEALTH_TEST_STANDARD 0x00
|
||||
@@ -36,10 +36,10 @@ struct bt_mesh_health_srv *health_srv;
|
||||
* the node for more than one Company ID.
|
||||
*/
|
||||
|
||||
static u8_t health_get_curr_fault_count(struct bt_mesh_model *model)
|
||||
static uint8_t health_get_curr_fault_count(struct bt_mesh_model *model)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
u8_t count = 0U;
|
||||
uint8_t count = 0U;
|
||||
size_t i = 0U;
|
||||
|
||||
for (i = 0U; i < ARRAY_SIZE(srv->test.curr_faults); i++) {
|
||||
@@ -66,14 +66,14 @@ static void health_get_fault_value(struct bt_mesh_model *model,
|
||||
return;
|
||||
}
|
||||
|
||||
u8_t fault = current ? srv->test.curr_faults[i] : srv->test.reg_faults[i];
|
||||
uint8_t fault = current ? srv->test.curr_faults[i] : srv->test.reg_faults[i];
|
||||
if (fault != HEALTH_NO_FAULT) {
|
||||
net_buf_simple_add_u8(msg, fault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool health_is_test_id_exist(struct bt_mesh_model *model, u8_t test_id)
|
||||
static bool health_is_test_id_exist(struct bt_mesh_model *model, uint8_t test_id)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
int i;
|
||||
@@ -125,7 +125,7 @@ static void health_fault_get(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
u16_t company_id = 0U;
|
||||
uint16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
@@ -148,7 +148,7 @@ static void health_fault_clear(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
u16_t company_id = 0U;
|
||||
uint16_t company_id = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
@@ -179,8 +179,8 @@ static void health_fault_test(struct bt_mesh_model *model,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
u16_t company_id = 0U;
|
||||
u8_t test_id = 0U;
|
||||
uint16_t company_id = 0U;
|
||||
uint8_t test_id = 0U;
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
@@ -219,7 +219,7 @@ static void send_attention_status(struct bt_mesh_model *model,
|
||||
{
|
||||
BLE_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_STATUS, 1);
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
u8_t time = 0U;
|
||||
uint8_t time = 0U;
|
||||
|
||||
if (!srv) {
|
||||
BT_ERR("No Health Server context provided");
|
||||
@@ -250,7 +250,7 @@ static void health_set_attention(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t time = 0U;
|
||||
uint8_t time = 0U;
|
||||
|
||||
time = net_buf_simple_pull_u8(buf);
|
||||
|
||||
@@ -298,7 +298,7 @@ static void health_set_period(struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
u8_t period = 0U;
|
||||
uint8_t period = 0U;
|
||||
|
||||
period = net_buf_simple_pull_u8(buf);
|
||||
if (period > 15) {
|
||||
@@ -469,6 +469,7 @@ static int health_srv_init(struct bt_mesh_model *model)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
static int health_srv_deinit(struct bt_mesh_model *model)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = model->user_data;
|
||||
@@ -499,13 +500,16 @@ static int health_srv_deinit(struct bt_mesh_model *model)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
|
||||
const struct bt_mesh_model_cb bt_mesh_health_srv_cb = {
|
||||
.init = health_srv_init,
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
.deinit = health_srv_deinit,
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
};
|
||||
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time)
|
||||
{
|
||||
struct bt_mesh_health_srv *srv = NULL;
|
||||
|
||||
@@ -543,3 +547,9 @@ void bt_mesh_attention(struct bt_mesh_model *model, u8_t time)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
void bt_mesh_attention(struct bt_mesh_model *model, uint8_t time)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif /* CONFIG_BLE_MESH_HEALTH_SRV */
|
||||
|
||||
@@ -35,84 +35,84 @@ extern const struct bt_mesh_model_cb bt_mesh_cfg_cli_cb;
|
||||
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_CFG_CLI, \
|
||||
bt_mesh_cfg_cli_op, NULL, cli_data, &bt_mesh_cfg_cli_cb)
|
||||
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, u8_t page);
|
||||
int bt_mesh_cfg_comp_data_get(bt_mesh_client_common_param_t *param, uint8_t page);
|
||||
|
||||
int bt_mesh_cfg_beacon_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_beacon_set(bt_mesh_client_common_param_t *param, uint8_t val);
|
||||
|
||||
int bt_mesh_cfg_ttl_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_ttl_set(bt_mesh_client_common_param_t *param, uint8_t val);
|
||||
|
||||
int bt_mesh_cfg_friend_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_friend_set(bt_mesh_client_common_param_t *param, uint8_t val);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, u8_t val);
|
||||
int bt_mesh_cfg_gatt_proxy_set(bt_mesh_client_common_param_t *param, uint8_t val);
|
||||
|
||||
int bt_mesh_cfg_relay_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_relay_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t relay, u8_t retransmit);
|
||||
uint8_t relay, uint8_t retransmit);
|
||||
|
||||
int bt_mesh_cfg_net_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
uint16_t net_idx, const uint8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
uint16_t net_idx, uint16_t app_idx,
|
||||
const uint8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_mod_app_bind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_mod_pub {
|
||||
u16_t addr;
|
||||
u16_t app_idx;
|
||||
bool cred_flag;
|
||||
u8_t ttl;
|
||||
u8_t period;
|
||||
u8_t transmit;
|
||||
uint16_t addr;
|
||||
uint16_t app_idx;
|
||||
bool cred_flag;
|
||||
uint8_t ttl;
|
||||
uint8_t period;
|
||||
uint8_t transmit;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_pub_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid,
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid,
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t sub_addr,
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t sub_addr,
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_add(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_del(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_va_overwrite(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, const u8_t label[16],
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, const uint8_t label[16],
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
struct bt_mesh_cfg_hb_sub {
|
||||
u16_t src;
|
||||
u16_t dst;
|
||||
u8_t period;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t period;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param,
|
||||
@@ -121,12 +121,12 @@ int bt_mesh_cfg_hb_sub_set(bt_mesh_client_common_param_t *param,
|
||||
int bt_mesh_cfg_hb_sub_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
struct bt_mesh_cfg_hb_pub {
|
||||
u16_t dst;
|
||||
u8_t count;
|
||||
u8_t period;
|
||||
u8_t ttl;
|
||||
u16_t feat;
|
||||
u16_t net_idx;
|
||||
uint16_t dst;
|
||||
uint8_t count;
|
||||
uint8_t period;
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_hb_pub_set(bt_mesh_client_common_param_t *param,
|
||||
@@ -139,80 +139,80 @@ int bt_mesh_cfg_node_reset(bt_mesh_client_common_param_t *param);
|
||||
/* Configuration Client Status Message Context */
|
||||
|
||||
struct bt_mesh_cfg_comp_data_status {
|
||||
u8_t page;
|
||||
uint8_t page;
|
||||
struct net_buf_simple *comp_data;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_relay_status {
|
||||
u8_t relay;
|
||||
u8_t retransmit;
|
||||
uint8_t relay;
|
||||
uint8_t retransmit;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_netkey_status {
|
||||
u8_t status;
|
||||
u16_t net_idx;
|
||||
uint8_t status;
|
||||
uint16_t net_idx;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_appkey_status {
|
||||
u8_t status;
|
||||
u16_t net_idx;
|
||||
u16_t app_idx;
|
||||
uint8_t status;
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_mod_app_status {
|
||||
u8_t status;
|
||||
u16_t elem_addr;
|
||||
u16_t app_idx;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t status;
|
||||
uint16_t elem_addr;
|
||||
uint16_t app_idx;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_mod_pub_status {
|
||||
u8_t status;
|
||||
u16_t elem_addr;
|
||||
u16_t addr;
|
||||
u16_t app_idx;
|
||||
bool cred_flag;
|
||||
u8_t ttl;
|
||||
u8_t period;
|
||||
u8_t transmit;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t status;
|
||||
uint16_t elem_addr;
|
||||
uint16_t addr;
|
||||
uint16_t app_idx;
|
||||
bool cred_flag;
|
||||
uint8_t ttl;
|
||||
uint8_t period;
|
||||
uint8_t transmit;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_mod_sub_status {
|
||||
u8_t status;
|
||||
u16_t elem_addr;
|
||||
u16_t sub_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t status;
|
||||
uint16_t elem_addr;
|
||||
uint16_t sub_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_hb_sub_status {
|
||||
u8_t status;
|
||||
u16_t src;
|
||||
u16_t dst;
|
||||
u8_t period;
|
||||
u8_t count;
|
||||
u8_t min;
|
||||
u8_t max;
|
||||
uint8_t status;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t period;
|
||||
uint8_t count;
|
||||
uint8_t min;
|
||||
uint8_t max;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_hb_pub_status {
|
||||
u8_t status;
|
||||
u16_t dst;
|
||||
u8_t count;
|
||||
u8_t period;
|
||||
u8_t ttl;
|
||||
u16_t feat;
|
||||
u16_t net_idx;
|
||||
uint8_t status;
|
||||
uint16_t dst;
|
||||
uint8_t count;
|
||||
uint8_t period;
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_mod_sub_list {
|
||||
u8_t status;
|
||||
u16_t elem_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t status;
|
||||
uint16_t elem_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
struct net_buf_simple *addr;
|
||||
};
|
||||
|
||||
@@ -221,91 +221,91 @@ struct bt_mesh_cfg_net_key_list {
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_app_key_list {
|
||||
u8_t status;
|
||||
u16_t net_idx;
|
||||
uint8_t status;
|
||||
uint16_t net_idx;
|
||||
struct net_buf_simple *app_idx;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_node_id_status {
|
||||
u8_t status;
|
||||
u16_t net_idx;
|
||||
u8_t identity;
|
||||
uint8_t status;
|
||||
uint16_t net_idx;
|
||||
uint8_t identity;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_mod_app_list {
|
||||
u8_t status;
|
||||
u16_t elem_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t status;
|
||||
uint16_t elem_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
struct net_buf_simple *app_idx;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_key_refresh_status {
|
||||
u8_t status;
|
||||
u16_t net_idx;
|
||||
u8_t phase;
|
||||
uint8_t status;
|
||||
uint16_t net_idx;
|
||||
uint8_t phase;
|
||||
};
|
||||
|
||||
struct bt_mesh_cfg_lpn_pollto_status {
|
||||
u16_t lpn_addr;
|
||||
s32_t timeout;
|
||||
uint16_t lpn_addr;
|
||||
int32_t timeout;
|
||||
};
|
||||
|
||||
int bt_mesh_cfg_mod_pub_va_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id,
|
||||
u16_t cid, const u8_t label[16],
|
||||
uint16_t elem_addr, uint16_t mod_id,
|
||||
uint16_t cid, const uint8_t label[16],
|
||||
struct bt_mesh_cfg_mod_pub *pub);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_del_all(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
uint16_t elem_addr, uint16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_sub_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_net_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, const u8_t net_key[16]);
|
||||
uint16_t net_idx, const uint8_t net_key[16]);
|
||||
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
int bt_mesh_cfg_net_key_delete(bt_mesh_client_common_param_t *param, uint16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_net_key_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_app_key_update(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx,
|
||||
const u8_t app_key[16]);
|
||||
uint16_t net_idx, uint16_t app_idx,
|
||||
const uint8_t app_key[16]);
|
||||
|
||||
int bt_mesh_cfg_app_key_delete(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u16_t app_idx);
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
int bt_mesh_cfg_app_key_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
int bt_mesh_cfg_node_identity_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_node_identity_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t identity);
|
||||
uint16_t net_idx, uint8_t identity);
|
||||
|
||||
int bt_mesh_cfg_mod_app_unbind(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t app_idx,
|
||||
u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id);
|
||||
uint16_t elem_addr, uint16_t mod_id);
|
||||
|
||||
int bt_mesh_cfg_mod_app_get_vnd(bt_mesh_client_common_param_t *param,
|
||||
u16_t elem_addr, u16_t mod_id, u16_t cid);
|
||||
uint16_t elem_addr, uint16_t mod_id, uint16_t cid);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, u16_t net_idx);
|
||||
int bt_mesh_cfg_kr_phase_get(bt_mesh_client_common_param_t *param, uint16_t net_idx);
|
||||
|
||||
int bt_mesh_cfg_kr_phase_set(bt_mesh_client_common_param_t *param,
|
||||
u16_t net_idx, u8_t transition);
|
||||
uint16_t net_idx, uint8_t transition);
|
||||
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, u16_t lpn_addr);
|
||||
int bt_mesh_cfg_lpn_timeout_get(bt_mesh_client_common_param_t *param, uint16_t lpn_addr);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, u8_t transmit);
|
||||
int bt_mesh_cfg_net_transmit_set(bt_mesh_client_common_param_t *param, uint8_t transmit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -27,38 +27,38 @@ extern "C" {
|
||||
struct bt_mesh_cfg_srv {
|
||||
struct bt_mesh_model *model;
|
||||
|
||||
u8_t net_transmit; /* Network Transmit state */
|
||||
u8_t relay; /* Relay Mode state */
|
||||
u8_t relay_retransmit; /* Relay Retransmit state */
|
||||
u8_t beacon; /* Secure Network Beacon state */
|
||||
u8_t gatt_proxy; /* GATT Proxy state */
|
||||
u8_t frnd; /* Friend state */
|
||||
u8_t default_ttl; /* Default TTL */
|
||||
uint8_t net_transmit; /* Network Transmit state */
|
||||
uint8_t relay; /* Relay Mode state */
|
||||
uint8_t relay_retransmit; /* Relay Retransmit state */
|
||||
uint8_t beacon; /* Secure Network Beacon state */
|
||||
uint8_t gatt_proxy; /* GATT Proxy state */
|
||||
uint8_t frnd; /* Friend state */
|
||||
uint8_t default_ttl; /* Default TTL */
|
||||
|
||||
/* Heartbeat Publication */
|
||||
struct bt_mesh_hb_pub {
|
||||
struct k_delayed_work timer;
|
||||
|
||||
u16_t dst;
|
||||
u16_t count;
|
||||
u8_t period;
|
||||
u8_t ttl;
|
||||
u16_t feat;
|
||||
u16_t net_idx;
|
||||
uint16_t dst;
|
||||
uint16_t count;
|
||||
uint8_t period;
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
} hb_pub;
|
||||
|
||||
/* Heartbeat Subscription */
|
||||
struct bt_mesh_hb_sub {
|
||||
s64_t expiry;
|
||||
int64_t expiry;
|
||||
|
||||
u16_t src;
|
||||
u16_t dst;
|
||||
u16_t count;
|
||||
u8_t min_hops;
|
||||
u8_t max_hops;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint16_t count;
|
||||
uint8_t min_hops;
|
||||
uint8_t max_hops;
|
||||
|
||||
/* Optional subscription tracking function */
|
||||
void (*func)(u8_t hops, u16_t feat);
|
||||
void (*func)(uint8_t hops, uint16_t feat);
|
||||
} hb_sub;
|
||||
};
|
||||
|
||||
@@ -71,144 +71,144 @@ extern const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u8_t beacon;
|
||||
uint8_t beacon;
|
||||
} cfg_beacon_set;
|
||||
struct {
|
||||
u8_t ttl;
|
||||
uint8_t ttl;
|
||||
} cfg_default_ttl_set;
|
||||
struct {
|
||||
u8_t gatt_proxy;
|
||||
uint8_t gatt_proxy;
|
||||
} cfg_gatt_proxy_set;
|
||||
struct {
|
||||
u8_t relay;
|
||||
u8_t retransmit;
|
||||
uint8_t relay;
|
||||
uint8_t retransmit;
|
||||
} cfg_relay_set;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t pub_addr;
|
||||
u16_t app_idx;
|
||||
uint16_t elem_addr;
|
||||
uint16_t pub_addr;
|
||||
uint16_t app_idx;
|
||||
bool cred_flag;
|
||||
u8_t ttl;
|
||||
u8_t period;
|
||||
u8_t transmit;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t ttl;
|
||||
uint8_t period;
|
||||
uint8_t transmit;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_pub_set;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u8_t pub_addr[16];
|
||||
u16_t app_idx;
|
||||
uint16_t elem_addr;
|
||||
uint8_t pub_addr[16];
|
||||
uint16_t app_idx;
|
||||
bool cred_flag;
|
||||
u8_t ttl;
|
||||
u8_t period;
|
||||
u8_t transmit;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint8_t ttl;
|
||||
uint8_t period;
|
||||
uint8_t transmit;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_pub_va_set;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t sub_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t sub_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_add;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u8_t sub_addr[16];
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint8_t sub_addr[16];
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_va_add;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t sub_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t sub_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_delete;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u8_t sub_addr[16];
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint8_t sub_addr[16];
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_va_delete;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t sub_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t sub_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_overwrite;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u8_t sub_addr[16];
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint8_t sub_addr[16];
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_va_overwrite;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_sub_delete_all;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u8_t net_key[16];
|
||||
uint16_t net_idx;
|
||||
uint8_t net_key[16];
|
||||
} cfg_netkey_add;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u8_t net_key[16];
|
||||
uint16_t net_idx;
|
||||
uint8_t net_key[16];
|
||||
} cfg_netkey_update;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
uint16_t net_idx;
|
||||
} cfg_netkey_delete;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u16_t app_idx;
|
||||
u8_t app_key[16];
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
uint8_t app_key[16];
|
||||
} cfg_appkey_add;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u16_t app_idx;
|
||||
u8_t app_key[16];
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
uint8_t app_key[16];
|
||||
} cfg_appkey_update;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u16_t app_idx;
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
} cfg_appkey_delete;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u8_t identity;
|
||||
uint16_t net_idx;
|
||||
uint8_t identity;
|
||||
} cfg_node_identity_set;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t app_idx;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t app_idx;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_app_bind;
|
||||
struct {
|
||||
u16_t elem_addr;
|
||||
u16_t app_idx;
|
||||
u16_t cid;
|
||||
u16_t mod_id;
|
||||
uint16_t elem_addr;
|
||||
uint16_t app_idx;
|
||||
uint16_t cid;
|
||||
uint16_t mod_id;
|
||||
} cfg_mod_app_unbind;
|
||||
struct {
|
||||
u8_t frnd;
|
||||
uint8_t frnd;
|
||||
} cfg_friend_set;
|
||||
struct {
|
||||
u16_t net_idx;
|
||||
u8_t kr_phase;
|
||||
uint16_t net_idx;
|
||||
uint8_t kr_phase;
|
||||
} cfg_kr_phase_set;
|
||||
struct {
|
||||
u16_t dst;
|
||||
u8_t count;
|
||||
u8_t period;
|
||||
u8_t ttl;
|
||||
u16_t feat;
|
||||
u16_t net_idx;
|
||||
uint16_t dst;
|
||||
uint8_t count;
|
||||
uint8_t period;
|
||||
uint8_t ttl;
|
||||
uint16_t feat;
|
||||
uint16_t net_idx;
|
||||
} cfg_hb_pub_set;
|
||||
struct {
|
||||
u16_t src;
|
||||
u16_t dst;
|
||||
u8_t period;
|
||||
uint16_t src;
|
||||
uint16_t dst;
|
||||
uint8_t period;
|
||||
} cfg_hb_sub_set;
|
||||
struct {
|
||||
u8_t transmit;
|
||||
uint8_t transmit;
|
||||
} cfg_net_transmit_set;
|
||||
} bt_mesh_cfg_server_state_change_t;
|
||||
|
||||
|
||||
@@ -35,35 +35,35 @@ extern const struct bt_mesh_model_cb bt_mesh_health_cli_cb;
|
||||
BLE_MESH_MODEL_CB(BLE_MESH_MODEL_ID_HEALTH_CLI, \
|
||||
bt_mesh_health_cli_op, NULL, cli_data, &bt_mesh_health_cli_cb)
|
||||
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, u16_t cid);
|
||||
int bt_mesh_health_fault_get(bt_mesh_client_common_param_t *param, uint16_t cid);
|
||||
|
||||
int bt_mesh_health_fault_clear(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, bool need_ack);
|
||||
uint16_t cid, bool need_ack);
|
||||
|
||||
int bt_mesh_health_fault_test(bt_mesh_client_common_param_t *param,
|
||||
u16_t cid, u8_t test_id, bool need_ack);
|
||||
uint16_t cid, uint8_t test_id, bool need_ack);
|
||||
|
||||
int bt_mesh_health_period_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_health_period_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t divisor, bool need_ack);
|
||||
uint8_t divisor, bool need_ack);
|
||||
|
||||
int bt_mesh_health_attention_get(bt_mesh_client_common_param_t *param);
|
||||
|
||||
int bt_mesh_health_attention_set(bt_mesh_client_common_param_t *param,
|
||||
u8_t attention, bool need_ack);
|
||||
uint8_t attention, bool need_ack);
|
||||
|
||||
/* Health Client Status Message Context */
|
||||
|
||||
struct bt_mesh_health_current_status {
|
||||
u8_t test_id;
|
||||
u16_t cid;
|
||||
uint8_t test_id;
|
||||
uint16_t cid;
|
||||
struct net_buf_simple *fault_array;
|
||||
};
|
||||
|
||||
struct bt_mesh_health_fault_status {
|
||||
u8_t test_id;
|
||||
u16_t cid;
|
||||
uint8_t test_id;
|
||||
uint16_t cid;
|
||||
struct net_buf_simple *fault_array;
|
||||
};
|
||||
|
||||
|
||||
@@ -25,14 +25,14 @@ extern "C" {
|
||||
|
||||
struct bt_mesh_health_srv_cb {
|
||||
/* Clear registered faults */
|
||||
void (*fault_clear)(struct bt_mesh_model *model, u16_t company_id);
|
||||
void (*fault_clear)(struct bt_mesh_model *model, uint16_t company_id);
|
||||
|
||||
/* Run a specific test */
|
||||
void (*fault_test)(struct bt_mesh_model *model, u8_t test_id,
|
||||
u16_t company_id);
|
||||
void (*fault_test)(struct bt_mesh_model *model, uint8_t test_id,
|
||||
uint16_t company_id);
|
||||
|
||||
/* Attention on */
|
||||
void (*attn_on)(struct bt_mesh_model *model, u8_t time);
|
||||
void (*attn_on)(struct bt_mesh_model *model, uint8_t time);
|
||||
|
||||
/* Attention off */
|
||||
void (*attn_off)(struct bt_mesh_model *model);
|
||||
@@ -49,12 +49,12 @@ struct bt_mesh_health_srv_cb {
|
||||
BLE_MESH_MODEL_PUB_DEFINE(_name, NULL, (1 + 3 + (_max_faults)))
|
||||
|
||||
struct bt_mesh_health_test {
|
||||
u8_t id_count; /* Number of Health self-test ID */
|
||||
const u8_t *test_ids; /* Array of Health self-test IDs */
|
||||
u16_t company_id; /* Company ID used to identify the Health Fault state */
|
||||
u8_t prev_test_id; /* Most currently performed test id */
|
||||
u8_t curr_faults[32]; /* Array of current faults */
|
||||
u8_t reg_faults[32]; /* Array of registered faults */
|
||||
uint8_t id_count; /* Number of Health self-test ID */
|
||||
const uint8_t *test_ids; /* Array of Health self-test IDs */
|
||||
uint16_t company_id; /* Company ID used to identify the Health Fault state */
|
||||
uint8_t prev_test_id; /* Most currently performed test id */
|
||||
uint8_t curr_faults[32]; /* Array of current faults */
|
||||
uint8_t reg_faults[32]; /* Array of registered faults */
|
||||
} __attribute__((packed));
|
||||
|
||||
/** Mesh Health Server Model Context */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#ifndef _BLE_MESH_ACCESS_H_
|
||||
#define _BLE_MESH_ACCESS_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_buf.h"
|
||||
#include "mesh_timer.h"
|
||||
|
||||
@@ -58,13 +58,13 @@ extern "C" {
|
||||
/** Abstraction that describes a Mesh Element */
|
||||
struct bt_mesh_elem {
|
||||
/* Unicast Address. Set at runtime during provisioning. */
|
||||
u16_t addr;
|
||||
uint16_t addr;
|
||||
|
||||
/* Location Descriptor (GATT Bluetooth Namespace Descriptors) */
|
||||
const u16_t loc;
|
||||
const uint16_t loc;
|
||||
|
||||
const u8_t model_count;
|
||||
const u8_t vnd_model_count;
|
||||
const uint8_t model_count;
|
||||
const uint8_t vnd_model_count;
|
||||
|
||||
struct bt_mesh_model *const models;
|
||||
struct bt_mesh_model *const vnd_models;
|
||||
@@ -133,32 +133,32 @@ struct bt_mesh_elem {
|
||||
/** Message sending context. */
|
||||
struct bt_mesh_msg_ctx {
|
||||
/** NetKey Index of the subnet to send the message on. */
|
||||
u16_t net_idx;
|
||||
uint16_t net_idx;
|
||||
|
||||
/** AppKey Index to encrypt the message with. */
|
||||
u16_t app_idx;
|
||||
uint16_t app_idx;
|
||||
|
||||
/** Remote address. */
|
||||
u16_t addr;
|
||||
uint16_t addr;
|
||||
|
||||
/** Destination address of a received message. Not used for sending. */
|
||||
u16_t recv_dst;
|
||||
uint16_t recv_dst;
|
||||
|
||||
/** RSSI of received packet. Not used for sending. */
|
||||
s8_t recv_rssi;
|
||||
int8_t recv_rssi;
|
||||
|
||||
/** Received TTL value. Not used for sending. */
|
||||
u8_t recv_ttl: 7;
|
||||
uint8_t recv_ttl: 7;
|
||||
|
||||
/** Force sending reliably by using segment acknowledgement */
|
||||
u8_t send_rel: 1;
|
||||
uint8_t send_rel: 1;
|
||||
|
||||
/** TTL, or BLE_MESH_TTL_DEFAULT for default TTL. */
|
||||
u8_t send_ttl;
|
||||
uint8_t send_ttl;
|
||||
|
||||
/** Change by Espressif, opcode of a received message.
|
||||
* Not used for sending message. */
|
||||
u32_t recv_op;
|
||||
uint32_t recv_op;
|
||||
|
||||
/** Change by Espressif, model corresponds to the message */
|
||||
struct bt_mesh_model *model;
|
||||
@@ -170,7 +170,7 @@ struct bt_mesh_msg_ctx {
|
||||
|
||||
struct bt_mesh_model_op {
|
||||
/* OpCode encoded using the BLE_MESH_MODEL_OP_* macros */
|
||||
const u32_t opcode;
|
||||
const uint32_t opcode;
|
||||
|
||||
/* Minimum required message length */
|
||||
const size_t min_len;
|
||||
@@ -311,7 +311,7 @@ struct bt_mesh_model_op {
|
||||
*
|
||||
* @return Transmission count (actual transmissions is N + 1).
|
||||
*/
|
||||
#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (u8_t)BIT_MASK(3)))
|
||||
#define BLE_MESH_TRANSMIT_COUNT(transmit) (((transmit) & (uint8_t)BIT_MASK(3)))
|
||||
|
||||
/** @def BLE_MESH_TRANSMIT_INT
|
||||
*
|
||||
@@ -361,19 +361,19 @@ struct bt_mesh_model_pub {
|
||||
/** The model the context belongs to. Initialized by the stack. */
|
||||
struct bt_mesh_model *mod;
|
||||
|
||||
u16_t addr; /**< Publish Address. */
|
||||
u16_t key:12, /**< Publish AppKey Index. */
|
||||
cred:1, /**< Friendship Credentials Flag. */
|
||||
send_rel:1; /**< Force reliable sending (segment acks) */
|
||||
uint16_t addr; /**< Publish Address. */
|
||||
uint16_t key:12, /**< Publish AppKey Index. */
|
||||
cred:1, /**< Friendship Credentials Flag. */
|
||||
send_rel:1; /**< Force reliable sending (segment acks) */
|
||||
|
||||
u8_t ttl; /**< Publish Time to Live. */
|
||||
u8_t retransmit; /**< Retransmit Count & Interval Steps. */
|
||||
u8_t period; /**< Publish Period. */
|
||||
u8_t period_div:4, /**< Divisor for the Period. */
|
||||
fast_period:1,/**< Use FastPeriodDivisor */
|
||||
count:3; /**< Retransmissions left. */
|
||||
uint8_t ttl; /**< Publish Time to Live. */
|
||||
uint8_t retransmit; /**< Retransmit Count & Interval Steps. */
|
||||
uint8_t period; /**< Publish Period. */
|
||||
uint8_t period_div:4, /**< Divisor for the Period. */
|
||||
fast_period:1, /**< Use FastPeriodDivisor */
|
||||
count:3; /**< Retransmissions left. */
|
||||
|
||||
u32_t period_start; /**< Start of the current period. */
|
||||
uint32_t period_start; /**< Start of the current period. */
|
||||
|
||||
/** @brief Publication buffer, containing the publication message.
|
||||
*
|
||||
@@ -405,7 +405,7 @@ struct bt_mesh_model_pub {
|
||||
struct k_delayed_work timer;
|
||||
|
||||
/* Change by Espressif, role of the device going to publish messages */
|
||||
u8_t dev_role;
|
||||
uint8_t dev_role;
|
||||
};
|
||||
|
||||
/** @def BLE_MESH_MODEL_PUB_DEFINE
|
||||
@@ -439,6 +439,7 @@ struct bt_mesh_model_cb {
|
||||
*/
|
||||
int (*const init)(struct bt_mesh_model *model);
|
||||
|
||||
#if CONFIG_BLE_MESH_DEINIT
|
||||
/** @brief Model deinit callback.
|
||||
*
|
||||
* Called on every model instance during mesh deinitialization.
|
||||
@@ -451,22 +452,23 @@ struct bt_mesh_model_cb {
|
||||
* @param model Model to be de-initialized.
|
||||
*/
|
||||
int (*const deinit)(struct bt_mesh_model *model);
|
||||
#endif /* CONFIG_BLE_MESH_DEINIT */
|
||||
};
|
||||
|
||||
/** Abstraction that describes a Mesh Model instance */
|
||||
struct bt_mesh_model {
|
||||
union {
|
||||
const u16_t id;
|
||||
const uint16_t id;
|
||||
struct {
|
||||
u16_t company;
|
||||
u16_t id;
|
||||
uint16_t company;
|
||||
uint16_t id;
|
||||
} vnd;
|
||||
};
|
||||
|
||||
/* Internal information, mainly for persistent storage */
|
||||
u8_t elem_idx; /* Belongs to Nth element */
|
||||
u8_t model_idx; /* Is the Nth model in the element */
|
||||
u16_t flags; /* Information about what has changed */
|
||||
uint8_t elem_idx; /* Belongs to Nth element */
|
||||
uint8_t model_idx; /* Is the Nth model in the element */
|
||||
uint16_t flags; /* Information about what has changed */
|
||||
|
||||
/* The Element this Model belongs to */
|
||||
struct bt_mesh_elem *elem;
|
||||
@@ -475,10 +477,10 @@ struct bt_mesh_model {
|
||||
struct bt_mesh_model_pub *const pub;
|
||||
|
||||
/* AppKey List */
|
||||
u16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
|
||||
uint16_t keys[CONFIG_BLE_MESH_MODEL_KEY_COUNT];
|
||||
|
||||
/* Subscription List (group or virtual addresses) */
|
||||
u16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
|
||||
uint16_t groups[CONFIG_BLE_MESH_MODEL_GROUP_COUNT];
|
||||
|
||||
/** Opcode handler list */
|
||||
const struct bt_mesh_model_op *const op;
|
||||
@@ -491,11 +493,11 @@ struct bt_mesh_model {
|
||||
};
|
||||
|
||||
struct bt_mesh_send_cb {
|
||||
void (*start)(u16_t duration, int err, void *cb_data);
|
||||
void (*start)(uint16_t duration, int err, void *cb_data);
|
||||
void (*end)(int err, void *cb_data);
|
||||
};
|
||||
|
||||
void bt_mesh_model_msg_init(struct net_buf_simple *msg, u32_t opcode);
|
||||
void bt_mesh_model_msg_init(struct net_buf_simple *msg, uint32_t opcode);
|
||||
|
||||
/** Special TTL value to request using configured default TTL */
|
||||
#define BLE_MESH_TTL_DEFAULT 0xff
|
||||
@@ -553,7 +555,7 @@ struct bt_mesh_elem *bt_mesh_model_elem(struct bt_mesh_model *mod);
|
||||
* @return A pointer to the Mesh model matching the given parameters, or NULL
|
||||
* if no SIG model with the given ID exists in the given element.
|
||||
*/
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id);
|
||||
struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, uint16_t id);
|
||||
|
||||
/** @brief Find a vendor model.
|
||||
*
|
||||
@@ -565,7 +567,7 @@ struct bt_mesh_model *bt_mesh_model_find(struct bt_mesh_elem *elem, u16_t id);
|
||||
* if no vendor model with the given ID exists in the given element.
|
||||
*/
|
||||
struct bt_mesh_model *bt_mesh_model_find_vnd(struct bt_mesh_elem *elem,
|
||||
u16_t company, u16_t id);
|
||||
uint16_t company, uint16_t id);
|
||||
|
||||
/** @brief Get whether the model is in the primary element of the device.
|
||||
*
|
||||
@@ -580,9 +582,9 @@ static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod)
|
||||
|
||||
/** Node Composition */
|
||||
struct bt_mesh_comp {
|
||||
u16_t cid;
|
||||
u16_t pid;
|
||||
u16_t vid;
|
||||
uint16_t cid;
|
||||
uint16_t pid;
|
||||
uint16_t vid;
|
||||
|
||||
size_t elem_count;
|
||||
struct bt_mesh_elem *elem;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define _BLE_MESH_BEARER_ADAPT_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_config.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_util.h"
|
||||
#include "mesh_uuid.h"
|
||||
@@ -22,7 +22,7 @@ extern "C" {
|
||||
|
||||
/* BLE Mesh Max Connection Count */
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#define BLE_MESH_MAX_CONN MIN(CONFIG_BT_ACL_CONNECTIONS, CONFIG_BTDM_CTRL_BLE_MAX_CONN)
|
||||
#define BLE_MESH_MAX_CONN CONFIG_BT_ACL_CONNECTIONS
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
||||
@@ -313,7 +313,7 @@ struct bt_mesh_gatt_char {
|
||||
/** Characteristic UUID. */
|
||||
const struct bt_mesh_uuid *uuid;
|
||||
/** Characteristic properties. */
|
||||
u8_t properties;
|
||||
uint8_t properties;
|
||||
};
|
||||
|
||||
/** @brief GATT Service structure */
|
||||
@@ -321,19 +321,13 @@ struct bt_mesh_gatt_service {
|
||||
/** Service Attributes */
|
||||
struct bt_mesh_gatt_attr *attrs;
|
||||
/** Service Attribute count */
|
||||
u16_t attr_count;
|
||||
sys_snode_t node;
|
||||
uint16_t attr_count;
|
||||
sys_snode_t node;
|
||||
};
|
||||
|
||||
struct bt_mesh_ecb_param {
|
||||
u8_t key[16];
|
||||
u8_t clear_text[16];
|
||||
u8_t cipher_text[16];
|
||||
} __packed;
|
||||
|
||||
typedef struct {
|
||||
u8_t type;
|
||||
u8_t val[6];
|
||||
uint8_t type;
|
||||
uint8_t val[6];
|
||||
} bt_mesh_addr_t;
|
||||
|
||||
/** Description of different data types that can be encoded into
|
||||
@@ -341,9 +335,9 @@ typedef struct {
|
||||
* bt_le_adv_start() function.
|
||||
*/
|
||||
struct bt_mesh_adv_data {
|
||||
u8_t type;
|
||||
u8_t data_len;
|
||||
const u8_t *data;
|
||||
uint8_t type;
|
||||
uint8_t data_len;
|
||||
const uint8_t *data;
|
||||
};
|
||||
|
||||
/** @brief Helper to declare elements of bt_data arrays
|
||||
@@ -360,7 +354,7 @@ struct bt_mesh_adv_data {
|
||||
{ \
|
||||
.type = (_type), \
|
||||
.data_len = (_data_len), \
|
||||
.data = (const u8_t *)(_data), \
|
||||
.data = (const uint8_t *)(_data), \
|
||||
}
|
||||
|
||||
/** @brief Helper to declare elements of bt_data arrays
|
||||
@@ -372,19 +366,19 @@ struct bt_mesh_adv_data {
|
||||
* @param _bytes Variable number of single-byte parameters
|
||||
*/
|
||||
#define BLE_MESH_ADV_DATA_BYTES(_type, _bytes...) \
|
||||
BLE_MESH_ADV_DATA(_type, ((u8_t []) { _bytes }), \
|
||||
sizeof((u8_t []) { _bytes }))
|
||||
BLE_MESH_ADV_DATA(_type, ((uint8_t []) { _bytes }), \
|
||||
sizeof((uint8_t []) { _bytes }))
|
||||
|
||||
/* BLE Mesh Advertising Parameters */
|
||||
struct bt_mesh_adv_param {
|
||||
/** Bit-field of advertising options */
|
||||
u8_t options;
|
||||
uint8_t options;
|
||||
|
||||
/** Minimum Advertising Interval (N * 0.625) */
|
||||
u16_t interval_min;
|
||||
uint16_t interval_min;
|
||||
|
||||
/** Maximum Advertising Interval (N * 0.625) */
|
||||
u16_t interval_max;
|
||||
uint16_t interval_max;
|
||||
};
|
||||
|
||||
#if CONFIG_BLE_MESH_SUPPORT_BLE_ADV
|
||||
@@ -394,47 +388,47 @@ enum bt_mesh_ble_adv_priority {
|
||||
};
|
||||
|
||||
struct bt_mesh_ble_adv_param {
|
||||
u16_t interval; /* Advertising interval */
|
||||
u8_t adv_type; /* Advertising type */
|
||||
u8_t own_addr_type; /* Own address type */
|
||||
u8_t peer_addr_type; /* Peer address type */
|
||||
u8_t peer_addr[6]; /* Peer address */
|
||||
u16_t duration; /* Duration is milliseconds */
|
||||
u16_t period; /* Period in milliseconds */
|
||||
u16_t count; /* Number of advertising duration */
|
||||
u8_t priority:2; /* Priority of BLE advertising packet */
|
||||
uint16_t interval; /* Advertising interval */
|
||||
uint8_t adv_type; /* Advertising type */
|
||||
uint8_t own_addr_type; /* Own address type */
|
||||
uint8_t peer_addr_type; /* Peer address type */
|
||||
uint8_t peer_addr[6]; /* Peer address */
|
||||
uint16_t duration; /* Duration is milliseconds */
|
||||
uint16_t period; /* Period in milliseconds */
|
||||
uint16_t count; /* Number of advertising duration */
|
||||
uint8_t priority:2; /* Priority of BLE advertising packet */
|
||||
};
|
||||
|
||||
struct bt_mesh_ble_adv_data {
|
||||
u8_t adv_data_len; /* Advertising data length */
|
||||
u8_t adv_data[31]; /* Advertising data */
|
||||
u8_t scan_rsp_data_len; /* Scan response data length */
|
||||
u8_t scan_rsp_data[31]; /* Scan response data */
|
||||
uint8_t adv_data_len; /* Advertising data length */
|
||||
uint8_t adv_data[31]; /* Advertising data */
|
||||
uint8_t scan_rsp_data_len; /* Scan response data length */
|
||||
uint8_t scan_rsp_data[31]; /* Scan response data */
|
||||
};
|
||||
#endif /* CONFIG_BLE_MESH_SUPPORT_BLE_ADV */
|
||||
|
||||
/* BLE Mesh scan parameters */
|
||||
struct bt_mesh_scan_param {
|
||||
/** Scan type (BLE_MESH_SCAN_ACTIVE or BLE_MESH_SCAN_PASSIVE) */
|
||||
u8_t type;
|
||||
uint8_t type;
|
||||
|
||||
/** Duplicate filtering (BLE_MESH_SCAN_FILTER_DUP_ENABLE or
|
||||
* BLE_MESH_SCAN_FILTER_DUP_DISABLE)
|
||||
*/
|
||||
u8_t filter_dup;
|
||||
uint8_t filter_dup;
|
||||
|
||||
/** Scan interval (N * 0.625 ms) */
|
||||
u16_t interval;
|
||||
uint16_t interval;
|
||||
|
||||
/** Scan window (N * 0.625 ms) */
|
||||
u16_t window;
|
||||
uint16_t window;
|
||||
|
||||
/** BLE scan filter policy */
|
||||
u8_t scan_fil_policy;
|
||||
uint8_t scan_fil_policy;
|
||||
};
|
||||
|
||||
struct bt_mesh_conn {
|
||||
u16_t handle;
|
||||
uint16_t handle;
|
||||
bt_mesh_atomic_t ref;
|
||||
};
|
||||
|
||||
@@ -449,8 +443,8 @@ struct bt_mesh_conn {
|
||||
* @param adv_type Type of advertising response from advertiser.
|
||||
* @param data Buffer containing advertiser data.
|
||||
*/
|
||||
typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, s8_t rssi,
|
||||
u8_t adv_type, struct net_buf_simple *buf);
|
||||
typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, int8_t rssi,
|
||||
uint8_t adv_type, struct net_buf_simple *buf);
|
||||
|
||||
/* @typedef bt_mesh_dh_key_cb_t
|
||||
* @brief Callback type for DH Key calculation.
|
||||
@@ -462,7 +456,7 @@ typedef void bt_mesh_scan_cb_t(const bt_mesh_addr_t *addr, s8_t rssi,
|
||||
*
|
||||
* @return The DH Key, or NULL in case of failure.
|
||||
*/
|
||||
typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx);
|
||||
typedef void (*bt_mesh_dh_key_cb_t)(const uint8_t key[32], const uint8_t idx);
|
||||
|
||||
/** @typedef bt_mesh_gatt_attr_func_t
|
||||
* @brief Attribute iterator callback.
|
||||
@@ -473,8 +467,8 @@ typedef void (*bt_mesh_dh_key_cb_t)(const u8_t key[32], const u8_t idx);
|
||||
* @return BLE_MESH_GATT_ITER_CONTINUE if should continue to the next attribute
|
||||
* or BLE_MESH_GATT_ITER_STOP to stop.
|
||||
*/
|
||||
typedef u8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr,
|
||||
void *user_data);
|
||||
typedef uint8_t (*bt_mesh_gatt_attr_func_t)(const struct bt_mesh_gatt_attr *attr,
|
||||
void *user_data);
|
||||
|
||||
/** @brief Connection callback structure.
|
||||
*
|
||||
@@ -496,7 +490,7 @@ struct bt_mesh_conn_cb {
|
||||
* @param conn New connection object.
|
||||
* @param err HCI error. Zero for success, non-zero otherwise.
|
||||
*/
|
||||
void (*connected)(struct bt_mesh_conn *conn, u8_t err);
|
||||
void (*connected)(struct bt_mesh_conn *conn, uint8_t err);
|
||||
|
||||
/** @brief A connection has been disconnected.
|
||||
*
|
||||
@@ -506,21 +500,21 @@ struct bt_mesh_conn_cb {
|
||||
* @param conn Connection object.
|
||||
* @param reason HCI reason for the disconnection.
|
||||
*/
|
||||
void (*disconnected)(struct bt_mesh_conn *conn, u8_t reason);
|
||||
void (*disconnected)(struct bt_mesh_conn *conn, uint8_t reason);
|
||||
};
|
||||
|
||||
struct bt_mesh_prov_conn_cb {
|
||||
void (*connected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, int id);
|
||||
|
||||
void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, u8_t reason);
|
||||
void (*disconnected)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn, uint8_t reason);
|
||||
|
||||
ssize_t (*prov_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn);
|
||||
|
||||
ssize_t (*prov_notify)(struct bt_mesh_conn *conn, u8_t *data, u16_t len);
|
||||
ssize_t (*prov_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len);
|
||||
|
||||
ssize_t (*proxy_write_descr)(bt_mesh_addr_t *addr, struct bt_mesh_conn *conn);
|
||||
|
||||
ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, u8_t *data, u16_t len);
|
||||
ssize_t (*proxy_notify)(struct bt_mesh_conn *conn, uint8_t *data, uint16_t len);
|
||||
};
|
||||
|
||||
/** @brief GATT Attribute structure. */
|
||||
@@ -541,8 +535,8 @@ struct bt_mesh_gatt_attr {
|
||||
*/
|
||||
ssize_t (*read)(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len,
|
||||
u16_t offset);
|
||||
void *buf, uint16_t len,
|
||||
uint16_t offset);
|
||||
|
||||
/** Attribute write callback
|
||||
*
|
||||
@@ -558,15 +552,15 @@ struct bt_mesh_gatt_attr {
|
||||
*/
|
||||
ssize_t (*write)(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *buf, u16_t len,
|
||||
u16_t offset, u8_t flags);
|
||||
const void *buf, uint16_t len,
|
||||
uint16_t offset, uint8_t flags);
|
||||
|
||||
/** Attribute user data */
|
||||
void *user_data;
|
||||
/** Attribute handle */
|
||||
u16_t handle;
|
||||
uint16_t handle;
|
||||
/** Attribute permissions */
|
||||
u8_t perm;
|
||||
uint8_t perm;
|
||||
};
|
||||
|
||||
/** @def BLE_MESH_GATT_PRIMARY_SERVICE
|
||||
@@ -688,12 +682,12 @@ typedef enum {
|
||||
|
||||
struct bt_mesh_white_list {
|
||||
bool add_remove;
|
||||
u8_t remote_bda[BLE_MESH_ADDR_LEN];
|
||||
u8_t addr_type;
|
||||
uint8_t remote_bda[BLE_MESH_ADDR_LEN];
|
||||
uint8_t addr_type;
|
||||
/* For Bluedroid host, this callback is used to notify the
|
||||
* result of updating white list.
|
||||
*/
|
||||
void (*update_wl_comp_cb)(u8_t status, bt_mesh_wl_operation wl_operation);
|
||||
void (*update_wl_comp_cb)(uint8_t status, bt_mesh_wl_operation wl_operation);
|
||||
};
|
||||
|
||||
int bt_le_update_white_list(struct bt_mesh_white_list *wl);
|
||||
@@ -701,7 +695,7 @@ int bt_le_update_white_list(struct bt_mesh_white_list *wl);
|
||||
void bt_mesh_gatts_conn_cb_register(struct bt_mesh_conn_cb *cb);
|
||||
void bt_mesh_gatts_conn_cb_deregister(void);
|
||||
|
||||
int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, u8_t reason);
|
||||
int bt_mesh_gatts_disconnect(struct bt_mesh_conn *conn, uint8_t reason);
|
||||
|
||||
int bt_mesh_gatts_service_register(struct bt_mesh_gatt_service *svc);
|
||||
int bt_mesh_gatts_service_deregister(struct bt_mesh_gatt_service *svc);
|
||||
@@ -710,26 +704,26 @@ int bt_mesh_gatts_service_unregister(struct bt_mesh_gatt_service *svc);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_included(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset);
|
||||
void *buf, uint16_t len, uint16_t offset);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t buf_len, u16_t offset,
|
||||
const void *value, u16_t value_len);
|
||||
void *buf, uint16_t buf_len, uint16_t offset,
|
||||
const void *value, uint16_t value_len);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_service(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset);
|
||||
void *buf, uint16_t len, uint16_t offset);
|
||||
|
||||
ssize_t bt_mesh_gatts_attr_read_chrc(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
void *buf, u16_t len, u16_t offset);
|
||||
void *buf, uint16_t len, uint16_t offset);
|
||||
|
||||
int bt_mesh_gatts_notify(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len);
|
||||
const void *data, uint16_t len);
|
||||
|
||||
u16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn);
|
||||
uint16_t bt_mesh_gatt_get_mtu(struct bt_mesh_conn *conn);
|
||||
|
||||
/** APIs added by Espressif */
|
||||
int bt_mesh_gatts_service_stop(struct bt_mesh_gatt_service *svc);
|
||||
@@ -740,21 +734,21 @@ int bt_mesh_gatts_set_local_device_name(const char *name);
|
||||
void bt_mesh_gattc_conn_cb_register(struct bt_mesh_prov_conn_cb *cb);
|
||||
void bt_mesh_gattc_conn_cb_deregister(void);
|
||||
|
||||
u8_t bt_mesh_gattc_get_free_conn_count(void);
|
||||
uint8_t bt_mesh_gattc_get_free_conn_count(void);
|
||||
|
||||
u16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn);
|
||||
uint16_t bt_mesh_gattc_get_service_uuid(struct bt_mesh_conn *conn);
|
||||
|
||||
int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, u16_t service_uuid);
|
||||
int bt_mesh_gattc_conn_create(const bt_mesh_addr_t *addr, uint16_t service_uuid);
|
||||
|
||||
void bt_gattc_conn_close(struct bt_mesh_conn *conn);
|
||||
|
||||
void bt_mesh_gattc_exchange_mtu(u8_t index);
|
||||
void bt_mesh_gattc_exchange_mtu(uint8_t index);
|
||||
|
||||
u16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn);
|
||||
uint16_t bt_mesh_gattc_get_mtu_info(struct bt_mesh_conn *conn);
|
||||
|
||||
int bt_mesh_gattc_write_no_rsp(struct bt_mesh_conn *conn,
|
||||
const struct bt_mesh_gatt_attr *attr,
|
||||
const void *data, u16_t len);
|
||||
const void *data, uint16_t len);
|
||||
|
||||
void bt_mesh_gattc_disconnect(struct bt_mesh_conn *conn);
|
||||
|
||||
@@ -767,21 +761,19 @@ void bt_mesh_gatt_deinit(void);
|
||||
|
||||
void bt_mesh_adapt_init(void);
|
||||
|
||||
int bt_mesh_rand(void *buf, size_t len);
|
||||
void bt_mesh_set_private_key(const uint8_t pri_key[32]);
|
||||
|
||||
void bt_mesh_set_private_key(const u8_t pri_key[32]);
|
||||
|
||||
const u8_t *bt_mesh_pub_key_get(void);
|
||||
const uint8_t *bt_mesh_pub_key_get(void);
|
||||
|
||||
bool bt_mesh_check_public_key(const uint8_t key[64]);
|
||||
|
||||
int bt_mesh_dh_key_gen(const u8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const u8_t idx);
|
||||
int bt_mesh_dh_key_gen(const uint8_t remote_pk[64], bt_mesh_dh_key_cb_t cb, const uint8_t idx);
|
||||
|
||||
int bt_mesh_encrypt_le(const u8_t key[16], const u8_t plaintext[16],
|
||||
u8_t enc_data[16]);
|
||||
int bt_mesh_encrypt_le(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
uint8_t enc_data[16]);
|
||||
|
||||
int bt_mesh_encrypt_be(const u8_t key[16], const u8_t plaintext[16],
|
||||
u8_t enc_data[16]);
|
||||
int bt_mesh_encrypt_be(const uint8_t key[16], const uint8_t plaintext[16],
|
||||
uint8_t enc_data[16]);
|
||||
|
||||
enum {
|
||||
BLE_MESH_EXCEP_LIST_ADD = 0,
|
||||
@@ -806,7 +798,7 @@ enum {
|
||||
BLE_MESH_EXCEP_CLEAN_ALL_LIST = 0xFFFF,
|
||||
};
|
||||
|
||||
int bt_mesh_update_exceptional_list(u8_t sub_code, u8_t type, void *info);
|
||||
int bt_mesh_update_exceptional_list(uint8_t sub_code, uint8_t type, void *info);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ enum {
|
||||
|
||||
struct bt_mesh_dev_le {
|
||||
/* LE features */
|
||||
u8_t features[8];
|
||||
uint8_t features[8];
|
||||
|
||||
/* LE states */
|
||||
u64_t states;
|
||||
uint64_t states;
|
||||
};
|
||||
|
||||
/* State tracking for the local Bluetooth controller */
|
||||
@@ -55,14 +55,14 @@ struct bt_mesh_dev {
|
||||
BLE_MESH_ATOMIC_DEFINE(flags, BLE_MESH_DEV_NUM_FLAGS);
|
||||
|
||||
/* Controller version & manufacturer information */
|
||||
u8_t hci_version;
|
||||
u8_t lmp_version;
|
||||
u16_t hci_revision;
|
||||
u16_t lmp_subversion;
|
||||
u16_t manufacturer;
|
||||
uint8_t hci_version;
|
||||
uint8_t lmp_version;
|
||||
uint16_t hci_revision;
|
||||
uint16_t lmp_subversion;
|
||||
uint16_t manufacturer;
|
||||
|
||||
/* LMP features (pages 0, 1, 2) */
|
||||
u8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8];
|
||||
uint8_t features[BLE_MESH_LMP_FEAT_PAGES_COUNT][8];
|
||||
|
||||
/* LE controller specific features */
|
||||
struct bt_mesh_dev_le le;
|
||||
@@ -100,25 +100,25 @@ struct bt_mesh_dev {
|
||||
|
||||
#define BLE_MESH_HCI_OP_SET_ADV_PARAM BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0006)
|
||||
struct bt_mesh_hci_cp_set_adv_param {
|
||||
u16_t min_interval;
|
||||
u16_t max_interval;
|
||||
u8_t type;
|
||||
u8_t own_addr_type;
|
||||
uint16_t min_interval;
|
||||
uint16_t max_interval;
|
||||
uint8_t type;
|
||||
uint8_t own_addr_type;
|
||||
bt_mesh_addr_t direct_addr;
|
||||
u8_t channel_map;
|
||||
u8_t filter_policy;
|
||||
uint8_t channel_map;
|
||||
uint8_t filter_policy;
|
||||
} __packed;
|
||||
|
||||
#define BLE_MESH_HCI_OP_SET_ADV_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0008)
|
||||
struct bt_mesh_hci_cp_set_adv_data {
|
||||
u8_t len;
|
||||
u8_t data[31];
|
||||
uint8_t len;
|
||||
uint8_t data[31];
|
||||
} __packed;
|
||||
|
||||
#define BLE_MESH_HCI_OP_SET_SCAN_RSP_DATA BLE_MESH_OP(BLE_MESH_OGF_LE, 0x0009)
|
||||
struct bt_mesh_hci_cp_set_scan_rsp_data {
|
||||
u8_t len;
|
||||
u8_t data[31];
|
||||
uint8_t len;
|
||||
uint8_t data[31];
|
||||
} __packed;
|
||||
|
||||
/* Added by Espressif */
|
||||
|
||||
@@ -70,7 +70,7 @@ typedef enum {
|
||||
struct bt_mesh_prov {
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
/** The UUID that's used when advertising as unprovisioned */
|
||||
const u8_t *uuid;
|
||||
const uint8_t *uuid;
|
||||
|
||||
/** Optional URI. This will be advertised separately from the
|
||||
* unprovisioned beacon, however the unprovisioned beacon will
|
||||
@@ -93,19 +93,19 @@ struct bt_mesh_prov {
|
||||
void (*oob_pub_key_cb)(void);
|
||||
|
||||
/** Static OOB value */
|
||||
const u8_t *static_val;
|
||||
const uint8_t *static_val;
|
||||
/** Static OOB value length */
|
||||
u8_t static_val_len;
|
||||
uint8_t static_val_len;
|
||||
|
||||
/** Maximum size of Output OOB supported */
|
||||
u8_t output_size;
|
||||
uint8_t output_size;
|
||||
/** Supported Output OOB Actions */
|
||||
u16_t output_actions;
|
||||
uint16_t output_actions;
|
||||
|
||||
/* Maximum size of Input OOB supported */
|
||||
u8_t input_size;
|
||||
uint8_t input_size;
|
||||
/** Supported Input OOB Actions */
|
||||
u16_t input_actions;
|
||||
uint16_t input_actions;
|
||||
|
||||
/** @brief Output of a number is requested.
|
||||
*
|
||||
@@ -117,7 +117,7 @@ struct bt_mesh_prov {
|
||||
*
|
||||
* @return Zero on success or negative error code otherwise
|
||||
*/
|
||||
int (*output_number)(bt_mesh_output_action_t act, u32_t num);
|
||||
int (*output_number)(bt_mesh_output_action_t act, uint32_t num);
|
||||
|
||||
/** @brief Output of a string is requested.
|
||||
*
|
||||
@@ -144,7 +144,7 @@ struct bt_mesh_prov {
|
||||
*
|
||||
* @return Zero on success or negative error code otherwise
|
||||
*/
|
||||
int (*input)(bt_mesh_input_action_t act, u8_t size);
|
||||
int (*input)(bt_mesh_input_action_t act, uint8_t size);
|
||||
|
||||
/** @brief Provisioning link has been opened.
|
||||
*
|
||||
@@ -176,7 +176,7 @@ struct bt_mesh_prov {
|
||||
* @param flags Key Refresh & IV Update flags
|
||||
* @param iv_index IV Index.
|
||||
*/
|
||||
void (*complete)(u16_t net_idx, const u8_t net_key[16], u16_t addr, u8_t flags, u32_t iv_index);
|
||||
void (*complete)(uint16_t net_idx, const uint8_t net_key[16], uint16_t addr, uint8_t flags, uint32_t iv_index);
|
||||
|
||||
/** @brief Node has been reset.
|
||||
*
|
||||
@@ -191,28 +191,28 @@ struct bt_mesh_prov {
|
||||
|
||||
#if CONFIG_BLE_MESH_PROVISIONER
|
||||
/* Provisioner device uuid */
|
||||
const u8_t *prov_uuid;
|
||||
const uint8_t *prov_uuid;
|
||||
|
||||
/*
|
||||
* Primary element address of the provisioner.
|
||||
* No need to initialize it for fast provisioning.
|
||||
*/
|
||||
const u16_t prov_unicast_addr;
|
||||
const uint16_t prov_unicast_addr;
|
||||
|
||||
/*
|
||||
* Starting unicast address going to assigned.
|
||||
* No need to initialize it for fast provisioning.
|
||||
*/
|
||||
u16_t prov_start_address;
|
||||
uint16_t prov_start_address;
|
||||
|
||||
/* Attention timer contained in Provisioning Invite */
|
||||
u8_t prov_attention;
|
||||
uint8_t prov_attention;
|
||||
|
||||
/* Provisioner provisioning Algorithm */
|
||||
u8_t prov_algorithm;
|
||||
uint8_t prov_algorithm;
|
||||
|
||||
/* Provisioner public key oob */
|
||||
u8_t prov_pub_key_oob;
|
||||
uint8_t prov_pub_key_oob;
|
||||
|
||||
/** @brief Input is requested.
|
||||
*
|
||||
@@ -223,13 +223,13 @@ struct bt_mesh_prov {
|
||||
*
|
||||
* @return Zero on success or negative error code otherwise
|
||||
*/
|
||||
int (*prov_pub_key_oob_cb)(u8_t link_idx);
|
||||
int (*prov_pub_key_oob_cb)(uint8_t link_idx);
|
||||
|
||||
/* Provisioner static oob value */
|
||||
u8_t *prov_static_oob_val;
|
||||
uint8_t *prov_static_oob_val;
|
||||
|
||||
/* Provisioner static oob value length */
|
||||
u8_t prov_static_oob_len;
|
||||
uint8_t prov_static_oob_len;
|
||||
|
||||
/** @brief Provisioner input a number read from device output
|
||||
*
|
||||
@@ -243,7 +243,7 @@ struct bt_mesh_prov {
|
||||
*
|
||||
* @return Zero on success or negative error code otherwise
|
||||
*/
|
||||
int (*prov_input_num)(u8_t method, bt_mesh_output_action_t act, u8_t size, u8_t link_idx);
|
||||
int (*prov_input_num)(uint8_t method, bt_mesh_output_action_t act, uint8_t size, uint8_t link_idx);
|
||||
|
||||
/** @brief Provisioner output a number to the device
|
||||
*
|
||||
@@ -258,18 +258,18 @@ struct bt_mesh_prov {
|
||||
*
|
||||
* @return Zero on success or negative error code otherwise
|
||||
*/
|
||||
int (*prov_output_num)(u8_t method, bt_mesh_input_action_t act, void *data, u8_t size, u8_t link_idx);
|
||||
int (*prov_output_num)(uint8_t method, bt_mesh_input_action_t act, void *data, uint8_t size, uint8_t link_idx);
|
||||
|
||||
/*
|
||||
* Key refresh and IV update flag.
|
||||
* No need to initialize it for fast provisioning.
|
||||
*/
|
||||
u8_t flags;
|
||||
uint8_t flags;
|
||||
|
||||
/*
|
||||
* IV index. No need to initialize it for fast provisioning.
|
||||
*/
|
||||
u32_t iv_index;
|
||||
uint32_t iv_index;
|
||||
|
||||
/** @brief Provisioner has opened a provisioning link.
|
||||
*
|
||||
@@ -288,7 +288,7 @@ struct bt_mesh_prov {
|
||||
* @param bearer Provisioning bearer.
|
||||
* @param reason Provisioning link close reason(disconnect reason)
|
||||
*/
|
||||
void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, u8_t reason);
|
||||
void (*prov_link_close)(bt_mesh_prov_bearer_t bearer, uint8_t reason);
|
||||
|
||||
/** @brief Provision one device is complete.
|
||||
*
|
||||
@@ -302,9 +302,9 @@ struct bt_mesh_prov {
|
||||
* @param element_num Provisioned device element number.
|
||||
* @param netkey_idx Provisioned device assigned netkey index.
|
||||
*/
|
||||
void (*prov_complete)(u16_t node_idx, const u8_t device_uuid[16],
|
||||
u16_t unicast_addr, u8_t element_num,
|
||||
u16_t netkey_idx);
|
||||
void (*prov_complete)(uint16_t node_idx, const uint8_t device_uuid[16],
|
||||
uint16_t unicast_addr, uint8_t element_num,
|
||||
uint16_t netkey_idx);
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
};
|
||||
|
||||
@@ -337,7 +337,7 @@ int bt_mesh_input_string(const char *str);
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_mesh_input_number(u32_t num);
|
||||
int bt_mesh_input_number(uint32_t num);
|
||||
|
||||
/** @brief Enable specific provisioning bearers
|
||||
*
|
||||
@@ -381,7 +381,7 @@ int bt_mesh_prov_input_string(const char *str);
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_mesh_prov_input_number(u32_t num);
|
||||
int bt_mesh_prov_input_number(uint32_t num);
|
||||
|
||||
/** @brief Enable specific provisioning bearers
|
||||
*
|
||||
@@ -527,9 +527,9 @@ int bt_mesh_resume(void);
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*/
|
||||
int bt_mesh_provision(const u8_t net_key[16], u16_t net_idx,
|
||||
u8_t flags, u32_t iv_index, u16_t addr,
|
||||
const u8_t dev_key[16]);
|
||||
int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx,
|
||||
uint8_t flags, uint32_t iv_index, uint16_t addr,
|
||||
const uint8_t dev_key[16]);
|
||||
|
||||
/** @brief Check if the device is an unprovisioned device
|
||||
* and will act as a node once provisioned.
|
||||
@@ -613,7 +613,7 @@ int bt_mesh_lpn_poll(void);
|
||||
*
|
||||
* @param cb Function to call when the Friendship status changes.
|
||||
*/
|
||||
void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established));
|
||||
void bt_mesh_lpn_set_cb(void (*cb)(uint16_t friend_addr, bool established));
|
||||
|
||||
/** @brief Register a callback for Friendship changes of friend node.
|
||||
*
|
||||
@@ -622,7 +622,7 @@ void bt_mesh_lpn_set_cb(void (*cb)(u16_t friend_addr, bool established));
|
||||
*
|
||||
* @param cb Function to call when the Friendship status of friend node changes.
|
||||
*/
|
||||
void bt_mesh_friend_set_cb(void (*cb)(bool establish, u16_t lpn_addr, u8_t reason));
|
||||
void bt_mesh_friend_set_cb(void (*cb)(bool establish, uint16_t lpn_addr, uint8_t reason));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -32,22 +32,22 @@ enum {
|
||||
|
||||
/** @brief This is a 'tentative' type and should be used as a pointer only */
|
||||
struct bt_mesh_uuid {
|
||||
u8_t type;
|
||||
uint8_t type;
|
||||
};
|
||||
|
||||
struct bt_mesh_uuid_16 {
|
||||
struct bt_mesh_uuid uuid;
|
||||
u16_t val;
|
||||
uint16_t val;
|
||||
};
|
||||
|
||||
struct bt_mesh_uuid_32 {
|
||||
struct bt_mesh_uuid uuid;
|
||||
u32_t val;
|
||||
uint32_t val;
|
||||
};
|
||||
|
||||
struct bt_mesh_uuid_128 {
|
||||
struct bt_mesh_uuid uuid;
|
||||
u8_t val[16];
|
||||
uint8_t val[16];
|
||||
};
|
||||
|
||||
#define BLE_MESH_UUID_INIT_16(value) \
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "mesh_main.h"
|
||||
#include "settings.h"
|
||||
|
||||
static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id)
|
||||
static struct bt_mesh_model *find_model(uint16_t elem_addr, uint16_t cid, uint16_t mod_id)
|
||||
{
|
||||
struct bt_mesh_elem *elem = NULL;
|
||||
|
||||
@@ -40,8 +40,8 @@ static struct bt_mesh_model *find_model(u16_t elem_addr, u16_t cid, u16_t mod_id
|
||||
}
|
||||
}
|
||||
|
||||
int bt_mesh_model_subscribe_group_addr(u16_t elem_addr, u16_t cid,
|
||||
u16_t mod_id, u16_t group_addr)
|
||||
int bt_mesh_model_subscribe_group_addr(uint16_t elem_addr, uint16_t cid,
|
||||
uint16_t mod_id, uint16_t group_addr)
|
||||
{
|
||||
struct bt_mesh_model *model = NULL;
|
||||
int i;
|
||||
@@ -83,11 +83,11 @@ int bt_mesh_model_subscribe_group_addr(u16_t elem_addr, u16_t cid,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int bt_mesh_model_unsubscribe_group_addr(u16_t elem_addr, u16_t cid,
|
||||
u16_t mod_id, u16_t group_addr)
|
||||
int bt_mesh_model_unsubscribe_group_addr(uint16_t elem_addr, uint16_t cid,
|
||||
uint16_t mod_id, uint16_t group_addr)
|
||||
{
|
||||
struct bt_mesh_model *model = NULL;
|
||||
u16_t *match = NULL;
|
||||
uint16_t *match = NULL;
|
||||
|
||||
model = find_model(elem_addr, cid, mod_id);
|
||||
if (model == NULL) {
|
||||
@@ -119,3 +119,225 @@ int bt_mesh_model_unsubscribe_group_addr(u16_t elem_addr, u16_t cid,
|
||||
BT_INFO("Unsubscribe group address 0x%04x", group_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if CONFIG_BLE_MESH_NODE
|
||||
|
||||
const uint8_t *bt_mesh_node_get_local_net_key(uint16_t net_idx)
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
|
||||
if (net_idx > 0xFFF) {
|
||||
BT_ERR("Invalid NetKeyIndex 0x%04x", net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sub = bt_mesh_subnet_get(net_idx);
|
||||
if (!sub) {
|
||||
BT_ERR("NetKey 0x%04x not exists", net_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return sub->kr_flag ? sub->keys[1].net : sub->keys[0].net;
|
||||
}
|
||||
|
||||
const uint8_t *bt_mesh_node_get_local_app_key(uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
|
||||
if (app_idx > 0xFFF) {
|
||||
BT_ERR("Invalid AppKeyIndex 0x%04x", app_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_find(app_idx);
|
||||
if (!key) {
|
||||
BT_ERR("AppKey 0x%04x not exists", app_idx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return key->updated ? key->keys[1].val : key->keys[0].val;
|
||||
}
|
||||
|
||||
int bt_mesh_node_local_net_key_add(uint16_t net_idx, const uint8_t net_key[16])
|
||||
{
|
||||
struct bt_mesh_subnet *sub = NULL;
|
||||
int err = 0;
|
||||
int i;
|
||||
|
||||
if (net_idx > 0xFFF || net_key == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!bt_mesh_is_provisioned()) {
|
||||
BT_ERR("Not provisioned, failed to add NetKey");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
sub = bt_mesh_subnet_get(net_idx);
|
||||
if (sub) {
|
||||
BT_WARN("NetKey 0x%04x already exists", net_idx);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
|
||||
if (bt_mesh.sub[i].net_idx != BLE_MESH_KEY_UNUSED) {
|
||||
if ((bt_mesh.sub[i].kr_flag == false &&
|
||||
memcmp(bt_mesh.sub[i].keys[0].net, net_key, 16) == 0) ||
|
||||
(bt_mesh.sub[i].kr_flag == true &&
|
||||
memcmp(bt_mesh.sub[i].keys[1].net, net_key, 16) == 0)) {
|
||||
BT_WARN("Key value %s already exists", bt_hex(net_key, 16));
|
||||
return -EEXIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(bt_mesh.sub); i++) {
|
||||
if (bt_mesh.sub[i].net_idx == BLE_MESH_KEY_UNUSED) {
|
||||
sub = &bt_mesh.sub[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sub == NULL) {
|
||||
BT_ERR("NetKey is full!");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
err = bt_mesh_net_keys_create(&sub->keys[0], net_key);
|
||||
if (err) {
|
||||
BT_ERR("Failed to create keys for NetKey 0x%04x", net_idx);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
sub->net_idx = net_idx;
|
||||
sub->kr_flag = false;
|
||||
sub->kr_phase = BLE_MESH_KR_NORMAL;
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_GATT_PROXY_SERVER)) {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_STOPPED;
|
||||
} else {
|
||||
sub->node_id = BLE_MESH_NODE_IDENTITY_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
BT_DBG("Storing NetKey persistently");
|
||||
bt_mesh_store_subnet(sub);
|
||||
}
|
||||
|
||||
/* Make sure we have valid beacon data to be sent */
|
||||
bt_mesh_net_beacon_update(sub);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bt_mesh_node_local_app_key_add(uint16_t net_idx, uint16_t app_idx,
|
||||
const uint8_t app_key[16])
|
||||
{
|
||||
struct bt_mesh_app_key *key = NULL;
|
||||
|
||||
if (net_idx > 0xFFF || app_idx > 0xFFF || app_key == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!bt_mesh_is_provisioned()) {
|
||||
BT_ERR("Not provisioned, failed to add AppKey");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
if (bt_mesh_subnet_get(net_idx) == NULL) {
|
||||
BT_ERR("Subnet 0x%04x not exists", net_idx);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_find(app_idx);
|
||||
if (key) {
|
||||
BT_WARN("AppKey 0x%04x already exists", app_idx);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(bt_mesh.app_keys); i++) {
|
||||
if (bt_mesh.app_keys[i].net_idx != BLE_MESH_KEY_UNUSED) {
|
||||
if ((bt_mesh.app_keys[i].updated == false &&
|
||||
memcmp(bt_mesh.app_keys[i].keys[0].val, app_key, 16) == 0) ||
|
||||
(bt_mesh.app_keys[i].updated == true &&
|
||||
memcmp(bt_mesh.app_keys[i].keys[1].val, app_key, 16) == 0)) {
|
||||
BT_WARN("Key value %s already exists", bt_hex(app_key, 16));
|
||||
return -EEXIST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
key = bt_mesh_app_key_alloc(app_idx);
|
||||
if (key) {
|
||||
struct bt_mesh_app_keys *keys = &key->keys[0];
|
||||
|
||||
if (bt_mesh_app_id(app_key, &keys->id)) {
|
||||
BT_ERR("Failed to generate AID");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
key->net_idx = net_idx;
|
||||
key->app_idx = app_idx;
|
||||
key->updated = false;
|
||||
memcpy(keys->val, app_key, 16);
|
||||
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
BT_DBG("Storing AppKey persistently");
|
||||
bt_mesh_store_app_key(key);
|
||||
}
|
||||
|
||||
BT_INFO("Add AppKey 0x%04x, NetKeyIndex 0x%04x", app_idx, net_idx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BT_ERR("AppKey is full!");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int bt_mesh_node_bind_app_key_to_model(uint16_t elem_addr, uint16_t mod_id,
|
||||
uint16_t cid, uint16_t app_idx)
|
||||
{
|
||||
struct bt_mesh_model *model = NULL;
|
||||
int i;
|
||||
|
||||
if (!bt_mesh_is_provisioned()) {
|
||||
BT_ERR("Not provisioned, failed to bind AppKey");
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
model = find_model(elem_addr, cid, mod_id);
|
||||
if (model == NULL) {
|
||||
BT_ERR("Bind, model(id 0x%04x, cid 0x%04x) not found", mod_id, cid);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
if (bt_mesh_app_key_find(app_idx) == NULL) {
|
||||
BT_ERR("Bind, AppKey 0x%03x not exists", app_idx);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
|
||||
if (model->keys[i] == app_idx) {
|
||||
BT_WARN("Already bound to AppKey 0x%04x", app_idx);
|
||||
return -EALREADY;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(model->keys); i++) {
|
||||
if (model->keys[i] == BLE_MESH_KEY_UNUSED) {
|
||||
model->keys[i] = app_idx;
|
||||
if (IS_ENABLED(CONFIG_BLE_MESH_SETTINGS)) {
|
||||
bt_mesh_store_mod_bind(model);
|
||||
}
|
||||
|
||||
BT_INFO("Model(id 0x%04x, cid 0x%04x) bound to AppKey 0x%04x", mod_id, cid, app_idx);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
BT_ERR("Model bound is full!");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_NODE */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user