forked from espressif/esp-idf
Compare commits
1505 Commits
Author | SHA1 | Date | |
---|---|---|---|
e5f754b26c | |||
4904606461 | |||
b7ccfb921f | |||
25813ebe2b | |||
db733d7321 | |||
4ae63961cd | |||
55acc10303 | |||
f28111b6fe | |||
dcb5d956d3 | |||
77dc24908c | |||
17e053930e | |||
1c7607d4a6 | |||
42e380270c | |||
e9dfea8421 | |||
0016d20946 | |||
d4499598e4 | |||
7af4c6f840 | |||
c783abc2e3 | |||
3e44ebd3d7 | |||
893d74f6ef | |||
3350a108c3 | |||
ac545ce97c | |||
445822104a | |||
dabceb4fe4 | |||
e6816163fe | |||
daab8014fb | |||
a1fe8fa851 | |||
3687627226 | |||
0fe7ac0bd7 | |||
9039ddb20c | |||
c308562a31 | |||
293c2d95f6 | |||
374b756f6b | |||
e3ecb8d073 | |||
9263b84f37 | |||
6093407d78 | |||
0fda05cc83 | |||
df7028dc52 | |||
c928bcc4b8 | |||
5812a935ba | |||
2ba90c8453 | |||
7009d7bcfe | |||
06fea3a2f7 | |||
e59336337c | |||
749e71e8e2 | |||
3f96604fda | |||
013654cc11 | |||
ce1905d6b5 | |||
4d8ba4b4de | |||
54c2bd7c0c | |||
d1fa5c712a | |||
c756f7c4d2 | |||
5ec780d6b5 | |||
5ad4713362 | |||
6dd8569b4b | |||
df52fb3942 | |||
e376e8f989 | |||
98d525c1ea | |||
c4107150ee | |||
6dde2eb3c5 | |||
d9660fcf9c | |||
45c4fef890 | |||
93aea71641 | |||
820621687c | |||
bb33120756 | |||
b88dc13ec3 | |||
ed0393d707 | |||
03abf3b209 | |||
d3eaf8bdb0 | |||
aa8f45e341 | |||
dfa6332606 | |||
ba38c974e6 | |||
3cc07d7969 | |||
035a24b468 | |||
c3e702da05 | |||
dfd0cd5f3e | |||
91cf59981c | |||
b3de361e51 | |||
b50bbe3a5b | |||
14140e7550 | |||
94f4a88c2d | |||
7cc07173b2 | |||
12e39e9291 | |||
100750ac1b | |||
2597e046c5 | |||
2995e78fa1 | |||
81e726e3fc | |||
cc0aa104e8 | |||
26d7fb7744 | |||
4cbb70541c | |||
b1fa527f41 | |||
9a580242e8 | |||
3f332ef02b | |||
2be17377bb | |||
a7fe03dcb0 | |||
c2d261c88e | |||
8ed6242e27 | |||
f32582b588 | |||
64c766ee4d | |||
4f86faa906 | |||
16d68e4dee | |||
426f03de5f | |||
d3034e8172 | |||
fcb0206c59 | |||
0dc46879c5 | |||
4e7d7426aa | |||
818a2f8768 | |||
7dfb6adf27 | |||
9c82e7c875 | |||
5fe10f1ff8 | |||
ebacef4304 | |||
9566e4ec19 | |||
7abb8e7fc3 | |||
8cfc9f1609 | |||
e5526e2953 | |||
8b5fb43d93 | |||
3b0a62a752 | |||
61bc60213e | |||
2595326978 | |||
53605395cf | |||
b994331b83 | |||
69059ea2cc | |||
34f4b5a4d3 | |||
d30f3b6edd | |||
948795265d | |||
ce88e9d3fe | |||
83895b4e78 | |||
53852b555e | |||
087a1e339e | |||
712aa3daa7 | |||
9a88eef632 | |||
beda5f0fd4 | |||
a1cf4fa871 | |||
bf1394eeb8 | |||
0dc0c54acd | |||
235cdd2ff0 | |||
f3566fd2af | |||
f10c62d84d | |||
775fd14310 | |||
e9a07592fc | |||
48ea44f3d1 | |||
009492ca9a | |||
e4501dc0ec | |||
1df9502301 | |||
d04a8da916 | |||
6e79097b4a | |||
c8601fface | |||
cf98746771 | |||
7f99280b40 | |||
59c6afda95 | |||
1e528fa739 | |||
a27478b54d | |||
2ff3c012ea | |||
0dc96d19aa | |||
9973f5ef04 | |||
ffc46954ae | |||
ee7b443d28 | |||
6182c172bf | |||
faae3ceec5 | |||
f7742dd9cc | |||
5a99038b1a | |||
80e0be6dbd | |||
6f034e9194 | |||
de438461f5 | |||
cb7c143523 | |||
0100d70dfd | |||
f73cd1d4f1 | |||
0b3954c0c3 | |||
bfbbb4d581 | |||
4cb1a2fdc3 | |||
94dfe1713c | |||
6a929916b7 | |||
ff6c39376a | |||
62e6b6f571 | |||
8560d88391 | |||
724a5baa4e | |||
c399b9520b | |||
067d840c76 | |||
b9dd8630ee | |||
4e831ac080 | |||
8ae3c733db | |||
576957b17d | |||
9e506a921b | |||
db7f558e34 | |||
0253a372be | |||
9fe1380b7f | |||
a9591d1c1f | |||
4ff6d873bb | |||
5da359c253 | |||
9216af8371 | |||
1e95aba03a | |||
8a2c055179 | |||
d7f251aef3 | |||
e0fc7b1c48 | |||
7358470ae9 | |||
200fa4abeb | |||
822b6986aa | |||
6787718e1b | |||
388522a886 | |||
a391a98a02 | |||
39705533f1 | |||
77fe2ced32 | |||
36ba6be9ae | |||
68b272f590 | |||
f12b8c7990 | |||
c4794f761e | |||
4d9af50eba | |||
0e028c044d | |||
813cf5cc00 | |||
ac0746aba1 | |||
e5f4ff2b1a | |||
4f37a08437 | |||
d8e590555c | |||
c7acaf9b44 | |||
2c45d430da | |||
671ecd7522 | |||
fd475fc9bc | |||
797971e8cc | |||
8309f06378 | |||
4fd867616c | |||
3b6145dc46 | |||
b823a2a35f | |||
4802585bfd | |||
b9b31e3c85 | |||
d921a06c1f | |||
dfcc8e77dc | |||
7f6735fd60 | |||
ca5ab9b607 | |||
acb54059be | |||
3e31c484ba | |||
fac0b1128f | |||
9969ec1de5 | |||
8cb2ad1fe6 | |||
3f0956bfa0 | |||
304c40f3ef | |||
ef136a664c | |||
666014447b | |||
e9dcba0d5d | |||
1658838efb | |||
b88982b666 | |||
59c1bf4d8f | |||
aa5b4fb372 | |||
67d7b60f19 | |||
28b4419c4e | |||
e933077fbc | |||
a68b9272c5 | |||
ae177f7077 | |||
a9d4ed4a55 | |||
939a3b78e2 | |||
f1c0fee05b | |||
268b0e5e3f | |||
940fcf0ca9 | |||
c6ce7d2866 | |||
b4554ca2a6 | |||
9b3aae1d32 | |||
0785d41c93 | |||
9624d9b19b | |||
4f22be795d | |||
b53c59b7a4 | |||
e37cb829f4 | |||
2967334138 | |||
0de2507b24 | |||
8c3a3766da | |||
26e280c824 | |||
3c630c7905 | |||
35f5cbaed4 | |||
b869e69c62 | |||
12759b951c | |||
d875485f89 | |||
ac2e34f611 | |||
211e7bb4c2 | |||
47fa80f7fe | |||
4a6e793322 | |||
458ed4085d | |||
e781279110 | |||
94d97499a3 | |||
6778712be4 | |||
18d7f27f6c | |||
e7ac221b42 | |||
b58e777596 | |||
0265c63e6c | |||
4f29dfa969 | |||
8357318945 | |||
83d6ab9b5f | |||
a972d3018c | |||
02a53166b6 | |||
f677655fcb | |||
6932b4d1c0 | |||
ccdd06937f | |||
f16a37d439 | |||
a864e3dcfe | |||
ef8613b7f7 | |||
d008eba708 | |||
b76773d943 | |||
ad95174a7a | |||
1ad7e276d9 | |||
2f51b520c6 | |||
84d6d48fe0 | |||
51bb86f0a6 | |||
7eaea6c726 | |||
9746fa569c | |||
40385ea454 | |||
d96d68ea38 | |||
9718338984 | |||
5a61c4c24c | |||
ceffc0837e | |||
ece24128da | |||
7d6bcf5f5e | |||
f75088d40d | |||
19f69333f7 | |||
695ad84654 | |||
1636c2ba6b | |||
db2376bb09 | |||
b55020ad80 | |||
1ac6d48fcf | |||
268f5ad6c6 | |||
1ab23bfd3d | |||
205425b86b | |||
c2589b0b57 | |||
f990d725f4 | |||
073b8daa6e | |||
6a844f3737 | |||
b571992626 | |||
cd40f3ad52 | |||
11cfb44e58 | |||
c00fe4c53c | |||
64114efdaf | |||
569575b404 | |||
2f15eacdeb | |||
193e9c0d5a | |||
5c2ed3af0e | |||
6b5c89b684 | |||
a5ffd527ab | |||
792605e8fd | |||
59e11421bf | |||
a90e8d67e9 | |||
a192095a5e | |||
9e21c09a11 | |||
63c83730c2 | |||
f781c6edac | |||
7078065980 | |||
a8afd951dc | |||
652e5352ee | |||
2ea5f522f3 | |||
20c34cac2d | |||
e0a70b0675 | |||
90eccf7cba | |||
d1107a5234 | |||
43c32f878a | |||
6059992efd | |||
90f6c9652e | |||
fa527dc6b3 | |||
e93405c3a7 | |||
1d7765eeea | |||
798cc4deb7 | |||
254967eea5 | |||
457e1160bc | |||
d6a2f9841d | |||
d9f4cb89a4 | |||
76d79dff7c | |||
9d5ea68c61 | |||
1ab129891a | |||
a748457a70 | |||
15916dfbec | |||
c18ffa8604 | |||
57932baef3 | |||
4c5fd2be70 | |||
7a60ae4bc8 | |||
7f049cd5dc | |||
699270e09e | |||
59187b0921 | |||
ec6ebf7d4e | |||
bcc1eb916b | |||
9891045018 | |||
009878f02d | |||
ee51d336d3 | |||
d7310ae008 | |||
8bbee15932 | |||
d15735c71f | |||
b63abd2069 | |||
acf1478a51 | |||
55dd3c8b77 | |||
7b01509b19 | |||
754f59fba7 | |||
9926b875d8 | |||
79831e64fd | |||
a128eae7b8 | |||
98ac272a3f | |||
13167a7579 | |||
acf41f93a9 | |||
470c959b04 | |||
dd7c98d6c2 | |||
90aa79fd2b | |||
97c1a4b5c6 | |||
5897354d7f | |||
6c99fdceb2 | |||
1340e600c2 | |||
cdd35648b7 | |||
6fe46c1798 | |||
d2bcb5c7ff | |||
2ea69e6df5 | |||
b5bd1bf67e | |||
8294055c65 | |||
11286e35a2 | |||
2c5b0a523a | |||
8c6f6318c0 | |||
632d9739b5 | |||
34cb56b7aa | |||
7c12074801 | |||
4b21a34675 | |||
ac51ec11ec | |||
7db10be193 | |||
fde075aec2 | |||
cbd2bcfbd2 | |||
5c5621790a | |||
fbdb7ff665 | |||
bbfaaa2044 | |||
ad14507e3f | |||
c9d1255ce4 | |||
25569cd9de | |||
416e8958fa | |||
cde1592bf3 | |||
0af05fdee1 | |||
4536a485be | |||
e7d37f2d1a | |||
fd17ff2f0b | |||
e322c5950b | |||
1f96a6f35d | |||
4fddf1156b | |||
833483bb22 | |||
3d4948664b | |||
203f871420 | |||
2c6a3f9e5b | |||
2b6131b5f4 | |||
793d2b11f1 | |||
bbc95d981c | |||
471171cb32 | |||
3b4ff12246 | |||
351dba9272 | |||
7b6236c2d9 | |||
1ce4c20115 | |||
3e885dc73b | |||
c85d7dfd5a | |||
9a654ec590 | |||
193828f121 | |||
fab2dcb790 | |||
d3619d0b45 | |||
5af06f49f5 | |||
e430860df3 | |||
4c81978a3e | |||
ddc2427385 | |||
6153026f22 | |||
18abdd7cb0 | |||
260fe847e2 | |||
fc2199c5d6 | |||
4695eeddee | |||
65d4596a36 | |||
748720a466 | |||
8688bd0593 | |||
6ee978c6aa | |||
d231b25bc4 | |||
456c8bdbdf | |||
94917184be | |||
b13d96ae8b | |||
496ab2a83f | |||
3c882991b5 | |||
4d35a99c12 | |||
6442184dd8 | |||
02c47360f1 | |||
db5f01429f | |||
b938846de6 | |||
7d295e18bc | |||
b47111c708 | |||
6a6de506b1 | |||
12a65aaac1 | |||
6bfad8a47d | |||
0863de4a69 | |||
db3a1110ec | |||
398dc28a4e | |||
4011393920 | |||
a87df25d9e | |||
814108f9ac | |||
baf0fb3576 | |||
a895bb157f | |||
b0f053d82d | |||
4242519894 | |||
b3c3b4e7f0 | |||
f09c9b957c | |||
24c9f56d45 | |||
08bcb587ec | |||
c5a8dc85b7 | |||
a7ca14b064 | |||
4557c686b8 | |||
5e33a351f1 | |||
1fc54cfad8 | |||
bc7a34b494 | |||
ab81940982 | |||
6d6b7b09e8 | |||
d36663b798 | |||
6b76228fcb | |||
8f5f828ad6 | |||
5c5ae96be2 | |||
1b7f3fee5c | |||
b7dc47108f | |||
8cd210b38b | |||
19e840aa53 | |||
39acf9c4dd | |||
2da4ffa2aa | |||
30c645d9c2 | |||
b9fa6b0b1a | |||
5f71ec3640 | |||
a44f473d4a | |||
beb64a1af4 | |||
7b8356ee2f | |||
7fbfb1aa03 | |||
02b5db37d1 | |||
7f4b651434 | |||
b97d4c617b | |||
765bd76ba3 | |||
9370264cac | |||
07c1d9d9c7 | |||
8bfa01cc28 | |||
90a9444696 | |||
b9fd2673a7 | |||
7595116353 | |||
9aae0f2dee | |||
f137546a4b | |||
388043c203 | |||
c496fa79de | |||
2af16b92e5 | |||
8c98f6bdaf | |||
c4af9d3e24 | |||
27da86fb6e | |||
2d13bfb8fa | |||
81f0744ada | |||
c3ae910529 | |||
c955b7d133 | |||
4131b51c16 | |||
1de273a901 | |||
2139d40f5e | |||
44d653adff | |||
41eabbefd6 | |||
8972461611 | |||
0e6bbdf683 | |||
778ebb4dba | |||
f87df26cf4 | |||
93b8fcf664 | |||
a78772bbc6 | |||
1490256968 | |||
5209dff76b | |||
b7f163530b | |||
a2d0fb348b | |||
fe67bedee2 | |||
85b27d3b03 | |||
cb466be9d9 | |||
64061541f0 | |||
6825d8e0be | |||
c4fe416f33 | |||
14c978b54f | |||
a6b08cb025 | |||
acdba0eb46 | |||
3b5eb3caf5 | |||
967e66bdf6 | |||
0b4e1ecdec | |||
fd58809899 | |||
ed3ea95cc2 | |||
3ba480ba53 | |||
2628f3ebbd | |||
0fc72b58e1 | |||
cfb331e71b | |||
d74995736c | |||
c8a05bae78 | |||
127fa7094a | |||
ccc6363a21 | |||
8ffb38265c | |||
17bd6e8fab | |||
192c20c9f7 | |||
c7ac9a296d | |||
50073a7e61 | |||
f69f96edab | |||
2ee765ffaf | |||
3ed127709e | |||
02c5c8d8ad | |||
bdfba3b88c | |||
904b85e365 | |||
2cc9d28a35 | |||
50e83cf374 | |||
a3f3c7bdc3 | |||
0b822a9ec7 | |||
dfd197b4c5 | |||
1e2ca78aac | |||
1d55af4bb2 | |||
b2a3a9041d | |||
286d249239 | |||
9d5d22c458 | |||
13f4656d2a | |||
57a5a486ff | |||
363f55f618 | |||
fb14ab08c8 | |||
6ce172bcae | |||
d71ac521cf | |||
921e56d0c3 | |||
e9fdc4c7b2 | |||
aed56d4da9 | |||
39e8e2003a | |||
b79062aeec | |||
66949e3b54 | |||
cb871f0472 | |||
fbd12902eb | |||
35839232c8 | |||
14d6dad650 | |||
7bdb7ee235 | |||
0f036b8749 | |||
7663928e49 | |||
365e6ce181 | |||
7b8aa11e12 | |||
5cbb726028 | |||
0e70b783ae | |||
ac302329d1 | |||
08f401b74e | |||
e1d78a218a | |||
13e3e26065 | |||
a8e0b9171b | |||
402e97ea51 | |||
0bdd75a344 | |||
662b39fc1e | |||
8785ac4c2a | |||
6627ca40da | |||
465d517fbd | |||
3bdebe2383 | |||
be08f6f2bb | |||
718af6ed07 | |||
233349c235 | |||
982e7b5538 | |||
9eb7eceeec | |||
28a9cb5be1 | |||
47fc70df7f | |||
be9725f8e7 | |||
a8364af83d | |||
75f6bc2de1 | |||
9866b4f17c | |||
8df1d1ffab | |||
5f7436006f | |||
6ee1947822 | |||
3aaf6a06dd | |||
3ee6dfa4d6 | |||
b6415d9a91 | |||
ce55956a8f | |||
7c2f1287ec | |||
eee8bd4612 | |||
4dde86e45d | |||
e6b4eb60ef | |||
c5b2f693b8 | |||
7cf29e0f3f | |||
cb31c71877 | |||
50040e8e99 | |||
a364541193 | |||
fdbdf9a0ec | |||
0ad0507f88 | |||
40bebcb39b | |||
1c12e67c8a | |||
cf77068675 | |||
68b4177f70 | |||
0cc802e6ab | |||
cb10ba5785 | |||
6023d60966 | |||
2161d09079 | |||
1b08b7c5fb | |||
8ea128ded5 | |||
c5a5b34ba4 | |||
c38c3ff3f0 | |||
376703bf05 | |||
3d887cfff7 | |||
af5adbc18e | |||
bcedff5a12 | |||
254b0e9693 | |||
af4c6ac0f3 | |||
3d0ecfdc70 | |||
e85c4a65a4 | |||
abab19ad4d | |||
cfb6ac13c4 | |||
5bcdce8272 | |||
d5d2d716f6 | |||
2a467d17bd | |||
e6a59ac038 | |||
a2af518069 | |||
dc193cea49 | |||
8eb263f9d1 | |||
5b402f8081 | |||
ea3d70382b | |||
2f8af222e9 | |||
2408dc2671 | |||
c924da6f0a | |||
198c8333d1 | |||
f542c979e9 | |||
1351e94a0e | |||
6eaeda9cf4 | |||
f2e5ee5d25 | |||
4a3b06dde3 | |||
ef7461ae1d | |||
bfed4fc90c | |||
6d61f6667a | |||
41cef4b1bb | |||
e24641cc89 | |||
280f0effc1 | |||
f9cb434eeb | |||
2236449f47 | |||
2a4173e9a6 | |||
e2cba84555 | |||
8a56c31a25 | |||
daf95803ec | |||
b006ffa643 | |||
80fd327308 | |||
ee8ab79696 | |||
a7f573c3a1 | |||
d292907fb7 | |||
4fa13a8575 | |||
216b8b4088 | |||
2c90bce980 | |||
3ed5b73617 | |||
a8fe083017 | |||
25dfb08435 | |||
bdeec924a2 | |||
5136605cb1 | |||
63d3fd17f9 | |||
636195fb29 | |||
6c19711778 | |||
28788e2d66 | |||
9d15ffb573 | |||
6fee9da72e | |||
54f7ed5dcc | |||
938c291973 | |||
2966f8cb8c | |||
b59bcb88ce | |||
f8fc84813c | |||
e29d17fcd0 | |||
2c5932e4fd | |||
06ff1ceae3 | |||
b04e643bd0 | |||
e4696f077d | |||
8911c52a58 | |||
53e355b355 | |||
d07b9e97d7 | |||
024a2755be | |||
6ad136a49e | |||
615dc00e86 | |||
8dd98715a4 | |||
3b954fb6d6 | |||
6f875f2db2 | |||
6b6d9d7321 | |||
477e6355eb | |||
008d2db20b | |||
78ecc043d5 | |||
c48a94d4a8 | |||
6f4e257601 | |||
2fdb56e741 | |||
3f6f658532 | |||
0155bce1be | |||
ba43d99db9 | |||
0f64291700 | |||
64c1e029fb | |||
99c9e86b7a | |||
7eeaa62c49 | |||
9037b8fb52 | |||
0f10d12b81 | |||
8c148ede22 | |||
70d4d32511 | |||
5826ed0c48 | |||
f92534f95d | |||
d2af36c9fb | |||
5894e049bc | |||
50b686bfb4 | |||
92d8558364 | |||
45454cd477 | |||
0a2bec85f3 | |||
b6bec84c6e | |||
fb924ece79 | |||
e07a64925b | |||
e07ecea868 | |||
5b9cb366c2 | |||
d5bd2256f4 | |||
c235640bf4 | |||
6193a439a3 | |||
a3cd5ab1ae | |||
3bf1b9b8ab | |||
04fc15a4f3 | |||
e95b59c089 | |||
2309313103 | |||
8cb3cc5154 | |||
bbbe6fd449 | |||
7ccf6ebada | |||
91dc4d78f8 | |||
5bf43a854c | |||
2bee223250 | |||
f92a52f275 | |||
f368f69922 | |||
8df70a1728 | |||
c5d20275dd | |||
f2ef0509e3 | |||
8c88f0f1f6 | |||
313c1ed1ba | |||
c3961fdacb | |||
c8215756fa | |||
0c2c821f8f | |||
f5dc81aaae | |||
97ef8fd057 | |||
204f19ac0b | |||
39194136e5 | |||
3f76083e8c | |||
87eccad969 | |||
8f0f3e8f88 | |||
c3a3a81b08 | |||
4ce7b666a6 | |||
c2bce897b8 | |||
5140eea3d1 | |||
1b0473494f | |||
e9d3800ad2 | |||
97242031e7 | |||
5ab36dc2ec | |||
09dd8ca3e9 | |||
f27a344fc9 | |||
02596a7efa | |||
a61fd1e42b | |||
d897e522af | |||
59649ea825 | |||
bdb0851065 | |||
9a24d95907 | |||
ead0e6da36 | |||
08219f3cf5 | |||
b324ab9c6e | |||
93e5a31685 | |||
01cc5a38cc | |||
7b128595ac | |||
f48930a040 | |||
642dc19c25 | |||
55834dd001 | |||
e38c080f79 | |||
c7e1416174 | |||
e0c88dbd73 | |||
a58fa7665a | |||
d84677493e | |||
443ea78e78 | |||
ef07a315bb | |||
ed6805625c | |||
74a89774fd | |||
7dc5c2af59 | |||
e5bd8b1982 | |||
983f528513 | |||
5445c80a8e | |||
69d341f7f0 | |||
f927957950 | |||
6fca0e3861 | |||
5202be013a | |||
ed44d25690 | |||
8c980c11aa | |||
4312c71e71 | |||
4900ead609 | |||
386804d407 | |||
93409bd57e | |||
32ba52760f | |||
158f2d065d | |||
14a408c478 | |||
92d0d7ad49 | |||
19c9ae400b | |||
566fb11a73 | |||
928480ada9 | |||
da0205b166 | |||
610fc8124a | |||
21dbee1291 | |||
e5431e55a9 | |||
4405560483 | |||
51616eacee | |||
4aa7f31f02 | |||
318f83e33a | |||
4bf2ceee4e | |||
a9c5092baf | |||
9e47e04897 | |||
ca0bfb84d0 | |||
cc772c1324 | |||
c344a4a3b9 | |||
32387250bc | |||
a870460f72 | |||
463a9d8b7f | |||
ef34e6f6f7 | |||
cf2c5b8d96 | |||
aa51829ec8 | |||
dcd735759e | |||
a36bbd4e95 | |||
3f8a89504f | |||
1d280a0825 | |||
3b13eba1b2 | |||
a388eb8806 | |||
1f263434a6 | |||
06cc4e888d | |||
0a2371972a | |||
b7a191a996 | |||
beb73456ee | |||
e3d65c8e3e | |||
d11bca44db | |||
6da2676a3c | |||
15aa9bc041 | |||
3ae110b30c | |||
509ac2cfc1 | |||
8c23bb4aa9 | |||
989dac1e64 | |||
2ea0062fe8 | |||
5cb04f3e13 | |||
16e102199a | |||
2215aeaad8 | |||
51a1421f65 | |||
0cefe6df78 | |||
20e75ef87d | |||
cb1d440cb8 | |||
e5d25fb51e | |||
8306ddf3c1 | |||
93928a5d11 | |||
96a5e34d7a | |||
6bc284f7b7 | |||
daa2178f30 | |||
92b10b4ba3 | |||
69b0919904 | |||
4cbbe6cca3 | |||
edcba21b28 | |||
e8b454e802 | |||
84029130cf | |||
6cbda6bd22 | |||
dae4da07c3 | |||
ca3b2a8909 | |||
95f0553f40 | |||
09935510bd | |||
fb81b516da | |||
d93bff2699 | |||
03addfb0c5 | |||
0631d185bd | |||
65cfbbda52 | |||
6a18a33bad | |||
6f6677ac42 | |||
0e623d4dbf | |||
d41c020649 | |||
b261647835 | |||
53e6eb8467 | |||
ebaa3e1c3e | |||
66889332ce | |||
23770edb43 | |||
6ea738eeb0 | |||
3e6d04fc86 | |||
9dc45e788d | |||
bf712e4f91 | |||
83813f830d | |||
b0d6c01b04 | |||
f955c49423 | |||
1b15e6cf56 | |||
1ad1e70077 | |||
d8665e5343 | |||
46cb254f21 | |||
20e6d46d44 | |||
a89decd3c1 | |||
1e7933049d | |||
626c58fc67 | |||
03d5742e11 | |||
3c081abb32 | |||
482d2f06c3 | |||
4ffa3dbffb | |||
bf0863a50a | |||
20d435c561 | |||
a82215d161 | |||
dcbcb5fe58 | |||
23e6b47a28 | |||
85656ca77d | |||
6f0f5d79f9 | |||
314a0443ad | |||
3ba9eae86c | |||
a8e01de0e4 | |||
0104a24a36 | |||
643757bfad | |||
30ac846112 | |||
8e54ee3f16 | |||
ba11fed9c1 | |||
bf01dd61f7 | |||
ee6ba0eb47 | |||
45a50ed701 | |||
fd481d9cdd | |||
ec8e057e4c | |||
510ec904c9 | |||
fbdedee4cb | |||
f8e1ee35e2 | |||
06aa755265 | |||
48786c1da0 | |||
e9be102224 | |||
3691ebc273 | |||
31b9329d36 | |||
d00acce7b2 | |||
6e05a79536 | |||
978bf09f83 | |||
7a5d17e1b7 | |||
d3e0301aee | |||
69c0e6243e | |||
cffe7bf3a1 | |||
1041bc800c | |||
dd74a331c7 | |||
6ee7492512 | |||
9bf656e12e | |||
6ae4c29191 | |||
3fcecdd12e | |||
f3c8907cef | |||
7db756fbd9 | |||
1d72766f1a | |||
5d03ae7428 | |||
bfbc10e2d8 | |||
1fd0e6f482 | |||
21995978e1 | |||
e0b6ad0d1a | |||
2b5a8fe5ea | |||
bb7e52a4a8 | |||
c0597aaf69 | |||
87c30adfed | |||
3636bf5813 | |||
ea2959af36 | |||
585654388f | |||
939d5a0f6a | |||
4d3c650b49 | |||
2318e6828d | |||
262acbc0a8 | |||
2b2f0d0f28 | |||
2887131b39 | |||
104299353d | |||
19d394a366 | |||
e4312f8ab5 | |||
1930c56bd2 | |||
5e67f9578d | |||
46a172178a | |||
e6006a6bdf | |||
a5b803540a | |||
673ccaa1e5 | |||
08e55b8a66 | |||
0508ad525a | |||
97defec6cd | |||
96e6049dab | |||
37154d4c08 | |||
14dd44c05f | |||
42a462d584 | |||
c68bd605f8 | |||
f37837f785 | |||
69c86bc37e | |||
14f1a30e38 | |||
afeed3cc6f | |||
139913baa2 | |||
e324013ed6 | |||
8d189d9fb4 | |||
e7a6fdca54 | |||
48dfbe05a4 | |||
5d00321d07 | |||
2e8ad19e35 | |||
c45830d03f | |||
7725ce4999 | |||
97488fe806 | |||
e3f0854771 | |||
b5d04a21fb | |||
337b1df430 | |||
41e64bd79c | |||
2b7681ec4f | |||
668c0dfb9b | |||
0b0f8d6d6c | |||
a8f956e590 | |||
3b879ce8c3 | |||
5102308b2b | |||
f95a723412 | |||
88cbc26f4d | |||
1b53af2e88 | |||
376107b2ae | |||
c9294aff6f | |||
99fb9a3f7c | |||
e5773cc2fe | |||
4e6c575fed | |||
8353ecdf36 | |||
5bb0b39700 | |||
9214c887f7 | |||
ebc2e7bce0 | |||
065e386c57 | |||
c595b2fa8c | |||
eb95bc68c4 | |||
2b208eecde | |||
f9f49107ca | |||
fae116bb2e | |||
8d90156c07 | |||
f22d46515b | |||
27cb3d7f72 | |||
e0e62232e0 | |||
a302d210b9 | |||
a32c72a1b2 | |||
f1850b54f3 | |||
c85abf87b5 | |||
9029ccd21b | |||
eaeb36375a | |||
805bc06127 | |||
4702cd1b51 | |||
720528ef11 | |||
d934badaa7 | |||
35b91ebf2d | |||
6c7f72cc1b | |||
7061c8aec2 | |||
3ba8ae7a62 | |||
2c27c55679 | |||
68ad6ad63a | |||
981b2496cb | |||
077b727608 | |||
79f36e85d5 | |||
d49077c13b | |||
0c2202ef3e | |||
e4137cc6ca | |||
308e4fcce1 | |||
a6d40e3583 | |||
95b5745c3c | |||
bc3134594d | |||
8300945189 | |||
c9ca3a05fc | |||
ecce2bc926 | |||
b69898257a | |||
22548d0ea4 | |||
088ac409d7 | |||
14ce4cde2e | |||
83cd515817 | |||
d48d9a1c88 | |||
f54cab62a2 | |||
c64d4236fb | |||
90568fbf00 | |||
475a746e46 | |||
947fc14a3f | |||
6f6629e568 | |||
4c4b1da7e7 | |||
9cc272978c | |||
5cb6a49c1e | |||
56d1e4411e | |||
05510e513b | |||
5e042803a2 | |||
74d06101b1 | |||
2cd3018c0a | |||
1a8e5a40d6 | |||
b529c6f282 | |||
7a05879024 | |||
1611386431 | |||
6181686489 | |||
0562281353 | |||
8bc1f6e2f5 | |||
dd99a6dbe8 | |||
5a686d7ad1 | |||
0ca0e7d3cc | |||
f06ef95610 | |||
0078896347 | |||
44599d3a84 | |||
0fa7dcb946 | |||
d3a8dcb929 | |||
4e8c1b91c0 | |||
4ed0d006b4 | |||
e85804824e | |||
304f6a577a | |||
29690afc57 | |||
98450e80e5 | |||
1007473a3b | |||
e875f59ed5 | |||
4f946ea00e | |||
666f87109f | |||
154f315a49 | |||
b175ec77ad | |||
f9fa039826 | |||
b54528696a | |||
fae64f79bb | |||
4f297ed3fa | |||
8eaa440221 | |||
56d5548747 | |||
665a341147 | |||
cab589af9d | |||
19e355e080 | |||
1cf2da8d67 | |||
744625f234 | |||
5e505898df | |||
3a1d0e9352 | |||
8afd0de501 | |||
1f7a66a22e | |||
bcc19b7826 | |||
0a03a55c1e | |||
61f26c985e | |||
165e778d7e | |||
859ddcdb63 | |||
c599d7aa49 | |||
da636bd4ac | |||
834893d8e4 | |||
059052acaa | |||
996db972f0 | |||
4ddc6916c3 | |||
c06519a759 | |||
f1e8a49836 | |||
09cc922b42 | |||
34c33f7440 | |||
5464aaac45 | |||
054e2dbb44 | |||
59a186b27e | |||
62a609190d | |||
9f1d992ef9 | |||
7cb3d5bc4a | |||
de27a71a56 | |||
ed8ddf7e76 | |||
3860753818 | |||
2056b891d3 | |||
c6a6740e3f | |||
dd1615d57c | |||
106f066254 | |||
32b8b60dc5 | |||
4283b59dde | |||
be894757ff | |||
3d0466ccd1 | |||
92adc524a2 | |||
0fc30f4379 | |||
905fdbc1ad | |||
3a115a1ad2 | |||
019c72e4fc | |||
21ecf51a40 | |||
3c97f7e42e | |||
de9b0b1c56 | |||
57a13b09cc | |||
6a60c4a046 | |||
f96c02adac | |||
9351ae7dc9 | |||
2cde888a6d | |||
c94434917d | |||
fb32429387 | |||
1cc6d2ef62 | |||
128d650d7d | |||
090dd78355 | |||
706df7ab12 | |||
cfa355c705 | |||
a87e699104 | |||
7566bfb548 | |||
57335cfc26 | |||
7a6faa093b | |||
a389312750 | |||
7d267a340f | |||
783ef22dd3 | |||
4f193dfa71 | |||
c875e5698a | |||
4cafa3e76e | |||
1e5ea2827c | |||
cf5331b9f1 | |||
28a2e6a775 | |||
34a327791c | |||
8bcf5a19d5 | |||
66a46de2a7 | |||
bcd496be49 | |||
79923d0199 | |||
858b3d2277 | |||
dedaf624db | |||
9ca33a260f | |||
abdf12dc9e | |||
10d26549fa | |||
26676c2b8f | |||
d9cfb05eb6 | |||
4322e89006 | |||
96748f3037 | |||
5a94142481 | |||
e5ff431b35 | |||
c225801b3e | |||
610e3cac31 | |||
c776991233 | |||
041fcceddf | |||
899957f521 | |||
815d7674ef | |||
57527ba6f9 | |||
a21eb04cc6 | |||
116d0c8145 | |||
dda49709fe | |||
ebffa5f9f2 | |||
fc738680f8 | |||
1c586ebcfd | |||
499accb652 | |||
988147a451 | |||
9e6c56f9f2 | |||
1b6eb69f53 | |||
daa65b6f91 | |||
7f9626d378 | |||
6cad60f34b | |||
b4c7ed999c | |||
8a5c08df98 | |||
b1eac64865 | |||
4e7b559101 | |||
43616f6f05 | |||
3b9ab9caa6 | |||
0dc9ddb77c | |||
9ab92331c4 | |||
08416d05ba | |||
200c82561a | |||
2e05c6020f | |||
d139c851f3 | |||
365e3fd685 | |||
71fad5e2c0 | |||
94ba3a20cb | |||
5a7d3ef319 | |||
e4a4e6ed81 | |||
8094e880c6 | |||
35b9223cf4 | |||
fe97d14e0f | |||
2c16557ee7 | |||
5f8e5db268 | |||
a9fe3165c4 | |||
b01036e13e | |||
10649ae23b | |||
c4306f7942 | |||
62be877ada | |||
546026d018 | |||
05d3665a14 | |||
0bba92b2a0 | |||
399477cd10 | |||
d3b54ec84a | |||
e4b44f3488 | |||
ca80b0445d | |||
1e01accaa4 | |||
2ca3735edd | |||
b9a2639ab4 | |||
77f186a7b9 | |||
89e848c820 | |||
5e0cc123ee | |||
536c131114 | |||
ef17d8bba1 | |||
3194e12479 | |||
bb52613bea | |||
4ee065df79 | |||
63c2834d7b | |||
dbf2c3d480 | |||
582d5de497 | |||
5a351af83f | |||
a6fc9bf246 | |||
d52b244ae8 | |||
00e3cb672b | |||
67eb732dbe | |||
c53a5ee427 | |||
69241907a5 | |||
d4ee21bd6d | |||
5b69614e32 | |||
3e12967535 | |||
d9f1219a21 | |||
f3fc4916d2 | |||
b17ca9cb38 | |||
801010dac6 | |||
f84394e550 | |||
a0256b9e9d | |||
a37694741c | |||
fae124a2c1 | |||
ad100e497a | |||
da8c09c463 | |||
6df148aa54 | |||
3fc9b022b6 | |||
28ee1c0da2 | |||
05b306bae1 | |||
8dbb2083ea | |||
a8590c7e8e | |||
8876cda09b | |||
cec1c5f856 | |||
a7107d9bbd | |||
850684438b | |||
9d00f3b420 | |||
72264ca9b9 | |||
da2025a74a | |||
93bad7a0de | |||
55f687c763 | |||
329388fa47 | |||
0f36dabcaf | |||
0299e22dd0 | |||
f072c5af4e | |||
6982663380 | |||
1d970ad276 | |||
a73cc70af9 | |||
225ee8e5d1 | |||
fa4cd56d00 | |||
15f8b0fccc | |||
97080afba2 | |||
612822d8c9 | |||
ff6cb921c3 | |||
6f7b7c552d | |||
e00186e683 | |||
a734b3b1bc | |||
6de637811f | |||
6ec0c6743a | |||
299c86cc84 | |||
d123f6c04b | |||
3c17bf1a6f | |||
8fb20e4529 | |||
e020d1055a | |||
05e4b28a74 | |||
27bc688ed8 | |||
a214fb2821 | |||
6b7b9d1550 | |||
18b873b2e3 | |||
d1755c1484 | |||
152ebb104d | |||
e3b304997f | |||
1e20ed4849 | |||
59b663c43d | |||
e9e28c1265 | |||
7030d612e2 | |||
2c852b0d74 | |||
708bff3b17 | |||
317f4c5ff5 | |||
2c025824d7 | |||
9b95064018 | |||
ecdffe531e | |||
31be6be147 | |||
305a4a1b57 | |||
e659f1b15a | |||
2c49592216 | |||
6afb2743e7 | |||
f7b458841f | |||
f1e9b8299f | |||
9ce1b8986a | |||
c5bea8dddb | |||
ba6b502cc9 | |||
3b0b5f92a7 | |||
d6bc1b3cbc | |||
199c4e55f2 | |||
61339353e9 | |||
3b2dda5197 | |||
1b8ed9abf0 | |||
f9453ef93d | |||
dcf571c1cd | |||
538c56426a | |||
1402e78844 | |||
01f0c8ef16 | |||
a774406b91 | |||
c9bff93080 | |||
4b8e4ff248 | |||
9dbf979cf3 | |||
ad70ab8957 | |||
cd5dc4d05f | |||
ebb9384681 | |||
0d3fde04ff | |||
0552ec5791 | |||
524eef9225 | |||
955f7e2877 | |||
e28834aa15 | |||
ac03786412 | |||
a5dae2ff43 | |||
1d0142d25d | |||
65ef597da6 | |||
310beae373 | |||
cf0caaec11 | |||
4af9504a65 | |||
64bece146c | |||
6b348b94e3 | |||
6222040888 | |||
ea1037742d | |||
465d46e9dd | |||
e71e4da388 | |||
c711e969cc | |||
3f1ec39a8d | |||
f62798cb8b | |||
b6c89984a9 | |||
520ecb0c4d | |||
b669495d97 | |||
8778c551eb | |||
c34d313a86 | |||
ebcb3a22b8 | |||
6781d01e89 | |||
4c9f30a869 | |||
61ba1c3026 | |||
90bbea65c1 | |||
672e9f4abc | |||
cb3d458050 | |||
b72ff61899 | |||
83b9727c42 | |||
7bb8b5ba9e | |||
1f5f6adcb6 | |||
aa0bb29404 | |||
2264ea7714 | |||
a626b26cf9 | |||
1cc860216e | |||
16ee476a77 | |||
674ecc3b56 | |||
43efee5232 | |||
5dab23ea98 | |||
79afd2d580 | |||
a8e8919bbf | |||
ba0f4f17ed | |||
a63b3c4fe6 | |||
6b8c75d87c | |||
68d82abe52 | |||
ec31f235e9 | |||
7e9d90b180 | |||
d4fcbe37f3 | |||
b9a5f764ba | |||
764b70d7e6 | |||
a1496b90e5 | |||
622d6d5504 | |||
1b903111b6 | |||
69ef694178 | |||
81651b47a4 | |||
30dc86179c | |||
eff3ac05b3 | |||
e5349d47a8 | |||
4253adf42b | |||
088ed65194 | |||
0ce94950b7 | |||
ae8b2684d7 | |||
9c51f679a7 | |||
5c07acad46 | |||
70af759dd2 | |||
76191a0f55 | |||
f0c3114f2f |
@ -15,67 +15,54 @@ variables:
|
||||
|
||||
# GitLab-CI environment
|
||||
|
||||
# more attempts for more robust
|
||||
GET_SOURCES_ATTEMPTS: "10"
|
||||
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
|
||||
# XXX_ATTEMPTS variables (https://docs.gitlab.com/ce/ci/yaml/README.html#job-stages-attempts) are not defined here.
|
||||
# Use values from "CI / CD Settings" - "Variables".
|
||||
|
||||
# GIT_STRATEGY is not defined here.
|
||||
# Use an option from "CI / CD Settings" - "General pipelines".
|
||||
|
||||
# "normal" strategy for fetching only top-level submodules since nothing requires the sub-submodules code for building IDF.
|
||||
# If the "recursive" strategy is used we have a problem with using relative URLs for sub-submodules.
|
||||
GIT_SUBMODULE_STRATEGY: normal
|
||||
|
||||
UNIT_TEST_BUILD_SYSTEM: make
|
||||
# IDF environment
|
||||
# we will download archive for each submodule instead of clone.
|
||||
# we don't do "recursive" when fetch submodule as they're not used in CI now.
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
|
||||
# by default we will fetch all submodules
|
||||
# jobs can overwrite this variable to only fetch submodules they required
|
||||
# set to "none" if don't need to fetch submodules
|
||||
SUBMODULES_TO_FETCH: "all"
|
||||
# tell build system do not check submodule update as we download archive instead of clone
|
||||
IDF_SKIP_CHECK_SUBMODULES: 1
|
||||
|
||||
UNIT_TEST_BUILD_SYSTEM: cmake
|
||||
IDF_PATH: "$CI_PROJECT_DIR"
|
||||
BATCH_BUILD: "1"
|
||||
V: "0"
|
||||
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
|
||||
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
|
||||
CUSTOM_TOOLCHAIN_PATH: "/opt/xtensa-custom"
|
||||
|
||||
# Docker images
|
||||
# Docker images
|
||||
BOT_DOCKER_IMAGE_TAG: ":latest"
|
||||
# target test config file, used by assign test job
|
||||
# target test config file, used by assign test job
|
||||
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/tools/ci/config/target-test.yml"
|
||||
# target test repo parameters
|
||||
TEST_ENV_CONFIG_REPO: "${GITLAB_SSH_SERVER}/qa/ci-test-runner-configs.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_URL: "${GITLAB_SSH_SERVER}/qa/auto_test_script.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_BRANCH: "ci/v3.1"
|
||||
|
||||
|
||||
|
||||
# before each job, we need to check if this job is filtered by bot stage/job filter
|
||||
.apply_bot_filter: &apply_bot_filter
|
||||
python $APPLY_BOT_FILTER_SCRIPT || exit 0
|
||||
|
||||
.setup_custom_toolchain: &setup_custom_toolchain |
|
||||
if [ "$IDF_XTENSA_TOOLCHAIN_URL" ] ; then
|
||||
echo "Use a custom toolchain: ${IDF_XTENSA_TOOLCHAIN_URL:-Unknown}"
|
||||
rm -rf "$CUSTOM_TOOLCHAIN_PATH" &&
|
||||
mkdir -p -v "$CUSTOM_TOOLCHAIN_PATH" &&
|
||||
pushd "$CUSTOM_TOOLCHAIN_PATH" &&
|
||||
curl -sSL -o xtensa-custom.xxx "$IDF_XTENSA_TOOLCHAIN_URL" &&
|
||||
ls -l xtensa-custom.xxx &&
|
||||
tar xf xtensa-custom.xxx --strip-components 1 &&
|
||||
ls -l . &&
|
||||
popd
|
||||
PATH=$CUSTOM_TOOLCHAIN_PATH/bin:$PATH
|
||||
export PATH
|
||||
fi
|
||||
|
||||
.cleanup_custom_toolchain: &cleanup_custom_toolchain |
|
||||
echo "Cleaning up $CUSTOM_TOOLCHAIN_PATH"
|
||||
rm -rf "$CUSTOM_TOOLCHAIN_PATH"
|
||||
|
||||
.setup_tools_unless_target_test: &setup_tools_unless_target_test |
|
||||
if [ "$CI_JOB_STAGE" != "target_test" ]; then
|
||||
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
|
||||
fi
|
||||
|
||||
.show_submodule_urls: &show_submodule_urls |
|
||||
git config --get-regexp '^submodule\..*\.url$' || true
|
||||
.fetch_submodules: &fetch_submodules |
|
||||
python $SUBMODULE_FETCH_TOOL -s $SUBMODULES_TO_FETCH
|
||||
|
||||
before_script:
|
||||
- echo "Running common script"
|
||||
- *show_submodule_urls
|
||||
- source tools/ci/setup_python.sh
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
@ -88,10 +75,9 @@ before_script:
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
# Set some options and environment for CI
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
|
||||
- *setup_tools_unless_target_test
|
||||
|
||||
- *setup_custom_toolchain
|
||||
- *fetch_submodules
|
||||
|
||||
# used for check scripts which we want to run unconditionally
|
||||
.before_script_lesser_nofilter:
|
||||
@ -101,7 +87,6 @@ before_script:
|
||||
- echo "Not setting up GitLab key, not fetching submodules, not applying bot filter"
|
||||
- source tools/ci/setup_python.sh
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
- *setup_custom_toolchain
|
||||
|
||||
# used for everything else where we want to do no prep, except for bot filter
|
||||
.before_script_lesser:
|
||||
@ -113,10 +98,6 @@ before_script:
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
- *setup_custom_toolchain
|
||||
|
||||
after_script:
|
||||
- *cleanup_custom_toolchain
|
||||
|
||||
.check_job_template:
|
||||
stage: check
|
||||
|
@ -1,10 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(esp-idf C CXX ASM)
|
||||
|
||||
if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
message(FATAL_ERROR "Current directory '${CMAKE_CURRENT_LIST_DIR}' is not buildable. "
|
||||
"Change directories to one of the example projects in '${CMAKE_CURRENT_LIST_DIR}/examples' and try "
|
||||
"again.")
|
||||
endif()
|
||||
|
||||
unset(compile_options)
|
||||
unset(c_compile_options)
|
||||
unset(cxx_compile_options)
|
||||
unset(compile_definitions)
|
||||
unset(link_options)
|
||||
|
||||
# Add the following build specifications here, since these seem to be dependent
|
||||
# on config values on the root Kconfig.
|
||||
@ -22,6 +29,13 @@ else()
|
||||
list(APPEND cxx_compile_options "-fno-exceptions")
|
||||
endif()
|
||||
|
||||
if(CONFIG_COMPILER_CXX_RTTI)
|
||||
list(APPEND cxx_compile_options "-frtti")
|
||||
else()
|
||||
list(APPEND cxx_compile_options "-fno-rtti")
|
||||
list(APPEND link_options "-fno-rtti") # used to invoke correct multilib variant (no-rtti) during linking
|
||||
endif()
|
||||
|
||||
if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
|
||||
list(APPEND compile_options "-Wno-parentheses"
|
||||
"-Wno-sizeof-pointer-memaccess"
|
||||
@ -54,11 +68,13 @@ elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
|
||||
list(APPEND compile_options "-fstack-protector-all")
|
||||
endif()
|
||||
|
||||
list(APPEND link_options "-fno-lto")
|
||||
|
||||
idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
|
||||
idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
|
||||
idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
|
||||
idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
|
||||
|
||||
idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
|
||||
|
||||
|
18
Kconfig
18
Kconfig
@ -29,6 +29,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
default "IDF_TARGET_NOT_SET" if IDF_TARGET_ENV=""
|
||||
default IDF_TARGET_ENV
|
||||
|
||||
config IDF_FIRMWARE_CHIP_ID
|
||||
hex
|
||||
default 0x0000 if IDF_TARGET="esp32"
|
||||
default 0xFFFF
|
||||
|
||||
menu "SDK tool configuration"
|
||||
config SDK_TOOLPREFIX
|
||||
@ -39,12 +43,11 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
a crosstool-ng gcc setup that is in your PATH.
|
||||
|
||||
config SDK_PYTHON
|
||||
string "Python 2 interpreter"
|
||||
string "Python interpreter"
|
||||
depends on !IDF_CMAKE
|
||||
default "python"
|
||||
help
|
||||
The executable name/path that is used to run python. On some systems Python 2.x
|
||||
may need to be invoked as python2.
|
||||
The executable name/path that is used to run python.
|
||||
|
||||
(Note: This option is used with the legacy GNU Make build system only.)
|
||||
|
||||
@ -145,6 +148,15 @@ mainmenu "Espressif IoT Development Framework Configuration"
|
||||
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
|
||||
memory for thrown exceptions when there is not enough memory on the heap.
|
||||
|
||||
config COMPILER_CXX_RTTI
|
||||
# Invisible option, until the toolchain with RTTI support is released.
|
||||
# Use prompt "Enable C++ run-time type info (RTTI)" when updating.
|
||||
bool
|
||||
help
|
||||
Enabling this option compiles all C++ files with RTTI support enabled.
|
||||
This increases binary size (typically by tens of kB) but allows using
|
||||
dynamic_cast conversion and typeid operator.
|
||||
|
||||
choice COMPILER_STACK_CHECK_MODE
|
||||
prompt "Stack smashing protection mode"
|
||||
default COMPILER_STACK_CHECK_MODE_NONE
|
||||
|
@ -39,7 +39,7 @@ See the Getting Started guide links above for a detailed setup guide. This is a
|
||||
|
||||
* Install host build dependencies mentioned in Getting Started guide.
|
||||
* Add `tools/` directory to the PATH
|
||||
* Run `python -m pip install requirements.txt` to install Python dependencies
|
||||
* Run `python -m pip install -r requirements.txt` to install Python dependencies
|
||||
|
||||
## Configuring the Project
|
||||
|
||||
|
66
SUPPORT_POLICY.md
Normal file
66
SUPPORT_POLICY.md
Normal file
@ -0,0 +1,66 @@
|
||||
The latest support policy for ESP-IDF can be found at [https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md](https://github.com/espressif/esp-idf/blob/master/SUPPORT_POLICY.md)
|
||||
|
||||
Support Period Policy
|
||||
=====================
|
||||
|
||||
Each ESP-IDF major and minor release (V4.0, V4.1, etc) is supported for
|
||||
18 months after the initial stable release date.
|
||||
|
||||
Supported means that the ESP-IDF team will continue to apply bug fixes,
|
||||
security fixes, etc to the release branch on GitHub, and periodically
|
||||
make new bugfix releases as needed.
|
||||
|
||||
Users are encouraged to upgrade to a newer ESP-IDF release before the
|
||||
support period finishes and the release becomes End of Life (EOL). It is
|
||||
our policy to not continue fixing bugs in End of Life releases.
|
||||
|
||||
Pre-release versions (betas, previews, `-rc` and `-dev` versions, etc)
|
||||
are not covered by any support period. Sometimes a particular feature is
|
||||
marked as \"Preview\" in a release, which means it is also not covered
|
||||
by the support period.
|
||||
|
||||
The ESP-IDF Programming Guide has information about the
|
||||
[different versions of ESP-IDF](https://docs.espressif.com/projects/esp-idf/en/latest/versions.html)
|
||||
(major, minor, bugfix, etc).
|
||||
|
||||
Long Term Support releases
|
||||
--------------------------
|
||||
|
||||
Some releases (starting with ESP-IDF V3.3) are designated Long Term
|
||||
Support (LTS). LTS releases are supported for 30 months (2.5 years)
|
||||
after the initial stable release date.
|
||||
|
||||
A new LTS release will be made at least every 18 months. This means
|
||||
there will always be a period of at least 12 months to upgrade from the
|
||||
previous LTS release to the following LTS release.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
ESP-IDF V3.3 was released in September 2019 and is a Long Term Support
|
||||
(LTS) release, meaning it will be supported for 30 months until February
|
||||
2022.
|
||||
|
||||
- The first V3.3 release was `v3.3` in September 2019.
|
||||
- The ESP-IDF team continues to backport bug fixes, security fixes,
|
||||
etc to the release branch `release/v3.3`.
|
||||
- Periodically stable bugfix releases are created from the release
|
||||
branch. For example `v3.3.1`, `v3.3.2`, etc. Users are encouraged to
|
||||
always update to the latest bugfix release.
|
||||
- V3.3 bugfix releases continue until February 2022, when all V3.3.x
|
||||
releases become End of Life.
|
||||
|
||||
Existing Releases
|
||||
-----------------
|
||||
|
||||
ESP-IDF release V3.3 and all newer releases will follow this support
|
||||
period policy. The support period for each release will be announced
|
||||
when the release is made.
|
||||
|
||||
For releases made before the support period policy was announced,
|
||||
the following support periods apply:
|
||||
|
||||
- ESP-IDF V3.1.x and V3.2.x will both be supported until October 2020.
|
||||
- ESP-IDF V3.0.9 (planned for October 2019) will be the last V3.0
|
||||
bugfix release. ESP-IDF V3.0.x is End of Life from October 2019.
|
||||
- ESP-IDF versions before V3.0 are already End of Life.
|
@ -22,4 +22,14 @@ menu "Application manager"
|
||||
The PROJECT_NAME variable from the build system will not affect the firmware image.
|
||||
This value will not be contained in the esp_app_desc structure.
|
||||
|
||||
config APP_RETRIEVE_LEN_ELF_SHA
|
||||
int "The length of APP ELF SHA is stored in RAM(chars)"
|
||||
default 16
|
||||
range 8 64
|
||||
help
|
||||
At startup, the app will read this many hex characters from the embedded APP ELF SHA-256 hash value
|
||||
and store it in static RAM. This ensures the app ELF SHA-256 value is always available
|
||||
if it needs to be printed by the panic handler code.
|
||||
Changing this value will change the size of a static buffer, in bytes.
|
||||
|
||||
endmenu # "Application manager"
|
||||
|
@ -40,9 +40,6 @@ read_otadata: $(PARTITION_TABLE_CSV_PATH) partition_table_get_info | check_pytho
|
||||
--partition-table-offset $(partition_table_offset) \
|
||||
read_otadata
|
||||
|
||||
erase_ota: erase_otadata
|
||||
@echo "WARNING: erase_ota is deprecated. Use erase_otadata instead."
|
||||
|
||||
all: blank_ota_data
|
||||
flash: blank_ota_data
|
||||
ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
|
||||
|
@ -72,13 +72,35 @@ static inline char IRAM_ATTR to_hex_digit(unsigned val)
|
||||
return (val < 10) ? ('0' + val) : ('a' + val - 10);
|
||||
}
|
||||
|
||||
__attribute__((constructor)) void esp_ota_init_app_elf_sha256(void)
|
||||
{
|
||||
esp_ota_get_app_elf_sha256(NULL, 0);
|
||||
}
|
||||
|
||||
/* The esp_app_desc.app_elf_sha256 should be possible to print in panic handler during cache is disabled.
|
||||
* But because the cache is disabled the reading esp_app_desc.app_elf_sha256 is not right and
|
||||
* can lead to a complete lock-up of the CPU.
|
||||
* For this reason we do a reading of esp_app_desc.app_elf_sha256 while start up in esp_ota_init_app_elf_sha256()
|
||||
* and keep it in the static s_app_elf_sha256 value.
|
||||
*/
|
||||
int IRAM_ATTR esp_ota_get_app_elf_sha256(char* dst, size_t size)
|
||||
{
|
||||
size_t n = MIN((size - 1) / 2, sizeof(esp_app_desc.app_elf_sha256));
|
||||
const uint8_t* src = esp_app_desc.app_elf_sha256;
|
||||
static char s_app_elf_sha256[CONFIG_APP_RETRIEVE_LEN_ELF_SHA / 2];
|
||||
static bool first_call = true;
|
||||
if (first_call) {
|
||||
first_call = false;
|
||||
const uint8_t* src = esp_app_desc.app_elf_sha256;
|
||||
for (size_t i = 0; i < sizeof(s_app_elf_sha256); ++i) {
|
||||
s_app_elf_sha256[i] = src[i];
|
||||
}
|
||||
}
|
||||
if (dst == NULL || size == 0) {
|
||||
return 0;
|
||||
}
|
||||
size_t n = MIN((size - 1) / 2, sizeof(s_app_elf_sha256));
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
dst[2*i] = to_hex_digit(src[i] >> 4);
|
||||
dst[2*i + 1] = to_hex_digit(src[i] & 0xf);
|
||||
dst[2*i] = to_hex_digit(s_app_elf_sha256[i] >> 4);
|
||||
dst[2*i + 1] = to_hex_digit(s_app_elf_sha256[i] & 0xf);
|
||||
}
|
||||
dst[2*n] = 0;
|
||||
return 2*n + 1;
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "esp_efuse.h"
|
||||
|
||||
|
||||
#define SUB_TYPE_ID(i) (i & 0x0F)
|
||||
#define SUB_TYPE_ID(i) (i & 0x0F)
|
||||
|
||||
typedef struct ota_ops_entry_ {
|
||||
uint32_t handle;
|
||||
@ -157,7 +157,8 @@ esp_err_t esp_ota_begin(const esp_partition_t *partition, size_t image_size, esp
|
||||
if ((image_size == 0) || (image_size == OTA_SIZE_UNKNOWN)) {
|
||||
ret = esp_partition_erase_range(partition, 0, partition->size);
|
||||
} else {
|
||||
ret = esp_partition_erase_range(partition, 0, (image_size / SPI_FLASH_SEC_SIZE + 1) * SPI_FLASH_SEC_SIZE);
|
||||
const int aligned_erase_size = (image_size + SPI_FLASH_SEC_SIZE - 1) & ~(SPI_FLASH_SEC_SIZE - 1);
|
||||
ret = esp_partition_erase_range(partition, 0, aligned_erase_size);
|
||||
}
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
@ -200,7 +201,7 @@ esp_err_t esp_ota_write(esp_ota_handle_t handle, const void *data, size_t size)
|
||||
// must erase the partition before writing to it
|
||||
assert(it->erased_size > 0 && "must erase the partition before writing to it");
|
||||
if (it->wrote_size == 0 && it->partial_bytes == 0 && size > 0 && data_bytes[0] != ESP_IMAGE_HEADER_MAGIC) {
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x", data_bytes[0]);
|
||||
ESP_LOGE(TAG, "OTA image has invalid magic byte (expected 0xE9, saw 0x%02x)", data_bytes[0]);
|
||||
return ESP_ERR_OTA_VALIDATE_FAILED;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
TEST_CASE("esp_ota_get_app_elf_sha256 test", "[esp_app_desc]")
|
||||
{
|
||||
const int sha256_hex_len = 64;
|
||||
const int sha256_hex_len = CONFIG_APP_RETRIEVE_LEN_ELF_SHA;
|
||||
char dst[sha256_hex_len + 2];
|
||||
const char fill = 0xcc;
|
||||
int res;
|
||||
|
@ -444,7 +444,7 @@ static void test_flow4(void)
|
||||
// 2 Stage: run factory -> check it -> copy factory to OTA0 -> reboot --//--
|
||||
// 3 Stage: run OTA0 -> check it -> set_pin_factory_reset -> reboot --//--
|
||||
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, OTA0, sets pin_factory_reset, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow4, test_flow4, test_flow4);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_APP_TEST
|
||||
@ -487,7 +487,7 @@ static void test_flow5(void)
|
||||
// 2 Stage: run factory -> check it -> copy factory to Test and set pin_test_app -> reboot --//--
|
||||
// 3 Stage: run test -> check it -> reset pin_test_app -> reboot --//--
|
||||
// 4 Stage: run factory -> check it -> erase OTA_DATA for next tests -> PASS
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
|
||||
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][ignore][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
|
||||
#endif
|
||||
|
||||
static const esp_partition_t* app_update(void)
|
||||
|
@ -234,12 +234,15 @@ menu "Security features"
|
||||
config SECURE_SIGNED_ON_UPDATE
|
||||
bool
|
||||
default y
|
||||
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
|
||||
|
||||
config SECURE_SIGNED_APPS
|
||||
bool
|
||||
default y
|
||||
select MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
select MBEDTLS_ECP_C
|
||||
select MBEDTLS_ECDH_C
|
||||
select MBEDTLS_ECDSA_C
|
||||
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
|
||||
|
||||
|
||||
@ -338,7 +341,7 @@ menu "Security features"
|
||||
config SECURE_BOOT_SIGNING_KEY
|
||||
string "Secure boot private signing key"
|
||||
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
default secure_boot_signing_key.pem
|
||||
default "secure_boot_signing_key.pem"
|
||||
help
|
||||
Path to the key file used to sign app images.
|
||||
|
||||
@ -354,7 +357,7 @@ menu "Security features"
|
||||
config SECURE_BOOT_VERIFICATION_KEY
|
||||
string "Secure boot public signature verification key"
|
||||
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
|
||||
default signature_verification_key.bin
|
||||
default "signature_verification_key.bin"
|
||||
help
|
||||
Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or
|
||||
app, to verify app images.
|
||||
@ -368,7 +371,7 @@ menu "Security features"
|
||||
choice SECURE_BOOTLOADER_KEY_ENCODING
|
||||
bool "Hardware Key Encoding"
|
||||
depends on SECURE_BOOTLOADER_REFLASHABLE
|
||||
default SECURE_BOOTLOADER_NO_ENCODING
|
||||
default SECURE_BOOTLOADER_KEY_ENCODING_256BIT
|
||||
help
|
||||
|
||||
In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and
|
||||
@ -515,6 +518,20 @@ menu "Security features"
|
||||
|
||||
Only set this option in testing environments.
|
||||
|
||||
config SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
bool "Require flash encryption to be already enabled"
|
||||
depends on SECURE_FLASH_ENCRYPTION_MODE_DEVELOPMENT
|
||||
default N
|
||||
help
|
||||
If not set (default), and flash encryption is not yet enabled in eFuses, the 2nd stage bootloader
|
||||
will enable flash encryption: generate the flash encryption key and program eFuses.
|
||||
If this option is set, and flash encryption is not yet enabled, the bootloader will error out and
|
||||
reboot.
|
||||
If flash encryption is enabled in eFuses, this option does not change the bootloader behavior.
|
||||
|
||||
Only use this option in testing environments, to avoid accidentally enabling flash encryption on
|
||||
the wrong device. The device needs to have flash encryption already enabled using espefuse.py.
|
||||
|
||||
endmenu # Potentially Insecure
|
||||
endmenu # Security features
|
||||
|
||||
|
@ -96,11 +96,13 @@ endif()
|
||||
idf_build_get_property(idf_path IDF_PATH)
|
||||
idf_build_get_property(idf_target IDF_TARGET)
|
||||
idf_build_get_property(sdkconfig SDKCONFIG)
|
||||
idf_build_get_property(python PYTHON)
|
||||
idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS)
|
||||
|
||||
externalproject_add(bootloader
|
||||
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject"
|
||||
BINARY_DIR "${BOOTLOADER_BUILD_DIR}"
|
||||
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target}
|
||||
CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON=${python}
|
||||
-DPYTHON_DEPS_CHECKED=1
|
||||
-DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR}
|
||||
${sign_key_arg} ${ver_key_arg}
|
||||
@ -108,6 +110,7 @@ externalproject_add(bootloader
|
||||
# the bootloader common component requirements depends on this and
|
||||
# config variables are not available before project() call.
|
||||
-DLEGACY_INCLUDE_COMMON_HEADERS=${CONFIG_LEGACY_INCLUDE_COMMON_HEADERS}
|
||||
${extra_cmake_args}
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_ALWAYS 1 # no easy way around this...
|
||||
BUILD_BYPRODUCTS ${bootloader_binary_files}
|
||||
@ -124,4 +127,4 @@ endif()
|
||||
# So for now we just have the top-level build remove the final build products...
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" APPEND PROPERTY
|
||||
ADDITIONAL_MAKE_CLEAN_FILES
|
||||
${bootloader_binary_files})
|
||||
${bootloader_binary_files})
|
||||
|
@ -75,7 +75,8 @@ if(CONFIG_SECURE_BOOTLOADER_REFLASHABLE)
|
||||
add_custom_command(OUTPUT "${bootloader_digest_bin}"
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "DIGEST ${bootloader_digest_bin}"
|
||||
COMMAND ${ESPSECUREPY} digest_secure_bootloader --keyfile "${secure_bootloader_key}"
|
||||
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
|
||||
-o "${bootloader_digest_bin}" "${CMAKE_BINARY_DIR}/bootloader.bin"
|
||||
MAIN_DEPENDENCY "${CMAKE_BINARY_DIR}/.bin_timestamp"
|
||||
DEPENDS gen_secure_bootloader_key gen_project_binary
|
||||
VERBATIM)
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "bootloader_common.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp32/rom/rtc.h"
|
||||
|
||||
static const char* TAG = "boot";
|
||||
|
||||
@ -74,7 +75,8 @@ static int selected_boot_partition(const bootloader_state_t *bs)
|
||||
int boot_index = bootloader_utility_get_selected_boot_partition(bs);
|
||||
if (boot_index == INVALID_INDEX) {
|
||||
return boot_index; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
|
||||
} else {
|
||||
}
|
||||
if (rtc_get_reset_reason(0) != DEEPSLEEP_RESET) {
|
||||
// Factory firmware.
|
||||
#ifdef CONFIG_BOOTLOADER_FACTORY_RESET
|
||||
if (bootloader_common_check_long_hold_gpio(CONFIG_BOOTLOADER_NUM_PIN_FACTORY_RESET, CONFIG_BOOTLOADER_HOLD_TIME_GPIO) == 1) {
|
||||
|
@ -40,6 +40,7 @@ SECTIONS
|
||||
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
|
||||
*liblog.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_clock.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_common.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
@ -53,6 +54,7 @@ SECTIONS
|
||||
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:rtc_clk.*(.literal .text .literal.* .text.*)
|
||||
*libefuse.a:*.*(.literal .text .literal.* .text.*)
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
|
@ -36,30 +36,60 @@ idf_component_register(SRCS "${srcs}"
|
||||
REQUIRES "${requires}"
|
||||
PRIV_REQUIRES "${priv_requires}")
|
||||
|
||||
if(BOOTLOADER_BUILD AND CONFIG_SECURE_SIGNED_APPS)
|
||||
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
|
||||
# in the library.
|
||||
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
|
||||
# We generate the key from the signing key. The signing key is passed from the main project.
|
||||
get_filename_component(secure_boot_signing_key
|
||||
"${SECURE_BOOT_SIGNING_KEY}"
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
get_filename_component(secure_boot_verification_key
|
||||
"signature_verification_key.bin"
|
||||
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_custom_command(OUTPUT "${secure_boot_verification_key}"
|
||||
COMMAND ${ESPSECUREPY}
|
||||
if(CONFIG_SECURE_SIGNED_APPS)
|
||||
if(BOOTLOADER_BUILD)
|
||||
# Whether CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES or not, we need verification key to embed
|
||||
# in the library.
|
||||
if(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)
|
||||
# We generate the key from the signing key. The signing key is passed from the main project.
|
||||
get_filename_component(secure_boot_signing_key
|
||||
"${SECURE_BOOT_SIGNING_KEY}"
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
get_filename_component(secure_boot_verification_key
|
||||
"signature_verification_key.bin"
|
||||
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
add_custom_command(OUTPUT "${secure_boot_verification_key}"
|
||||
COMMAND ${ESPSECUREPY}
|
||||
extract_public_key --keyfile "${secure_boot_signing_key}"
|
||||
"${secure_boot_verification_key}"
|
||||
VERBATIM)
|
||||
else()
|
||||
# We expect to 'inherit' the verification key passed from main project.
|
||||
get_filename_component(secure_boot_verification_key
|
||||
${SECURE_BOOT_VERIFICATION_KEY}
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
DEPENDS ${secure_boot_signing_key}
|
||||
VERBATIM)
|
||||
else()
|
||||
# We expect to 'inherit' the verification key passed from main project.
|
||||
get_filename_component(secure_boot_verification_key
|
||||
${SECURE_BOOT_VERIFICATION_KEY}
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
endif()
|
||||
else() # normal app build
|
||||
idf_build_get_property(project_dir PROJECT_DIR)
|
||||
|
||||
if(CONFIG_SECURE_BOOT_VERIFICATION_KEY)
|
||||
# verification-only build supplies verification key
|
||||
set(secure_boot_verification_key ${CONFIG_SECURE_BOOT_VERIFICATION_KEY})
|
||||
get_filename_component(secure_boot_verification_key
|
||||
${secure_boot_verification_key}
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
else()
|
||||
# sign at build time, extracts key from signing key
|
||||
set(secure_boot_verification_key "${CMAKE_BINARY_DIR}/signature_verification_key.bin")
|
||||
get_filename_component(secure_boot_signing_key
|
||||
${CONFIG_SECURE_BOOT_SIGNING_KEY}
|
||||
ABSOLUTE BASE_DIR "${project_dir}")
|
||||
|
||||
add_custom_command(OUTPUT "${secure_boot_verification_key}"
|
||||
COMMAND ${ESPSECUREPY}
|
||||
extract_public_key --keyfile "${secure_boot_signing_key}"
|
||||
"${secure_boot_verification_key}"
|
||||
WORKING_DIRECTORY ${project_dir}
|
||||
DEPENDS ${secure_boot_signing_key}
|
||||
VERBATIM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY")
|
||||
# Embed the verification key in the binary (app & bootloader)
|
||||
#
|
||||
target_add_binary_data(${COMPONENT_LIB} "${secure_boot_verification_key}" "BINARY"
|
||||
RENAME_TO signature_verification_key_bin)
|
||||
set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
|
||||
"${secure_boot_verification_key}")
|
||||
|
@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_app_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -27,6 +28,11 @@ typedef enum {
|
||||
GPIO_NOT_HOLD = 0 /*!< If the GPIO input is not low */
|
||||
} esp_comm_gpio_hold_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_IMAGE_BOOTLOADER,
|
||||
ESP_IMAGE_APPLICATION
|
||||
} esp_image_type;
|
||||
|
||||
/**
|
||||
* @brief Calculate crc for the OTA data select.
|
||||
*
|
||||
@ -129,7 +135,7 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
|
||||
/**
|
||||
* @brief Returns esp_app_desc structure for app partition. This structure includes app version.
|
||||
*
|
||||
*
|
||||
* Returns a description for the requested app partition.
|
||||
* @param[in] partition App partition description.
|
||||
* @param[out] app_desc Structure of info about app.
|
||||
@ -141,6 +147,24 @@ int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata,
|
||||
*/
|
||||
esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t *partition, esp_app_desc_t *app_desc);
|
||||
|
||||
/**
|
||||
* @brief Get chip revision
|
||||
*
|
||||
* @return Chip revision number
|
||||
*/
|
||||
uint8_t bootloader_common_get_chip_revision(void);
|
||||
|
||||
/**
|
||||
* @brief Check if the image (bootloader and application) has valid chip ID and revision
|
||||
*
|
||||
* @param[in] img_hdr: image header
|
||||
* @param[in] type: image type, bootloader or application
|
||||
* @return
|
||||
* - ESP_OK: image and chip are matched well
|
||||
* - ESP_FAIL: image doesn't match to the chip
|
||||
*/
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type);
|
||||
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
|
@ -13,6 +13,19 @@
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief ESP chip ID
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_CHIP_ID_ESP32 = 0x0000, /*!< chip ID: ESP32 */
|
||||
ESP_CHIP_ID_INVALID = 0xFFFF /*!< Invalid chip ID (we defined it to make sure the esp_chip_id_t is 2 bytes size) */
|
||||
} __attribute__((packed)) esp_chip_id_t;
|
||||
|
||||
/** @cond */
|
||||
_Static_assert(sizeof(esp_chip_id_t) == 2, "esp_chip_id_t should be 16 bit");
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief SPI flash mode, used in esp_image_header_t
|
||||
*/
|
||||
@ -63,7 +76,9 @@ typedef struct {
|
||||
* the IDF bootloader uses software to configure the WP
|
||||
* pin and sets this field to 0xEE=disabled) */
|
||||
uint8_t spi_pin_drv[3]; /*!< Drive settings for the SPI flash pins (read by ROM bootloader) */
|
||||
uint8_t reserved[11]; /*!< Reserved bytes in ESP32 additional header space, currently unused */
|
||||
esp_chip_id_t chip_id; /*!< Chip identification number */
|
||||
uint8_t min_chip_rev; /*!< Minimum chip revision supported by image */
|
||||
uint8_t reserved[8]; /*!< Reserved bytes in additional header space, currently unused */
|
||||
uint8_t hash_appended; /*!< If 1, a SHA256 digest "simple hash" (of the entire image) is appended after the checksum.
|
||||
* Included in image length. This digest
|
||||
* is separate to secure boot and only used for detecting corruption.
|
||||
|
@ -133,6 +133,21 @@ void esp_flash_write_protect_crypt_cnt();
|
||||
*/
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode();
|
||||
|
||||
|
||||
/** @brief Check the flash encryption mode during startup
|
||||
*
|
||||
* @note This function is called automatically during app startup,
|
||||
* it doesn't need to be called from the app.
|
||||
*
|
||||
* Verifies the flash encryption config during startup:
|
||||
*
|
||||
* - Correct any insecure flash encryption settings if hardware
|
||||
* Secure Boot is enabled.
|
||||
* - Log warnings if the efuse config doesn't match the project
|
||||
* config in any way
|
||||
*/
|
||||
void esp_flash_encryption_init_checks(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -98,12 +98,6 @@ typedef struct {
|
||||
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
|
||||
|
||||
|
||||
/* This function is included for compatibility with the ESP-IDF v3.x API */
|
||||
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
|
||||
{
|
||||
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the region on the main flash is safe to write.
|
||||
*
|
||||
|
@ -51,36 +51,6 @@ typedef enum {
|
||||
#endif
|
||||
} esp_image_load_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Verify and (optionally, in bootloader mode) load an app image.
|
||||
*
|
||||
* This name is deprecated and is included for compatibility with the ESP-IDF v3.x API.
|
||||
* It will be removed in V4.0 version.
|
||||
* Function has been renamed to esp_image_verify().
|
||||
* Use function esp_image_verify() to verify a image. And use function bootloader_load_image() to load image from a bootloader space.
|
||||
*
|
||||
* If encryption is enabled, data will be transparently decrypted.
|
||||
*
|
||||
* @param mode Mode of operation (verify, silent verify, or load).
|
||||
* @param part Partition to load the app from.
|
||||
* @param[inout] data Pointer to the image metadata structure which is be filled in by this function. 'start_addr' member should be set (to the start address of the image.) Other fields will all be initialised by this function.
|
||||
*
|
||||
* Image validation checks:
|
||||
* - Magic byte.
|
||||
* - Partition smaller than 16MB.
|
||||
* - All segments & image fit in partition.
|
||||
* - 8 bit image checksum is valid.
|
||||
* - SHA-256 of image is valid (if image has this appended).
|
||||
* - (Signature) if signature verification is enabled.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK if verify or load was successful
|
||||
* - ESP_ERR_IMAGE_FLASH_FAIL if a SPI flash error occurs
|
||||
* - ESP_ERR_IMAGE_INVALID if the image appears invalid.
|
||||
* - ESP_ERR_INVALID_ARG if the partition or data pointers are invalid.
|
||||
*/
|
||||
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Verify an app image.
|
||||
*
|
||||
|
@ -58,3 +58,12 @@ void bootloader_clock_configure()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
|
||||
int esp_clk_apb_freq(void)
|
||||
{
|
||||
return rtc_clk_apb_freq_get();
|
||||
}
|
||||
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "bootloader_common.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/apb_ctrl_reg.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "sys/param.h"
|
||||
@ -270,3 +272,51 @@ void bootloader_common_vddsdio_configure()
|
||||
}
|
||||
#endif // CONFIG_BOOTLOADER_VDDSDIO_BOOST
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
uint8_t bootloader_common_get_chip_revision(void)
|
||||
{
|
||||
uint8_t eco_bit0, eco_bit1, eco_bit2;
|
||||
eco_bit0 = (REG_READ(EFUSE_BLK0_RDATA3_REG) & 0xF000) >> 15;
|
||||
eco_bit1 = (REG_READ(EFUSE_BLK0_RDATA5_REG) & 0x100000) >> 20;
|
||||
eco_bit2 = (REG_READ(APB_CTRL_DATE_REG) & 0x80000000) >> 31;
|
||||
uint32_t combine_value = (eco_bit2 << 2) | (eco_bit1 << 1) | eco_bit0;
|
||||
uint8_t chip_ver = 0;
|
||||
switch (combine_value) {
|
||||
case 0:
|
||||
chip_ver = 0;
|
||||
break;
|
||||
case 1:
|
||||
chip_ver = 1;
|
||||
break;
|
||||
case 3:
|
||||
chip_ver = 2;
|
||||
break;
|
||||
case 7:
|
||||
chip_ver = 3;
|
||||
break;
|
||||
default:
|
||||
chip_ver = 0;
|
||||
break;
|
||||
}
|
||||
return chip_ver;
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t bootloader_common_check_chip_validity(const esp_image_header_t* img_hdr, esp_image_type type)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
esp_chip_id_t chip_id = CONFIG_IDF_FIRMWARE_CHIP_ID;
|
||||
if (chip_id != img_hdr->chip_id) {
|
||||
ESP_LOGE(TAG, "mismatch chip ID, expected %d, found %d", chip_id, img_hdr->chip_id);
|
||||
err = ESP_FAIL;
|
||||
}
|
||||
uint8_t revision = bootloader_common_get_chip_revision();
|
||||
if (revision < img_hdr->min_chip_rev) {
|
||||
ESP_LOGE(TAG, "can't run on lower chip revision, expected %d, found %d", revision, img_hdr->min_chip_rev);
|
||||
err = ESP_FAIL;
|
||||
} else if (revision != img_hdr->min_chip_rev) {
|
||||
ESP_LOGI(TAG, "chip revision: %d, min. %s chip revision: %d", revision, type == ESP_IMAGE_BOOTLOADER ? "bootloader" : "application", img_hdr->min_chip_rev);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
|
||||
break;
|
||||
}
|
||||
esp_rom_spiflash_config_clk(spi_clk_div, 0);
|
||||
esp_rom_spiflash_config_clk(spi_clk_div, 1);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)
|
||||
|
@ -127,6 +127,14 @@ static esp_err_t bootloader_main()
|
||||
ESP_LOGE(TAG, "failed to load bootloader header!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Check chip ID and minimum chip revision that supported by this image */
|
||||
uint8_t revision = bootloader_common_get_chip_revision();
|
||||
ESP_LOGI(TAG, "Chip Revision: %d", revision);
|
||||
if (bootloader_common_check_chip_validity(&fhdr, ESP_IMAGE_BOOTLOADER) != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
bootloader_init_flash_configure(&fhdr);
|
||||
#if (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240)
|
||||
//Check if ESP32 is rated for a CPU frequency of 160MHz only
|
||||
|
@ -114,17 +114,18 @@ void bootloader_random_enable(void)
|
||||
|
||||
void bootloader_random_disable(void)
|
||||
{
|
||||
/* Disable i2s clock */
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
|
||||
|
||||
/* Reset some i2s configuration (possibly redundant as we reset entire
|
||||
I2S peripheral further down). */
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
||||
SET_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_RESET);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_CAMERA_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_LCD_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE_TEST_EN);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF2_REG(0), I2S_DATA_ENABLE);
|
||||
CLEAR_PERI_REG_MASK(I2S_CONF_REG(0), I2S_RX_START);
|
||||
|
||||
/* Disable i2s clock */
|
||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_I2S0_CLK_EN);
|
||||
|
||||
/* Restore SYSCON mode registers */
|
||||
CLEAR_PERI_REG_MASK(SENS_SAR_READ_CTRL_REG, SENS_SAR1_DIG_FORCE);
|
||||
|
@ -37,7 +37,7 @@ static const char *TAG = "flash_encrypt";
|
||||
|
||||
/* Static functions for stages of flash encryption */
|
||||
static esp_err_t initialise_flash_encryption(void);
|
||||
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis);
|
||||
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis) __attribute__((unused));
|
||||
static esp_err_t encrypt_bootloader();
|
||||
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions);
|
||||
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition);
|
||||
@ -60,8 +60,14 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
else {
|
||||
#ifndef CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
/* Flash is not encrypted, so encrypt it! */
|
||||
return encrypt_flash_contents(flash_crypt_cnt, flash_crypt_wr_dis);
|
||||
#else
|
||||
ESP_LOGE(TAG, "flash encryption is not enabled, and SECURE_FLASH_REQUIRE_ALREADY_ENABLED "
|
||||
"is set, refusing to boot.");
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
#endif // CONFIG_SECURE_FLASH_REQUIRE_ALREADY_ENABLED
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <bootloader_random.h>
|
||||
#include <bootloader_sha.h>
|
||||
#include "bootloader_util.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
/* Checking signatures as part of verifying images is necessary:
|
||||
- Always if secure boot is enabled
|
||||
@ -268,8 +269,6 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
|
||||
return image_load(mode, part, data);
|
||||
}
|
||||
|
||||
esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) __attribute__((alias("esp_image_verify")));
|
||||
|
||||
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
@ -280,6 +279,9 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
|
||||
}
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION) != ESP_OK) {
|
||||
err = ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (!silent) {
|
||||
if (image->spi_mode > ESP_IMAGE_SPI_MODE_SLOW_READ) {
|
||||
ESP_LOGW(TAG, "image at 0x%x has invalid SPI mode %d", src_addr, image->spi_mode);
|
||||
|
@ -13,9 +13,51 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <strings.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_efuse_table.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
#include "esp_secure_boot.h"
|
||||
|
||||
#ifndef BOOTLOADER_BUILD
|
||||
static const char *TAG = "flash_encrypt";
|
||||
|
||||
void esp_flash_encryption_init_checks()
|
||||
{
|
||||
esp_flash_enc_mode_t mode;
|
||||
|
||||
// First check is: if Release mode flash encryption & secure boot are enabled then
|
||||
// FLASH_CRYPT_CNT *must* be write protected. This will have happened automatically
|
||||
// if bootloader is IDF V4.0 or newer but may not have happened for previous ESP-IDF bootloaders.
|
||||
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
|
||||
#ifdef CONFIG_SECURE_BOOT_ENABLED
|
||||
if (esp_secure_boot_enabled() && esp_flash_encryption_enabled()) {
|
||||
uint8_t flash_crypt_cnt_wr_dis = 0;
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
|
||||
if (!flash_crypt_cnt_wr_dis) {
|
||||
ESP_LOGE(TAG, "Flash encryption & Secure Boot together requires FLASH_CRYPT_CNT efuse to be write protected. Fixing now...");
|
||||
esp_flash_write_protect_crypt_cnt();
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_SECURE_BOOT_ENABLED
|
||||
#endif // CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
|
||||
|
||||
// Second check is to print a warning or error if the current running flash encryption mode
|
||||
// doesn't match the expectation from project config (due to mismatched bootloader and app, probably)
|
||||
mode = esp_get_flash_encryption_mode();
|
||||
if (mode == ESP_FLASH_ENC_MODE_DEVELOPMENT) {
|
||||
#ifdef CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE
|
||||
ESP_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
|
||||
ESP_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
|
||||
#else
|
||||
ESP_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
|
||||
#endif
|
||||
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
|
||||
ESP_LOGI(TAG, "Flash encryption mode is RELEASE");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_flash_write_protect_crypt_cnt()
|
||||
{
|
||||
|
@ -56,6 +56,10 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
|
||||
|
||||
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
|
||||
{
|
||||
#if !(defined(CONFIG_MBEDTLS_ECDSA_C) && defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED))
|
||||
ESP_LOGE(TAG, "Signature verification requires ECDSA & SECP256R1 curve enabled");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#else
|
||||
ptrdiff_t keylen;
|
||||
|
||||
keylen = signature_verification_key_end - signature_verification_key_start;
|
||||
@ -117,4 +121,5 @@ cleanup:
|
||||
mbedtls_mpi_free(&s);
|
||||
mbedtls_ecdsa_free(&ecdsa_context);
|
||||
return ret == 0 ? ESP_OK : ESP_ERR_IMAGE_INVALID;
|
||||
#endif // CONFIG_MBEDTLS_ECDSA_C && CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
}
|
||||
|
@ -289,20 +289,30 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/bluedroid/stack/smp/smp_l2c.c"
|
||||
"host/bluedroid/stack/smp/smp_main.c"
|
||||
"host/bluedroid/stack/smp/smp_utils.c")
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND srcs "esp_ble_mesh/mesh_core/bluedroid_host/mesh_bearer_adapt.c")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if(CONFIG_BLE_MESH)
|
||||
list(APPEND include_dirs
|
||||
"esp_ble_mesh/mesh_common/include"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/include"
|
||||
"esp_ble_mesh/mesh_core"
|
||||
"esp_ble_mesh/mesh_core/include"
|
||||
"esp_ble_mesh/mesh_core/settings"
|
||||
"esp_ble_mesh/mesh_core/storage"
|
||||
"esp_ble_mesh/btc/include"
|
||||
"esp_ble_mesh/mesh_models/include"
|
||||
"esp_ble_mesh/mesh_models/common/include"
|
||||
"esp_ble_mesh/mesh_models/client/include"
|
||||
"esp_ble_mesh/mesh_models/server/include"
|
||||
"esp_ble_mesh/api/core/include"
|
||||
"esp_ble_mesh/api/models/include"
|
||||
"esp_ble_mesh/api")
|
||||
|
||||
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
|
||||
list(APPEND srcs "esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c"
|
||||
"esp_ble_mesh/api/core/esp_ble_mesh_common_api.c"
|
||||
"esp_ble_mesh/api/core/esp_ble_mesh_local_data_operation_api.c"
|
||||
"esp_ble_mesh/api/core/esp_ble_mesh_low_power_api.c"
|
||||
"esp_ble_mesh/api/core/esp_ble_mesh_networking_api.c"
|
||||
@ -321,41 +331,64 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
|
||||
"esp_ble_mesh/mesh_core/settings/settings_nvs.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_decrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/aes_encrypt.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cbc_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ccm_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/cmac_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_mode.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ctr_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dh.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_dsa.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc_platform_specific.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/ecc.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac_prng.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/hmac.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/sha256.c"
|
||||
"esp_ble_mesh/mesh_common/tinycrypt/src/utils.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_atomic.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_buf.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_common.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_kernel.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_mutex.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_timer.c"
|
||||
"esp_ble_mesh/mesh_common/mesh_util.c"
|
||||
"esp_ble_mesh/mesh_core/storage/settings_nvs.c"
|
||||
"esp_ble_mesh/mesh_core/access.c"
|
||||
"esp_ble_mesh/mesh_core/adv.c"
|
||||
"esp_ble_mesh/mesh_core/beacon.c"
|
||||
"esp_ble_mesh/mesh_core/cfg_cli.c"
|
||||
"esp_ble_mesh/mesh_core/cfg_srv.c"
|
||||
"esp_ble_mesh/mesh_core/crypto.c"
|
||||
"esp_ble_mesh/mesh_core/fast_prov.c"
|
||||
"esp_ble_mesh/mesh_core/friend.c"
|
||||
"esp_ble_mesh/mesh_core/health_cli.c"
|
||||
"esp_ble_mesh/mesh_core/health_srv.c"
|
||||
"esp_ble_mesh/mesh_core/local_operation.c"
|
||||
"esp_ble_mesh/mesh_core/lpn.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_aes_encrypt.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_atomic.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_bearer_adapt.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_buf.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_hci.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_kernel.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_main.c"
|
||||
"esp_ble_mesh/mesh_core/mesh_util.c"
|
||||
"esp_ble_mesh/mesh_core/main.c"
|
||||
"esp_ble_mesh/mesh_core/net.c"
|
||||
"esp_ble_mesh/mesh_core/prov.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_beacon.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_main.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_prov.c"
|
||||
"esp_ble_mesh/mesh_core/provisioner_proxy.c"
|
||||
"esp_ble_mesh/mesh_core/proxy.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_client.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_server.c"
|
||||
"esp_ble_mesh/mesh_core/settings.c"
|
||||
"esp_ble_mesh/mesh_core/test.c"
|
||||
"esp_ble_mesh/mesh_core/transport.c"
|
||||
"esp_ble_mesh/mesh_models/generic_client.c"
|
||||
"esp_ble_mesh/mesh_models/lighting_client.c"
|
||||
"esp_ble_mesh/mesh_models/mesh_common.c"
|
||||
"esp_ble_mesh/mesh_models/model_common.c"
|
||||
"esp_ble_mesh/mesh_models/sensor_client.c"
|
||||
"esp_ble_mesh/mesh_models/time_scene_client.c")
|
||||
"esp_ble_mesh/mesh_models/client/client_common.c"
|
||||
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/sensor_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
|
||||
"esp_ble_mesh/mesh_models/server/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/server/generic_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/lighting_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/sensor_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/server_common.c"
|
||||
"esp_ble_mesh/mesh_models/server/state_binding.c"
|
||||
"esp_ble_mesh/mesh_models/server/state_transition.c"
|
||||
"esp_ble_mesh/mesh_models/server/time_scene_server.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_ENABLED)
|
||||
@ -376,9 +409,13 @@ if(CONFIG_BT_ENABLED)
|
||||
host/nimble/nimble/nimble/host/store/ram/include
|
||||
host/nimble/nimble/nimble/host/store/config/include
|
||||
host/nimble/nimble/porting/npl/freertos/include
|
||||
host/nimble/nimble/ext/tinycrypt/include
|
||||
host/nimble/esp-hci/include)
|
||||
|
||||
if(NOT CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS)
|
||||
|
||||
list(APPEND include_dirs
|
||||
host/nimble/nimble/ext/tinycrypt/include)
|
||||
|
||||
list(APPEND srcs "host/nimble/nimble/ext/tinycrypt/src/utils.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/sha256.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/ecc.c"
|
||||
@ -393,8 +430,10 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/ext/tinycrypt/src/hmac_prng.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/ecc_platform_specific.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/hmac.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c"
|
||||
"host/nimble/nimble/nimble/host/util/src/addr.c"
|
||||
"host/nimble/nimble/ext/tinycrypt/src/cbc_mode.c")
|
||||
endif()
|
||||
|
||||
list(APPEND srcs "host/nimble/nimble/nimble/host/util/src/addr.c"
|
||||
"host/nimble/nimble/nimble/host/services/gatt/src/ble_svc_gatt.c"
|
||||
"host/nimble/nimble/nimble/host/services/tps/src/ble_svc_tps.c"
|
||||
"host/nimble/nimble/nimble/host/services/ias/src/ble_svc_ias.c"
|
||||
@ -445,6 +484,7 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_adv.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_hci.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_hci_util.c"
|
||||
"host/nimble/nimble/nimble/host/src/ble_hs_resolv.c"
|
||||
"host/nimble/nimble/nimble/host/store/ram/src/ble_store_ram.c"
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_config.c"
|
||||
"host/nimble/nimble/nimble/host/store/config/src/ble_store_nvs.c"
|
||||
@ -460,7 +500,12 @@ if(CONFIG_BT_ENABLED)
|
||||
"host/nimble/nimble/porting/nimble/src/mem.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_mbuf.c"
|
||||
"host/nimble/nimble/porting/nimble/src/os_cputime.c"
|
||||
"host/nimble/esp-hci/src/esp_nimble_hci.c")
|
||||
"host/nimble/esp-hci/src/esp_nimble_hci.c"
|
||||
"host/nimble/port/src/esp_nimble_mem.c")
|
||||
|
||||
if (CONFIG_BLE_MESH)
|
||||
list(APPEND srcs "esp_ble_mesh/mesh_core/nimble_host/mesh_bearer_adapt.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_BT_NIMBLE_MESH)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
menu Bluetooth
|
||||
menu "Bluetooth"
|
||||
|
||||
config BT_ENABLED
|
||||
bool "Bluetooth"
|
||||
@ -77,6 +77,33 @@ menu Bluetooth
|
||||
default 1 if BTDM_CTRL_BR_EDR_SCO_DATA_PATH_PCM
|
||||
default 0
|
||||
|
||||
config BTDM_CTRL_AUTO_LATENCY
|
||||
bool "Auto latency"
|
||||
depends on BTDM_CTRL_MODE_BTDM
|
||||
default n
|
||||
help
|
||||
BLE auto latency, used to enhance classic BT performance
|
||||
while classic BT and BLE are enabled at the same time.
|
||||
|
||||
config BTDM_CTRL_AUTO_LATENCY_EFF
|
||||
bool
|
||||
default BTDM_CTRL_AUTO_LATENCY if BTDM_CTRL_MODE_BTDM
|
||||
default n
|
||||
|
||||
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT
|
||||
bool "Legacy Authentication Vendor Specific Event Enable"
|
||||
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default y
|
||||
help
|
||||
To protect from BIAS attack during Legacy authentication,
|
||||
Legacy authentication Vendor specific event should be enabled
|
||||
|
||||
config BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF
|
||||
bool
|
||||
default BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default 0
|
||||
|
||||
|
||||
config BTDM_CTRL_BLE_MAX_CONN_EFF
|
||||
int
|
||||
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
@ -318,8 +345,8 @@ menu Bluetooth
|
||||
|
||||
config BTDM_CTRL_FULL_SCAN_SUPPORTED
|
||||
bool "BLE full scan feature supported"
|
||||
depends on BTDM_CTRL_MODE_BLE_ONLY
|
||||
default n
|
||||
depends on BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
default y
|
||||
help
|
||||
The full scan function is mainly used to provide BLE scan performance.
|
||||
This is required for scenes with high scan performance requirements, such as BLE Mesh scenes.
|
||||
@ -358,6 +385,21 @@ 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
|
||||
@ -378,6 +420,13 @@ menu Bluetooth
|
||||
help
|
||||
This option is recommended for BLE only usecases to save on memory
|
||||
|
||||
config BT_CONTROLLER_ONLY
|
||||
bool "Controller Only"
|
||||
help
|
||||
This option is recommended when you want to communicate directly with the
|
||||
controller (without any host) or when you are using any other host stack
|
||||
not supported by Espressif (not mentioned here).
|
||||
|
||||
endchoice
|
||||
|
||||
menu "Bluedroid Options"
|
||||
@ -395,7 +444,6 @@ endmenu
|
||||
|
||||
menuconfig BLE_MESH
|
||||
bool "ESP BLE Mesh Support"
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
help
|
||||
This option enables ESP BLE Mesh support. The specific features that are
|
||||
available may depend on other features that have been enabled in the
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "bt_common.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "btc/btc_alarm.h"
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#include "common/bt_target.h"
|
||||
@ -32,7 +33,6 @@
|
||||
#include "btc_blufi_prf.h"
|
||||
#include "blufi_int.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#include "btc/btc_alarm.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
#include "btc/btc_profile_queue.h"
|
||||
@ -94,7 +94,9 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
[BTC_PID_DM_SEC] = {NULL, btc_dm_sec_cb_handler },
|
||||
#endif
|
||||
[BTC_PID_ALARM] = {btc_alarm_handler, NULL },
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#if CLASSIC_BT_INCLUDED
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
[BTC_PID_GAP_BT] = {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
|
||||
@ -114,16 +116,20 @@ static const btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
#endif /* #if CLASSIC_BT_INCLUDED */
|
||||
#endif
|
||||
#if CONFIG_BLE_MESH
|
||||
[BTC_PID_PROV] = {btc_mesh_prov_call_handler, btc_mesh_prov_cb_handler},
|
||||
[BTC_PID_MODEL] = {btc_mesh_model_call_handler, btc_mesh_model_cb_handler},
|
||||
[BTC_PID_HEALTH_CLIENT] = {btc_mesh_health_client_call_handler, btc_mesh_health_client_cb_handler},
|
||||
[BTC_PID_HEALTH_SERVER] = {btc_mesh_health_server_call_handler, btc_mesh_health_server_cb_handler},
|
||||
[BTC_PID_CFG_CLIENT] = {btc_mesh_cfg_client_call_handler, btc_mesh_cfg_client_cb_handler},
|
||||
[BTC_PID_CFG_SERVER] = {NULL , btc_mesh_cfg_server_cb_handler},
|
||||
[BTC_PID_GENERIC_CLIENT] = {btc_mesh_generic_client_call_handler, btc_mesh_generic_client_cb_handler},
|
||||
[BTC_PID_LIGHT_CLIENT] = {btc_mesh_light_client_call_handler, btc_mesh_light_client_cb_handler},
|
||||
[BTC_PID_SENSOR_CLIENT] = {btc_mesh_sensor_client_call_handler, btc_mesh_sensor_client_cb_handler},
|
||||
[BTC_PID_TIME_SCENE_CLIENT] = {btc_mesh_time_scene_client_call_handler, btc_mesh_time_scene_client_cb_handler},
|
||||
[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 },
|
||||
[BTC_PID_HEALTH_CLIENT] = {btc_ble_mesh_health_client_call_handler, btc_ble_mesh_health_client_cb_handler },
|
||||
[BTC_PID_HEALTH_SERVER] = {btc_ble_mesh_health_server_call_handler, btc_ble_mesh_health_server_cb_handler },
|
||||
[BTC_PID_CONFIG_CLIENT] = {btc_ble_mesh_config_client_call_handler, btc_ble_mesh_config_client_cb_handler },
|
||||
[BTC_PID_CONFIG_SERVER] = {NULL, btc_ble_mesh_config_server_cb_handler },
|
||||
[BTC_PID_GENERIC_CLIENT] = {btc_ble_mesh_generic_client_call_handler, btc_ble_mesh_generic_client_cb_handler },
|
||||
[BTC_PID_LIGHTING_CLIENT] = {btc_ble_mesh_lighting_client_call_handler, btc_ble_mesh_lighting_client_cb_handler },
|
||||
[BTC_PID_SENSOR_CLIENT] = {btc_ble_mesh_sensor_client_call_handler, btc_ble_mesh_sensor_client_cb_handler },
|
||||
[BTC_PID_TIME_SCENE_CLIENT] = {btc_ble_mesh_time_scene_client_call_handler, btc_ble_mesh_time_scene_client_cb_handler},
|
||||
[BTC_PID_GENERIC_SERVER] = {NULL, btc_ble_mesh_generic_server_cb_handler },
|
||||
[BTC_PID_LIGHTING_SERVER] = {NULL, btc_ble_mesh_lighting_server_cb_handler },
|
||||
[BTC_PID_SENSOR_SERVER] = {NULL, btc_ble_mesh_sensor_server_cb_handler },
|
||||
[BTC_PID_TIME_SCENE_SERVER] = {NULL, btc_ble_mesh_time_scene_server_cb_handler},
|
||||
#endif /* #if CONFIG_BLE_MESH */
|
||||
};
|
||||
|
||||
@ -321,7 +327,7 @@ error_exit:;
|
||||
|
||||
int btc_init(void)
|
||||
{
|
||||
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 3);
|
||||
btc_thread = osi_thread_create("BTC_TASK", BTC_TASK_STACK_SIZE, BTC_TASK_PRIO, BTC_TASK_PINNED_TO_CORE, 2);
|
||||
if (btc_thread == NULL) {
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
|
@ -15,9 +15,7 @@
|
||||
#ifndef __BTC_MANAGE_H__
|
||||
#define __BTC_MANAGE_H__
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#if BTC_DYNAMIC_MEMORY == FALSE
|
||||
extern void *btc_profile_cb_tab[BTC_PID_NUM];
|
||||
|
@ -72,12 +72,16 @@ typedef enum {
|
||||
BTC_PID_MODEL,
|
||||
BTC_PID_HEALTH_CLIENT,
|
||||
BTC_PID_HEALTH_SERVER,
|
||||
BTC_PID_CFG_CLIENT,
|
||||
BTC_PID_CFG_SERVER,
|
||||
BTC_PID_CONFIG_CLIENT,
|
||||
BTC_PID_CONFIG_SERVER,
|
||||
BTC_PID_GENERIC_CLIENT,
|
||||
BTC_PID_LIGHT_CLIENT,
|
||||
BTC_PID_LIGHTING_CLIENT,
|
||||
BTC_PID_SENSOR_CLIENT,
|
||||
BTC_PID_TIME_SCENE_CLIENT,
|
||||
BTC_PID_GENERIC_SERVER,
|
||||
BTC_PID_LIGHTING_SERVER,
|
||||
BTC_PID_SENSOR_SERVER,
|
||||
BTC_PID_TIME_SCENE_SERVER,
|
||||
#endif /* CONFIG_BLE_MESH */
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
@ -49,7 +49,7 @@
|
||||
#ifdef CONFIG_BTC_TASK_STACK_SIZE
|
||||
#define UC_BTC_TASK_STACK_SIZE CONFIG_BTC_TASK_STACK_SIZE
|
||||
#else
|
||||
#define UC_BTC_TASK_STACK_SIZE 3072
|
||||
#define UC_BTC_TASK_STACK_SIZE 4096
|
||||
#endif
|
||||
|
||||
/**********************************************************
|
||||
|
@ -267,6 +267,7 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
|
||||
assert(config != NULL);
|
||||
assert(section != NULL);
|
||||
assert(key != NULL);
|
||||
bool ret;
|
||||
|
||||
section_t *sec = section_find(config, section);
|
||||
entry_t *entry = entry_find(config, section, key);
|
||||
@ -274,7 +275,12 @@ bool config_remove_key(config_t *config, const char *section, const char *key)
|
||||
return false;
|
||||
}
|
||||
|
||||
return list_remove(sec->entries, entry);
|
||||
ret = list_remove(sec->entries, entry);
|
||||
if (list_length(sec->entries) == 0) {
|
||||
OSI_TRACE_DEBUG("%s remove section name:%s",__func__, section);
|
||||
ret &= config_remove_section(config, section);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
const config_section_node_t *config_section_begin(const config_t *config)
|
||||
@ -389,7 +395,7 @@ bool config_save(const config_t *config, const char *filename)
|
||||
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
|
||||
char *keyname = osi_calloc(keyname_bufsz);
|
||||
int config_size = get_config_size(config);
|
||||
char *buf = osi_calloc(config_size + 100);
|
||||
char *buf = osi_calloc(config_size);
|
||||
if (!line || !buf || !keyname) {
|
||||
err_code |= 0x01;
|
||||
goto error;
|
||||
@ -409,6 +415,16 @@ bool config_save(const config_t *config, const char *filename)
|
||||
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
|
||||
const section_t *section = (const section_t *)list_node(node);
|
||||
w_cnt = snprintf(line, 1024, "[%s]\n", section->name);
|
||||
if(w_cnt < 0) {
|
||||
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
|
||||
err_code |= 0x10;
|
||||
goto error;
|
||||
}
|
||||
if(w_cnt_total + w_cnt > config_size) {
|
||||
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size (config_size = %d).", __func__, (w_cnt + w_cnt_total), config_size);
|
||||
err_code |= 0x20;
|
||||
goto error;
|
||||
}
|
||||
OSI_TRACE_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total);
|
||||
memcpy(buf + w_cnt_total, line, w_cnt);
|
||||
w_cnt_total += w_cnt;
|
||||
@ -417,6 +433,16 @@ bool config_save(const config_t *config, const char *filename)
|
||||
const entry_t *entry = (const entry_t *)list_node(enode);
|
||||
OSI_TRACE_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value);
|
||||
w_cnt = snprintf(line, 1024, "%s = %s\n", entry->key, entry->value);
|
||||
if(w_cnt < 0) {
|
||||
OSI_TRACE_ERROR("snprintf error w_cnt %d.",w_cnt);
|
||||
err_code |= 0x10;
|
||||
goto error;
|
||||
}
|
||||
if(w_cnt_total + w_cnt > config_size) {
|
||||
OSI_TRACE_ERROR("%s, memcpy size (w_cnt + w_cnt_total = %d) is larger than buffer size.(config_size = %d)", __func__, (w_cnt + w_cnt_total), config_size);
|
||||
err_code |= 0x20;
|
||||
goto error;
|
||||
}
|
||||
OSI_TRACE_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total);
|
||||
memcpy(buf + w_cnt_total, line, w_cnt);
|
||||
w_cnt_total += w_cnt;
|
||||
@ -524,7 +550,10 @@ static void config_parse(nvs_handle_t fp, config_t *config)
|
||||
const size_t keyname_bufsz = sizeof(CONFIG_KEY) + 5 + 1; // including log10(sizeof(i))
|
||||
char *keyname = osi_calloc(keyname_bufsz);
|
||||
int buf_size = get_config_size_from_flash(fp);
|
||||
char *buf = osi_calloc(buf_size + 100);
|
||||
char *buf = osi_calloc(buf_size);
|
||||
if(buf_size == 0) { //First use nvs
|
||||
goto error;
|
||||
}
|
||||
if (!line || !section || !buf || !keyname) {
|
||||
err_code |= 0x01;
|
||||
goto error;
|
||||
|
@ -129,6 +129,8 @@ size_t fixed_queue_capacity(fixed_queue_t *queue)
|
||||
|
||||
bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
|
||||
{
|
||||
bool status=false; //Flag whether enqueued success
|
||||
|
||||
assert(queue != NULL);
|
||||
assert(data != NULL);
|
||||
|
||||
@ -137,13 +139,13 @@ bool fixed_queue_enqueue(fixed_queue_t *queue, void *data, uint32_t timeout)
|
||||
}
|
||||
|
||||
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
|
||||
list_append(queue->list, data);
|
||||
status = list_append(queue->list, data); //Check whether enqueued success
|
||||
osi_mutex_unlock(&queue->lock);
|
||||
|
||||
osi_sem_give(&queue->dequeue_sem);
|
||||
if(status == true )
|
||||
osi_sem_give(&queue->dequeue_sem);
|
||||
|
||||
return true;
|
||||
return status;
|
||||
}
|
||||
|
||||
void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
|
||||
@ -152,7 +154,7 @@ void *fixed_queue_dequeue(fixed_queue_t *queue, uint32_t timeout)
|
||||
|
||||
assert(queue != NULL);
|
||||
|
||||
if (osi_sem_take(queue->dequeue_sem, timeout) != 0) {
|
||||
if (osi_sem_take(&queue->dequeue_sem, timeout) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -206,14 +208,14 @@ void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data)
|
||||
|
||||
osi_mutex_lock(&queue->lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
if (list_contains(queue->list, data) &&
|
||||
osi_sem_take(queue->dequeue_sem, 0) == 0) {
|
||||
osi_sem_take(&queue->dequeue_sem, 0) == 0) {
|
||||
removed = list_remove(queue->list, data);
|
||||
assert(removed);
|
||||
}
|
||||
osi_mutex_unlock(&queue->lock);
|
||||
|
||||
if (removed) {
|
||||
osi_sem_give(queue->enqueue_sem);
|
||||
osi_sem_give(&queue->enqueue_sem);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ bool list_insert_after(list_t *list, list_node_t *prev_node, void *data) {
|
||||
assert(data != NULL);
|
||||
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
|
||||
if (!node) {
|
||||
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
node->next = prev_node->next;
|
||||
@ -120,6 +121,7 @@ bool list_prepend(list_t *list, void *data)
|
||||
assert(data != NULL);
|
||||
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
|
||||
if (!node) {
|
||||
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
node->next = list->head;
|
||||
@ -138,6 +140,7 @@ bool list_append(list_t *list, void *data)
|
||||
assert(data != NULL);
|
||||
list_node_t *node = (list_node_t *)osi_calloc(sizeof(list_node_t));
|
||||
if (!node) {
|
||||
OSI_TRACE_ERROR("%s osi_calloc failed.\n", __FUNCTION__ );
|
||||
return false;
|
||||
}
|
||||
node->next = NULL;
|
||||
|
@ -129,28 +129,41 @@ COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
|
||||
COMPONENT_SRCDIRS += common/osi \
|
||||
common/btc/core
|
||||
|
||||
ifdef CONFIG_BLE_MESH
|
||||
|
||||
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core/bluedroid_host
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef CONFIG_BLE_MESH
|
||||
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/include \
|
||||
esp_ble_mesh/mesh_core/settings \
|
||||
esp_ble_mesh/btc/include \
|
||||
esp_ble_mesh/mesh_models/include \
|
||||
esp_ble_mesh/api/core/include \
|
||||
esp_ble_mesh/api/models/include \
|
||||
esp_ble_mesh/api
|
||||
COMPONENT_ADD_INCLUDEDIRS += esp_ble_mesh/mesh_common/include \
|
||||
esp_ble_mesh/mesh_common/tinycrypt/include \
|
||||
esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/include \
|
||||
esp_ble_mesh/mesh_core/storage \
|
||||
esp_ble_mesh/btc/include \
|
||||
esp_ble_mesh/mesh_models/common/include \
|
||||
esp_ble_mesh/mesh_models/client/include \
|
||||
esp_ble_mesh/mesh_models/server/include \
|
||||
esp_ble_mesh/api/core/include \
|
||||
esp_ble_mesh/api/models/include \
|
||||
esp_ble_mesh/api
|
||||
|
||||
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/settings \
|
||||
esp_ble_mesh/btc \
|
||||
esp_ble_mesh/mesh_models \
|
||||
esp_ble_mesh/api/core \
|
||||
esp_ble_mesh/api/models
|
||||
COMPONENT_SRCDIRS += esp_ble_mesh/mesh_common \
|
||||
esp_ble_mesh/mesh_common/tinycrypt/src \
|
||||
esp_ble_mesh/mesh_core \
|
||||
esp_ble_mesh/mesh_core/storage \
|
||||
esp_ble_mesh/btc \
|
||||
esp_ble_mesh/mesh_models/client \
|
||||
esp_ble_mesh/mesh_models/server \
|
||||
esp_ble_mesh/api/core \
|
||||
esp_ble_mesh/api/models
|
||||
endif
|
||||
|
||||
|
||||
ifdef CONFIG_BT_NIMBLE_ENABLED
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include \
|
||||
host/nimble/nimble/nimble/host/include \
|
||||
host/nimble/nimble/porting/nimble/include \
|
||||
@ -165,14 +178,16 @@ COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/include
|
||||
host/nimble/nimble/nimble/host/util/include \
|
||||
host/nimble/nimble/nimble/host/store/ram/include \
|
||||
host/nimble/nimble/nimble/host/store/config/include \
|
||||
host/nimble/nimble/ext/tinycrypt/include \
|
||||
host/nimble/esp-hci/include \
|
||||
host/nimble/port/include
|
||||
|
||||
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
|
||||
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/ext/tinycrypt/include
|
||||
endif
|
||||
|
||||
COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src \
|
||||
host/nimble/nimble/porting/nimble/src \
|
||||
host/nimble/nimble/porting/npl/freertos/src \
|
||||
host/nimble/nimble/ext/tinycrypt/src \
|
||||
host/nimble/nimble/nimble/host/services/ans/src \
|
||||
host/nimble/nimble/nimble/host/services/bas/src \
|
||||
host/nimble/nimble/nimble/host/services/gap/src \
|
||||
@ -183,10 +198,26 @@ COMPONENT_SRCDIRS += host/nimble/nimble/nimble/host/src
|
||||
host/nimble/nimble/nimble/host/util/src \
|
||||
host/nimble/nimble/nimble/host/store/ram/src \
|
||||
host/nimble/nimble/nimble/host/store/config/src \
|
||||
host/nimble/esp-hci/src
|
||||
host/nimble/esp-hci/src \
|
||||
host/nimble/port/src
|
||||
|
||||
ifndef CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS
|
||||
COMPONENT_SRCDIRS += host/nimble/nimble/ext/tinycrypt/src
|
||||
endif
|
||||
|
||||
COMPONENT_OBJEXCLUDE += host/nimble/nimble/nimble/host/store/config/src/ble_store_config_conf.o
|
||||
|
||||
ifdef CONFIG_BLE_MESH
|
||||
COMPONENT_PRIV_INCLUDEDIRS += common/btc/include \
|
||||
common/include
|
||||
|
||||
COMPONENT_SRCDIRS += common/osi \
|
||||
common/btc/core \
|
||||
esp_ble_mesh/mesh_core/nimble_host
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS += common/osi/include
|
||||
endif
|
||||
|
||||
ifdef CONFIG_BT_NIMBLE_MESH
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS += host/nimble/nimble/nimble/host/mesh/include
|
||||
|
@ -37,13 +37,14 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_ipc.h"
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
#include "esp32/clk.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
#include "esp_ipc.h"
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_ENABLED
|
||||
|
||||
@ -78,14 +79,6 @@
|
||||
#define BTDM_MIN_SLEEP_DURATION (12) // threshold of interval in slots to allow to fall into modem sleep
|
||||
#define BTDM_MODEM_WAKE_UP_DELAY (4) // delay in slots of modem wake up procedure, including re-enable PHY/RF
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#ifndef CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
|
||||
#define BTDM_ALLOW_LIGHT_SLEEP 1
|
||||
#else
|
||||
#define BTDM_ALLOW_LIGHT_SLEEP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BT_DEBUG(...)
|
||||
#define BT_API_CALL_CHECK(info, api_call, ret) \
|
||||
do{\
|
||||
@ -97,7 +90,7 @@ do{\
|
||||
} while(0)
|
||||
|
||||
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
|
||||
#define OSI_VERSION 0x00010001
|
||||
#define OSI_VERSION 0x00010002
|
||||
#define OSI_MAGIC_VALUE 0xFADEBEAD
|
||||
|
||||
/* SPIRAM Configuration */
|
||||
@ -174,6 +167,8 @@ struct osi_funcs_t {
|
||||
void (* _btdm_sleep_exit_phase1)(void); /* called from ISR */
|
||||
void (* _btdm_sleep_exit_phase2)(void); /* called from ISR */
|
||||
void (* _btdm_sleep_exit_phase3)(void); /* called from task */
|
||||
bool (* _coex_bt_wakeup_request)(void);
|
||||
void (* _coex_bt_wakeup_request_end)(void);
|
||||
int (* _coex_bt_request)(uint32_t event, uint32_t latency, uint32_t duration);
|
||||
int (* _coex_bt_release)(uint32_t event);
|
||||
int (* _coex_register_bt_cb)(coex_func_cb_t cb);
|
||||
@ -203,7 +198,8 @@ extern void btdm_controller_enable_sleep(bool enable);
|
||||
extern void btdm_controller_set_sleep_mode(uint8_t mode);
|
||||
extern uint8_t btdm_controller_get_sleep_mode(void);
|
||||
extern bool btdm_power_state_active(void);
|
||||
extern void btdm_wakeup_request(void);
|
||||
extern void btdm_wakeup_request(bool request_lock);
|
||||
extern void btdm_wakeup_request_end(void);
|
||||
/* Low Power Clock */
|
||||
extern bool btdm_lpclk_select_src(uint32_t sel);
|
||||
extern bool btdm_lpclk_set_div(uint32_t div);
|
||||
@ -224,6 +220,7 @@ 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 char _bss_start_btdm;
|
||||
extern char _bss_end_btdm;
|
||||
@ -287,6 +284,8 @@ static void btdm_sleep_enter_phase1_wrapper(uint32_t lpcycles);
|
||||
static void btdm_sleep_enter_phase2_wrapper(void);
|
||||
static void IRAM_ATTR btdm_sleep_exit_phase1_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);
|
||||
|
||||
/* Local variable definition
|
||||
***************************************************************************
|
||||
@ -334,6 +333,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
|
||||
._btdm_sleep_exit_phase1 = btdm_sleep_exit_phase1_wrapper,
|
||||
._btdm_sleep_exit_phase2 = NULL,
|
||||
._btdm_sleep_exit_phase3 = btdm_sleep_exit_phase3_wrapper,
|
||||
._coex_bt_wakeup_request = coex_bt_wakeup_request,
|
||||
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
|
||||
._coex_bt_request = coex_bt_request_wrapper,
|
||||
._coex_bt_release = coex_bt_release_wrapper,
|
||||
._coex_register_bt_cb = coex_register_bt_cb_wrapper,
|
||||
@ -381,16 +382,21 @@ static DRAM_ATTR portMUX_TYPE global_int_mux = portMUX_INITIALIZER_UNLOCKED;
|
||||
static DRAM_ATTR uint32_t btdm_lpcycle_us = 0;
|
||||
static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit for btdm_lpcycle_us
|
||||
|
||||
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
// used low power clock
|
||||
static DRAM_ATTR uint8_t btdm_lpclk_sel;
|
||||
#endif /* #ifdef CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG */
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static DRAM_ATTR esp_timer_handle_t s_btdm_slp_tmr;
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
|
||||
static DRAM_ATTR QueueHandle_t s_pm_lock_sem = NULL;
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
static DRAM_ATTR bool s_btdm_allow_light_sleep;
|
||||
// pm_lock to prevent light sleep when using main crystal as Bluetooth low power clock
|
||||
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
static void btdm_slp_tmr_callback(void *arg);
|
||||
#endif
|
||||
#endif /* #ifdef CONFIG_PM_ENABLE */
|
||||
|
||||
|
||||
static inline void btdm_check_and_init_bb(void)
|
||||
{
|
||||
@ -740,7 +746,7 @@ static void task_delete_wrapper(void *task_handle)
|
||||
|
||||
static bool IRAM_ATTR is_in_isr_wrapper(void)
|
||||
{
|
||||
return (bool)xPortInIsrContext();
|
||||
return !xPortCanYield();
|
||||
}
|
||||
|
||||
static void IRAM_ATTR cause_sw_intr(void *arg)
|
||||
@ -754,18 +760,21 @@ static int IRAM_ATTR cause_sw_intr_to_core_wrapper(int core_id, int intr_no)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
cause_sw_intr((void *)intr_no);
|
||||
#else /* CONFIG_FREERTOS_UNICORE */
|
||||
if (xPortGetCoreID() == core_id) {
|
||||
cause_sw_intr((void *)intr_no);
|
||||
} else {
|
||||
err = esp_ipc_call(core_id, cause_sw_intr, (void *)intr_no);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_FREERTOS_UNICORE */
|
||||
return err;
|
||||
}
|
||||
|
||||
static void *malloc_internal_wrapper(size_t size)
|
||||
{
|
||||
return heap_caps_malloc(size, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL);
|
||||
return heap_caps_malloc(size, MALLOC_CAP_8BIT|MALLOC_CAP_DMA|MALLOC_CAP_INTERNAL);
|
||||
}
|
||||
|
||||
static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
|
||||
@ -886,13 +895,26 @@ static void IRAM_ATTR btdm_slp_tmr_callback(void *arg)
|
||||
}
|
||||
#endif
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
{
|
||||
return API_vhci_host_check_send_available();
|
||||
}
|
||||
#define BTDM_ASYNC_WAKEUP_REQ_HCI 0
|
||||
#define BTDM_ASYNC_WAKEUP_REQ_COEX 1
|
||||
#define BTDM_ASYNC_WAKEUP_REQMAX 2
|
||||
|
||||
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
static bool async_wakeup_request(int event)
|
||||
{
|
||||
bool request_lock = false;
|
||||
switch (event) {
|
||||
case BTDM_ASYNC_WAKEUP_REQ_HCI:
|
||||
request_lock = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
request_lock = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool do_wakeup_request = false;
|
||||
|
||||
if (!btdm_power_state_active()) {
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (semphr_take_wrapper(s_pm_lock_sem, 0)) {
|
||||
@ -900,9 +922,59 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
}
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
#endif
|
||||
btdm_wakeup_request();
|
||||
do_wakeup_request = true;
|
||||
btdm_wakeup_request(request_lock);
|
||||
}
|
||||
|
||||
return do_wakeup_request;
|
||||
}
|
||||
|
||||
static void async_wakeup_request_end(int event)
|
||||
{
|
||||
bool request_lock = false;
|
||||
switch (event) {
|
||||
case BTDM_ASYNC_WAKEUP_REQ_HCI:
|
||||
request_lock = true;
|
||||
break;
|
||||
case BTDM_ASYNC_WAKEUP_REQ_COEX:
|
||||
request_lock = false;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (request_lock) {
|
||||
btdm_wakeup_request_end();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static bool coex_bt_wakeup_request(void)
|
||||
{
|
||||
return async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
}
|
||||
|
||||
static void coex_bt_wakeup_request_end(void)
|
||||
{
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_COEX);
|
||||
return;
|
||||
}
|
||||
|
||||
bool esp_vhci_host_check_send_available(void)
|
||||
{
|
||||
return API_vhci_host_check_send_available();
|
||||
}
|
||||
|
||||
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
{
|
||||
bool do_wakeup_request = async_wakeup_request(BTDM_ASYNC_WAKEUP_REQ_HCI);
|
||||
|
||||
API_vhci_host_send_packet(data, len);
|
||||
|
||||
if (do_wakeup_request) {
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
|
||||
@ -961,7 +1033,7 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end)
|
||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||
{
|
||||
bool update = true;
|
||||
intptr_t mem_start, mem_end;
|
||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||
|
||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@ -1119,12 +1191,67 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
memset(btdm_queue_table, 0, sizeof(btdm_queue_item_t) * BTDM_MAX_QUEUE_NUM);
|
||||
#endif
|
||||
|
||||
btdm_controller_mem_init();
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
goto error;
|
||||
s_btdm_allow_light_sleep = false;
|
||||
#endif
|
||||
|
||||
// set default sleep clock cycle and its fractional bits
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
|
||||
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#if CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
|
||||
// check whether or not EXT_CRYS is working
|
||||
if (rtc_clk_slow_freq_get() == RTC_SLOW_FREQ_32K_XTAL) {
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // set default value
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
s_btdm_allow_light_sleep = true;
|
||||
#endif
|
||||
} else {
|
||||
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
|
||||
"light sleep mode will not be able to apply when bluetooth is enabled");
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
}
|
||||
#else
|
||||
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
|
||||
#endif
|
||||
|
||||
bool select_src_ret, set_div_ret;
|
||||
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
}
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
|
||||
|
||||
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
|
||||
#else
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
|
||||
goto error;
|
||||
}
|
||||
@ -1144,37 +1271,6 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
|
||||
}
|
||||
#endif
|
||||
|
||||
btdm_controller_mem_init();
|
||||
|
||||
periph_module_enable(PERIPH_BT_MODULE);
|
||||
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 32 << btdm_lpcycle_us_frac;
|
||||
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
|
||||
bool select_src_ret = false;
|
||||
bool set_div_ret = false;
|
||||
#if CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
|
||||
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 - 1);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
|
||||
#elif CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
|
||||
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
|
||||
set_div_ret = btdm_lpclk_set_div(0);
|
||||
assert(select_src_ret && set_div_ret);
|
||||
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
|
||||
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
|
||||
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
|
||||
assert(btdm_lpcycle_us != 0);
|
||||
#endif // CONFIG_BTDM_LPCLK_SEL_XX
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
|
||||
#elif CONFIG_BTDM_MODEM_SLEEP_MODE_EVED
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
|
||||
#else
|
||||
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
|
||||
#endif
|
||||
|
||||
btdm_cfg_mask = btdm_config_mask_load();
|
||||
|
||||
if (btdm_controller_init(btdm_cfg_mask, cfg) != 0) {
|
||||
@ -1182,18 +1278,24 @@ 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;
|
||||
|
||||
error:
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
if (s_light_sleep_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if (s_pm_lock != NULL) {
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
@ -1221,10 +1323,10 @@ esp_err_t esp_bt_controller_deinit(void)
|
||||
periph_module_disable(PERIPH_BT_MODULE);
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_delete(s_light_sleep_pm_lock);
|
||||
s_light_sleep_pm_lock = NULL;
|
||||
}
|
||||
esp_pm_lock_delete(s_pm_lock);
|
||||
s_pm_lock = NULL;
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
@ -1265,9 +1367,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
esp_pm_lock_acquire(s_light_sleep_pm_lock);
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_acquire(s_light_sleep_pm_lock);
|
||||
}
|
||||
esp_pm_lock_acquire(s_pm_lock);
|
||||
#endif
|
||||
|
||||
@ -1305,9 +1407,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
}
|
||||
esp_phy_rf_deinit(PHY_BT_MODULE);
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
}
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@ -1328,7 +1430,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
|
||||
btdm_controller_enable_sleep(false);
|
||||
if (!btdm_power_state_active()) {
|
||||
btdm_wakeup_request();
|
||||
btdm_wakeup_request(false);
|
||||
}
|
||||
while (!btdm_power_state_active()) {
|
||||
ets_delay_us(1000);
|
||||
@ -1348,9 +1450,9 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
#if !BTDM_ALLOW_LIGHT_SLEEP
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
#endif /* #if !BTDM_ALLOW_LIGHT_SLEEP */
|
||||
if (!s_btdm_allow_light_sleep) {
|
||||
esp_pm_lock_release(s_light_sleep_pm_lock);
|
||||
}
|
||||
esp_pm_lock_release(s_pm_lock);
|
||||
#endif
|
||||
|
||||
@ -1466,7 +1568,7 @@ void esp_bt_controller_wakeup_request(void)
|
||||
return;
|
||||
}
|
||||
|
||||
btdm_wakeup_request();
|
||||
btdm_wakeup_request(false);
|
||||
}
|
||||
|
||||
esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)
|
||||
|
Submodule components/bt/controller/lib updated: cc2fd1177d...6cd3e6546e
@ -8,12 +8,75 @@ if BLE_MESH
|
||||
|
||||
config BLE_MESH_USE_DUPLICATE_SCAN
|
||||
bool "Support Duplicate Scan in BLE Mesh"
|
||||
select BLE_SCAN_DUPLICATE
|
||||
select BLE_MESH_SCAN_DUPLICATE_EN
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
select BTDM_BLE_SCAN_DUPL
|
||||
select BTDM_BLE_MESH_SCAN_DUPL_EN
|
||||
default y
|
||||
help
|
||||
Enable this option to allow using specific duplicate scan filter
|
||||
in BLE Mesh, and Scan Duplicate Type must be set to 0x02.
|
||||
in BLE Mesh, and Scan Duplicate Type must be set by choosing the
|
||||
option in the Bluetooth Controller section in menuconfig, which is
|
||||
"Scan Duplicate By Device Address and Advertising Data".
|
||||
|
||||
choice BLE_MESH_MEM_ALLOC_MODE
|
||||
prompt "Memory allocation strategy"
|
||||
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
help
|
||||
Allocation strategy for BLE Mesh stack, essentially provides ability to
|
||||
allocate all required dynamic allocations from,
|
||||
|
||||
- Internal DRAM memory only
|
||||
- External SPIRAM memory only
|
||||
- Either internal or external memory based on default malloc()
|
||||
behavior in ESP-IDF
|
||||
|
||||
Recommended mode here is always internal, since that is most preferred
|
||||
from security perspective. But if application requirement does not allow
|
||||
sufficient free internal memory then alternate mode can be selected.
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
bool "Internal DRAM"
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_EXTERNAL
|
||||
bool "External SPIRAM"
|
||||
depends on ESP32_SPIRAM_SUPPORT
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
|
||||
bool "Default alloc mode"
|
||||
depends on ESP32_SPIRAM_SUPPORT
|
||||
help
|
||||
Enable this option to use the default memory allocation strategy when
|
||||
external SPIRAM is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_MEM_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
bool "Enable FreeRTOS static allocation"
|
||||
depends on FREERTOS_SUPPORT_STATIC_ALLOCATION && ESP32_SPIRAM_SUPPORT
|
||||
default n
|
||||
help
|
||||
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
|
||||
which provides the ability to use different dynamic memory (i.e. SPIRAM)
|
||||
for FreeRTOS objects.
|
||||
If this option is disabled, the FreeRTOS static allocation APIs will not
|
||||
be used, and internal DRAM will be allocated for FreeRTOS objects.
|
||||
|
||||
choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
prompt "Memory allocation for FreeRTOS objects"
|
||||
depends on BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
help
|
||||
Choose the memory to be used for FreeRTOS objects.
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
bool "External SPIRAM"
|
||||
depends on ESP32_SPIRAM_SUPPORT
|
||||
help
|
||||
If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for
|
||||
FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM
|
||||
can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
@ -23,75 +86,90 @@ if BLE_MESH
|
||||
default n
|
||||
help
|
||||
Enable this option to allow BLE Mesh fast provisioning solution to be used.
|
||||
When there are multiple unprovisioned devices around, fast provisioning can
|
||||
greatly reduce the time consumption of the whole provisioning process.
|
||||
When this option is enabled, and after an unprovisioned device is provisioned
|
||||
into a node successfully, it can be changed to a temporary Provisioner.
|
||||
|
||||
config BLE_MESH_NODE
|
||||
bool "Support for BLE Mesh Node"
|
||||
help
|
||||
Enable the device to be provisioned into a node.
|
||||
Enable the device to be provisioned into a node. This option should be
|
||||
enabled when an unprovisioned device is going to be provisioned into a
|
||||
node and communicate with other nodes in the BLE Mesh network.
|
||||
|
||||
config BLE_MESH_PROVISIONER
|
||||
bool "Support for BLE Mesh Provisioner"
|
||||
help
|
||||
Enable the device to be a provisioner.
|
||||
Enable the device to be a Provisioner. The option should be enabled when
|
||||
a device is going to act as a Provisioner and provision unprovisioned
|
||||
devices into the BLE Mesh network.
|
||||
|
||||
if BLE_MESH_PROVISIONER
|
||||
|
||||
config BLE_MESH_WAIT_FOR_PROV_MAX_DEV_NUM
|
||||
int "Maximum number of unprovisioned devices that can be added to device queue"
|
||||
default 20
|
||||
default 10
|
||||
range 1 100
|
||||
help
|
||||
This option specifies how may unprovisioned devices can be added to device
|
||||
queue for provisioning.
|
||||
|
||||
config BLE_MESH_MAX_STORED_NODES
|
||||
int "Maximum number of nodes whose information can be stored"
|
||||
default 20
|
||||
range 1 1000
|
||||
help
|
||||
This option specifies the maximum number of nodes whose information can be
|
||||
stored by a provisioner in its upper layer.
|
||||
This option specifies how many unprovisioned devices can be added to device
|
||||
queue for provisioning. Users can use this option to define the size of the
|
||||
queue in the bottom layer which is used to store unprovisioned device
|
||||
information (e.g. Device UUID, address).
|
||||
|
||||
config BLE_MESH_MAX_PROV_NODES
|
||||
int "Maximum number of devices that can be provisioned by provisioner"
|
||||
default 20
|
||||
range 1 100
|
||||
int "Maximum number of devices that can be provisioned by Provisioner"
|
||||
default 10
|
||||
range 1 1000
|
||||
help
|
||||
This option specifies how many devices can be provisioned by provisioner.
|
||||
This option specifies how many devices can be provisioned by a Provisioner.
|
||||
This value indicates the maximum number of unprovisioned devices which can be
|
||||
provisioned by a Provisioner. For instance, if the value is 6, it means the
|
||||
Provisioner can provision up to 6 unprovisioned devices.
|
||||
Theoretically a Provisioner without the limitation of its memory can provision
|
||||
up to 32766 unprovisioned devices, here we limit the maximum number to 100
|
||||
just to limit the memory used by a Provisioner. The bigger the value is, the
|
||||
more memory it will cost by a Provisioner to store the information of nodes.
|
||||
|
||||
if BLE_MESH_PB_ADV
|
||||
config BLE_MESH_PBA_SAME_TIME
|
||||
int "Maximum number of PB-ADV running at the same time by provisioner"
|
||||
int "Maximum number of PB-ADV running at the same time by Provisioner"
|
||||
default 2
|
||||
range 1 10
|
||||
help
|
||||
This option specifies how many devices can be provisioned at the same
|
||||
time using PB-ADV.
|
||||
This option specifies how many devices can be provisioned at the same time
|
||||
using PB-ADV. For examples, if the value is 2, it means a Provisioner can
|
||||
provision two unprovisioned devices with PB-ADV at the same time.
|
||||
|
||||
endif # BLE_MESH_PB_ADV
|
||||
|
||||
if BLE_MESH_PB_GATT
|
||||
config BLE_MESH_PBG_SAME_TIME
|
||||
int "Maximum number of PB-GATT running at the same time by provisioner"
|
||||
int "Maximum number of PB-GATT running at the same time by Provisioner"
|
||||
default 1
|
||||
range 1 5
|
||||
help
|
||||
This option specifies how many devices can be provisioned at the same
|
||||
time using PB-GATT.
|
||||
time using PB-GATT. For example, if the value is 2, it means a Provisioner
|
||||
can provision two unprovisioned devices with PB-GATT at the same time.
|
||||
|
||||
endif # BLE_MESH_PB_GATT
|
||||
|
||||
config BLE_MESH_PROVISIONER_SUBNET_COUNT
|
||||
int "Maximum number of mesh subnets that can be created by provisioner"
|
||||
int "Maximum number of mesh subnets that can be created by Provisioner"
|
||||
default 3
|
||||
range 1 4096
|
||||
help
|
||||
This option specifies how many subnets per network a provisioner can create.
|
||||
This option specifies how many subnets per network a Provisioner can create.
|
||||
Indeed, this value decides the number of network keys which can be added by a Provisioner.
|
||||
|
||||
config BLE_MESH_PROVISIONER_APP_KEY_COUNT
|
||||
int "Maximum number of application keys that can be owned by provisioner"
|
||||
default 9
|
||||
int "Maximum number of application keys that can be owned by Provisioner"
|
||||
default 3
|
||||
range 1 4096
|
||||
help
|
||||
This option specifies how many application keys the provisioner can have.
|
||||
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.
|
||||
|
||||
endif # BLE_MESH_PROVISIONER
|
||||
|
||||
@ -109,7 +187,8 @@ if BLE_MESH
|
||||
default y
|
||||
help
|
||||
Enable this option to allow the device to be provisioned over the
|
||||
advertising bearer.
|
||||
advertising bearer. This option should be enabled if PB-ADV is
|
||||
going to be used during provisioning procedure.
|
||||
|
||||
config BLE_MESH_PB_GATT
|
||||
bool "Provisioning support using GATT (PB-GATT)"
|
||||
@ -117,6 +196,8 @@ if BLE_MESH
|
||||
select BLE_MESH_PROV
|
||||
help
|
||||
Enable this option to allow the device to be provisioned over GATT.
|
||||
This option should be enabled if PB-GATT is going to be used during
|
||||
provisioning procedure.
|
||||
|
||||
# Virtual option enabled whenever any Proxy protocol is needed
|
||||
config BLE_MESH_PROXY
|
||||
@ -126,16 +207,19 @@ if BLE_MESH
|
||||
Enable this option to support BLE Mesh Proxy protocol used by PB-GATT
|
||||
and other proxy pdu transmission.
|
||||
|
||||
config BLE_MESH_GATT_PROXY
|
||||
bool "BLE Mesh GATT Proxy Service"
|
||||
config BLE_MESH_GATT_PROXY_SERVER
|
||||
bool "BLE Mesh GATT Proxy Server"
|
||||
select BLE_MESH_PROXY
|
||||
depends on BLE_MESH_NODE
|
||||
default y
|
||||
help
|
||||
This option enables support for Mesh GATT Proxy Service, i.e. the
|
||||
ability to act as a proxy between a Mesh GATT Client and a Mesh network.
|
||||
This option should be enabled if a node is going to be a Proxy Server.
|
||||
|
||||
config BLE_MESH_NODE_ID_TIMEOUT
|
||||
int "Node Identity advertising timeout"
|
||||
depends on BLE_MESH_GATT_PROXY
|
||||
depends on BLE_MESH_GATT_PROXY_SERVER
|
||||
range 1 60
|
||||
default 60
|
||||
help
|
||||
@ -143,34 +227,75 @@ if BLE_MESH
|
||||
Node Identity. The given value is in seconds. The specification limits
|
||||
this to 60 seconds and lists it as the recommended value as well.
|
||||
So leaving the default value is the safest option.
|
||||
When an unprovisioned device is provisioned successfully and becomes a
|
||||
node, it will start to advertise using Node Identity during the time
|
||||
set by this option. And after that, Network ID will be advertised.
|
||||
|
||||
if BLE_MESH_PROXY
|
||||
config BLE_MESH_PROXY_FILTER_SIZE
|
||||
int "Maximum number of filter entries per Proxy Client"
|
||||
depends on BLE_MESH_GATT_PROXY_SERVER
|
||||
default 4
|
||||
range 1 32767
|
||||
help
|
||||
This option specifies how many Proxy Filter entries the local node supports.
|
||||
The entries of Proxy filter (whitelist or blacklist) are used to store a
|
||||
list of addresses which can be used to decide which messages will be forwarded
|
||||
to the Proxy Client by the Proxy Server.
|
||||
|
||||
config BLE_MESH_PROXY_FILTER_SIZE
|
||||
int "Maximum number of filter entries per Proxy Client"
|
||||
default 1
|
||||
default 3 if BLE_MESH_GATT_PROXY
|
||||
range 1 32767
|
||||
help
|
||||
This option specifies how many Proxy Filter entries the local node supports.
|
||||
|
||||
endif # BLE_MESH_PROXY
|
||||
config BLE_MESH_GATT_PROXY_CLIENT
|
||||
bool "BLE Mesh GATT Proxy Client"
|
||||
select BLE_MESH_PROXY
|
||||
default n
|
||||
help
|
||||
This option enables support for Mesh GATT Proxy Client. The Proxy Client
|
||||
can use the GATT bearer to send mesh messages to a node that supports the
|
||||
advertising bearer.
|
||||
|
||||
config BLE_MESH_NET_BUF_POOL_USAGE
|
||||
bool "BLE Mesh net buffer pool usage tracking"
|
||||
default y
|
||||
help
|
||||
Enable BLE Mesh net buffer pool tracking.
|
||||
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
|
||||
variable in the bottom layer to record the usage of advertising buffers of BLE Mesh
|
||||
devices. Recommend to enable this option as default.
|
||||
|
||||
config BLE_MESH_SETTINGS
|
||||
bool "Store BLE Mesh Node configuration persistently"
|
||||
bool "Store BLE Mesh configuration persistently"
|
||||
default n
|
||||
help
|
||||
When selected, the BLE Mesh stack will take care of storing/restoring the
|
||||
BLE Mesh configuration persistently in flash. Currently this only supports
|
||||
storing BLE Mesh node configuration.
|
||||
When selected, the BLE Mesh stack will take care of storing/restoring the BLE
|
||||
Mesh configuration persistently in flash.
|
||||
If the device is a BLE Mesh node, when this option is enabled, the configuration
|
||||
of the device will be stored persistently, including unicast address, NetKey,
|
||||
AppKey, etc.
|
||||
And if the device is a BLE Mesh Provisioner, the information of the device will
|
||||
be stored persistently, including the information of provisioned nodes, NetKey,
|
||||
AppKey, etc.
|
||||
|
||||
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
|
||||
@ -178,11 +303,14 @@ if BLE_MESH
|
||||
help
|
||||
This value defines in seconds how soon any pending changes are actually
|
||||
written into persistent storage (flash) after a change occurs.
|
||||
The option allows nodes to delay a certain period of time to save proper
|
||||
information to flash. The default value is 0, which means information
|
||||
will be stored immediately once there are updates.
|
||||
|
||||
config BLE_MESH_SEQ_STORE_RATE
|
||||
int "How often the sequence number gets updated in storage"
|
||||
range 0 1000000
|
||||
default 128
|
||||
default 6
|
||||
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
|
||||
@ -199,16 +327,40 @@ if BLE_MESH
|
||||
range 0 1000000
|
||||
default 5
|
||||
help
|
||||
This value defines in seconds how soon the RPL(Replay Protection List)
|
||||
This value defines in seconds how soon the RPL (Replay Protection List)
|
||||
gets written to persistent storage after a change occurs. If the node
|
||||
receives messages frequently, then a large value is recommended. If the
|
||||
node receives messages rarely, then the value can be as low as 0 (which
|
||||
means the PRL is written into the storage immediately).
|
||||
means the RPL is written into the storage immediately).
|
||||
Note that if the node operates in a security-sensitive case, and there is
|
||||
a risk of sudden power-off, then a value of 0 is strongly recommended.
|
||||
Otherwise, a power loss before RPL being written into the storage may
|
||||
introduce message replay attacks and system security will be in a
|
||||
vulnerable state.
|
||||
|
||||
config BLE_MESH_SETTINGS_BACKWARD_COMPATIBILITY
|
||||
bool "A specific option for settings backward compatibility"
|
||||
depends on BLE_MESH_NODE
|
||||
default n
|
||||
help
|
||||
This option is created to solve the issue of failure in recovering
|
||||
node information after mesh stack updates. In the old version mesh
|
||||
stack, there is no key of "mesh/role" in nvs. In the new version
|
||||
mesh stack, key of "mesh/role" is added in nvs, recovering node
|
||||
information needs to check "mesh/role" key in nvs and implements
|
||||
selective recovery of mesh node information. Therefore, there may
|
||||
be failure in recovering node information during node restarting
|
||||
after OTA.
|
||||
|
||||
The new version mesh stack adds the option of "mesh/role" because
|
||||
we have added the support of storing Provisioner information, while
|
||||
the old version only supports storing node information.
|
||||
|
||||
If users are updating their nodes from old version to new version,
|
||||
we recommend enabling this option, so that system could set the flag
|
||||
in advance before recovering node information and make sure the node
|
||||
information recovering could work as expected.
|
||||
|
||||
endif # if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SUBNET_COUNT
|
||||
@ -217,6 +369,7 @@ if BLE_MESH
|
||||
range 1 4096
|
||||
help
|
||||
This option specifies how many subnets a Mesh network can have at the same time.
|
||||
Indeed, this value decides the number of the network keys which can be owned by a node.
|
||||
|
||||
config BLE_MESH_APP_KEY_COUNT
|
||||
int "Maximum number of application keys per network"
|
||||
@ -224,6 +377,7 @@ if BLE_MESH
|
||||
range 1 4096
|
||||
help
|
||||
This option specifies how many application keys the device can store per network.
|
||||
Indeed, this value decides the number of the application keys which can be owned by a node.
|
||||
|
||||
config BLE_MESH_MODEL_KEY_COUNT
|
||||
int "Maximum number of application keys per model"
|
||||
@ -247,6 +401,7 @@ if BLE_MESH
|
||||
range 0 4096
|
||||
help
|
||||
This option specifies how many Label UUIDs can be stored.
|
||||
Indeed, this value decides the number of the Virtual Addresses can be supported by a node.
|
||||
|
||||
config BLE_MESH_CRPL
|
||||
int "Maximum capacity of the replay protection list"
|
||||
@ -255,6 +410,14 @@ if BLE_MESH
|
||||
help
|
||||
This option specifies the maximum capacity of the replay protection list.
|
||||
It is similar to Network message cache size, but has a different purpose.
|
||||
The replay protection list is used to prevent a node from replay attack,
|
||||
which will store the source address and sequence number of the received
|
||||
mesh messages.
|
||||
For Provisioner, the replay protection list size should not be smaller than
|
||||
the maximum number of nodes whose information can be stored. And the element
|
||||
number of each node should also be taken into consideration. For example, if
|
||||
Provisioner can provision up to 20 nodes and each node contains two elements,
|
||||
then the replay protection list size of Provisioner should be at least 40.
|
||||
|
||||
config BLE_MESH_MSG_CACHE_SIZE
|
||||
int "Network message cache size"
|
||||
@ -264,6 +427,8 @@ if BLE_MESH
|
||||
Number of messages that are cached for the network. This helps prevent
|
||||
unnecessary decryption operations and unnecessary relays. This option
|
||||
is similar to Replay protection list, but has a different purpose.
|
||||
A node is not required to cache the entire Network PDU and may cache
|
||||
only part of it for tracking, such as values for SRC/SEQ or others.
|
||||
|
||||
config BLE_MESH_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers"
|
||||
@ -277,6 +442,24 @@ 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
|
||||
@ -309,6 +492,11 @@ if BLE_MESH
|
||||
range 1 BLE_MESH_ADV_BUF_COUNT
|
||||
help
|
||||
Maximum number of simultaneous outgoing multi-segment and/or reliable messages.
|
||||
The default value is 1, which means the device can only send one segmented
|
||||
message at a time. And if another segmented message is going to be sent, it
|
||||
should wait for the completion of the previous one.
|
||||
If users are going to send multiple segmented messages at the same time, this
|
||||
value should be configured properly.
|
||||
|
||||
config BLE_MESH_RX_SEG_MSG_COUNT
|
||||
int "Maximum number of simultaneous incoming segmented messages"
|
||||
@ -316,6 +504,11 @@ if BLE_MESH
|
||||
range 1 255
|
||||
help
|
||||
Maximum number of simultaneous incoming multi-segment and/or reliable messages.
|
||||
The default value is 1, which means the device can only receive one segmented
|
||||
message at a time. And if another segmented message is going to be received,
|
||||
it should wait for the completion of the previous one.
|
||||
If users are going to receive multiple segmented messages at the same time, this
|
||||
value should be configured properly.
|
||||
|
||||
config BLE_MESH_RX_SDU_MAX
|
||||
int "Maximum incoming Upper Transport Access PDU length"
|
||||
@ -327,7 +520,7 @@ if BLE_MESH
|
||||
|
||||
config BLE_MESH_TX_SEG_MAX
|
||||
int "Maximum number of segments in outgoing messages"
|
||||
default 20
|
||||
default 32
|
||||
range 2 32
|
||||
help
|
||||
Maximum number of segments supported for outgoing messages.
|
||||
@ -351,32 +544,69 @@ if BLE_MESH
|
||||
|
||||
config BLE_MESH_RELAY
|
||||
bool "Relay support"
|
||||
depends on BLE_MESH_NODE
|
||||
default y
|
||||
help
|
||||
Support for acting as a Mesh Relay Node.
|
||||
Support for acting as a Mesh Relay Node. Enabling this option will allow
|
||||
a node to support the Relay feature, and the Relay feature can still
|
||||
be enabled or disabled by proper configuration messages. Disabling this
|
||||
option will let a node not support the Relay feature.
|
||||
|
||||
if BLE_MESH_RELAY
|
||||
|
||||
config BLE_MESH_RELAY_ADV_BUF
|
||||
bool "Use separate advertising buffers for relay packets"
|
||||
default n
|
||||
help
|
||||
When selected, self-send packets will be put in a high-priority
|
||||
queue and relay packets will be put in a low-priority queue.
|
||||
|
||||
if BLE_MESH_RELAY_ADV_BUF
|
||||
|
||||
config BLE_MESH_RELAY_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers for relay packets"
|
||||
default 60
|
||||
range 6 256
|
||||
help
|
||||
Number of advertising buffers for relay packets available.
|
||||
|
||||
endif # BLE_MESH_RELAY_ADV_BUF
|
||||
|
||||
endif # BLE_MESH_RELAY
|
||||
|
||||
config BLE_MESH_LOW_POWER
|
||||
bool "Support for Low Power features"
|
||||
depends on BLE_MESH_NODE
|
||||
help
|
||||
Enable this option to operate as a Low Power Node.
|
||||
Enable this option to operate as a Low Power Node. If low power consumption
|
||||
is required by a node, this option should be enabled. And once the node
|
||||
enters the mesh network, it will try to find a Friend node and establish a
|
||||
friendship.
|
||||
|
||||
if BLE_MESH_LOW_POWER
|
||||
|
||||
config BLE_MESH_LPN_ESTABLISHMENT
|
||||
bool "Perform Friendship establishment using low power"
|
||||
default y
|
||||
default n
|
||||
help
|
||||
Perform the Friendship establishment using low power with the help of a
|
||||
reduced scan duty cycle. The downside of this is that the node may miss
|
||||
out on messages intended for it until it has successfully set up Friendship
|
||||
with a Friend node.
|
||||
When this option is enabled, the node will stop scanning for a period of
|
||||
time after a Friend Request or Friend Poll is sent, so as to reduce more
|
||||
power consumption.
|
||||
|
||||
config BLE_MESH_LPN_AUTO
|
||||
bool "Automatically start looking for Friend nodes once provisioned"
|
||||
default y
|
||||
default n
|
||||
help
|
||||
Once provisioned, automatically enable LPN functionality and start looking
|
||||
for Friend nodes. If this option is disabled LPN mode needs to be manually
|
||||
enabled by calling bt_mesh_lpn_set(true).
|
||||
When an unprovisioned device is provisioned successfully and becomes a node,
|
||||
enabling this option will trigger the node starts to send Friend Request at
|
||||
a certain period until it finds a proper Friend node.
|
||||
|
||||
config BLE_MESH_LPN_AUTO_TIMEOUT
|
||||
int "Time from last received message before going to LPN mode"
|
||||
@ -389,7 +619,7 @@ if BLE_MESH
|
||||
|
||||
config BLE_MESH_LPN_RETRY_TIMEOUT
|
||||
int "Retry timeout for Friend requests"
|
||||
default 8
|
||||
default 6
|
||||
range 1 3600
|
||||
help
|
||||
Time in seconds between Friend Requests, if a previous Friend Request did
|
||||
@ -402,6 +632,8 @@ if BLE_MESH
|
||||
help
|
||||
The contribution of the RSSI, measured by the Friend node, used in Friend
|
||||
Offer Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
|
||||
RSSIFactor, one of the parameters carried by Friend Request sent by Low Power
|
||||
node, which is used to calculate the Friend Offer Delay.
|
||||
|
||||
config BLE_MESH_LPN_RECV_WIN_FACTOR
|
||||
int "ReceiveWindowFactor, used in Friend Offer Delay calculation"
|
||||
@ -410,6 +642,8 @@ if BLE_MESH
|
||||
help
|
||||
The contribution of the supported Receive Window used in Friend Offer
|
||||
Delay calculations. 0 = 1, 1 = 1.5, 2 = 2, 3 = 2.5.
|
||||
ReceiveWindowFactor, one of the parameters carried by Friend Request sent by
|
||||
Low Power node, which is used to calculate the Friend Offer Delay.
|
||||
|
||||
config BLE_MESH_LPN_MIN_QUEUE_SIZE
|
||||
int "Minimum size of the acceptable friend queue (MinQueueSizeLog)"
|
||||
@ -440,6 +674,8 @@ if BLE_MESH
|
||||
the Friend node before the PollTimeout timer expires, then the
|
||||
friendship is considered terminated. The value is in units of 100
|
||||
milliseconds, so e.g. a value of 300 means 30 seconds.
|
||||
The smaller the value, the faster the Low Power node tries to get
|
||||
messages from corresponding Friend node and vice versa.
|
||||
|
||||
config BLE_MESH_LPN_INIT_POLL_TIMEOUT
|
||||
int "The starting value of the PollTimeout timer"
|
||||
@ -467,10 +703,11 @@ if BLE_MESH
|
||||
default 8
|
||||
help
|
||||
Maximum number of groups to which the LPN can subscribe.
|
||||
|
||||
endif # BLE_MESH_LOW_POWER
|
||||
|
||||
config BLE_MESH_FRIEND
|
||||
bool "Support for acting as a Friend Node"
|
||||
bool "Support for Friend feature"
|
||||
help
|
||||
Enable this option to be able to act as a Friend Node.
|
||||
|
||||
@ -489,6 +726,8 @@ if BLE_MESH
|
||||
default 16
|
||||
help
|
||||
Minimum number of buffers available to be stored for each local Friend Queue.
|
||||
This option decides the size of each buffer which can be used by a Friend node
|
||||
to store messages for each Low Power node.
|
||||
|
||||
config BLE_MESH_FRIEND_SUB_LIST_SIZE
|
||||
int "Friend Subscription List Size"
|
||||
@ -496,7 +735,9 @@ if BLE_MESH
|
||||
default 3
|
||||
help
|
||||
Size of the Subscription List that can be supported by a Friend node for a
|
||||
Low Power node.
|
||||
Low Power node. And Low Power node can send Friend Subscription List Add or
|
||||
Friend Subscription List Remove messages to the Friend node to add or remove
|
||||
subscription addresses.
|
||||
|
||||
config BLE_MESH_FRIEND_LPN_COUNT
|
||||
int "Number of supported LPN nodes"
|
||||
@ -504,6 +745,9 @@ if BLE_MESH
|
||||
default 2
|
||||
help
|
||||
Number of Low Power Nodes with which a Friend can have Friendship simultaneously.
|
||||
A Friend node can have friendship with multiple Low Power nodes at the same time,
|
||||
while a Low Power node can only establish friendship with only one Friend node at
|
||||
the same time.
|
||||
|
||||
config BLE_MESH_FRIEND_SEG_RX
|
||||
int "Number of incomplete segment lists per LPN"
|
||||
@ -521,7 +765,8 @@ if BLE_MESH
|
||||
depends on BLE_MESH
|
||||
default n
|
||||
help
|
||||
Select this to save the BLE Mesh related rodata code size.
|
||||
Select this to save the BLE Mesh related rodata code size. Enabling this option
|
||||
will disable the output of BLE Mesh debug log.
|
||||
|
||||
menu "BLE Mesh STACK DEBUG LOG LEVEL"
|
||||
depends on BLE_MESH && !BLE_MESH_NO_LOG
|
||||
@ -597,12 +842,6 @@ if BLE_MESH
|
||||
|
||||
endmenu #BLE Mesh NET BUF DEBUG LOG LEVEL
|
||||
|
||||
config BLE_MESH_IRQ_LOCK
|
||||
bool "Used the IRQ lock instead of task lock"
|
||||
help
|
||||
To improve the real-time requirements of bt controller in BLE Mesh,
|
||||
task lock is used to replace IRQ lock.
|
||||
|
||||
config BLE_MESH_CLIENT_MSG_TIMEOUT
|
||||
int "Timeout(ms) for client message response"
|
||||
range 100 1200000
|
||||
@ -610,6 +849,10 @@ if BLE_MESH
|
||||
help
|
||||
Timeout value used by the node to get response of the acknowledged
|
||||
message which is sent by the client model.
|
||||
This value indicates the maximum time that a client model waits for
|
||||
the response of the sent acknowledged messages. If a client model
|
||||
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"
|
||||
|
||||
@ -639,9 +882,9 @@ if BLE_MESH
|
||||
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"
|
||||
@ -716,6 +959,7 @@ if BLE_MESH
|
||||
help
|
||||
This option removes the 96 hour limit of the IV Update Procedure and
|
||||
lets the state to be changed at any time.
|
||||
If IV Update test mode is going to be used, this option should be enabled.
|
||||
|
||||
menu "BLE Mesh specific test option"
|
||||
|
||||
@ -726,6 +970,26 @@ if BLE_MESH
|
||||
This option adds extra self-tests which are run every time BLE Mesh
|
||||
networking is initialized.
|
||||
|
||||
if BLE_MESH_SELF_TEST
|
||||
|
||||
config BLE_MESH_TEST_AUTO_ENTER_NETWORK
|
||||
bool "Unprovisioned device enters mesh network automatically"
|
||||
default y
|
||||
help
|
||||
With this option enabled, an unprovisioned device can automatically
|
||||
enters mesh network using a specific test function without the pro-
|
||||
visioning procedure. And on the Provisioner side, a test function
|
||||
needs to be invoked to add the node information into the mesh stack.
|
||||
|
||||
config BLE_MESH_TEST_USE_WHITE_LIST
|
||||
bool "Use white list to filter mesh advertising packets"
|
||||
default n
|
||||
help
|
||||
With this option enabled, users can use white list to filter mesh
|
||||
advertising packets while scanning.
|
||||
|
||||
endif # BLE_MESH_SELF_TEST
|
||||
|
||||
config BLE_MESH_SHELL
|
||||
bool "Enable BLE Mesh shell"
|
||||
default n
|
||||
@ -801,3 +1065,4 @@ if BLE_MESH
|
||||
endmenu
|
||||
|
||||
endif # BLE_MESH
|
||||
|
||||
|
21
components/bt/esp_ble_mesh/README.md
Normal file
21
components/bt/esp_ble_mesh/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# ESP-BLE-MESH Component
|
||||
|
||||
This is Espressif Bluetooth Low Energy Mesh component folder.
|
||||
|
||||
This component is a part of Espressif IoT Development Framework (ESP-IDF). For the latest documentation please refer to [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/index.html).
|
||||
|
||||
The ESP-BLE-MESH networking enables many-to-many (m:m) device communications and is optimized for creating large-scale device networks.
|
||||
|
||||
|
||||
### [ESP-BLE-MESH Documentation](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html)
|
||||
|
||||
- [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh)
|
||||
- [Architecture](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/arhitecture.html)
|
||||
- [Feature List](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh-feature-list.html)
|
||||
- [FAQ](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/ble_mesh_faq.html)
|
||||
- [API Reference](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/bluetooth/ble_mesh.html)
|
||||
|
||||
|
||||
### [ESP-BLE-MESH Examples](https://github.com/espressif/esp-idf/tree/master/examples/bluetooth/esp_ble_mesh)
|
||||
|
||||
- Refer to **ESP-BLE-MESH Examples** of [Getting Started](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/esp_ble_mesh/index.html##getting-started-with-ble-mesh) for the tutorials of ESP BLE Mesh examples.
|
73
components/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c
Normal file
73
components/bt/esp_ble_mesh/api/core/esp_ble_mesh_ble_api.c
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright 2017-2019 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/btc_manage.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#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_msg_t msg = {0};
|
||||
|
||||
if (param == NULL) {
|
||||
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_START_BLE_ADVERTISING;
|
||||
|
||||
memcpy(&arg.start_ble_advertising.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));
|
||||
}
|
||||
|
||||
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_stop_ble_advertising(uint8_t index)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (index >= CONFIG_BLE_MESH_BLE_ADV_BUF_COUNT) {
|
||||
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_STOP_BLE_ADVERTISING;
|
||||
|
||||
arg.stop_ble_advertising.index = index;
|
||||
|
||||
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_SUPPORT_BLE_ADV */
|
@ -17,12 +17,7 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
@ -32,16 +27,22 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
SemaphoreHandle_t semaphore = NULL;
|
||||
btc_msg_t msg = {0};
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (prov == NULL || comp == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
ret = bt_mesh_host_init();
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Create a semaphore
|
||||
if ((semaphore = xSemaphoreCreateCounting(1, 0)) == NULL) {
|
||||
LOG_ERROR("%s, Failed to allocate memory for the semaphore", __func__);
|
||||
BT_ERR("Failed to create semaphore");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
|
||||
if (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL) != BT_STATUS_SUCCESS) {
|
||||
vSemaphoreDelete(semaphore);
|
||||
LOG_ERROR("%s, BLE Mesh initialise failed", __func__);
|
||||
BT_ERR("Failed to start mesh init");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@ -68,3 +69,24 @@ esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (param == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
arg.mesh_deinit.param.erase_flash = param->erase_flash;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
msg.act = BTC_BLE_MESH_ACT_DEINIT_MESH;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
@ -13,14 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
@ -38,7 +32,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void)
|
||||
return btc_ble_mesh_get_primary_addr();
|
||||
}
|
||||
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr)
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr)
|
||||
{
|
||||
if (model == NULL) {
|
||||
return NULL;
|
||||
@ -48,6 +43,9 @@ uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
|
||||
esp_ble_mesh_elem_t *esp_ble_mesh_find_element(uint16_t element_addr)
|
||||
{
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr)) {
|
||||
return NULL;
|
||||
}
|
||||
return btc_ble_mesh_elem_find(element_addr);
|
||||
}
|
||||
|
||||
@ -57,7 +55,7 @@ uint8_t esp_ble_mesh_get_element_count(void)
|
||||
}
|
||||
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t company_id, uint16_t model_id)
|
||||
uint16_t company_id, uint16_t model_id)
|
||||
{
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
@ -65,7 +63,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
||||
return btc_ble_mesh_model_find_vnd(element, company_id, model_id);
|
||||
}
|
||||
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id)
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id)
|
||||
{
|
||||
if (element == NULL) {
|
||||
return NULL;
|
||||
@ -78,3 +77,54 @@ const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void)
|
||||
return btc_ble_mesh_comp_get();
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) ||
|
||||
!ESP_BLE_MESH_ADDR_IS_GROUP(group_addr)) {
|
||||
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_MODEL_SUBSCRIBE_GROUP_ADDR;
|
||||
|
||||
arg.model_sub_group_addr.element_addr = element_addr;
|
||||
arg.model_sub_group_addr.company_id = company_id;
|
||||
arg.model_sub_group_addr.model_id = model_id;
|
||||
arg.model_sub_group_addr.group_addr = group_addr;
|
||||
|
||||
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_model_unsubscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(element_addr) ||
|
||||
!ESP_BLE_MESH_ADDR_IS_GROUP(group_addr)) {
|
||||
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_MODEL_UNSUBSCRIBE_GROUP_ADDR;
|
||||
|
||||
arg.model_unsub_group_addr.element_addr = element_addr;
|
||||
arg.model_unsub_group_addr.company_id = company_id;
|
||||
arg.model_unsub_group_addr.model_id = model_id;
|
||||
arg.model_unsub_group_addr.group_addr = group_addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -14,13 +14,50 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_lpn_enable(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_LPN_ENABLE;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_lpn_disable(bool force)
|
||||
{
|
||||
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_LPN_DISABLE;
|
||||
|
||||
arg.lpn_disable.force = force;
|
||||
|
||||
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_lpn_poll(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_LPN_POLL;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -13,37 +13,38 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_networking_api.h"
|
||||
|
||||
#define ESP_BLE_MESH_TX_SDU_MAX ((CONFIG_BLE_MESH_ADV_BUF_COUNT - 3) * 12)
|
||||
|
||||
static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
btc_ble_mesh_model_act_t act,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
static esp_err_t ble_mesh_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
btc_ble_mesh_model_act_t act,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
btc_ble_mesh_model_args_t arg = {0};
|
||||
uint8_t op_len = 0, mic_len = 0;
|
||||
uint8_t *msg_data = NULL;
|
||||
btc_msg_t msg = {0};
|
||||
esp_err_t status;
|
||||
esp_err_t status = ESP_OK;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
if (ctx && ctx->addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
BT_ERR("Invalid destination address 0x0000");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("Invalid device role 0x%02x", device_role);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@ -62,19 +63,19 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
|
||||
|
||||
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
|
||||
if (op_len + length > model->pub->msg->size) {
|
||||
LOG_ERROR("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
|
||||
BT_ERR("Too small publication msg size %d", model->pub->msg->size);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
if (act == BTC_BLE_MESH_ACT_MODEL_PUBLISH) {
|
||||
mic_len = 4;
|
||||
mic_len = ESP_BLE_MESH_MIC_SHORT;
|
||||
} else {
|
||||
mic_len = ctx->send_rel ? 8 : 4;
|
||||
mic_len = ctx->send_rel ? ESP_BLE_MESH_MIC_LONG : ESP_BLE_MESH_MIC_SHORT;
|
||||
}
|
||||
|
||||
if (op_len + length + mic_len > MIN(ESP_BLE_MESH_SDU_MAX_LEN, ESP_BLE_MESH_TX_SDU_MAX)) {
|
||||
LOG_ERROR("%s, Data length %d is too large", __func__, length);
|
||||
BT_ERR("Too large data length %d", length);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@ -82,7 +83,7 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
|
||||
bt_mesh_model_msg_init(model->pub->msg, opcode);
|
||||
net_buf_simple_add_mem(model->pub->msg, data, length);
|
||||
} else {
|
||||
msg_data = (uint8_t *)osi_malloc(op_len + length);
|
||||
msg_data = (uint8_t *)bt_mesh_malloc(op_len + length);
|
||||
if (msg_data == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
@ -108,24 +109,24 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
|
||||
arg.model_send.msg_timeout = msg_timeout;
|
||||
}
|
||||
|
||||
status = (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_model_args_t), btc_ble_mesh_prov_arg_deep_copy)
|
||||
status = (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);
|
||||
|
||||
osi_free(msg_data);
|
||||
bt_mesh_free(msg_data);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_register_custom_model_callback(esp_ble_mesh_model_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_MODEL, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode)
|
||||
{
|
||||
uint16_t val;
|
||||
uint16_t val = 0;
|
||||
|
||||
if (data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@ -157,48 +158,98 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model)
|
||||
if (model == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return btc_ble_mesh_client_init(model);
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return btc_ble_mesh_client_model_init(model);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model)
|
||||
{
|
||||
if (model == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return btc_ble_mesh_client_model_deinit(model);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data)
|
||||
{
|
||||
if (!model || !ctx) {
|
||||
if (model == NULL || ctx == NULL ||
|
||||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return ble_mesh_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
|
||||
length, data, 0, false, ROLE_NODE);
|
||||
|
||||
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
|
||||
length, data, 0, false, ROLE_NODE);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role)
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
if (!model || !ctx) {
|
||||
if (model == NULL || ctx == NULL ||
|
||||
ctx->net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
ctx->app_idx == ESP_BLE_MESH_KEY_UNUSED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return ble_mesh_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
|
||||
length, data, msg_timeout, need_rsp, device_role);
|
||||
|
||||
return ble_mesh_model_send_msg(model, ctx, opcode, BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
|
||||
length, data, msg_timeout, need_rsp, device_role);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
esp_ble_mesh_dev_role_t device_role)
|
||||
{
|
||||
if (!model || !model->pub || !model->pub->msg) {
|
||||
if (model == NULL || model->pub == NULL || model->pub->msg == NULL ||
|
||||
model->pub->publish_addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return ble_mesh_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
|
||||
length, data, 0, false, device_role);
|
||||
|
||||
return ble_mesh_model_send_msg(model, NULL, opcode, BTC_BLE_MESH_ACT_MODEL_PUBLISH,
|
||||
length, data, 0, false, device_role);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
btc_ble_mesh_model_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!model || !value || type >= ESP_BLE_MESH_SERVER_MODEL_STATE_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
arg.model_update_state.model = model;
|
||||
arg.model_update_state.type = type;
|
||||
arg.model_update_state.value = value;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MODEL;
|
||||
msg.act = BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_local_reset(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -209,7 +260,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void)
|
||||
|
||||
#if (CONFIG_BLE_MESH_PROVISIONER)
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
@ -218,7 +269,7 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -226,36 +277,139 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
|
||||
|
||||
arg.set_node_name.index = index;
|
||||
memset(arg.set_node_name.name, 0, sizeof(arg.set_node_name.name));
|
||||
memcpy(arg.set_node_name.name, name, strlen(name));
|
||||
strncpy(arg.set_node_name.name, name, ESP_BLE_MESH_NODE_NAME_MAX_LEN);
|
||||
|
||||
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_node_name(int index)
|
||||
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index)
|
||||
{
|
||||
return bt_mesh_provisioner_get_node_name(index);
|
||||
}
|
||||
|
||||
int esp_ble_mesh_provisioner_get_node_index(const char *name)
|
||||
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name)
|
||||
{
|
||||
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
|
||||
return -EINVAL;
|
||||
return ESP_BLE_MESH_INVALID_NODE_INDEX;
|
||||
}
|
||||
|
||||
return bt_mesh_provisioner_get_node_index(name);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx)
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr) || !data || length <= 14) {
|
||||
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_LOCAL_APP_KEY;
|
||||
msg.act = BTC_BLE_MESH_ACT_PROVISIONER_STORE_NODE_COMP_DATA;
|
||||
|
||||
arg.store_node_comp_data.unicast_addr = unicast_addr;
|
||||
arg.store_node_comp_data.length = length;
|
||||
arg.store_node_comp_data.data = data;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16])
|
||||
{
|
||||
if (!uuid) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_node_with_uuid(uuid);
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr)
|
||||
{
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_node_with_addr(unicast_addr);
|
||||
}
|
||||
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name)
|
||||
{
|
||||
if (!name || (strlen(name) > ESP_BLE_MESH_NODE_NAME_MAX_LEN)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_ble_mesh_provisioner_get_node_with_name(name);
|
||||
}
|
||||
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_prov_node_count();
|
||||
}
|
||||
|
||||
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_node_table_entry();
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!uuid) {
|
||||
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_NODE_WITH_UUID;
|
||||
|
||||
memcpy(arg.delete_node_with_uuid.uuid, uuid, 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_provisioner_delete_node_with_addr(uint16_t unicast_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
|
||||
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_NODE_WITH_ADDR;
|
||||
|
||||
arg.delete_node_with_addr.unicast_addr = unicast_addr;
|
||||
|
||||
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_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};
|
||||
|
||||
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_ADD_LOCAL_APP_KEY;
|
||||
|
||||
arg.add_local_app_key.net_idx = net_idx;
|
||||
arg.add_local_app_key.app_idx = app_idx;
|
||||
@ -268,13 +422,36 @@ esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_update_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) {
|
||||
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_UPDATE_LOCAL_APP_KEY;
|
||||
|
||||
memcpy(arg.update_local_app_key.app_key, app_key, 16);
|
||||
arg.update_local_app_key.net_idx = net_idx;
|
||||
arg.update_local_app_key.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);
|
||||
}
|
||||
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint16_t app_idx)
|
||||
{
|
||||
return bt_mesh_provisioner_local_app_key_get(net_idx, app_idx);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
|
||||
uint16_t model_id, uint16_t company_id)
|
||||
uint16_t model_id, uint16_t company_id)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
@ -283,7 +460,7 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -306,7 +483,7 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -322,11 +499,31 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_update_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) {
|
||||
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_UPDATE_LOCAL_NET_KEY;
|
||||
|
||||
memcpy(arg.update_local_net_key.net_key, net_key, 16);
|
||||
arg.update_local_net_key.net_idx = net_idx;
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
|
@ -13,13 +13,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_provisioning_api.h"
|
||||
@ -29,7 +25,7 @@
|
||||
|
||||
esp_err_t esp_ble_mesh_register_prov_callback(esp_ble_mesh_prov_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_PROV, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@ -39,12 +35,30 @@ bool esp_ble_mesh_node_is_provisioned(void)
|
||||
return bt_mesh_is_provisioned();
|
||||
}
|
||||
|
||||
static bool prov_bearers_valid(esp_ble_mesh_prov_bearer_t bearers)
|
||||
{
|
||||
if ((!(bearers & (ESP_BLE_MESH_PROV_ADV | ESP_BLE_MESH_PROV_GATT))) ||
|
||||
(IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
!IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_ADV)) ||
|
||||
(!IS_ENABLED(CONFIG_BLE_MESH_PB_ADV) &&
|
||||
IS_ENABLED(CONFIG_BLE_MESH_PB_GATT) &&
|
||||
!(bearers & ESP_BLE_MESH_PROV_GATT))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_prov_enable(esp_ble_mesh_prov_bearer_t bearers)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
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;
|
||||
@ -60,7 +74,11 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
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;
|
||||
@ -72,7 +90,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers)
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
|
||||
uint8_t private_key[32])
|
||||
uint8_t private_key[32])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
@ -81,7 +99,7 @@ esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_k
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -104,7 +122,7 @@ esp_err_t esp_ble_mesh_node_input_number(uint32_t number)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -120,17 +138,18 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!string) {
|
||||
if (!string || strlen(string) > ESP_BLE_MESH_PROV_INPUT_OOB_MAX_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
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_INPUT_STRING;
|
||||
memset(arg.input_string.string, 0, sizeof(arg.input_string.string));
|
||||
strncpy(arg.input_string.string, string, strlen(string));
|
||||
strncpy(arg.input_string.string, string,
|
||||
MIN(strlen(string), sizeof(arg.input_string.string)));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
@ -145,21 +164,22 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
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_SET_DEVICE_NAME;
|
||||
|
||||
memset(arg.set_device_name.name, 0, sizeof(arg.set_device_name.name));
|
||||
memcpy(arg.set_device_name.name, name, strlen(name));
|
||||
strncpy(arg.set_device_name.name, name, ESP_BLE_MESH_DEVICE_NAME_MAX_LEN);
|
||||
|
||||
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_PROVISIONER)
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32])
|
||||
uint8_t pub_key_y[32])
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
@ -168,7 +188,7 @@ esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pu
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -187,18 +207,20 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!string || link_idx >= MAX_PROV_LINK_IDX) {
|
||||
if (!string || strlen(string) > ESP_BLE_MESH_PROV_OUTPUT_OOB_MAX_LEN ||
|
||||
link_idx >= MAX_PROV_LINK_IDX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
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_INPUT_STR;
|
||||
|
||||
memset(arg.provisioner_input_str.string, 0, sizeof(arg.provisioner_input_str.string));
|
||||
strncpy(arg.provisioner_input_str.string, string, strlen(string));
|
||||
strncpy(arg.provisioner_input_str.string, string,
|
||||
MIN(strlen(string), sizeof(arg.provisioner_input_str.string)));
|
||||
arg.provisioner_input_str.link_idx = link_idx;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), NULL)
|
||||
@ -214,7 +236,7 @@ esp_err_t esp_ble_mesh_provisioner_input_number(uint32_t number, uint8_t link_id
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -232,7 +254,11 @@ esp_err_t esp_ble_mesh_provisioner_prov_enable(esp_ble_mesh_prov_bearer_t bearer
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
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;
|
||||
@ -249,7 +275,11 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (prov_bearers_valid(bearers) == false) {
|
||||
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;
|
||||
@ -262,7 +292,7 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
|
||||
esp_ble_mesh_dev_add_flag_t flags)
|
||||
esp_ble_mesh_dev_add_flag_t flags)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
@ -271,7 +301,7 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -280,13 +310,47 @@ esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t
|
||||
arg.provisioner_dev_add.add_dev.addr_type = add_dev->addr_type;
|
||||
arg.provisioner_dev_add.add_dev.oob_info = add_dev->oob_info;
|
||||
arg.provisioner_dev_add.add_dev.bearer = add_dev->bearer;
|
||||
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_bd_addr_t));
|
||||
memcpy(arg.provisioner_dev_add.add_dev.addr, add_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
|
||||
memcpy(arg.provisioner_dev_add.add_dev.uuid, add_dev->uuid, 16);
|
||||
arg.provisioner_dev_add.flags = flags;
|
||||
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_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (uuid == NULL || (bearer == ESP_BLE_MESH_PROV_GATT && (addr == NULL ||
|
||||
addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM)) ||
|
||||
(bearer != ESP_BLE_MESH_PROV_ADV && bearer != ESP_BLE_MESH_PROV_GATT) ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(unicast_addr)) {
|
||||
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_PROV_DEV_WITH_ADDR;
|
||||
|
||||
memcpy(arg.provisioner_prov_dev_with_addr.uuid, uuid, 16);
|
||||
if (addr) {
|
||||
memcpy(arg.provisioner_prov_dev_with_addr.addr, addr, BD_ADDR_LEN);
|
||||
arg.provisioner_prov_dev_with_addr.addr_type = addr_type;
|
||||
}
|
||||
arg.provisioner_prov_dev_with_addr.bearer = bearer;
|
||||
arg.provisioner_prov_dev_with_addr.oob_info = oob_info;
|
||||
arg.provisioner_prov_dev_with_addr.unicast_addr = unicast_addr;
|
||||
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_dev(esp_ble_mesh_device_delete_t *del_dev)
|
||||
{
|
||||
uint8_t val = DEL_DEV_ADDR_FLAG | DEL_DEV_UUID_FLAG;
|
||||
@ -297,7 +361,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -306,7 +370,7 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
||||
arg.provisioner_dev_del.del_dev.flag = del_dev->flag;
|
||||
if (del_dev->flag & DEL_DEV_ADDR_FLAG) {
|
||||
arg.provisioner_dev_del.del_dev.addr_type = del_dev->addr_type;
|
||||
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_bd_addr_t));
|
||||
memcpy(arg.provisioner_dev_del.del_dev.addr, del_dev->addr, sizeof(esp_ble_mesh_bd_addr_t));
|
||||
} else if (del_dev->flag & DEL_DEV_UUID_FLAG) {
|
||||
memcpy(arg.provisioner_dev_del.del_dev.uuid, del_dev->uuid, 16);
|
||||
}
|
||||
@ -315,12 +379,16 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
|
||||
uint8_t offset, bool prov_after_match)
|
||||
uint8_t offset, bool prov_after_match)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (match_len + offset > ESP_BLE_MESH_OCTET16_LEN) {
|
||||
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;
|
||||
@ -346,7 +414,7 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -364,6 +432,47 @@ esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_inf
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (value == NULL || length == 0 || length > 16) {
|
||||
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_STATIC_OOB_VAL;
|
||||
|
||||
arg.set_static_oob_val.length = length;
|
||||
memcpy(arg.set_static_oob_val.value, value, length);
|
||||
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_primary_elem_addr(uint16_t addr)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!ESP_BLE_MESH_ADDR_IS_UNICAST(addr)) {
|
||||
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_PRIMARY_ELEM_ADDR;
|
||||
|
||||
arg.set_primary_elem_addr.addr = addr;
|
||||
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 */
|
||||
|
||||
/* The following APIs are for fast provisioning */
|
||||
@ -375,11 +484,12 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (fast_prov_info == NULL) {
|
||||
if (fast_prov_info == NULL || (fast_prov_info->offset +
|
||||
fast_prov_info->match_len > ESP_BLE_MESH_OCTET16_LEN)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -408,7 +518,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t acti
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
|
@ -13,13 +13,9 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
@ -28,7 +24,7 @@ esp_err_t esp_ble_mesh_proxy_identity_enable(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -41,7 +37,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -54,7 +50,7 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@ -63,3 +59,118 @@ esp_err_t esp_ble_mesh_proxy_gatt_disable(void)
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!addr || addr_type > ESP_BLE_MESH_ADDR_TYPE_RANDOM) {
|
||||
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_PROXY_CLIENT_CONNECT;
|
||||
|
||||
memcpy(arg.proxy_client_connect.addr, addr, BD_ADDR_LEN);
|
||||
arg.proxy_client_connect.addr_type = addr_type;
|
||||
arg.proxy_client_connect.net_idx = net_idx;
|
||||
|
||||
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_proxy_client_disconnect(uint8_t conn_handle)
|
||||
{
|
||||
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_PROXY_CLIENT_DISCONNECT;
|
||||
|
||||
arg.proxy_client_disconnect.conn_handle = conn_handle;
|
||||
|
||||
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_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (filter_type > PROXY_FILTER_BLACKLIST) {
|
||||
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_PROXY_CLIENT_SET_FILTER_TYPE;
|
||||
|
||||
arg.proxy_client_set_filter_type.conn_handle = conn_handle;
|
||||
arg.proxy_client_set_filter_type.net_idx = net_idx;
|
||||
arg.proxy_client_set_filter_type.filter_type = filter_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_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!addr || addr_num == 0) {
|
||||
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_PROXY_CLIENT_ADD_FILTER_ADDR;
|
||||
|
||||
arg.proxy_client_add_filter_addr.conn_handle = conn_handle;
|
||||
arg.proxy_client_add_filter_addr.net_idx = net_idx;
|
||||
arg.proxy_client_add_filter_addr.addr_num = addr_num;
|
||||
arg.proxy_client_add_filter_addr.addr = addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num)
|
||||
{
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!addr || addr_num == 0) {
|
||||
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_PROXY_CLIENT_REMOVE_FILTER_ADDR;
|
||||
|
||||
arg.proxy_client_remove_filter_addr.conn_handle = conn_handle;
|
||||
arg.proxy_client_remove_filter_addr.net_idx = net_idx;
|
||||
arg.proxy_client_remove_filter_addr.addr_num = addr_num;
|
||||
arg.proxy_client_remove_filter_addr.addr = addr;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_prov_args_t), btc_ble_mesh_prov_arg_deep_copy)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -0,0 +1,65 @@
|
||||
// Copyright 2017-2019 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 _ESP_BLE_MESH_BLE_API_H_
|
||||
#define _ESP_BLE_MESH_BLE_API_H_
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief This function is called to start BLE advertising with the corresponding data
|
||||
* and parameters while BLE Mesh is working at the same time.
|
||||
*
|
||||
* @note 1. When this function is called, the BLE advertising packet will be posted to
|
||||
* the BLE mesh adv queue in the mesh stack and waited to be sent.
|
||||
* 2. In the BLE advertising parameters, the "duration" means the time used for
|
||||
* sending the BLE advertising packet each time, it shall not be smaller than the
|
||||
* advertising interval. When the packet is sent successfully, it will be posted
|
||||
* to the adv queue again after the "period" time if the "count" is bigger than 0.
|
||||
* The "count" means how many durations the packet will be sent after it is sent
|
||||
* successfully for the first time. And if the "count" is set to 0xFFFF, which
|
||||
* means the packet will be sent infinitely.
|
||||
* 3. The "priority" means the priority of BLE advertising packet compared with
|
||||
* BLE Mesh packets. Currently two options (i.e. low/high) are provided. If the
|
||||
* "priority" is high, the BLE advertising packet will be posted to the front of
|
||||
* adv queue. Otherwise it will be posted to the back of adv queue.
|
||||
*
|
||||
* @param[in] param: Pointer to the BLE advertising parameters
|
||||
* @param[in] data: Pointer to the BLE advertising data and scan response data
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief This function is called to stop BLE advertising with the corresponding index.
|
||||
*
|
||||
* @param[in] index: Index of BLE advertising
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_stop_ble_advertising(uint8_t index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_BLE_API_H_ */
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize BLE Mesh module.
|
||||
* This API initializes provisioning capabilities and composition data information.
|
||||
@ -34,4 +38,20 @@
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_init(esp_ble_mesh_prov_t *prov, esp_ble_mesh_comp_t *comp);
|
||||
|
||||
/**
|
||||
* @brief De-initialize BLE Mesh module.
|
||||
*
|
||||
* @note This function shall be invoked after esp_ble_mesh_client_model_deinit().
|
||||
*
|
||||
* @param[in] param: Pointer to the structure of BLE Mesh deinit parameters.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_deinit(esp_ble_mesh_deinit_param_t *param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_COMMON_API_H_ */
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the model publish period, the unit is ms.
|
||||
*
|
||||
@ -51,7 +55,8 @@ uint16_t esp_ble_mesh_get_primary_element_address(void);
|
||||
* to 0x0000 in order to unsubscribe the model from the group.
|
||||
*
|
||||
*/
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model, uint16_t group_addr);
|
||||
uint16_t *esp_ble_mesh_is_model_subscribed_to_group(esp_ble_mesh_model_t *model,
|
||||
uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief Find the BLE Mesh element pointer via the element address.
|
||||
@ -83,7 +88,7 @@ uint8_t esp_ble_mesh_get_element_count(void);
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t company_id, uint16_t model_id);
|
||||
uint16_t company_id, uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Find the SIG model with the given element and Model id.
|
||||
@ -94,7 +99,8 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_vendor_model(const esp_ble_mesh_elem_t *
|
||||
* @return Pointer to the SIG Model on success, or NULL on failure which means the SIG Model is not found.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element, uint16_t model_id);
|
||||
esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *element,
|
||||
uint16_t model_id);
|
||||
|
||||
/**
|
||||
* @brief Get the Composition data which has been registered.
|
||||
@ -104,4 +110,40 @@ esp_ble_mesh_model_t *esp_ble_mesh_find_sig_model(const esp_ble_mesh_elem_t *ele
|
||||
*/
|
||||
const esp_ble_mesh_comp_t *esp_ble_mesh_get_composition_data(void);
|
||||
|
||||
/**
|
||||
* @brief A local model of node or Provisioner subscribes a group address.
|
||||
*
|
||||
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
|
||||
*
|
||||
* @param[in] element_addr: Unicast address of the element to which the model belongs.
|
||||
* @param[in] company_id: A 16-bit company identifier.
|
||||
* @param[in] model_id: A 16-bit model identifier.
|
||||
* @param[in] group_addr: The group address to be subscribed.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_model_subscribe_group_addr(uint16_t element_addr, uint16_t company_id,
|
||||
uint16_t model_id, uint16_t group_addr);
|
||||
|
||||
/**
|
||||
* @brief A local model of node or Provisioner unsubscribes a group address.
|
||||
*
|
||||
* @note This function shall not be invoked before node is provisioned or Provisioner is enabled.
|
||||
*
|
||||
* @param[in] element_addr: Unicast address of the element to which the model belongs.
|
||||
* @param[in] company_id: A 16-bit company identifier.
|
||||
* @param[in] model_id: A 16-bit model identifier.
|
||||
* @param[in] group_addr: The subscribed group address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_LOCAL_DATA_OPERATION_API_H_ */
|
||||
|
@ -17,4 +17,53 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable BLE Mesh device LPN functionality.
|
||||
*
|
||||
* @note This API enables LPN functionality. Once called, the proper
|
||||
* Friend Request will be sent.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable BLE Mesh device LPN functionality.
|
||||
*
|
||||
* @param[in] force: when disabling LPN functionality, use this flag to indicate
|
||||
* whether directly clear corresponding information or just
|
||||
* send friend clear to disable it if friendship has already
|
||||
* been established.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_disable(bool force);
|
||||
|
||||
/**
|
||||
* @brief LPN tries to poll messages from the Friend Node.
|
||||
*
|
||||
* @note The Friend Poll message is sent by a Low Power node to ask the Friend
|
||||
* node to send a message that it has stored for the Low Power node.
|
||||
* Users can call this API to send Friend Poll message manually. If this
|
||||
* API is not invoked, the bottom layer of the Low Power node will send
|
||||
* Friend Poll before the PollTimeout timer expires.
|
||||
* If the corresponding Friend Update is received and MD is set to 0,
|
||||
* which means there are no messages for the Low Power node, then the
|
||||
* Low Power node will stop scanning.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_lpn_poll(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_LOW_POWER_API_H_ */
|
||||
|
@ -17,9 +17,13 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief: event, event code of user-defined model events; param, parameters of user-defined model events */
|
||||
typedef void (* esp_ble_mesh_model_cb_t)(esp_ble_mesh_model_cb_event_t event,
|
||||
esp_ble_mesh_model_cb_param_t *param);
|
||||
esp_ble_mesh_model_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh callback for user-defined models' operations.
|
||||
@ -75,6 +79,18 @@ esp_err_t esp_ble_mesh_model_msg_opcode_init(uint8_t *data, uint32_t opcode);
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief De-initialize the user-defined client model.
|
||||
*
|
||||
* @note This function shall be invoked before esp_ble_mesh_deinit() is called.
|
||||
*
|
||||
* @param[in] model: Pointer of the Client model.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
||||
|
||||
/**
|
||||
* @brief Send server model messages(such as server model status messages).
|
||||
*
|
||||
@ -88,8 +104,9 @@ esp_err_t esp_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Send client model message (such as model get, set, etc).
|
||||
@ -107,9 +124,11 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
esp_ble_mesh_msg_ctx_t *ctx, uint32_t opcode,
|
||||
uint16_t length, uint8_t *data, int32_t msg_timeout,
|
||||
bool need_rsp, esp_ble_mesh_dev_role_t device_role);
|
||||
esp_ble_mesh_msg_ctx_t *ctx,
|
||||
uint32_t opcode,
|
||||
uint16_t length, uint8_t *data,
|
||||
int32_t msg_timeout, bool need_rsp,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Send a model publication message.
|
||||
@ -134,6 +153,25 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
|
||||
uint16_t length, uint8_t *data,
|
||||
esp_ble_mesh_dev_role_t device_role);
|
||||
|
||||
/**
|
||||
* @brief Update a server model state value. If the model publication
|
||||
* state is set properly (e.g. publish address is set to a valid
|
||||
* address), it will publish corresponding status message.
|
||||
*
|
||||
* @note Currently this API is used to update bound state value, not
|
||||
* for all server model states.
|
||||
*
|
||||
* @param[in] model: Server model which is going to update the state.
|
||||
* @param[in] type: Server model state type.
|
||||
* @param[in] value: Server model state value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Reset the provisioning procedure of the local BLE Mesh node.
|
||||
*
|
||||
@ -157,7 +195,7 @@ esp_err_t esp_ble_mesh_node_local_reset(void);
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
|
||||
esp_err_t esp_ble_mesh_provisioner_set_node_name(uint16_t index, const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the node (provisioned device) name.
|
||||
@ -169,20 +207,119 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name);
|
||||
* @return Node name on success, or NULL on failure.
|
||||
*
|
||||
*/
|
||||
const char *esp_ble_mesh_provisioner_get_node_name(int index);
|
||||
const char *esp_ble_mesh_provisioner_get_node_name(uint16_t index);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the node (provisioned device) index.
|
||||
*
|
||||
* @param[in] name: Name of the node (end by '\0').
|
||||
*
|
||||
* @return Node index on success, or (negative) error code from errno.h on failure.
|
||||
* @return Node index on success, or an invalid value (0xFFFF) on failure.
|
||||
*
|
||||
*/
|
||||
int esp_ble_mesh_provisioner_get_node_index(const char *name);
|
||||
uint16_t esp_ble_mesh_provisioner_get_node_index(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the app key for the local BLE Mesh stack.
|
||||
* @brief This function is called to store the Composition Data of the node.
|
||||
*
|
||||
* @param[in] unicast_addr: Element address of the node
|
||||
* @param[in] data: Pointer of Composition Data
|
||||
* @param[in] length: Length of Composition Data
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_store_node_comp_data(uint16_t unicast_addr,
|
||||
uint8_t *data, uint16_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node device uuid.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the node
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_uuid(const uint8_t uuid[16]);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node unicast address.
|
||||
*
|
||||
* @param[in] unicast_addr: Unicast address of the node
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to get the provisioned node information
|
||||
* with the node name.
|
||||
*
|
||||
* @param[in] name: Name of the node (end by '\0').
|
||||
*
|
||||
* @return Pointer of the node info struct or NULL on failure.
|
||||
*
|
||||
*/
|
||||
esp_ble_mesh_node_t *esp_ble_mesh_provisioner_get_node_with_name(const char *name);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get provisioned node count.
|
||||
*
|
||||
* @return Number of the provisioned nodes.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the entry of the node table.
|
||||
*
|
||||
* @note After invoking the function to get the entry of nodes, users can use the "for"
|
||||
* loop combined with the macro CONFIG_BLE_MESH_MAX_PROV_NODES to get each node's
|
||||
* information. Before trying to read the node's information, users need to check
|
||||
* if the node exists, i.e. if the *(esp_ble_mesh_node_t **node) is NULL.
|
||||
* For example:
|
||||
* ```
|
||||
* const esp_ble_mesh_node_t **entry = esp_ble_mesh_provisioner_get_node_table_entry();
|
||||
* for (int i = 0; i < CONFIG_BLE_MESH_MAX_PROV_NODES; i++) {
|
||||
* const esp_ble_mesh_node_t *node = entry[i];
|
||||
* if (node) {
|
||||
* ......
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return Pointer to the start of the node table.
|
||||
*
|
||||
*/
|
||||
const esp_ble_mesh_node_t **esp_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete the provisioned node information
|
||||
* with the node device uuid.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the node
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_uuid(const uint8_t uuid[16]);
|
||||
|
||||
/**
|
||||
* @brief This function is called to delete the provisioned node information
|
||||
* with the node unicast address.
|
||||
*
|
||||
* @param[in] unicast_addr: Unicast address of the node
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_delete_node_with_addr(uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to add a local AppKey for Provisioner.
|
||||
*
|
||||
* @param[in] app_key: The app key to be set for the local BLE Mesh stack.
|
||||
* @param[in] net_idx: The network key index.
|
||||
@ -196,7 +333,21 @@ int esp_ble_mesh_provisioner_get_node_index(const char *name);
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16], uint16_t net_idx, uint16_t app_idx);
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is used to update a local AppKey for Provisioner.
|
||||
*
|
||||
* @param[in] app_key: Value of the AppKey.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] app_idx: The AppKey Index
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_app_key(const uint8_t app_key[16],
|
||||
uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the local app key value.
|
||||
@ -224,7 +375,7 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_app_key(uint16_t net_idx, uint
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_addr, uint16_t app_idx,
|
||||
uint16_t model_id, uint16_t company_id);
|
||||
uint16_t model_id, uint16_t company_id);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to add local network key.
|
||||
@ -241,6 +392,17 @@ esp_err_t esp_ble_mesh_provisioner_bind_app_key_to_local_model(uint16_t element_
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to update a local network key.
|
||||
*
|
||||
* @param[in] net_key: Value of the NetKey.
|
||||
* @param[in] net_idx: The NetKey Index.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_update_local_net_key(const uint8_t net_key[16], uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to get the local network key value.
|
||||
*
|
||||
@ -262,4 +424,8 @@ const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_get_fast_prov_app_key(uint16_t net_idx, uint16_t app_idx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_NETWORKING_API_H_ */
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief: event, event code of provisioning events; param, parameters of provisioning events */
|
||||
typedef void (* esp_ble_mesh_prov_cb_t)(esp_ble_mesh_prov_cb_event_t event,
|
||||
esp_ble_mesh_prov_cb_param_t *param);
|
||||
@ -72,7 +76,7 @@ esp_err_t esp_ble_mesh_node_prov_disable(esp_ble_mesh_prov_bearer_t bearers);
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_node_set_oob_pub_key(uint8_t pub_key_x[32], uint8_t pub_key_y[32],
|
||||
uint8_t private_key[32]);
|
||||
uint8_t private_key[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB number.
|
||||
@ -124,7 +128,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name);
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_read_oob_pub_key(uint8_t link_idx, uint8_t pub_key_x[32],
|
||||
uint8_t pub_key_y[32]);
|
||||
uint8_t pub_key_y[32]);
|
||||
|
||||
/**
|
||||
* @brief Provide provisioning input OOB string.
|
||||
@ -228,7 +232,35 @@ esp_err_t esp_ble_mesh_provisioner_prov_disable(esp_ble_mesh_prov_bearer_t beare
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_add_unprov_dev(esp_ble_mesh_unprov_dev_add_t *add_dev,
|
||||
esp_ble_mesh_dev_add_flag_t flags);
|
||||
esp_ble_mesh_dev_add_flag_t flags);
|
||||
|
||||
/** @brief Provision an unprovisioned device and assign a fixed unicast address for it in advance.
|
||||
*
|
||||
* @param[in] uuid: Device UUID of the unprovisioned device
|
||||
* @param[in] addr: Device address of the unprovisioned device
|
||||
* @param[in] addr_type: Device address type of the unprovisioned device
|
||||
* @param[in] bearer: Provisioning bearer going to be used by Provisioner
|
||||
* @param[in] oob_info: OOB info of the unprovisioned device
|
||||
* @param[in] unicast_addr: Unicast address going to be allocated for the unprovisioned device
|
||||
*
|
||||
* @return Zero on success or (negative) error code otherwise.
|
||||
*
|
||||
* @note: 1. Currently address type only supports public address and static random address.
|
||||
* 2. Bearer must be equal to ESP_BLE_MESH_PROV_ADV or ESP_BLE_MESH_PROV_GATT, since
|
||||
* Provisioner will start to provision a device immediately once this function is
|
||||
* invoked. And the input bearer must be identical with the one within the parameters
|
||||
* of the ESP_BLE_MESH_PROVISIONER_RECV_UNPROV_ADV_PKT_EVT event.
|
||||
* 3. If this function is used by a Provisioner to provision devices, the application
|
||||
* should take care of the assigned unicast address and avoid overlap of the unicast
|
||||
* addresses of different nodes.
|
||||
* 4. Recommend to use only one of the functions "esp_ble_mesh_provisioner_add_unprov_dev"
|
||||
* and "esp_ble_mesh_provisioner_prov_device_with_addr" by a Provisioner.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_prov_device_with_addr(const uint8_t uuid[16],
|
||||
esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
esp_ble_mesh_prov_bearer_t bearer,
|
||||
uint16_t oob_info, uint16_t unicast_addr);
|
||||
|
||||
/**
|
||||
* @brief Delete device from queue, reset current provisioning link and reset the node.
|
||||
@ -259,9 +291,9 @@ esp_err_t esp_ble_mesh_provisioner_delete_dev(esp_ble_mesh_device_delete_t *del_
|
||||
* @param[in] bearer: Adv packet received from PB-GATT or PB-ADV bearer.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_bd_addr_t addr, const esp_ble_addr_type_t addr_type,
|
||||
const uint8_t adv_type, const uint8_t *dev_uuid,
|
||||
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
|
||||
typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_ble_mesh_bd_addr_t addr, const esp_ble_mesh_addr_type_t addr_type,
|
||||
const uint8_t adv_type, const uint8_t *dev_uuid,
|
||||
uint16_t oob_info, esp_ble_mesh_prov_bearer_t bearer);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set the part of the device UUID
|
||||
@ -277,7 +309,7 @@ typedef void (*esp_ble_mesh_prov_adv_cb_t)(const esp_bd_addr_t addr, const esp_b
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val, uint8_t match_len,
|
||||
uint8_t offset, bool prov_after_match);
|
||||
uint8_t offset, bool prov_after_match);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set provisioning data information
|
||||
@ -290,6 +322,36 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_prov_data_info(esp_ble_mesh_prov_data_info_t *prov_data_info);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set static oob value used for provisioning.
|
||||
*
|
||||
* @param[in] value: Pointer to the static oob value.
|
||||
* @param[in] length: Length of the static oob value.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_static_oob_value(const uint8_t *value, uint8_t length);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to set own Primary element address.
|
||||
*
|
||||
* @note This API must be invoked when BLE Mesh initialization is completed successfully,
|
||||
* and can be invoked before Provisioner functionality is enabled.
|
||||
* Once this API is invoked successfully, the prov_unicast_addr value in the struct
|
||||
* esp_ble_mesh_prov_t will be ignored, and Provisioner will use this address as its
|
||||
* own primary element address.
|
||||
* And if the unicast address going to assigned for the next unprovisioned device is
|
||||
* smaller than the input address + element number of Provisioner, then the address
|
||||
* for the next unprovisioned device will be recalculated internally.
|
||||
*
|
||||
* @param[in] addr: Unicast address of the Primary element of Provisioner.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_provisioner_set_primary_elem_addr(uint16_t addr);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set provisioning data information before starting
|
||||
* fast provisioning.
|
||||
@ -311,4 +373,8 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_set_fast_prov_action(esp_ble_mesh_fast_prov_action_t action);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_PROVISIONING_API_H_ */
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable advertising with Node Identity.
|
||||
*
|
||||
@ -49,5 +53,75 @@ esp_err_t esp_ble_mesh_proxy_gatt_enable(void);
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_gatt_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client creates a connection with the Proxy Server.
|
||||
*
|
||||
* @param[in] addr: Device address of the Proxy Server.
|
||||
* @param[in] addr_type: Device address type(public or static random).
|
||||
* @param[in] net_idx: NetKey Index related with Network ID in the Mesh Proxy
|
||||
* advertising packet.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_connect(esp_ble_mesh_bd_addr_t addr,
|
||||
esp_ble_mesh_addr_type_t addr_type,
|
||||
uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client terminates a connection with the Proxy Server.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_disconnect(uint8_t conn_handle);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client sets the filter type of the Proxy Server.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] filter_type: whitelist or blacklist.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_set_filter_type(uint8_t conn_handle, uint16_t net_idx,
|
||||
esp_ble_mesh_proxy_filter_type_t filter_type);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client adds address to the Proxy Server filter list.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] addr: Pointer to the filter address.
|
||||
* @param[in] addr_num: Number of the filter address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_add_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
/**
|
||||
* @brief Proxy Client removes address from the Proxy Server filter list.
|
||||
*
|
||||
* @param[in] conn_handle: Proxy connection handle.
|
||||
* @param[in] net_idx: Corresponding NetKey Index.
|
||||
* @param[in] addr: Pointer to the filter address.
|
||||
* @param[in] addr_num: Number of the filter address.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_proxy_client_remove_filter_addr(uint8_t conn_handle, uint16_t net_idx,
|
||||
uint16_t *addr, uint16_t addr_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_PROXY_API_H_ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -14,69 +14,90 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_config_model.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_config_client_callback(esp_ble_mesh_cfg_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_CFG_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_CFG_SERVER, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
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) {
|
||||
case ESP_BLE_MESH_MODEL_OP_COMPOSITION_DATA_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_MODEL_PUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_SUB_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_APP_KEY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_NODE_IDENTITY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SIG_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_VENDOR_MODEL_APP_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_KEY_REFRESH_PHASE_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LPN_POLLTIMEOUT_GET:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state)
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_cfg_client_args_t arg = {0};
|
||||
btc_ble_mesh_config_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(config_client_get_need_param(params->opcode) && get_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_CFG_CLIENT;
|
||||
msg.pid = BTC_PID_CONFIG_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE;
|
||||
arg.cfg_client_get_state.params = params;
|
||||
arg.cfg_client_get_state.get_state = get_state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
|
||||
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);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state)
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_cfg_client_args_t arg = {0};
|
||||
btc_ble_mesh_config_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
!ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && set_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_CFG_CLIENT;
|
||||
msg.pid = BTC_PID_CONFIG_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE;
|
||||
arg.cfg_client_set_state.params = params;
|
||||
arg.cfg_client_set_state.set_state = set_state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_cfg_client_args_t), btc_ble_mesh_cfg_client_arg_deep_copy)
|
||||
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);
|
||||
}
|
||||
|
@ -14,33 +14,46 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_generic_model.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_GENERIC_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
static bool generic_client_get_need_param(esp_ble_mesh_opcode_t opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_MANUFACTURER_PROPERTY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_CLIENT_PROPERTIES_GET:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state)
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
|
||||
(generic_client_get_need_param(params->opcode) && get_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GENERIC_CLIENT;
|
||||
@ -53,16 +66,19 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state)
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL || set_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GENERIC_CLIENT;
|
||||
@ -73,3 +89,10 @@ 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -14,40 +14,40 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_health_client_callback(esp_ble_mesh_health_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
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_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
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)
|
||||
esp_ble_mesh_health_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
|
||||
(params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HEALTH_CLIENT;
|
||||
@ -60,16 +60,19 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state)
|
||||
esp_ble_mesh_health_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL || set_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_HEALTH_CLIENT;
|
||||
@ -86,12 +89,16 @@ esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element)
|
||||
btc_ble_mesh_health_server_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (element == NULL) {
|
||||
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_HEALTH_SERVER;
|
||||
msg.act = BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE;
|
||||
arg.fault_update.element = element;
|
||||
arg.health_fault_update.element = element;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_health_server_args_t), NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
@ -14,63 +14,72 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_lighting_model.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_light_client_callback(esp_ble_mesh_light_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_LIGHT_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
return (btc_profile_cb_set(BTC_PID_LIGHTING_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_light_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_get_state_t *get_state)
|
||||
esp_ble_mesh_light_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_light_client_args_t arg = {0};
|
||||
btc_ble_mesh_lighting_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
|
||||
(params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET && get_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_LIGHT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE;
|
||||
msg.pid = BTC_PID_LIGHTING_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE;
|
||||
arg.light_client_get_state.params = params;
|
||||
arg.light_client_get_state.get_state = get_state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
|
||||
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);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_light_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_light_client_set_state_t *set_state)
|
||||
esp_ble_mesh_light_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_light_client_args_t arg = {0};
|
||||
btc_ble_mesh_lighting_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL || set_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_LIGHT_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE;
|
||||
msg.pid = BTC_PID_LIGHTING_CLIENT;
|
||||
msg.act = BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE;
|
||||
arg.light_client_set_state.params = params;
|
||||
arg.light_client_set_state.set_state = set_state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_mesh_light_client_args_t), btc_ble_mesh_light_client_arg_deep_copy)
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -14,33 +14,32 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_sensor_model.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_SENSOR_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state)
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL || get_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SENSOR_CLIENT;
|
||||
@ -53,16 +52,19 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state)
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL || set_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SENSOR_CLIENT;
|
||||
@ -74,3 +76,11 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,33 +14,33 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
|
||||
#include "btc_ble_mesh_time_scene_model.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_t callback)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
return (btc_profile_cb_set(BTC_PID_TIME_SCENE_CLIENT, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state)
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !get_state) {
|
||||
if (params == NULL || params->model == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED ||
|
||||
(params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET && get_state == NULL)) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
|
||||
@ -53,16 +53,19 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state)
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t arg = {0};
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
if (!params || !params->model || !params->ctx.addr || !set_state) {
|
||||
if (params == NULL || params->model == NULL || set_state == NULL ||
|
||||
params->ctx.net_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.app_idx == ESP_BLE_MESH_KEY_UNUSED ||
|
||||
params->ctx.addr == ESP_BLE_MESH_ADDR_UNASSIGNED) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
|
||||
@ -74,3 +77,10 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_CFG_SRV
|
||||
*
|
||||
* @brief Define a new Config Server Model.
|
||||
@ -79,8 +83,8 @@ typedef struct esp_ble_mesh_cfg_srv {
|
||||
uint8_t min_hops; /*!< Minimum hops when receiving Heartbeat messages */
|
||||
uint8_t max_hops; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
|
||||
/** Optional subscription tracking function */
|
||||
void (*func)(uint8_t hops, uint16_t feature);
|
||||
/** Optional heartbeat subscription tracking function */
|
||||
esp_ble_mesh_cb_t heartbeat_recv_cb;
|
||||
} heartbeat_sub;
|
||||
} esp_ble_mesh_cfg_srv_t;
|
||||
|
||||
@ -513,8 +517,8 @@ typedef struct {
|
||||
|
||||
/** Parameters of Config Network Transmit Status */
|
||||
typedef struct {
|
||||
uint8_t net_trans_count:3; /*!< Number of transmissions for each Network PDU originating from the node */
|
||||
uint8_t net_trans_step :5; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
uint8_t net_trans_count: 3; /*!< Number of transmissions for each Network PDU originating from the node */
|
||||
uint8_t net_trans_step : 5; /*!< Maximum hops when receiving Heartbeat messages */
|
||||
} esp_ble_mesh_cfg_net_trans_status_cb_t;
|
||||
|
||||
/** Parameters of Config SIG/Vendor Subscription List */
|
||||
@ -610,28 +614,135 @@ typedef enum {
|
||||
ESP_BLE_MESH_CFG_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_cfg_client_cb_event_t;
|
||||
|
||||
/** Parameter of Config AppKey Add */
|
||||
/**
|
||||
* @brief Configuration Server model related context.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint16_t app_idx; /*!< AppKey Index of the Config AppKey Add */
|
||||
} esp_ble_mesh_cfg_srv_app_key_add_cb_t;
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t pub_addr; /*!< Publish Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
bool cred_flag; /*!< Friendship Credential Flag */
|
||||
uint8_t pub_ttl; /*!< Publish TTL */
|
||||
uint8_t pub_period; /*!< Publish Period */
|
||||
uint8_t pub_retransmit; /*!< Publish Retransmit */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_mod_pub_set_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Add */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t sub_addr; /*!< Subscription Address */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_sub_add_t;
|
||||
|
||||
/** Parameters of Config Model Subscription Delete */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t sub_addr; /*!< Subscription Address */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_sub_delete_t;
|
||||
|
||||
/** Parameters of Config NetKey Add */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t net_key[16]; /*!< NetKey */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_add_t;
|
||||
|
||||
/** Parameters of Config NetKey Update */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t net_key[16]; /*!< NetKey */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_update_t;
|
||||
|
||||
/** Parameter of Config NetKey Delete */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
} esp_ble_mesh_state_change_cfg_netkey_delete_t;
|
||||
|
||||
/** Parameters of Config AppKey Add */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint8_t app_key[16]; /*!< AppKey */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_add_t;
|
||||
|
||||
/** Parameters of Config AppKey Update */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint8_t app_key[16]; /*!< AppKey */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_update_t;
|
||||
|
||||
/** Parameters of Config AppKey Delete */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
} esp_ble_mesh_state_change_cfg_appkey_delete_t;
|
||||
|
||||
/** Parameters of Config Model App Bind */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_app_bind_t;
|
||||
|
||||
/** Parameters of Config Model App Unbind */
|
||||
typedef struct {
|
||||
uint16_t element_addr; /*!< Element Address */
|
||||
uint16_t app_idx; /*!< AppKey Index */
|
||||
uint16_t company_id; /*!< Company ID */
|
||||
uint16_t model_id; /*!< Model ID */
|
||||
} esp_ble_mesh_state_change_cfg_model_app_unbind_t;
|
||||
|
||||
/** Parameters of Config Key Refresh Phase Set */
|
||||
typedef struct {
|
||||
uint16_t net_idx; /*!< NetKey Index */
|
||||
uint8_t kr_phase; /*!< New Key Refresh Phase Transition */
|
||||
} esp_ble_mesh_state_change_cfg_kr_phase_set_t;
|
||||
|
||||
/**
|
||||
* @brief Configuration Server Model received message union
|
||||
* @brief Configuration Server model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_srv_app_key_add_cb_t app_key_add; /*!< The Config AppKey Add event value */
|
||||
} esp_ble_mesh_cfg_server_common_cb_param_t;
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_cfg_mod_pub_set_t mod_pub_set; /*!< Config Model Publication Set */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_add_t mod_sub_add; /*!< Config Model Subscription Add */
|
||||
esp_ble_mesh_state_change_cfg_model_sub_delete_t mod_sub_delete; /*!< Config Model Subscription Delete */
|
||||
esp_ble_mesh_state_change_cfg_netkey_add_t netkey_add; /*!< Config NetKey Add */
|
||||
esp_ble_mesh_state_change_cfg_netkey_update_t netkey_update; /*!< Config NetKey Update */
|
||||
esp_ble_mesh_state_change_cfg_netkey_delete_t netkey_delete; /*!< Config NetKey Delete */
|
||||
esp_ble_mesh_state_change_cfg_appkey_add_t appkey_add; /*!< Config AppKey Add */
|
||||
esp_ble_mesh_state_change_cfg_appkey_update_t appkey_update; /*!< Config AppKey Update */
|
||||
esp_ble_mesh_state_change_cfg_appkey_delete_t appkey_delete; /*!< Config AppKey Delete */
|
||||
esp_ble_mesh_state_change_cfg_model_app_bind_t mod_app_bind; /*!< Config Model App Bind */
|
||||
esp_ble_mesh_state_change_cfg_model_app_unbind_t mod_app_unbind; /*!< Config Model App Unbind */
|
||||
esp_ble_mesh_state_change_cfg_kr_phase_set_t kr_phase_set; /*!< Config Key Refresh Phase Set */
|
||||
} esp_ble_mesh_cfg_server_state_change_t;
|
||||
|
||||
/** Configuration Server Model callback parameters */
|
||||
/**
|
||||
* @brief Configuration Server model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_cfg_server_state_change_t state_change; /*!< ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT */
|
||||
} esp_ble_mesh_cfg_server_cb_value_t;
|
||||
|
||||
/** Configuration Server model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< The context of the received message */
|
||||
esp_ble_mesh_cfg_server_common_cb_param_t status_cb; /*!< The received configuration message callback values */
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the server model structure */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received message */
|
||||
esp_ble_mesh_cfg_server_cb_value_t value; /*!< Value of the received configuration messages */
|
||||
} esp_ble_mesh_cfg_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Configuration Server Model */
|
||||
/** This enum value is the event of Configuration Server model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_CFG_SERVER_RECV_MSG_EVT,
|
||||
ESP_BLE_MESH_CFG_SERVER_STATE_CHANGE_EVT,
|
||||
ESP_BLE_MESH_CFG_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_cfg_server_cb_event_t;
|
||||
|
||||
@ -645,7 +756,7 @@ typedef enum {
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t event,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param);
|
||||
esp_ble_mesh_cfg_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Configuration Server Model callback function type
|
||||
@ -653,7 +764,7 @@ typedef void (* esp_ble_mesh_cfg_client_cb_t)(esp_ble_mesh_cfg_client_cb_event_t
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_cfg_server_cb_t)(esp_ble_mesh_cfg_server_cb_event_t event,
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param);
|
||||
esp_ble_mesh_cfg_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Config Client Model callback.
|
||||
@ -689,7 +800,7 @@ esp_err_t esp_ble_mesh_register_config_server_callback(esp_ble_mesh_cfg_server_c
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state);
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the Configuration Server Model states using the Config Client Model set messages.
|
||||
@ -705,7 +816,11 @@ esp_err_t esp_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state);
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state);
|
||||
|
||||
#endif /** _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_CONFIG_MODEL_API_H_ */
|
||||
|
||||
|
@ -19,9 +19,12 @@
|
||||
#ifndef _ESP_BLE_MESH_GENERIC_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_GENERIC_MODEL_API_H_
|
||||
|
||||
#include "generic_client.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_CLI
|
||||
*
|
||||
* @brief Define a new Generic OnOff Client Model.
|
||||
@ -257,7 +260,7 @@ typedef struct {
|
||||
/** Parameters of Generic Admin Property Set. */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
|
||||
uint8_t user_access; /*!< Enumeration indicating user accessn */
|
||||
uint8_t user_access; /*!< Enumeration indicating user access */
|
||||
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
|
||||
} esp_ble_mesh_gen_admin_property_set_t;
|
||||
|
||||
@ -480,7 +483,7 @@ typedef enum {
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_generic_client_cb_t)(esp_ble_mesh_generic_client_cb_event_t event,
|
||||
esp_ble_mesh_generic_client_cb_param_t *param);
|
||||
esp_ble_mesh_generic_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Generic Client Model callback.
|
||||
@ -506,7 +509,7 @@ esp_err_t esp_ble_mesh_register_generic_client_callback(esp_ble_mesh_generic_cli
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state);
|
||||
esp_ble_mesh_generic_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Generic Server Model states using the Generic Client Model set messages.
|
||||
@ -522,8 +525,781 @@ esp_err_t esp_ble_mesh_generic_client_get_state(esp_ble_mesh_client_common_param
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state);
|
||||
esp_ble_mesh_generic_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Generic Server Models related context.
|
||||
*/
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV
|
||||
*
|
||||
* @brief Define a new Generic OnOff Server Model.
|
||||
*
|
||||
* @note 1. The Generic OnOff Server Model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_onoff_srv_t.
|
||||
*
|
||||
* @return New Generic OnOff Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_ONOFF_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ONOFF_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV
|
||||
*
|
||||
* @brief Define a new Generic Level Server Model.
|
||||
*
|
||||
* @note 1. The Generic Level Server Model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_level_srv_t.
|
||||
*
|
||||
* @return New Generic Level Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_LEVEL_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LEVEL_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV
|
||||
*
|
||||
* @brief Define a new Generic Default Transition Time Server Model.
|
||||
*
|
||||
* @note 1. The Generic Default Transition Time Server Model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_def_trans_time_srv_t.
|
||||
*
|
||||
* @return New Generic Default Transition Time Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_DEF_TRANS_TIME_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_DEF_TRANS_TIME_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV
|
||||
*
|
||||
* @brief Define a new Generic Power OnOff Server Model.
|
||||
*
|
||||
* @note 1. The Generic Power OnOff Server model extends the Generic OnOff Server
|
||||
* model. When this model is present on an element, the corresponding
|
||||
* Generic Power OnOff Setup Server model shall also be present.
|
||||
* 2. This model may be used to represent a variety of devices that do not
|
||||
* fit any of the model descriptions that have been defined but support
|
||||
* the generic properties of On/Off.
|
||||
* 3. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_srv_t.
|
||||
*
|
||||
* @return New Generic Power OnOff Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Generic Power OnOff Setup Server Model.
|
||||
*
|
||||
* @note 1. The Generic Power OnOff Setup Server model extends the Generic Power
|
||||
* OnOff Server model and the Generic Default Transition Time Server model.
|
||||
* 2. This model shall support model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_onoff_setup_srv_t.
|
||||
*
|
||||
* @return New Generic Power OnOff Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_POWER_ONOFF_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_ONOFF_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV
|
||||
*
|
||||
* @brief Define a new Generic Power Level Server Model.
|
||||
*
|
||||
* @note 1. The Generic Power Level Server model extends the Generic Power OnOff
|
||||
* Server model and the Generic Level Server model. When this model is
|
||||
* present on an Element, the corresponding Generic Power Level Setup
|
||||
* Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_srv_t.
|
||||
*
|
||||
* @return New Generic Power Level Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Generic Power Level Setup Server Model.
|
||||
*
|
||||
* @note 1. The Generic Power Level Setup Server model extends the Generic Power
|
||||
* Level Server model and the Generic Power OnOff Setup Server model.
|
||||
* 2. This model shall support model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_power_level_setup_srv_t.
|
||||
*
|
||||
* @return New Generic Power Level Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_POWER_LEVEL_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_POWER_LEVEL_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV
|
||||
*
|
||||
* @brief Define a new Generic Battery Server Model.
|
||||
*
|
||||
* @note 1. The Generic Battery Server Model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be used to represent an element that is powered by a battery.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_battery_srv_t.
|
||||
*
|
||||
* @return New Generic Battery Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_BATTERY_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_BATTERY_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV
|
||||
*
|
||||
* @brief Define a new Generic Location Server Model.
|
||||
*
|
||||
* @note 1. The Generic Location Server model is a root model. When this model
|
||||
* is present on an Element, the corresponding Generic Location Setup
|
||||
* Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be used to represent an element that knows its
|
||||
* location (global or local).
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_srv_t.
|
||||
*
|
||||
* @return New Generic Location Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Generic Location Setup Server Model.
|
||||
*
|
||||
* @note 1. The Generic Location Setup Server model extends the Generic Location
|
||||
* Server model.
|
||||
* 2. This model shall support model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_location_setup_srv_t.
|
||||
*
|
||||
* @return New Generic Location Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_LOCATION_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_LOCATION_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV
|
||||
*
|
||||
* @brief Define a new Generic User Property Server Model.
|
||||
*
|
||||
* @note 1. The Generic User Property Server model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_user_prop_srv_t.
|
||||
*
|
||||
* @return New Generic User Property Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_USER_PROP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_USER_PROP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV
|
||||
*
|
||||
* @brief Define a new Generic Admin Property Server Model.
|
||||
*
|
||||
* @note 1. The Generic Admin Property Server model extends the Generic User
|
||||
* Property Server model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_admin_prop_srv_t.
|
||||
*
|
||||
* @return New Generic Admin Property Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_ADMIN_PROP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_ADMIN_PROP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV
|
||||
*
|
||||
* @brief Define a new Generic Manufacturer Property Server Model.
|
||||
*
|
||||
* @note 1. The Generic Manufacturer Property Server model extends the Generic
|
||||
* User Property Server model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_manu_prop_srv_t.
|
||||
*
|
||||
* @return New Generic Manufacturer Property Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_MANUFACTURER_PROP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_MANUFACTURER_PROP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV
|
||||
*
|
||||
* @brief Define a new Generic User Property Server Model.
|
||||
*
|
||||
* @note 1. The Generic Client Property Server model is a root model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_gen_client_prop_srv_t.
|
||||
*
|
||||
* @return New Generic Client Property Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_GEN_CLIENT_PROP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_GEN_CLIENT_PROP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** Parameters of Generic OnOff state */
|
||||
typedef struct {
|
||||
uint8_t onoff; /*!< The present value of the Generic OnOff state */
|
||||
uint8_t target_onoff; /*!< The target value of the Generic OnOff state */
|
||||
} esp_ble_mesh_gen_onoff_state_t;
|
||||
|
||||
/** User data of Generic OnOff Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic OnOff Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_onoff_state_t state; /*!< Parameters of the Generic OnOff state */
|
||||
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
|
||||
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
|
||||
} esp_ble_mesh_gen_onoff_srv_t;
|
||||
|
||||
/** Parameters of Generic Level state */
|
||||
typedef struct {
|
||||
int16_t level; /*!< The present value of the Generic Level state */
|
||||
int16_t target_level; /*!< The target value of the Generic Level state */
|
||||
|
||||
/**
|
||||
* When a new transaction starts, level should be set to last_last, and use
|
||||
* "level + incoming delta" to calculate the target level. In another word,
|
||||
* "last_level" is used to record "level" of the last transaction, and
|
||||
* "last_delta" is used to record the previously received delta_level value.
|
||||
*/
|
||||
int16_t last_level; /*!< The last value of the Generic Level state */
|
||||
int32_t last_delta; /*!< The last delta change of the Generic Level state */
|
||||
|
||||
bool move_start; /*!< Indicate if the transition of the Generic Level state has been started */
|
||||
bool positive; /*!< Indicate if the transition is positive or negative */
|
||||
} esp_ble_mesh_gen_level_state_t;
|
||||
|
||||
/** User data of Generic Level Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Level Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_level_state_t state; /*!< Parameters of the Generic Level state */
|
||||
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
|
||||
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
|
||||
int32_t tt_delta_level; /*!< Delta change value of level state transition */
|
||||
} esp_ble_mesh_gen_level_srv_t;
|
||||
|
||||
/** Parameter of Generic Default Transition Time state */
|
||||
typedef struct {
|
||||
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
|
||||
} esp_ble_mesh_gen_def_trans_time_state_t;
|
||||
|
||||
/** User data of Generic Default Transition Time Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Default Transition Time Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_def_trans_time_state_t state; /*!< Parameters of the Generic Default Transition Time state */
|
||||
} esp_ble_mesh_gen_def_trans_time_srv_t;
|
||||
|
||||
/** Parameter of Generic OnPowerUp state */
|
||||
typedef struct {
|
||||
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
|
||||
} esp_ble_mesh_gen_onpowerup_state_t;
|
||||
|
||||
/** User data of Generic Power OnOff Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
|
||||
} esp_ble_mesh_gen_power_onoff_srv_t;
|
||||
|
||||
/** User data of Generic Power OnOff Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power OnOff Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_onpowerup_state_t *state; /*!< Parameters of the Generic OnPowerUp state */
|
||||
} esp_ble_mesh_gen_power_onoff_setup_srv_t;
|
||||
|
||||
/** Parameters of Generic Power Level state */
|
||||
typedef struct {
|
||||
uint16_t power_actual; /*!< The present value of the Generic Power Actual state */
|
||||
uint16_t target_power_actual; /*!< The target value of the Generic Power Actual state */
|
||||
|
||||
uint16_t power_last; /*!< The value of the Generic Power Last state */
|
||||
uint16_t power_default; /*!< The value of the Generic Power Default state */
|
||||
|
||||
uint8_t status_code; /*!< The status code of setting Generic Power Range state */
|
||||
uint16_t power_range_min; /*!< The minimum value of the Generic Power Range state */
|
||||
uint16_t power_range_max; /*!< The maximum value of the Generic Power Range state */
|
||||
} esp_ble_mesh_gen_power_level_state_t;
|
||||
|
||||
/** User data of Generic Power Level Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
|
||||
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
|
||||
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
|
||||
int32_t tt_delta_level; /*!< Delta change value of level state transition */
|
||||
} esp_ble_mesh_gen_power_level_srv_t;
|
||||
|
||||
/** User data of Generic Power Level Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Power Level Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_power_level_state_t *state; /*!< Parameters of the Generic Power Level state */
|
||||
} esp_ble_mesh_gen_power_level_setup_srv_t;
|
||||
|
||||
/** Parameters of Generic Battery state */
|
||||
typedef struct {
|
||||
uint32_t battery_level : 8, /*!< The value of the Generic Battery Level state */
|
||||
time_to_discharge : 24; /*!< The value of the Generic Battery Time to Discharge state */
|
||||
uint32_t time_to_charge : 24, /*!< The value of the Generic Battery Time to Charge state */
|
||||
battery_flags : 8; /*!< The value of the Generic Battery Flags state */
|
||||
} esp_ble_mesh_gen_battery_state_t;
|
||||
|
||||
/** User data of Generic Battery Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Battery Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_battery_state_t state; /*!< Parameters of the Generic Battery state */
|
||||
} esp_ble_mesh_gen_battery_srv_t;
|
||||
|
||||
/** Parameters of Generic Location state */
|
||||
typedef struct {
|
||||
int32_t global_latitude; /*!< The value of the Global Latitude field */
|
||||
int32_t global_longitude; /*!< The value of the Global Longitude field */
|
||||
int16_t global_altitude; /*!< The value of the Global Altitude field */
|
||||
int16_t local_north; /*!< The value of the Local North field */
|
||||
int16_t local_east; /*!< The value of the Local East field */
|
||||
int16_t local_altitude; /*!< The value of the Local Altitude field */
|
||||
uint8_t floor_number; /*!< The value of the Floor Number field */
|
||||
uint16_t uncertainty; /*!< The value of the Uncertainty field */
|
||||
} esp_ble_mesh_gen_location_state_t;
|
||||
|
||||
/** User data of Generic Location Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
|
||||
} esp_ble_mesh_gen_location_srv_t;
|
||||
|
||||
/** User data of Generic Location Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Location Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_gen_location_state_t *state; /*!< Parameters of the Generic Location state */
|
||||
} esp_ble_mesh_gen_location_setup_srv_t;
|
||||
|
||||
/** This enum value is the access value of Generic User Property */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_GEN_USER_ACCESS_PROHIBIT,
|
||||
ESP_BLE_MESH_GEN_USER_ACCESS_READ,
|
||||
ESP_BLE_MESH_GEN_USER_ACCESS_WRITE,
|
||||
ESP_BLE_MESH_GEN_USER_ACCESS_READ_WRITE,
|
||||
} esp_ble_mesh_gen_user_prop_access_t;
|
||||
|
||||
/** This enum value is the access value of Generic Admin Property */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_GEN_ADMIN_NOT_USER_PROP,
|
||||
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ,
|
||||
ESP_BLE_MESH_GEN_ADMIN_ACCESS_WRITE,
|
||||
ESP_BLE_MESH_GEN_ADMIN_ACCESS_READ_WRITE,
|
||||
} esp_ble_mesh_gen_admin_prop_access_t;
|
||||
|
||||
/** This enum value is the access value of Generic Manufacturer Property */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_GEN_MANU_NOT_USER_PROP,
|
||||
ESP_BLE_MESH_GEN_MANU_ACCESS_READ,
|
||||
} esp_ble_mesh_gen_manu_prop_access_t;
|
||||
|
||||
/** Parameters of Generic Property states */
|
||||
typedef struct {
|
||||
uint16_t id; /*!< The value of User/Admin/Manufacturer Property ID */
|
||||
uint8_t user_access; /*!< The value of User Access field */
|
||||
uint8_t admin_access; /*!< The value of Admin Access field */
|
||||
uint8_t manu_access; /*!< The value of Manufacturer Access field */
|
||||
struct net_buf_simple *val; /*!< The value of User/Admin/Manufacturer Property */
|
||||
} esp_ble_mesh_generic_property_t;
|
||||
|
||||
/** User data of Generic User Property Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic User Property Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
uint8_t property_count; /*!< Generic User Property count */
|
||||
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic User Property state */
|
||||
} esp_ble_mesh_gen_user_prop_srv_t;
|
||||
|
||||
/** User data of Generic Admin Property Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Admin Property Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
uint8_t property_count; /*!< Generic Admin Property count */
|
||||
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Admin Property state */
|
||||
} esp_ble_mesh_gen_admin_prop_srv_t;
|
||||
|
||||
/** User data of Generic Manufacturer Property Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Manufacturer Property Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
uint8_t property_count; /*!< Generic Manufacturer Property count */
|
||||
esp_ble_mesh_generic_property_t *properties; /*!< Parameters of the Generic Manufacturer Property state */
|
||||
} esp_ble_mesh_gen_manu_prop_srv_t;
|
||||
|
||||
/** User data of Generic Client Property Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Generic Client Property Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
uint8_t id_count; /*!< Generic Client Property ID count */
|
||||
uint16_t *property_ids; /*!< Parameters of the Generic Client Property state */
|
||||
} esp_ble_mesh_gen_client_prop_srv_t;
|
||||
|
||||
/** Parameter of Generic OnOff Set state change event */
|
||||
typedef struct {
|
||||
uint8_t onoff; /*!< The value of Generic OnOff state */
|
||||
} esp_ble_mesh_state_change_gen_onoff_set_t;
|
||||
|
||||
/** Parameter of Generic Level Set state change event */
|
||||
typedef struct {
|
||||
int16_t level; /*!< The value of Generic Level state */
|
||||
} esp_ble_mesh_state_change_gen_level_set_t;
|
||||
|
||||
/** Parameter of Generic Delta Set state change event */
|
||||
typedef struct {
|
||||
int16_t level; /*!< The value of Generic Level state */
|
||||
} esp_ble_mesh_state_change_gen_delta_set_t;
|
||||
|
||||
/** Parameter of Generic Move Set state change event */
|
||||
typedef struct {
|
||||
int16_t level; /*!< The value of Generic Level state */
|
||||
} esp_ble_mesh_state_change_gen_move_set_t;
|
||||
|
||||
/** Parameter of Generic Default Transition Time Set state change event */
|
||||
typedef struct {
|
||||
uint8_t trans_time; /*!< The value of Generic Default Transition Time state */
|
||||
} esp_ble_mesh_state_change_gen_def_trans_time_set_t;
|
||||
|
||||
/** Parameter of Generic OnPowerUp Set state change event */
|
||||
typedef struct {
|
||||
uint8_t onpowerup; /*!< The value of Generic OnPowerUp state */
|
||||
} esp_ble_mesh_state_change_gen_onpowerup_set_t;
|
||||
|
||||
/** Parameter of Generic Power Level Set state change event */
|
||||
typedef struct {
|
||||
uint16_t power; /*!< The value of Generic Power Actual state */
|
||||
} esp_ble_mesh_state_change_gen_power_level_set_t;
|
||||
|
||||
/** Parameter of Generic Power Default Set state change event */
|
||||
typedef struct {
|
||||
uint16_t power; /*!< The value of Generic Power Default state */
|
||||
} esp_ble_mesh_state_change_gen_power_default_set_t;
|
||||
|
||||
/** Parameters of Generic Power Range Set state change event */
|
||||
typedef struct {
|
||||
uint16_t range_min; /*!< The minimum value of Generic Power Range state */
|
||||
uint16_t range_max; /*!< The maximum value of Generic Power Range state */
|
||||
} esp_ble_mesh_state_change_gen_power_range_set_t;
|
||||
|
||||
/** Parameters of Generic Location Global Set state change event */
|
||||
typedef struct {
|
||||
int32_t latitude; /*!< The Global Latitude value of Generic Location state */
|
||||
int32_t longitude; /*!< The Global Longitude value of Generic Location state */
|
||||
int16_t altitude; /*!< The Global Altitude value of Generic Location state */
|
||||
} esp_ble_mesh_state_change_gen_loc_global_set_t;
|
||||
|
||||
/** Parameters of Generic Location Local Set state change event */
|
||||
typedef struct {
|
||||
int16_t north; /*!< The Local North value of Generic Location state */
|
||||
int16_t east; /*!< The Local East value of Generic Location state */
|
||||
int16_t altitude; /*!< The Local Altitude value of Generic Location state */
|
||||
uint8_t floor_number; /*!< The Floor Number value of Generic Location state */
|
||||
uint16_t uncertainty; /*!< The Uncertainty value of Generic Location state */
|
||||
} esp_ble_mesh_state_change_gen_loc_local_set_t;
|
||||
|
||||
/** Parameters of Generic User Property Set state change event */
|
||||
typedef struct {
|
||||
uint16_t id; /*!< The property id of Generic User Property state */
|
||||
struct net_buf_simple *value; /*!< The property value of Generic User Property state */
|
||||
} esp_ble_mesh_state_change_gen_user_property_set_t;
|
||||
|
||||
/** Parameters of Generic Admin Property Set state change event */
|
||||
typedef struct {
|
||||
uint16_t id; /*!< The property id of Generic Admin Property state */
|
||||
uint8_t access; /*!< The property access of Generic Admin Property state */
|
||||
struct net_buf_simple *value; /*!< The property value of Generic Admin Property state */
|
||||
} esp_ble_mesh_state_change_gen_admin_property_set_t;
|
||||
|
||||
/** Parameters of Generic Manufacturer Property Set state change event */
|
||||
typedef struct {
|
||||
uint16_t id; /*!< The property id of Generic Manufacturer Property state */
|
||||
uint8_t access; /*!< The property value of Generic Manufacturer Property state */
|
||||
} esp_ble_mesh_state_change_gen_manu_property_set_t;
|
||||
|
||||
/**
|
||||
* @brief Generic Server Model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_gen_onoff_set_t onoff_set; /*!< Generic OnOff Set */
|
||||
esp_ble_mesh_state_change_gen_level_set_t level_set; /*!< Generic Level Set */
|
||||
esp_ble_mesh_state_change_gen_delta_set_t delta_set; /*!< Generic Delta Set */
|
||||
esp_ble_mesh_state_change_gen_move_set_t move_set; /*!< Generic Move Set */
|
||||
esp_ble_mesh_state_change_gen_def_trans_time_set_t def_trans_time_set; /*!< Generic Default Transition Time Set */
|
||||
esp_ble_mesh_state_change_gen_onpowerup_set_t onpowerup_set; /*!< Generic OnPowerUp Set */
|
||||
esp_ble_mesh_state_change_gen_power_level_set_t power_level_set; /*!< Generic Power Level Set */
|
||||
esp_ble_mesh_state_change_gen_power_default_set_t power_default_set; /*!< Generic Power Default Set */
|
||||
esp_ble_mesh_state_change_gen_power_range_set_t power_range_set; /*!< Generic Power Range Set */
|
||||
esp_ble_mesh_state_change_gen_loc_global_set_t loc_global_set; /*!< Generic Location Global Set */
|
||||
esp_ble_mesh_state_change_gen_loc_local_set_t loc_local_set; /*!< Generic Location Local Set */
|
||||
esp_ble_mesh_state_change_gen_user_property_set_t user_property_set; /*!< Generic User Property Set */
|
||||
esp_ble_mesh_state_change_gen_admin_property_set_t admin_property_set; /*!< Generic Admin Property Set */
|
||||
esp_ble_mesh_state_change_gen_manu_property_set_t manu_property_set; /*!< Generic Manufacturer Property Set */
|
||||
} esp_ble_mesh_generic_server_state_change_t;
|
||||
|
||||
/** Context of the received Generic User Property Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
|
||||
} esp_ble_mesh_server_recv_gen_user_property_get_t;
|
||||
|
||||
/** Context of the received Generic Admin Property Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
|
||||
} esp_ble_mesh_server_recv_gen_admin_property_get_t;
|
||||
|
||||
/** Context of the received Generic Manufacturer Property message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
|
||||
} esp_ble_mesh_server_recv_gen_manufacturer_property_get_t;
|
||||
|
||||
/** Context of the received Generic Client Properties Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< A starting Client Property ID present within an element */
|
||||
} esp_ble_mesh_server_recv_gen_client_properties_get_t;
|
||||
|
||||
/**
|
||||
* @brief Generic Server Model received get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_gen_user_property_get_t user_property; /*!< Generic User Property Get */
|
||||
esp_ble_mesh_server_recv_gen_admin_property_get_t admin_property; /*!< Generic Admin Property Get */
|
||||
esp_ble_mesh_server_recv_gen_manufacturer_property_get_t manu_property; /*!< Generic Manufacturer Property Get */
|
||||
esp_ble_mesh_server_recv_gen_client_properties_get_t client_properties; /*!< Generic Client Properties Get */
|
||||
} esp_ble_mesh_generic_server_recv_get_msg_t;
|
||||
|
||||
/** Context of the received Generic OnOff Set message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint8_t onoff; /*!< Target value of Generic OnOff state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_gen_onoff_set_t;
|
||||
|
||||
/** Context of the received Generic Level Set message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
int16_t level; /*!< Target value of Generic Level state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_gen_level_set_t;
|
||||
|
||||
/** Context of the received Generic Delta Set message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
int32_t delta_level; /*!< Delta change of Generic Level state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_gen_delta_set_t;
|
||||
|
||||
/** Context of the received Generic Move Set message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
int16_t delta_level; /*!< Delta Level step to calculate Move speed for Generic Level state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_gen_move_set_t;
|
||||
|
||||
/** Context of the received Generic Default Transition Time Set message */
|
||||
typedef struct {
|
||||
uint8_t trans_time; /*!< The value of the Generic Default Transition Time state */
|
||||
} esp_ble_mesh_server_recv_gen_def_trans_time_set_t;
|
||||
|
||||
/** Context of the received Generic OnPowerUp Set message */
|
||||
typedef struct {
|
||||
uint8_t onpowerup; /*!< The value of the Generic OnPowerUp state */
|
||||
} esp_ble_mesh_server_recv_gen_onpowerup_set_t;
|
||||
|
||||
/** Context of the received Generic Power Level Set message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t power; /*!< Target value of Generic Power Actual state */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_gen_power_level_set_t;
|
||||
|
||||
/** Context of the received Generic Power Default Set message */
|
||||
typedef struct {
|
||||
uint16_t power; /*!< The value of the Generic Power Default state */
|
||||
} esp_ble_mesh_server_recv_gen_power_default_set_t;
|
||||
|
||||
/** Context of the received Generic Power Range Set message */
|
||||
typedef struct {
|
||||
uint16_t range_min; /*!< Value of Range Min field of Generic Power Range state */
|
||||
uint16_t range_max; /*!< Value of Range Max field of Generic Power Range state */
|
||||
} esp_ble_mesh_server_recv_gen_power_range_set_t;
|
||||
|
||||
/** Context of the received Generic Location Global Set message */
|
||||
typedef struct {
|
||||
int32_t global_latitude; /*!< Global Coordinates (Latitude) */
|
||||
int32_t global_longitude; /*!< Global Coordinates (Longitude) */
|
||||
int16_t global_altitude; /*!< Global Altitude */
|
||||
} esp_ble_mesh_server_recv_gen_loc_global_set_t;
|
||||
|
||||
/** Context of the received Generic Location Local Set message */
|
||||
typedef struct {
|
||||
int16_t local_north; /*!< Local Coordinates (North) */
|
||||
int16_t local_east; /*!< Local Coordinates (East) */
|
||||
int16_t local_altitude; /*!< Local Altitude */
|
||||
uint8_t floor_number; /*!< Floor Number */
|
||||
uint16_t uncertainty; /*!< Uncertainty */
|
||||
} esp_ble_mesh_server_recv_gen_loc_local_set_t;
|
||||
|
||||
/** Context of the received Generic User Property Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic User Property */
|
||||
struct net_buf_simple *property_value; /*!< Raw value for the User Property */
|
||||
} esp_ble_mesh_server_recv_gen_user_property_set_t;
|
||||
|
||||
/** Context of the received Generic Admin Property Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic Admin Property */
|
||||
uint8_t user_access; /*!< Enumeration indicating user access */
|
||||
struct net_buf_simple *property_value; /*!< Raw value for the Admin Property */
|
||||
} esp_ble_mesh_server_recv_gen_admin_property_set_t;
|
||||
|
||||
/** Context of the received Generic Manufacturer Property Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a Generic Manufacturer Property */
|
||||
uint8_t user_access; /*!< Enumeration indicating user access */
|
||||
} esp_ble_mesh_server_recv_gen_manufacturer_property_set_t;
|
||||
|
||||
/**
|
||||
* @brief Generic Server Model received set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_gen_onoff_set_t onoff; /*!< Generic OnOff Set/Generic OnOff Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_level_set_t level; /*!< Generic Level Set/Generic Level Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_delta_set_t delta; /*!< Generic Delta Set/Generic Delta Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_move_set_t move; /*!< Generic Move Set/Generic Move Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_def_trans_time_set_t def_trans_time; /*!< Generic Default Transition Time Set/Generic Default Transition Time Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_onpowerup_set_t onpowerup; /*!< Generic OnPowerUp Set/Generic OnPowerUp Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_power_level_set_t power_level; /*!< Generic Power Level Set/Generic Power Level Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_power_default_set_t power_default; /*!< Generic Power Default Set/Generic Power Default Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_power_range_set_t power_range; /*!< Generic Power Range Set/Generic Power Range Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_loc_global_set_t location_global; /*!< Generic Location Global Set/Generic Location Global Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_loc_local_set_t location_local; /*!< Generic Location Local Set/Generic Location Local Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_user_property_set_t user_property; /*!< Generic User Property Set/Generic User Property Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_admin_property_set_t admin_property; /*!< Generic Admin Property Set/Generic Admin Property Set Unack */
|
||||
esp_ble_mesh_server_recv_gen_manufacturer_property_set_t manu_property; /*!< Generic Manufacturer Property Set/Generic Manufacturer Property Set Unack */
|
||||
} esp_ble_mesh_generic_server_recv_set_msg_t;
|
||||
|
||||
/**
|
||||
* @brief Generic Server Model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_generic_server_state_change_t state_change; /*!< ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_generic_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT */
|
||||
esp_ble_mesh_generic_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT */
|
||||
} esp_ble_mesh_generic_server_cb_value_t;
|
||||
|
||||
/** Generic Server Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Generic Server Models */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
|
||||
esp_ble_mesh_generic_server_cb_value_t value; /*!< Value of the received Generic Messages */
|
||||
} esp_ble_mesh_generic_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Generic Server Model */
|
||||
typedef enum {
|
||||
/**
|
||||
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
|
||||
* callback to the application layer when Generic Get messages are received.
|
||||
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
|
||||
* be callback to the application layer when Generic Set/Set Unack messages
|
||||
* are received.
|
||||
*/
|
||||
ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT,
|
||||
/**
|
||||
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Generic Get messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT,
|
||||
/**
|
||||
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Generic Set/Set Unack messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT,
|
||||
ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_generic_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Generic Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Generic Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_generic_server_cb_t)(esp_ble_mesh_generic_server_cb_event_t event,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Generic Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_generic_server_callback(esp_ble_mesh_generic_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_GENERIC_MODEL_API_H_ */
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
||||
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_HEALTH_SRV
|
||||
*
|
||||
* @brief Define a new Health Server Model.
|
||||
@ -47,39 +51,123 @@
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_HEALTH_CLI, \
|
||||
NULL, NULL, cli_data)
|
||||
|
||||
/** Health Server Model callbacks */
|
||||
/** @def ESP_BLE_MESH_HEALTH_PUB_DEFINE
|
||||
*
|
||||
* A helper to define a health publication context
|
||||
*
|
||||
* @param _name Name given to the publication context variable.
|
||||
* @param _max Maximum number of faults the element can have.
|
||||
* @param _role Role of the device which contains the model.
|
||||
*/
|
||||
#define ESP_BLE_MESH_HEALTH_PUB_DEFINE(_name, _max, _role) \
|
||||
ESP_BLE_MESH_MODEL_PUB_DEFINE(_name, (1 + 3 + (_max)), _role)
|
||||
|
||||
/**
|
||||
* SIG identifier of Health Fault Test.
|
||||
* 0x01 ~ 0xFF: Vendor Specific Test.
|
||||
*/
|
||||
#define ESP_BLE_MESH_HEALTH_STANDARD_TEST 0x00
|
||||
|
||||
/**
|
||||
* Fault values of Health Fault Test.
|
||||
* 0x33 ~ 0x7F: Reserved for Future Use.
|
||||
* 0x80 ~ 0xFF: Vendor Specific Warning/Error.
|
||||
*/
|
||||
#define ESP_BLE_MESH_NO_FAULT 0x00
|
||||
#define ESP_BLE_MESH_BATTERY_LOW_WARNING 0x01
|
||||
#define ESP_BLE_MESH_BATTERY_LOW_ERROR 0x02
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_WARNING 0x03
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_LOW_ERROR 0x04
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_WARNING 0x05
|
||||
#define ESP_BLE_MESH_SUPPLY_VOLTAGE_TOO_HIGH_ERROR 0x06
|
||||
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_WARNING 0x07
|
||||
#define ESP_BLE_MESH_POWER_SUPPLY_INTERRUPTED_ERROR 0x08
|
||||
#define ESP_BLE_MESH_NO_LOAD_WARNING 0x09
|
||||
#define ESP_BLE_MESH_NO_LOAD_ERROR 0x0A
|
||||
#define ESP_BLE_MESH_OVERLOAD_WARNING 0x0B
|
||||
#define ESP_BLE_MESH_OVERLOAD_ERROR 0x0C
|
||||
#define ESP_BLE_MESH_OVERHEAT_WARNING 0x0D
|
||||
#define ESP_BLE_MESH_OVERHEAT_ERROR 0x0E
|
||||
#define ESP_BLE_MESH_CONDENSATION_WARNING 0x0F
|
||||
#define ESP_BLE_MESH_CONDENSATION_ERROR 0x10
|
||||
#define ESP_BLE_MESH_VIBRATION_WARNING 0x11
|
||||
#define ESP_BLE_MESH_VIBRATION_ERROR 0x12
|
||||
#define ESP_BLE_MESH_CONFIGURATION_WARNING 0x13
|
||||
#define ESP_BLE_MESH_CONFIGURATION_ERROR 0x14
|
||||
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_WARNING 0x15
|
||||
#define ESP_BLE_MESH_ELEMENT_NOT_CALIBRATED_ERROR 0x16
|
||||
#define ESP_BLE_MESH_MEMORY_WARNING 0x17
|
||||
#define ESP_BLE_MESH_MEMORY_ERROR 0x18
|
||||
#define ESP_BLE_MESH_SELF_TEST_WARNING 0x19
|
||||
#define ESP_BLE_MESH_SELF_TEST_ERROR 0x1A
|
||||
#define ESP_BLE_MESH_INPUT_TOO_LOW_WARNING 0x1B
|
||||
#define ESP_BLE_MESH_INPUT_TOO_LOW_ERROR 0x1C
|
||||
#define ESP_BLE_MESH_INPUT_TOO_HIGH_WARNING 0x1D
|
||||
#define ESP_BLE_MESH_INPUT_TOO_HIGH_ERROR 0x1E
|
||||
#define ESP_BLE_MESH_INPUT_NO_CHANGE_WARNING 0x1F
|
||||
#define ESP_BLE_MESH_INPUT_NO_CHANGE_ERROR 0x20
|
||||
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_WARNING 0x21
|
||||
#define ESP_BLE_MESH_ACTUATOR_BLOCKED_ERROR 0x22
|
||||
#define ESP_BLE_MESH_HOUSING_OPENED_WARNING 0x23
|
||||
#define ESP_BLE_MESH_HOUSING_OPENED_ERROR 0x24
|
||||
#define ESP_BLE_MESH_TAMPER_WARNING 0x25
|
||||
#define ESP_BLE_MESH_TAMPER_ERROR 0x26
|
||||
#define ESP_BLE_MESH_DEVICE_MOVED_WARNING 0x27
|
||||
#define ESP_BLE_MESH_DEVICE_MOVED_ERROR 0x28
|
||||
#define ESP_BLE_MESH_DEVICE_DROPPED_WARNING 0x29
|
||||
#define ESP_BLE_MESH_DEVICE_DROPPED_ERROR 0x2A
|
||||
#define ESP_BLE_MESH_OVERFLOW_WARNING 0x2B
|
||||
#define ESP_BLE_MESH_OVERFLOW_ERROR 0x2C
|
||||
#define ESP_BLE_MESH_EMPTY_WARNING 0x2D
|
||||
#define ESP_BLE_MESH_EMPTY_ERROR 0x2E
|
||||
#define ESP_BLE_MESH_INTERNAL_BUS_WARNING 0x2F
|
||||
#define ESP_BLE_MESH_INTERNAL_BUS_ERROR 0x30
|
||||
#define ESP_BLE_MESH_MECHANISM_JAMMED_WARNING 0x31
|
||||
#define ESP_BLE_MESH_MECHANISM_JAMMED_ERROR 0x32
|
||||
|
||||
/** ESP BLE Mesh Health Server callback */
|
||||
typedef struct {
|
||||
/** Fetch current faults */
|
||||
int (*fault_get_cur)(esp_ble_mesh_model_t *model, uint8_t *test_id,
|
||||
uint16_t *company_id, uint8_t *faults, uint8_t *fault_count);
|
||||
/** Clear health registered faults. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t fault_clear;
|
||||
|
||||
/** Fetch registered faults */
|
||||
int (*fault_get_reg)(esp_ble_mesh_model_t *model, uint16_t company_id,
|
||||
uint8_t *test_id, uint8_t *faults, uint8_t *fault_count);
|
||||
/** Run a specific health test. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t fault_test;
|
||||
|
||||
/** Clear registered faults */
|
||||
int (*fault_clear)(esp_ble_mesh_model_t *model, uint16_t company_id);
|
||||
/** Health attention on callback. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t attention_on;
|
||||
|
||||
/** Run a specific test */
|
||||
int (*fault_test)(esp_ble_mesh_model_t *model, uint8_t test_id, uint16_t company_id);
|
||||
|
||||
/** Attention on */
|
||||
void (*attn_on)(esp_ble_mesh_model_t *model);
|
||||
|
||||
/** Attention off */
|
||||
void (*attn_off)(esp_ble_mesh_model_t *model);
|
||||
/** Health attention off callback. Initialized by the stack. */
|
||||
esp_ble_mesh_cb_t attention_off;
|
||||
} esp_ble_mesh_health_srv_cb_t;
|
||||
|
||||
/** Health Server Model Context */
|
||||
#define ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE 32
|
||||
|
||||
/** ESP BLE Mesh Health Server test Context */
|
||||
typedef struct {
|
||||
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; /*!< Current test ID of the health fault test */
|
||||
uint8_t current_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of current faults */
|
||||
uint8_t registered_faults[ESP_BLE_MESH_HEALTH_FAULT_ARRAY_SIZE]; /*!< Array of registered faults */
|
||||
} __attribute__((packed)) esp_ble_mesh_health_test_t;
|
||||
|
||||
/** ESP BLE Mesh Health Server Model Context */
|
||||
typedef struct {
|
||||
/** Pointer to Health Server Model */
|
||||
esp_ble_mesh_model_t *model;
|
||||
|
||||
/** Optional callback struct */
|
||||
const esp_ble_mesh_health_srv_cb_t *cb;
|
||||
/** Health callback struct */
|
||||
esp_ble_mesh_health_srv_cb_t health_cb;
|
||||
|
||||
/** Attention Timer state */
|
||||
struct k_delayed_work attn_timer;
|
||||
struct k_delayed_work attention_timer;
|
||||
|
||||
/** Attention Timer start flag */
|
||||
bool attention_timer_start;
|
||||
|
||||
/** Health Server fault test */
|
||||
esp_ble_mesh_health_test_t health_test;
|
||||
} esp_ble_mesh_health_srv_t;
|
||||
|
||||
/** Parameter of Health Fault Get */
|
||||
@ -186,14 +274,54 @@ typedef enum {
|
||||
ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX,
|
||||
} esp_ble_mesh_health_client_cb_event_t;
|
||||
|
||||
/** Health Server Model callback parameter */
|
||||
/** Parameter of publishing Health Current Status completion event */
|
||||
typedef struct {
|
||||
int error_code; /*!< Appropriate error code */
|
||||
int error_code; /*!< The result of publishing Health Current Status */
|
||||
esp_ble_mesh_elem_t *element; /*!< Pointer to the element which contains the Health Server Model */
|
||||
} esp_ble_mesh_health_fault_update_comp_cb_t;
|
||||
|
||||
/** Parameters of Health Fault Clear event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_clear_cb_t;
|
||||
|
||||
/** Parameters of Health Fault Test event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint8_t test_id; /*!< ID of a specific test to be performed */
|
||||
uint16_t company_id; /*!< Bluetooth assigned 16-bit Company ID */
|
||||
} esp_ble_mesh_health_fault_test_cb_t;
|
||||
|
||||
/** Parameter of Health Attention On event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
uint8_t time; /*!< Duration of attention timer on (in seconds) */
|
||||
} esp_ble_mesh_health_attention_on_cb_t;
|
||||
|
||||
/** Parameter of Health Attention Off event */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Health Server Model */
|
||||
} esp_ble_mesh_health_attention_off_cb_t;
|
||||
|
||||
/**
|
||||
* @brief Health Server Model callback parameters union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_health_fault_update_comp_cb_t fault_update_comp; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT */
|
||||
esp_ble_mesh_health_fault_clear_cb_t fault_clear; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT */
|
||||
esp_ble_mesh_health_fault_test_cb_t fault_test; /*!< ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT */
|
||||
esp_ble_mesh_health_attention_on_cb_t attention_on; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT */
|
||||
esp_ble_mesh_health_attention_off_cb_t attention_off; /*!< ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT */
|
||||
} esp_ble_mesh_health_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Health Server Model */
|
||||
typedef enum {
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_FAULT_TEST_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT,
|
||||
ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_health_server_cb_event_t;
|
||||
|
||||
@ -207,7 +335,7 @@ typedef enum {
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_event_t event,
|
||||
esp_ble_mesh_health_client_cb_param_t *param);
|
||||
esp_ble_mesh_health_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Health Server Model callback function type
|
||||
@ -215,7 +343,7 @@ typedef void (* esp_ble_mesh_health_client_cb_t)(esp_ble_mesh_health_client_cb_e
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_health_server_cb_t)(esp_ble_mesh_health_server_cb_event_t event,
|
||||
esp_ble_mesh_health_server_cb_param_t *param);
|
||||
esp_ble_mesh_health_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Health Model callback, the callback will report Health Client & Server Model events.
|
||||
@ -251,7 +379,7 @@ esp_err_t esp_ble_mesh_register_health_server_callback(esp_ble_mesh_health_serve
|
||||
*
|
||||
*/
|
||||
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);
|
||||
esp_ble_mesh_health_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called to set the Health Server states using the Health Client Model set messages.
|
||||
@ -267,10 +395,10 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state);
|
||||
esp_ble_mesh_health_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief This function is called by the Health Server Model to start to publish its Current Health Fault.
|
||||
* @brief This function is called by the Health Server Model to update the context of its Health Current status.
|
||||
*
|
||||
* @param[in] element: The element to which the Health Server Model belongs.
|
||||
*
|
||||
@ -279,4 +407,8 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_health_server_fault_update(esp_ble_mesh_elem_t *element);
|
||||
|
||||
#endif /** _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_HEALTH_MODEL_API_H_ */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,9 +19,12 @@
|
||||
#ifndef _ESP_BLE_MESH_SENSOR_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_SENSOR_MODEL_API_H_
|
||||
|
||||
#include "sensor_client.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_CLI
|
||||
*
|
||||
* @brief Define a new Sensor Client Model.
|
||||
@ -45,60 +48,60 @@
|
||||
/** Parameters of Sensor Descriptor Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
u16_t property_id; /*!< Property ID of a sensor (optional) */
|
||||
uint16_t property_id; /*!< Property ID of a sensor (optional) */
|
||||
} esp_ble_mesh_sensor_descriptor_get_t;
|
||||
|
||||
/** Parameter of Sensor Cadence Get */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property ID of a sensor */
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_sensor_cadence_get_t;
|
||||
|
||||
/** Parameters of Sensor Cadence Set */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property ID for the sensor */
|
||||
u8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
|
||||
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
|
||||
uint16_t property_id; /*!< Property ID for the sensor */
|
||||
uint8_t fast_cadence_period_divisor : 7, /*!< Divisor for the publish period */
|
||||
status_trigger_type : 1; /*!< The unit and format of the Status Trigger Delta fields */
|
||||
struct net_buf_simple *status_trigger_delta_down; /*!< Delta down value that triggers a status message */
|
||||
struct net_buf_simple *status_trigger_delta_up; /*!< Delta up value that triggers a status message */
|
||||
u8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
|
||||
uint8_t status_min_interval; /*!< Minimum interval between two consecutive Status messages */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< Low value for the fast cadence range */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< Fast value for the fast cadence range */
|
||||
} esp_ble_mesh_sensor_cadence_set_t;
|
||||
|
||||
/** Parameter of Sensor Settings Get */
|
||||
typedef struct {
|
||||
u16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
uint16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_sensor_settings_get_t;
|
||||
|
||||
/** Parameters of Sensor Setting Get */
|
||||
typedef struct {
|
||||
u16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
uint16_t sensor_property_id; /*!< Property ID of a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
} esp_ble_mesh_sensor_setting_get_t;
|
||||
|
||||
/** Parameters of Sensor Setting Set */
|
||||
typedef struct {
|
||||
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_sensor_setting_set_t;
|
||||
|
||||
/** Parameters of Sensor Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
u16_t property_id; /*!< Property ID for the sensor (optional) */
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID for the sensor (optional) */
|
||||
} esp_ble_mesh_sensor_get_t;
|
||||
|
||||
/** Parameters of Sensor Column Get */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property identifying a sensor */
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
|
||||
} esp_ble_mesh_sensor_column_get_t;
|
||||
|
||||
/** Parameters of Sensor Series Get */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
u16_t property_id; /*!< Property identifying a sensor */
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x1; /*!< Raw value identifying a starting column (optional) */
|
||||
struct net_buf_simple *raw_value_x2; /*!< Raw value identifying an ending column (C.1) */
|
||||
} esp_ble_mesh_sensor_series_get_t;
|
||||
@ -135,22 +138,22 @@ typedef struct {
|
||||
|
||||
/** Parameters of Sensor Cadence Status */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property for the sensor */
|
||||
uint16_t property_id; /*!< Property for the sensor */
|
||||
struct net_buf_simple *sensor_cadence_value; /*!< Value of sensor cadence state */
|
||||
} esp_ble_mesh_sensor_cadence_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Settings Status */
|
||||
typedef struct {
|
||||
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
struct net_buf_simple *sensor_setting_property_ids; /*!< A sequence of N sensor setting property IDs (optional) */
|
||||
} esp_ble_mesh_sensor_settings_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Setting Status */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate id optional parameters are included */
|
||||
u16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
u16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
u8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
|
||||
bool op_en; /*!< Indicate id optional parameters are included */
|
||||
uint16_t sensor_property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t sensor_setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
uint8_t sensor_setting_access; /*!< Read/Write access rights for the setting (optional) */
|
||||
struct net_buf_simple *sensor_setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_sensor_setting_status_cb_t;
|
||||
|
||||
@ -161,13 +164,13 @@ typedef struct {
|
||||
|
||||
/** Parameters of Sensor Column Status */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
struct net_buf_simple *sensor_column_value; /*!< Left values of sensor column status */
|
||||
} esp_ble_mesh_sensor_column_status_cb_t;
|
||||
|
||||
/** Parameters of Sensor Series Status */
|
||||
typedef struct {
|
||||
u16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
uint16_t property_id; /*!< Property identifying a sensor and the Y axis */
|
||||
struct net_buf_simple *sensor_series_value; /*!< Left values of sensor series status */
|
||||
} esp_ble_mesh_sensor_series_status_cb_t;
|
||||
|
||||
@ -212,7 +215,7 @@ typedef enum {
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_client_cb_t)(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param);
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Client Model callback.
|
||||
@ -238,7 +241,7 @@ esp_err_t esp_ble_mesh_register_sensor_client_callback(esp_ble_mesh_sensor_clien
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state);
|
||||
esp_ble_mesh_sensor_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Sensor Server Model states using the Sensor Client Model set messages.
|
||||
@ -254,7 +257,462 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state);
|
||||
esp_ble_mesh_sensor_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Models related context.
|
||||
*/
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_SRV
|
||||
*
|
||||
* @brief Define a new Sensor Server Model.
|
||||
*
|
||||
* @note 1. The Sensor Server model is a root model. When this model is present
|
||||
* on an element, the corresponding Sensor Setup Server model shall
|
||||
* also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_srv_t.
|
||||
*
|
||||
* @return New Sensor Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SENSOR_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Sensor Setup Server Model.
|
||||
*
|
||||
* @note 1. The Sensor Setup Server model extends the Sensor Server model.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_sensor_setup_srv_t.
|
||||
*
|
||||
* @return New Sensor Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SENSOR_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SENSOR_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SENSOR_PROPERTY_ID 0x0000 /*!< Invalid Sensor Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DESCRIPTOR_LEN 0x08 /*!< Length of Sensor Descriptor state */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_POS_TOLERANCE 0x000 /*!< Unspecified Sensor Positive Tolerance */
|
||||
#define ESP_BLE_MESH_SENSOR_UNSPECIFIED_NEG_TOLERANCE 0x000 /*!< Unspecified Sensor Negative Tolerance */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_NOT_APPL_MEASURE_PERIOD 0x00 /*!< Not applicable Sensor Measurement Period */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_NOT_APPL_UPDATE_INTERVAL 0x00 /*!< Not applicable Sensor Update Interval */
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SENSOR_SETTING_PROPERTY_ID 0x0000 /*!< Invalid Sensor Setting Property ID */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_PROPERTY_ID_LEN 0x02 /*!< Length of Sensor Setting Property ID */
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_LEN 0x01 /*!< Length of Sensor Setting Access */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ 0x01 /*!< Sensor Setting Access - Read */
|
||||
#define ESP_BLE_MESH_SENSOR_SETTING_ACCESS_READ_WRITE 0x03 /*!< Sensor Setting Access - Read & Write */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DIVISOR_TRIGGER_TYPE_LEN 0x01 /*!< Length of Sensor Divisor Trigger Type */
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_LEN 0x01 /*!< Length of Sensor Status Min Interval */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_PERIOD_DIVISOR_MAX_VALUE 15 /*!< Maximum value of Sensor Period Divisor */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_MIN_INTERVAL_MAX 26 /*!< Maximum value of Sensor Status Min Interval */
|
||||
|
||||
/**
|
||||
* Sensor Status Trigger Type - Format Type of the characteristic
|
||||
* that the Sensor Property ID state references
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_CHAR 0
|
||||
/** Sensor Status Trigger Type - Format Type "uint16" */
|
||||
#define ESP_BLE_MESH_SENSOR_STATUS_TRIGGER_TYPE_UINT16 1
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A 0x00 /*!< Sensor Data Format A */
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B 0x01 /*!< Sensor Data Format B */
|
||||
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID_LEN 0x02 /*!< MPID length of Sensor Data Format A */
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID_LEN 0x03 /*!< MPID length of Sensor Data Format B */
|
||||
|
||||
/**
|
||||
* Zero length of Sensor Data.
|
||||
*
|
||||
* Note:
|
||||
* The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
|
||||
* representing range of 1–127). The value 0x7F represents a length
|
||||
* of zero.
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_ZERO_LEN 0x7F
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT
|
||||
*
|
||||
* @brief Get format of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting the format of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
*
|
||||
* @return Format of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_FORMAT(_data) (((_data)[0]) & BIT_MASK(1))
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH
|
||||
*
|
||||
* @brief Get length of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting the length of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
* @param _fmt Format of the sensor data.
|
||||
*
|
||||
* @return Length (zero-based) of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_LENGTH(_data, _fmt) \
|
||||
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[0]) >> 1) & BIT_MASK(4)) : ((((_data)[0]) >> 1) & BIT_MASK(7)))
|
||||
|
||||
/** @def ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID
|
||||
*
|
||||
* @brief Get Sensor Property ID of the sensor data.
|
||||
*
|
||||
* @note Multiple sensor data may be concatenated. Make sure the _data pointer is
|
||||
* updated before getting Sensor Property ID of the corresponding sensor data.
|
||||
*
|
||||
* @param _data Pointer to the start of the sensor data.
|
||||
* @param _fmt Format of the sensor data.
|
||||
*
|
||||
* @return Sensor Property ID of the sensor data.
|
||||
*/
|
||||
#define ESP_BLE_MESH_GET_SENSOR_DATA_PROPERTY_ID(_data, _fmt) \
|
||||
(((_fmt) == ESP_BLE_MESH_SENSOR_DATA_FORMAT_A) ? ((((_data)[1]) << 3) | (((_data)[0]) >> 5)) : ((((_data)[2]) << 8) | ((_data)[1])))
|
||||
|
||||
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID
|
||||
*
|
||||
* @brief Generate a MPID value for sensor data with Format A.
|
||||
*
|
||||
* @note 1. The Format field is 0b0 and indicates that Format A is used.
|
||||
* 2. The Length field is a 1-based uint4 value (valid range 0x0–0xF,
|
||||
* representing range of 1–16).
|
||||
* 3. The Property ID is an 11-bit bit field representing 11 LSb of a Property ID.
|
||||
* 4. This format may be used for Property Values that are not longer than 16
|
||||
* octets and for Property IDs less than 0x0800.
|
||||
*
|
||||
* @param _len Length of Sensor Raw value.
|
||||
* @param _id Sensor Property ID.
|
||||
*
|
||||
* @return 2-octet MPID value for sensor data with Format A.
|
||||
*
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_A_MPID(_len, _id) \
|
||||
((((_id) & BIT_MASK(11)) << 5) | (((_len) & BIT_MASK(4)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_A)
|
||||
|
||||
/** @def ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID
|
||||
*
|
||||
* @brief Generate a MPID value for sensor data with Format B.
|
||||
*
|
||||
* @note 1. The Format field is 0b1 and indicates Format B is used.
|
||||
* 2. The Length field is a 1-based uint7 value (valid range 0x0–0x7F, representing
|
||||
* range of 1–127). The value 0x7F represents a length of zero.
|
||||
* 3. The Property ID is a 16-bit bit field representing a Property ID.
|
||||
* 4. This format may be used for Property Values not longer than 128 octets and for
|
||||
* any Property IDs. Property values longer than 128 octets are not supported by
|
||||
* the Sensor Status message.
|
||||
* 5. Exclude the generated 1-octet value, the 2-octet Sensor Property ID
|
||||
*
|
||||
* @param _len Length of Sensor Raw value.
|
||||
* @param _id Sensor Property ID.
|
||||
*
|
||||
* @return 3-octet MPID value for sensor data with Format B.
|
||||
*
|
||||
*/
|
||||
#define ESP_BLE_MESH_SENSOR_DATA_FORMAT_B_MPID(_len, _id) \
|
||||
(((_id) << 8) | (((_len) & BIT_MASK(7)) << 1) | ESP_BLE_MESH_SENSOR_DATA_FORMAT_B)
|
||||
|
||||
/** This enum value is value of Sensor Sampling Function */
|
||||
enum esp_ble_mesh_sensor_sample_func {
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_UNSPECIFIED,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_INSTANTANEOUS,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_ARITHMETIC_MEAN,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_RMS,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_MAXIMUM,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_MINIMUM,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_ACCUMULATED,
|
||||
ESP_BLE_MESH_SAMPLE_FUNC_COUNT,
|
||||
};
|
||||
|
||||
/** Parameters of Sensor Descriptor state */
|
||||
typedef struct {
|
||||
uint32_t positive_tolerance : 12, /*!< The value of Sensor Positive Tolerance field */
|
||||
negative_tolerance : 12, /*!< The value of Sensor Negative Tolerance field */
|
||||
sampling_function : 8; /*!< The value of Sensor Sampling Function field */
|
||||
uint8_t measure_period; /*!< The value of Sensor Measurement Period field */
|
||||
uint8_t update_interval; /*!< The value of Sensor Update Interval field */
|
||||
} esp_ble_mesh_sensor_descriptor_t;
|
||||
|
||||
/** Parameters of Sensor Setting state */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Setting Property ID field */
|
||||
uint8_t access; /*!< The value of Sensor Setting Access field */
|
||||
struct net_buf_simple *raw; /*!< The value of Sensor Setting Raw field */
|
||||
} esp_ble_mesh_sensor_setting_t;
|
||||
|
||||
/** Parameters of Sensor Cadence state */
|
||||
typedef struct {
|
||||
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor field */
|
||||
trigger_type : 1; /*!< The value of Status Trigger Type field */
|
||||
/**
|
||||
* Note:
|
||||
* The parameter "size" in trigger_delta_down, trigger_delta_up, fast_cadence_low &
|
||||
* fast_cadence_high indicates the exact length of these four parameters, and they
|
||||
* are associated with the Sensor Property ID. Users need to initialize the "size"
|
||||
* precisely.
|
||||
*/
|
||||
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down field */
|
||||
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up field */
|
||||
uint8_t min_interval; /*!< The value of Status Min Interval field */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low field */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High field */
|
||||
} esp_ble_mesh_sensor_cadence_t;
|
||||
|
||||
/** Parameters of Sensor Data state */
|
||||
typedef struct {
|
||||
/**
|
||||
* Format A: The Length field is a 1-based uint4 value (valid range 0x0–0xF,
|
||||
* representing range of 1 – 16).
|
||||
* Format B: The Length field is a 1-based uint7 value (valid range 0x0–0x7F,
|
||||
* representing range of 1 – 127). The value 0x7F represents a
|
||||
* length of zero.
|
||||
*/
|
||||
uint8_t format : 1, /*!< The value of the Sensor Data format */
|
||||
length : 7; /*!< The value of the Sensor Data length */
|
||||
struct net_buf_simple *raw_value; /*!< The value of Sensor Data raw value */
|
||||
} esp_ble_mesh_sensor_data_t;
|
||||
|
||||
/** Parameters of Sensor Series Column state */
|
||||
typedef struct {
|
||||
struct net_buf_simple *raw_value_x; /*!< The value of Sensor Raw Value X field */
|
||||
struct net_buf_simple *column_width; /*!< The value of Sensor Column Width field */
|
||||
struct net_buf_simple *raw_value_y; /*!< The value of Sensor Raw Value Y field */
|
||||
} esp_ble_mesh_sensor_series_column_t;
|
||||
|
||||
/** Parameters of Sensor states */
|
||||
typedef struct {
|
||||
uint16_t sensor_property_id; /*!< The value of Sensor Property ID field */
|
||||
|
||||
/* Constant throughout the lifetime of an element */
|
||||
esp_ble_mesh_sensor_descriptor_t descriptor; /*!< Parameters of the Sensor Descriptor state */
|
||||
|
||||
/**
|
||||
* Multiple Sensor Setting states may be present for each sensor.
|
||||
* The Sensor Setting Property ID values shall be unique for each
|
||||
* Sensor Property ID that identifies a sensor within an element.
|
||||
*/
|
||||
const uint8_t setting_count; /*!< */
|
||||
esp_ble_mesh_sensor_setting_t *settings; /*!< Parameters of the Sensor Setting state */
|
||||
|
||||
/**
|
||||
* The Sensor Cadence state may be not supported by sensors based
|
||||
* on device properties referencing "non-scalar characteristics"
|
||||
* such as "histograms" or "composite characteristics".
|
||||
*/
|
||||
esp_ble_mesh_sensor_cadence_t *cadence; /*!< Parameters of the Sensor Cadence state */
|
||||
|
||||
esp_ble_mesh_sensor_data_t sensor_data; /*!< Parameters of the Sensor Data state */
|
||||
|
||||
esp_ble_mesh_sensor_series_column_t series_column; /*!< Parameters of the Sensor Series Column state */
|
||||
} esp_ble_mesh_sensor_state_t;
|
||||
|
||||
/** User data of Sensor Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
const uint8_t state_count; /*!< Sensor state count */
|
||||
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
|
||||
} esp_ble_mesh_sensor_srv_t;
|
||||
|
||||
/** User data of Sensor Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Sensor Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
const uint8_t state_count; /*!< Sensor state count */
|
||||
esp_ble_mesh_sensor_state_t *states; /*!< Parameters of the Sensor states */
|
||||
} esp_ble_mesh_sensor_setup_srv_t;
|
||||
|
||||
/** Parameters of Sensor Cadence Set state change event */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Property ID state */
|
||||
uint8_t period_divisor : 7, /*!< The value of Fast Cadence Period Divisor state */
|
||||
trigger_type : 1; /*!< The value of Status Trigger Type state */
|
||||
struct net_buf_simple *trigger_delta_down; /*!< The value of Status Trigger Delta Down state */
|
||||
struct net_buf_simple *trigger_delta_up; /*!< The value of Status Trigger Delta Up state */
|
||||
uint8_t min_interval; /*!< The value of Status Min Interval state */
|
||||
struct net_buf_simple *fast_cadence_low; /*!< The value of Fast Cadence Low state */
|
||||
struct net_buf_simple *fast_cadence_high; /*!< The value of Fast Cadence High state */
|
||||
} esp_ble_mesh_state_change_sensor_cadence_set_t;
|
||||
|
||||
/** Parameters of Sensor Setting Set state change event */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< The value of Sensor Property ID state */
|
||||
uint16_t setting_property_id; /*!< The value of Sensor Setting Property ID state */
|
||||
struct net_buf_simple *setting_value; /*!< The value of Sensor Property Value state */
|
||||
} esp_ble_mesh_state_change_sensor_setting_set_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_sensor_cadence_set_t sensor_cadence_set; /*!< Sensor Cadence Set */
|
||||
esp_ble_mesh_state_change_sensor_setting_set_t sensor_setting_set; /*!< Sensor Setting Set */
|
||||
} esp_ble_mesh_sensor_server_state_change_t;
|
||||
|
||||
/** Context of the received Sensor Descriptor Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID of a sensor (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_descriptor_get_t;
|
||||
|
||||
/** Context of the received Sensor Cadence Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_cadence_get_t;
|
||||
|
||||
/** Context of the received Sensor Settings Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_settings_get_t;
|
||||
|
||||
/** Context of the received Sensor Setting Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID of a sensor */
|
||||
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
} esp_ble_mesh_server_recv_sensor_setting_get_t;
|
||||
|
||||
/** Context of the received Sensor Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property ID for the sensor (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_get_t;
|
||||
|
||||
/** Context of the received Sensor Column Get message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value_x; /*!< Raw value identifying a column */
|
||||
} esp_ble_mesh_server_recv_sensor_column_get_t;
|
||||
|
||||
/** Context of the received Sensor Series Get message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t property_id; /*!< Property identifying a sensor */
|
||||
struct net_buf_simple *raw_value; /*!< Raw value containing X1 and X2 (optional) */
|
||||
} esp_ble_mesh_server_recv_sensor_series_get_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model received get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_sensor_descriptor_get_t sensor_descriptor; /*!< Sensor Descriptor Get */
|
||||
esp_ble_mesh_server_recv_sensor_cadence_get_t sensor_cadence; /*!< Sensor Cadence Get */
|
||||
esp_ble_mesh_server_recv_sensor_settings_get_t sensor_settings; /*!< Sensor Settings Get */
|
||||
esp_ble_mesh_server_recv_sensor_setting_get_t sensor_setting; /*!< Sensor Setting Get */
|
||||
esp_ble_mesh_server_recv_sensor_get_t sensor_data; /*!< Sensor Get */
|
||||
esp_ble_mesh_server_recv_sensor_column_get_t sensor_column; /*!< Sensor Column Get */
|
||||
esp_ble_mesh_server_recv_sensor_series_get_t sensor_series; /*!< Sensor Series Get */
|
||||
} esp_ble_mesh_sensor_server_recv_get_msg_t;
|
||||
|
||||
/** Context of the received Sensor Cadence Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID for the sensor */
|
||||
struct net_buf_simple *cadence; /*!< Value of Sensor Cadence state */
|
||||
} esp_ble_mesh_server_recv_sensor_cadence_set_t;
|
||||
|
||||
/** Context of the received Sensor Setting Set message */
|
||||
typedef struct {
|
||||
uint16_t property_id; /*!< Property ID identifying a sensor */
|
||||
uint16_t setting_property_id; /*!< Setting ID identifying a setting within a sensor */
|
||||
struct net_buf_simple *setting_raw; /*!< Raw value for the setting */
|
||||
} esp_ble_mesh_server_recv_sensor_setting_set_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model received set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_sensor_cadence_set_t sensor_cadence; /*!< Sensor Cadence Set */
|
||||
esp_ble_mesh_server_recv_sensor_setting_set_t sensor_setting; /*!< Sensor Setting Set */
|
||||
} esp_ble_mesh_sensor_server_recv_set_msg_t;
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_sensor_server_state_change_t state_change; /*!< ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_sensor_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT */
|
||||
esp_ble_mesh_sensor_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT */
|
||||
} esp_ble_mesh_sensor_server_cb_value_t;
|
||||
|
||||
/** Sensor Server Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Sensor Server Models */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
|
||||
esp_ble_mesh_sensor_server_cb_value_t value; /*!< Value of the received Sensor Messages */
|
||||
} esp_ble_mesh_sensor_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Sensor Server Model */
|
||||
typedef enum {
|
||||
/**
|
||||
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
|
||||
* callback to the application layer when Sensor Get messages are received.
|
||||
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
|
||||
* be callback to the application layer when Sensor Set/Set Unack messages
|
||||
* are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT,
|
||||
/**
|
||||
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Sensor Get messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT,
|
||||
/**
|
||||
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Sensor Set/Set Unack messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT,
|
||||
ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_sensor_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Sensor Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Sensor Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_sensor_server_cb_t)(esp_ble_mesh_sensor_server_cb_event_t event,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Sensor Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_sensor_server_callback(esp_ble_mesh_sensor_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_SENSOR_MODEL_API_H_ */
|
||||
|
||||
|
@ -19,9 +19,12 @@
|
||||
#ifndef _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
|
||||
#define _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_
|
||||
|
||||
#include "time_scene_client.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_CLI
|
||||
*
|
||||
* @brief Define a new Time Client Model.
|
||||
@ -76,69 +79,69 @@
|
||||
|
||||
/** Parameters of Time Set */
|
||||
typedef struct {
|
||||
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_time_set_t;
|
||||
|
||||
/** Parameters of Time Zone Set */
|
||||
typedef struct {
|
||||
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_time_zone_set_t;
|
||||
|
||||
/** Parameters of TAI-UTC Delta Set */
|
||||
typedef struct {
|
||||
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
u16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_tai_utc_delta_set_t;
|
||||
|
||||
/** Parameter of Time Role Set */
|
||||
typedef struct {
|
||||
u8_t time_role; /*!< The Time Role for the element */
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_time_role_set_t;
|
||||
|
||||
/** Parameter of Scene Store */
|
||||
typedef struct {
|
||||
u16_t scene_number; /*!< The number of scenes to be stored */
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_scene_store_t;
|
||||
|
||||
/** Parameters of Scene Recall */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
u16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
u8_t tid; /*!< Transaction ID */
|
||||
u8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
u8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_scene_recall_t;
|
||||
|
||||
/** Parameter of Scene Delete */
|
||||
typedef struct {
|
||||
u16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_scene_delete_t;
|
||||
|
||||
/** Parameter of Scheduler Action Get */
|
||||
typedef struct {
|
||||
u8_t index; /*!< Index of the Schedule Register entry to get */
|
||||
uint8_t index; /*!< Index of the Schedule Register entry to get */
|
||||
} esp_ble_mesh_scheduler_act_get_t;
|
||||
|
||||
/** Parameters of Scheduler Action Set */
|
||||
typedef struct {
|
||||
u64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
u64_t year : 7; /*!< Scheduled year for the action */
|
||||
u64_t month : 12; /*!< Scheduled month for the action */
|
||||
u64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
u64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
u64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
u64_t second : 6; /*!< Scheduled second for the action */
|
||||
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
u64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
u64_t trans_time : 8; /*!< Transition time for this action */
|
||||
u16_t scene_number; /*!< Transition time for this action */
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Transition time for this action */
|
||||
} esp_ble_mesh_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
@ -168,69 +171,69 @@ typedef union {
|
||||
|
||||
/** Parameters of Time Status */
|
||||
typedef struct {
|
||||
u8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
u8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
u8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
u16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
u16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
u8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t sub_second; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_time_status_cb_t;
|
||||
|
||||
/** Parameters of Time Zone Status */
|
||||
typedef struct {
|
||||
u8_t time_zone_offset_curr; /*!< Current local time zone offset */
|
||||
u8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
u8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
uint8_t time_zone_offset_curr; /*!< Current local time zone offset */
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_time_zone_status_cb_t;
|
||||
|
||||
/** Parameters of TAI-UTC Delta Status */
|
||||
typedef struct {
|
||||
u16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
u16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
u16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
u16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
u8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint16_t padding_1 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding_2 : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_tai_utc_delta_status_cb_t;
|
||||
|
||||
/** Parameter of Time Role Status */
|
||||
typedef struct {
|
||||
u8_t time_role; /*!< The Time Role for the element */
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_time_role_status_cb_t;
|
||||
|
||||
/** Parameters of Scene Status */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
u8_t status_code; /*!< Status code of the last operation */
|
||||
u16_t current_scene; /*!< Scene Number of the current scene */
|
||||
u16_t target_scene; /*!< Scene Number of the target scene (optional) */
|
||||
u8_t remain_time; /*!< Time to complete state transition (C.1) */
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint8_t status_code; /*!< Status code of the last operation */
|
||||
uint16_t current_scene; /*!< Scene Number of the current scene */
|
||||
uint16_t target_scene; /*!< Scene Number of the target scene (optional) */
|
||||
uint8_t remain_time; /*!< Time to complete state transition (C.1) */
|
||||
} esp_ble_mesh_scene_status_cb_t;
|
||||
|
||||
/** Parameters of Scene Register Status */
|
||||
typedef struct {
|
||||
u8_t status_code; /*!< Status code for the previous operation */
|
||||
u16_t current_scene; /*!< Scene Number of the current scene */
|
||||
uint8_t status_code; /*!< Status code for the previous operation */
|
||||
uint16_t current_scene; /*!< Scene Number of the current scene */
|
||||
struct net_buf_simple *scenes; /*!< A list of scenes stored within an element */
|
||||
} esp_ble_mesh_scene_register_status_cb_t;
|
||||
|
||||
/** Parameter of Scheduler Status */
|
||||
typedef struct {
|
||||
u16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
|
||||
uint16_t schedules; /*!< Bit field indicating defined Actions in the Schedule Register */
|
||||
} esp_ble_mesh_scheduler_status_cb_t;
|
||||
|
||||
/** Parameters of Scheduler Action Status */
|
||||
typedef struct {
|
||||
u64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
|
||||
u64_t year : 7; /*!< Scheduled year for the action */
|
||||
u64_t month : 12; /*!< Scheduled month for the action */
|
||||
u64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
u64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
u64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
u64_t second : 6; /*!< Scheduled second for the action */
|
||||
u64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
u64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
u64_t trans_time : 8; /*!< Transition time for this action */
|
||||
u16_t scene_number; /*!< Transition time for this action */
|
||||
uint64_t index : 4; /*!< Enumerates (selects) a Schedule Register entry */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Transition time for this action */
|
||||
} esp_ble_mesh_scheduler_act_status_cb_t;
|
||||
|
||||
/**
|
||||
@ -273,7 +276,7 @@ typedef enum {
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_client_cb_t)(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param);
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time Scene Client Model callback.
|
||||
@ -298,7 +301,7 @@ esp_err_t esp_ble_mesh_register_time_scene_client_callback(esp_ble_mesh_time_sce
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state);
|
||||
esp_ble_mesh_time_scene_client_get_state_t *get_state);
|
||||
|
||||
/**
|
||||
* @brief Set the value of Time Scene Server Model states using the Time Scene Client Model set messages.
|
||||
@ -313,7 +316,605 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state);
|
||||
esp_ble_mesh_time_scene_client_set_state_t *set_state);
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Models related context.
|
||||
*/
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_SRV
|
||||
*
|
||||
* @brief Define a new Time Server Model.
|
||||
*
|
||||
* @note 1. The Time Server model is a root model. When this model is present on an
|
||||
* Element, the corresponding Time Setup Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_srv_t.
|
||||
*
|
||||
* @return New Time Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_TIME_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_TIME_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Time Setup Server Model.
|
||||
*
|
||||
* @note 1. The Time Setup Server model extends the Time Server model. Time is
|
||||
* sensitive information that is propagated across a mesh network.
|
||||
* 2. Only an authorized Time Client should be allowed to change the Time
|
||||
* and Time Role states. A dedicated application key Bluetooth SIG
|
||||
* Proprietary should be used on the Time Setup Server to restrict
|
||||
* access to the server to only authorized Time Clients.
|
||||
* 3. This model does not support subscribing nor publishing.
|
||||
*
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_time_setup_srv_t.
|
||||
*
|
||||
* @return New Time Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_TIME_SETUP_SRV(srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_TIME_SETUP_SRV, \
|
||||
NULL, NULL, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCENE_SRV
|
||||
*
|
||||
* @brief Define a new Scene Server Model.
|
||||
*
|
||||
* @note 1. The Scene Server model is a root model. When this model is present
|
||||
* on an Element, the corresponding Scene Setup Server model shall
|
||||
* also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_srv_t.
|
||||
*
|
||||
* @return New Scene Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCENE_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Scene Setup Server Model.
|
||||
*
|
||||
* @note 1. The Scene Setup Server model extends the Scene Server model and
|
||||
* the Generic Default Transition Time Server model.
|
||||
* 2. This model shall support model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scene_setup_srv_t.
|
||||
*
|
||||
* @return New Scene Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCENE_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCENE_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SRV
|
||||
*
|
||||
* @brief Define a new Scheduler Server Model.
|
||||
*
|
||||
* @note 1. The Scheduler Server model extends the Scene Server model. When
|
||||
* this model is present on an Element, the corresponding Scheduler
|
||||
* Setup Server model shall also be present.
|
||||
* 2. This model shall support model publication and model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
* 4. The model requires the Time Server model shall be present on the element.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_srv_t.
|
||||
*
|
||||
* @return New Scheduler Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCHEDULER_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
/** @def ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV
|
||||
*
|
||||
* @brief Define a new Scheduler Setup Server Model.
|
||||
*
|
||||
* @note 1. The Scheduler Setup Server model extends the Scheduler Server and
|
||||
* the Scene Setup Server models.
|
||||
* 2. This model shall support model subscription.
|
||||
* 3. The model may be present only on the Primary element of a node.
|
||||
*
|
||||
* @param srv_pub Pointer to the unique struct esp_ble_mesh_model_pub_t.
|
||||
* @param srv_data Pointer to the unique struct esp_ble_mesh_scheduler_setup_srv_t.
|
||||
*
|
||||
* @return New Scheduler Setup Server Model instance.
|
||||
*/
|
||||
#define ESP_BLE_MESH_MODEL_SCHEDULER_SETUP_SRV(srv_pub, srv_data) \
|
||||
ESP_BLE_MESH_SIG_MODEL(ESP_BLE_MESH_MODEL_ID_SCHEDULER_SETUP_SRV, \
|
||||
NULL, srv_pub, srv_data)
|
||||
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_SECONDS 0x0000000000 /*!< Unknown TAI Seconds */
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_ZONE_CHANGE 0x0000000000 /*!< Unknown TAI of Zone Change */
|
||||
#define ESP_BLE_MESH_UNKNOWN_TAI_DELTA_CHANGE 0x0000000000 /*!< Unknown TAI of Delta Change */
|
||||
|
||||
#define ESP_BLE_MESH_TAI_UTC_DELTA_MAX_VALUE 0x7FFF /*!< Maximum TAI-UTC Delta value */
|
||||
|
||||
#define ESP_BLE_MESH_TAI_SECONDS_LEN 0x05 /*!< Length of TAI Seconds */
|
||||
#define ESP_BLE_MESH_TAI_OF_ZONE_CHANGE_LEN 0x05 /*!< Length of TAI of Zone Change */
|
||||
#define ESP_BLE_MESH_TAI_OF_DELTA_CHANGE_LEN 0x05 /*!< Length of TAI of Delta Change */
|
||||
|
||||
#define ESP_BLE_MESH_INVALID_SCENE_NUMBER 0x0000 /*!< Invalid Scene Number */
|
||||
#define ESP_BLE_MESH_SCENE_NUMBER_LEN 0x02 /*!< Length of the Scene Number */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_YEAR_ANY_YEAR 0x64 /*!< Any year of the Scheduled year */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_DAY_ANY_DAY 0x00 /*!< Any day of the Scheduled day */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_HOUR_ANY_HOUR 0x18 /*!< Any hour of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_HOUR_ONCE_A_DAY 0x19 /*!< Any hour of the Scheduled Day */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_HOUR 0x3C /*!< Any minute of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_MIN 0x3D /*!< Every 15 minutes of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_MIN 0x3E /*!< Every 20 minutes of the Scheduled hour */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_HOUR 0x3F /*!< Once of the Scheduled hour */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ANY_OF_MIN 0x3C /*!< Any second of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_15_SEC 0x3D /*!< Every 15 seconds of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_EVERY_20_SEC 0x3E /*!< Every 20 seconds of the Scheduled minute */
|
||||
#define ESP_BLE_MESH_SCHEDULE_SEC_ONCE_AN_MIN 0x3F /*!< Once of the Scheduled minute */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_OFF 0x00 /*!< Scheduled Action - Turn Off */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_TURN_ON 0x01 /*!< Scheduled Action - Turn On */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_SCENE_RECALL 0x02 /*!< Scheduled Action - Scene Recall */
|
||||
#define ESP_BLE_MESH_SCHEDULE_ACT_NO_ACTION 0x0F /*!< Scheduled Action - No Action */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_SCENE_NO_SCENE 0x0000 /*!< Scheduled Scene - No Scene */
|
||||
|
||||
#define ESP_BLE_MESH_SCHEDULE_ENTRY_MAX_INDEX 0x0F /*!< Maximum number of Scheduled entries */
|
||||
|
||||
#define ESP_BLE_MESH_TIME_NONE 0x00 /*!< Time Role - None */
|
||||
#define ESP_BLE_MESH_TIME_AUTHORITY 0x01 /*!< Time Role - Mesh Time Authority */
|
||||
#define ESP_BLE_MESH_TIME_RELAY 0x02 /*!< Time Role - Mesh Time Relay */
|
||||
#define ESP_BLE_MESH_TIME_CLINET 0x03 /*!< Time Role - Mesh Time Client */
|
||||
|
||||
#define ESP_BLE_MESH_SCENE_SUCCESS 0x00 /*!< Scene operation - Success */
|
||||
#define ESP_BLE_MESH_SCENE_REG_FULL 0x01 /*!< Scene operation - Scene Register Full */
|
||||
#define ESP_BLE_MESH_SCENE_NOT_FOUND 0x02 /*!< Scene operation - Scene Not Found */
|
||||
|
||||
/** Parameters of Time state */
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t tai_seconds[5]; /*!< The value of the TAI Seconds state */
|
||||
uint8_t subsecond; /*!< The value of the Subsecond field */
|
||||
uint8_t uncertainty; /*!< The value of the Uncertainty field */
|
||||
uint8_t time_zone_offset_curr; /*!< The value of the Time Zone Offset Current field */
|
||||
uint8_t time_zone_offset_new; /*!< The value of the Time Zone Offset New state */
|
||||
uint8_t tai_zone_change[5]; /*!< The value of the TAI of Zone Chaneg field */
|
||||
uint16_t time_authority : 1, /*!< The value of the Time Authority bit */
|
||||
tai_utc_delta_curr : 15; /*!< The value of the TAI-UTC Delta Current state */
|
||||
uint16_t tai_utc_delta_new : 15; /*!< The value of the TAI-UTC Delta New state */
|
||||
uint8_t tai_delta_change[5]; /*!< The value of the TAI of Delta Change field */
|
||||
} time; /*!< Parameters of the Time state */
|
||||
uint8_t time_role; /*!< The value of the Time Role state */
|
||||
} esp_ble_mesh_time_state_t;
|
||||
|
||||
/** User data of Time Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
|
||||
} esp_ble_mesh_time_srv_t;
|
||||
|
||||
/** User data of Time Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Time Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_time_state_t *state; /*!< Parameters of the Time state */
|
||||
} esp_ble_mesh_time_setup_srv_t;
|
||||
|
||||
/**
|
||||
* 1. Scene Store is an operation of storing values of a present state of an element.
|
||||
* 2. The structure and meaning of the stored state is determined by a model. States
|
||||
* to be stored are specified by each model.
|
||||
* 3. The Scene Store operation shall persistently store all values of all states
|
||||
* marked as Stored with Scene for all models present on all elements of a node.
|
||||
* 4. If a model is extending another model, the extending model shall determine the
|
||||
* Stored with Scene behavior of that model.
|
||||
*/
|
||||
|
||||
/** Parameters of Scene Register state */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The value of the Scene Number */
|
||||
uint8_t scene_type; /*!< The value of the Scene Type */
|
||||
/**
|
||||
* Scene value may use a union to represent later, the union contains
|
||||
* structures of all the model states which can be stored in a scene.
|
||||
*/
|
||||
struct net_buf_simple *scene_value; /*!< The value of the Scene Value */
|
||||
} esp_ble_mesh_scene_register_t;
|
||||
|
||||
/**
|
||||
* Parameters of Scenes state.
|
||||
*
|
||||
* Scenes serve as memory banks for storage of states (e.g., a power level
|
||||
* or a light level/color). Values of states of an element can be stored
|
||||
* as a scene and can be recalled later from the scene memory.
|
||||
*
|
||||
* A scene is represented by a Scene Number, which is a 16-bit non-zero,
|
||||
* mesh-wide value. (There can be a maximum of 65535 scenes in a mesh
|
||||
* network.) The meaning of a scene, as well as the state storage container
|
||||
* associated with it, are determined by a model.
|
||||
*
|
||||
* The Scenes state change may start numerous parallel model transitions.
|
||||
* In that case, each individual model handles the transition internally.
|
||||
*
|
||||
* The scene transition is defined as a group of individual model transitions
|
||||
* started by a Scene Recall operation. The scene transition is in progress
|
||||
* when at least one transition from the group of individual model transitions
|
||||
* is in progress.
|
||||
*/
|
||||
typedef struct {
|
||||
const uint16_t scene_count; /*!< The Scenes state's scene count */
|
||||
esp_ble_mesh_scene_register_t *scenes; /*!< Parameters of the Scenes state */
|
||||
|
||||
/**
|
||||
* The Current Scene state is a 16-bit value that contains either the Scene
|
||||
* Number of the currently active scene or a value of 0x0000 when no scene
|
||||
* is active.
|
||||
*
|
||||
* When a Scene Store operation or a Scene Recall operation completes with
|
||||
* success, the Current Scene state value shall be to the Scene Number used
|
||||
* during that operation.
|
||||
*
|
||||
* When the Current Scene Number is deleted from a Scene Register state as a
|
||||
* result of Scene Delete operation, the Current Scene state shall be set to
|
||||
* 0x0000.
|
||||
*
|
||||
* When any of the element's state that is marked as “Stored with Scene” has
|
||||
* changed not as a result of a Scene Recall operation, the value of the
|
||||
* Current Scene state shall be set to 0x0000.
|
||||
*
|
||||
* When a scene transition is in progress, the value of the Current Scene
|
||||
* state shall be set to 0x0000.
|
||||
*/
|
||||
uint16_t current_scene; /*!< The value of the Current Scene state */
|
||||
|
||||
/**
|
||||
* The Target Scene state is a 16-bit value that contains the target Scene
|
||||
* Number when a scene transition is in progress.
|
||||
*
|
||||
* When the scene transition is in progress and the target Scene Number is
|
||||
* deleted from a Scene Register state as a result of Scene Delete operation,
|
||||
* the Target Scene state shall be set to 0x0000.
|
||||
*
|
||||
* When the scene transition is in progress and a new Scene Number is stored
|
||||
* in the Scene Register as a result of Scene Store operation, the Target
|
||||
* Scene state shall be set to the new Scene Number.
|
||||
*
|
||||
* When the scene transition is not in progress, the value of the Target Scene
|
||||
* state shall be set to 0x0000.
|
||||
*/
|
||||
uint16_t target_scene; /*!< The value of the Target Scene state */
|
||||
|
||||
/* Indicate the status code for the last operation */
|
||||
uint8_t status_code; /*!< The status code of the last scene operation */
|
||||
|
||||
/* Indicate if scene transition is in progress */
|
||||
bool in_progress; /*!< Indicate if the scene transition is in progress */
|
||||
} esp_ble_mesh_scenes_state_t;
|
||||
|
||||
/** User data of Scene Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
|
||||
esp_ble_mesh_last_msg_info_t last; /*!< Parameters of the last received set message */
|
||||
esp_ble_mesh_state_transition_t transition; /*!< Parameters of state transition */
|
||||
} esp_ble_mesh_scene_srv_t;
|
||||
|
||||
/** User data of Scene Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scene Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scenes_state_t *state; /*!< Parameters of the Scenes state */
|
||||
} esp_ble_mesh_scene_setup_srv_t;
|
||||
|
||||
/** Parameters of Scheduler Register state */
|
||||
typedef struct {
|
||||
bool in_use; /*!< Indicate if the registered schedule is in use */
|
||||
uint64_t year : 7, /*!< The value of Scheduled year for the action */
|
||||
month : 12, /*!< The value of Scheduled month for the action */
|
||||
day : 5, /*!< The value of Scheduled day of the month for the action */
|
||||
hour : 5, /*!< The value of Scheduled hour for the action */
|
||||
minute : 6, /*!< The value of Scheduled minute for the action */
|
||||
second : 6, /*!< The value of Scheduled second for the action */
|
||||
day_of_week : 7, /*!< The value of Schedule days of the week for the action */
|
||||
action : 4, /*!< The value of Action to be performed at the scheduled time */
|
||||
trans_time : 8; /*!< The value of Transition time for this action */
|
||||
uint16_t scene_number; /*!< The value of Scene Number to be used for some actions */
|
||||
} esp_ble_mesh_schedule_register_t;
|
||||
|
||||
/** Parameters of Scheduler state */
|
||||
typedef struct {
|
||||
const uint8_t schedule_count; /*!< Scheduler count */
|
||||
esp_ble_mesh_schedule_register_t *schedules; /*!< Up to 16 scheduled entries */
|
||||
} esp_ble_mesh_scheduler_state_t;
|
||||
|
||||
/** User data of Scheduler Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
|
||||
} esp_ble_mesh_scheduler_srv_t;
|
||||
|
||||
/** User data of Scheduler Setup Server Model */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to the Scheduler Setup Server Model. Initialized internally. */
|
||||
esp_ble_mesh_server_rsp_ctrl_t rsp_ctrl; /*!< Response control of the server model received messages */
|
||||
esp_ble_mesh_scheduler_state_t *state; /*!< Parameters of the Scheduler state */
|
||||
} esp_ble_mesh_scheduler_setup_srv_t;
|
||||
|
||||
/** Parameters of Time Set state change event */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_state_change_time_set_t;
|
||||
|
||||
/** Parameters of Time Status state change event */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta_curr : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset_curr; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_state_change_time_status_t;
|
||||
|
||||
/** Parameters of Time Zone Set state change event */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_state_change_time_zone_set_t;
|
||||
|
||||
/** Parameters of TAI UTC Delta Set state change event */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_state_change_tai_utc_delta_set_t;
|
||||
|
||||
/** Parameter of Time Role Set state change event */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_state_change_time_role_set_t;
|
||||
|
||||
/** Parameter of Scene Store state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_state_change_scene_store_t;
|
||||
|
||||
/** Parameter of Scene Recall state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
} esp_ble_mesh_state_change_scene_recall_t;
|
||||
|
||||
/** Parameter of Scene Delete state change event */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_state_change_scene_delete_t;
|
||||
|
||||
/** Parameter of Scheduler Action Set state change event */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Scene number to be used for some actions */
|
||||
} esp_ble_mesh_state_change_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model state change value union
|
||||
*/
|
||||
typedef union {
|
||||
/**
|
||||
* The recv_op in ctx can be used to decide which state is changed.
|
||||
*/
|
||||
esp_ble_mesh_state_change_time_set_t time_set; /*!< Time Set */
|
||||
esp_ble_mesh_state_change_time_status_t time_status; /*!< Time Status */
|
||||
esp_ble_mesh_state_change_time_zone_set_t time_zone_set; /*!< Time Zone Set */
|
||||
esp_ble_mesh_state_change_tai_utc_delta_set_t tai_utc_delta_set; /*!< TAI UTC Delta Set */
|
||||
esp_ble_mesh_state_change_time_role_set_t time_role_set; /*!< Time Role Set */
|
||||
esp_ble_mesh_state_change_scene_store_t scene_store; /*!< Scene Store */
|
||||
esp_ble_mesh_state_change_scene_recall_t scene_recall; /*!< Scene Recall */
|
||||
esp_ble_mesh_state_change_scene_delete_t scene_delete; /*!< Scene Delete */
|
||||
esp_ble_mesh_state_change_scheduler_act_set_t scheduler_act_set; /*!< Scheduler Action Set */
|
||||
} esp_ble_mesh_time_scene_server_state_change_t;
|
||||
|
||||
/** Context of the received Scheduler Action Get message */
|
||||
typedef struct {
|
||||
uint8_t index; /*!< Index of the Schedule Register entry to get */
|
||||
} esp_ble_mesh_server_recv_scheduler_act_get_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received get message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_scheduler_act_get_t scheduler_act; /*!< Scheduler Action Get */
|
||||
} esp_ble_mesh_time_scene_server_recv_get_msg_t;
|
||||
|
||||
/** Context of the received Time Set message */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_server_recv_time_set_t;
|
||||
|
||||
/** Context of the received Time Zone Set message */
|
||||
typedef struct {
|
||||
uint8_t time_zone_offset_new; /*!< Upcoming local time zone offset */
|
||||
uint8_t tai_zone_change[5]; /*!< TAI Seconds time of the upcoming Time Zone Offset change */
|
||||
} esp_ble_mesh_server_recv_time_zone_set_t;
|
||||
|
||||
/** Context of the received TAI UTC Delta Set message */
|
||||
typedef struct {
|
||||
uint16_t tai_utc_delta_new : 15; /*!< Upcoming difference between TAI and UTC in seconds */
|
||||
uint16_t padding : 1; /*!< Always 0b0. Other values are Prohibited. */
|
||||
uint8_t tai_delta_change[5]; /*!< TAI Seconds time of the upcoming TAI-UTC Delta change */
|
||||
} esp_ble_mesh_server_recv_tai_utc_delta_set_t;
|
||||
|
||||
/** Context of the received Time Role Set message */
|
||||
typedef struct {
|
||||
uint8_t time_role; /*!< The Time Role for the element */
|
||||
} esp_ble_mesh_server_recv_time_role_set_t;
|
||||
|
||||
/** Context of the received Scene Store message */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be stored */
|
||||
} esp_ble_mesh_server_recv_scene_store_t;
|
||||
|
||||
/** Context of the received Scene Recall message */
|
||||
typedef struct {
|
||||
bool op_en; /*!< Indicate if optional parameters are included */
|
||||
uint16_t scene_number; /*!< The number of scenes to be recalled */
|
||||
uint8_t tid; /*!< Transaction ID */
|
||||
uint8_t trans_time; /*!< Time to complete state transition (optional) */
|
||||
uint8_t delay; /*!< Indicate message execution delay (C.1) */
|
||||
} esp_ble_mesh_server_recv_scene_recall_t;
|
||||
|
||||
/** Context of the received Scene Delete message */
|
||||
typedef struct {
|
||||
uint16_t scene_number; /*!< The number of scenes to be deleted */
|
||||
} esp_ble_mesh_server_recv_scene_delete_t;
|
||||
|
||||
/** Context of the received Scheduler Action Set message */
|
||||
typedef struct {
|
||||
uint64_t index : 4; /*!< Index of the Schedule Register entry to set */
|
||||
uint64_t year : 7; /*!< Scheduled year for the action */
|
||||
uint64_t month : 12; /*!< Scheduled month for the action */
|
||||
uint64_t day : 5; /*!< Scheduled day of the month for the action */
|
||||
uint64_t hour : 5; /*!< Scheduled hour for the action */
|
||||
uint64_t minute : 6; /*!< Scheduled minute for the action */
|
||||
uint64_t second : 6; /*!< Scheduled second for the action */
|
||||
uint64_t day_of_week : 7; /*!< Schedule days of the week for the action */
|
||||
uint64_t action : 4; /*!< Action to be performed at the scheduled time */
|
||||
uint64_t trans_time : 8; /*!< Transition time for this action */
|
||||
uint16_t scene_number; /*!< Scene number to be used for some actions */
|
||||
} esp_ble_mesh_server_recv_scheduler_act_set_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received set message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_time_set_t time; /*!< Time Set */
|
||||
esp_ble_mesh_server_recv_time_zone_set_t time_zone; /*!< Time Zone Set */
|
||||
esp_ble_mesh_server_recv_tai_utc_delta_set_t tai_utc_delta; /*!< TAI-UTC Delta Set */
|
||||
esp_ble_mesh_server_recv_time_role_set_t time_role; /*!< Time Role Set */
|
||||
esp_ble_mesh_server_recv_scene_store_t scene_store; /*!< Scene Store/Scene Store Unack */
|
||||
esp_ble_mesh_server_recv_scene_recall_t scene_recall; /*!< Scene Recall/Scene Recall Unack */
|
||||
esp_ble_mesh_server_recv_scene_delete_t scene_delete; /*!< Scene Delete/Scene Delete Unack */
|
||||
esp_ble_mesh_server_recv_scheduler_act_set_t scheduler_act; /*!< Scheduler Action Set/Scheduler Action Set Unack */
|
||||
} esp_ble_mesh_time_scene_server_recv_set_msg_t;
|
||||
|
||||
/** Context of the received Time Status message */
|
||||
typedef struct {
|
||||
uint8_t tai_seconds[5]; /*!< The current TAI time in seconds */
|
||||
uint8_t subsecond; /*!< The sub-second time in units of 1/256 second */
|
||||
uint8_t uncertainty; /*!< The estimated uncertainty in 10-millisecond steps */
|
||||
uint16_t time_authority : 1; /*!< 0 = No Time Authority, 1 = Time Authority */
|
||||
uint16_t tai_utc_delta : 15; /*!< Current difference between TAI and UTC in seconds */
|
||||
uint8_t time_zone_offset; /*!< The local time zone offset in 15-minute increments */
|
||||
} esp_ble_mesh_server_recv_time_status_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model received status message union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_server_recv_time_status_t time_status; /*!< Time Status */
|
||||
} esp_ble_mesh_time_scene_server_recv_status_msg_t;
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model callback value union
|
||||
*/
|
||||
typedef union {
|
||||
esp_ble_mesh_time_scene_server_state_change_t state_change; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_get_msg_t get; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_set_msg_t set; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT */
|
||||
esp_ble_mesh_time_scene_server_recv_status_msg_t status; /*!< ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT */
|
||||
} esp_ble_mesh_time_scene_server_cb_value_t;
|
||||
|
||||
/** Time Scene Server Model callback parameters */
|
||||
typedef struct {
|
||||
esp_ble_mesh_model_t *model; /*!< Pointer to Time and Scenes Server Models */
|
||||
esp_ble_mesh_msg_ctx_t ctx; /*!< Context of the received messages */
|
||||
esp_ble_mesh_time_scene_server_cb_value_t value; /*!< Value of the received Time and Scenes Messages */
|
||||
} esp_ble_mesh_time_scene_server_cb_param_t;
|
||||
|
||||
/** This enum value is the event of Time Scene Server Model */
|
||||
typedef enum {
|
||||
/**
|
||||
* 1. When get_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, no event will be
|
||||
* callback to the application layer when Time Scene Get messages are received.
|
||||
* 2. When set_auto_rsp is set to ESP_BLE_MESH_SERVER_AUTO_RSP, this event will
|
||||
* be callback to the application layer when Time Scene Set/Set Unack messages
|
||||
* are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT,
|
||||
/**
|
||||
* When get_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Time Scene Get messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT,
|
||||
/**
|
||||
* When set_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will be
|
||||
* callback to the application layer when Time Scene Set/Set Unack messages are received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT,
|
||||
/**
|
||||
* When status_auto_rsp is set to ESP_BLE_MESH_SERVER_RSP_BY_APP, this event will
|
||||
* be callback to the application layer when TIme Status message is received.
|
||||
*/
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT,
|
||||
ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX,
|
||||
} esp_ble_mesh_time_scene_server_cb_event_t;
|
||||
|
||||
/**
|
||||
* @brief Bluetooth Mesh Time and Scenes Server Model function.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Time Scene Server Model callback function type
|
||||
* @param event: Event type
|
||||
* @param param: Pointer to callback parameter
|
||||
*/
|
||||
typedef void (* esp_ble_mesh_time_scene_server_cb_t)(esp_ble_mesh_time_scene_server_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param);
|
||||
|
||||
/**
|
||||
* @brief Register BLE Mesh Time and Scenes Server Model callback.
|
||||
*
|
||||
* @param[in] callback: Pointer to the callback function.
|
||||
*
|
||||
* @return ESP_OK on success or error code otherwise.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_mesh_register_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_t callback);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ESP_BLE_MESH_TIME_SCENE_MODEL_API_H_ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,19 +15,19 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "cfg_cli.h"
|
||||
#include "btc_ble_mesh_generic_model.h"
|
||||
#include "generic_client.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_generic_client_cb_event_t event,
|
||||
esp_ble_mesh_generic_client_cb_param_t *param)
|
||||
/* 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,
|
||||
esp_ble_mesh_generic_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_t btc_mesh_cb = (esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
esp_ble_mesh_generic_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_generic_client_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,45 +35,50 @@ 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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
|
||||
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
|
||||
if (dst->generic_client_get_state.params && dst->generic_client_get_state.get_state) {
|
||||
dst->generic_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->generic_client_get_state.params) {
|
||||
memcpy(dst->generic_client_get_state.params, src->generic_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_generic_client_get_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->generic_client_get_state.get_state) {
|
||||
dst->generic_client_get_state.get_state = (esp_ble_mesh_generic_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_get_state_t));
|
||||
if (dst->generic_client_get_state.get_state) {
|
||||
memcpy(dst->generic_client_get_state.get_state, src->generic_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_generic_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
|
||||
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
|
||||
dst->generic_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->generic_client_set_state.set_state = (esp_ble_mesh_generic_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_generic_client_set_state_t));
|
||||
if (dst->generic_client_set_state.params && dst->generic_client_set_state.set_state) {
|
||||
memcpy(dst->generic_client_set_state.params, src->generic_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->generic_client_set_state.set_state, src->generic_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_generic_client_set_state_t));
|
||||
|
||||
opcode = src->generic_client_set_state.params->opcode;
|
||||
switch (opcode) {
|
||||
switch (src->generic_client_set_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
if (src->generic_client_set_state.set_state->user_property_set.property_value) {
|
||||
length = src->generic_client_set_state.set_state->user_property_set.property_value->len;
|
||||
dst->generic_client_set_state.set_state->user_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!dst->generic_client_set_state.set_state->user_property_set.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->user_property_set.property_value,
|
||||
@ -86,7 +91,7 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
||||
length = src->generic_client_set_state.set_state->admin_property_set.property_value->len;
|
||||
dst->generic_client_set_state.set_state->admin_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!dst->generic_client_set_state.set_state->admin_property_set.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->generic_client_set_state.set_state->admin_property_set.property_value,
|
||||
@ -98,42 +103,95 @@ void btc_ble_mesh_generic_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, voi
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
static void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
|
||||
if (arg->generic_client_get_state.params) {
|
||||
bt_mesh_free(arg->generic_client_get_state.params);
|
||||
}
|
||||
if (arg->generic_client_get_state.get_state) {
|
||||
bt_mesh_free(arg->generic_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
|
||||
if (arg->generic_client_set_state.set_state) {
|
||||
if (arg->generic_client_set_state.params) {
|
||||
switch (arg->generic_client_set_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
bt_mesh_free(arg->generic_client_set_state.set_state);
|
||||
}
|
||||
if (arg->generic_client_set_state.params) {
|
||||
bt_mesh_free(arg->generic_client_set_state.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_generic_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
opcode = p_src_data->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
|
||||
if (p_src_data->status_cb.user_properties_status.property_ids) {
|
||||
length = p_src_data->status_cb.user_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.user_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.user_properties_status.property_ids) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
|
||||
@ -148,7 +206,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.user_property_status.property_value->len;
|
||||
p_dest_data->status_cb.user_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.user_property_status.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
|
||||
@ -162,7 +220,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.admin_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.admin_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.admin_properties_status.property_ids) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
|
||||
@ -177,7 +235,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.admin_property_status.property_value->len;
|
||||
p_dest_data->status_cb.admin_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.admin_property_status.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
|
||||
@ -191,7 +249,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.manufacturer_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.manufacturer_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.manufacturer_properties_status.property_ids) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
|
||||
@ -206,7 +264,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.manufacturer_property_status.property_value->len;
|
||||
p_dest_data->status_cb.manufacturer_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.manufacturer_property_status.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
|
||||
@ -220,7 +278,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.client_properties_status.property_ids->len;
|
||||
p_dest_data->status_cb.client_properties_status.property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.client_properties_status.property_ids) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
|
||||
@ -233,27 +291,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
static void btc_ble_mesh_generic_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t *arg = NULL;
|
||||
u32_t opcode;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -264,8 +313,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
opcode = arg->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTIES_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.user_properties_status.property_ids);
|
||||
@ -303,7 +351,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
case ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
osi_free(arg->params);
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -311,99 +359,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
u32_t opcode = 0;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_generic_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE:
|
||||
if (arg->generic_client_get_state.params) {
|
||||
osi_free(arg->generic_client_get_state.params);
|
||||
}
|
||||
if (arg->generic_client_get_state.get_state) {
|
||||
osi_free(arg->generic_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE:
|
||||
if (arg->generic_client_set_state.params) {
|
||||
opcode = arg->generic_client_set_state.params->opcode;
|
||||
osi_free(arg->generic_client_set_state.params);
|
||||
}
|
||||
if (arg->generic_client_set_state.set_state) {
|
||||
if (opcode) {
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
bt_mesh_free_buf(arg->generic_client_set_state.set_state->user_property_set.property_value);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
bt_mesh_free_buf(arg->generic_client_set_state.set_state->admin_property_set.property_value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
osi_free(arg->generic_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
|
||||
static void btc_ble_mesh_generic_client_callback(esp_ble_mesh_generic_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_GENERIC_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GENERIC_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_generic_client_cb_param_t), btc_ble_mesh_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_client_cb_param_t),
|
||||
btc_ble_mesh_generic_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_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};
|
||||
size_t length;
|
||||
uint8_t act;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case 0x00:
|
||||
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE:
|
||||
act = ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT;
|
||||
break;
|
||||
case 0x01:
|
||||
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE:
|
||||
act = ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT;
|
||||
break;
|
||||
case 0x02:
|
||||
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH:
|
||||
act = ESP_BLE_MESH_GENERIC_CLIENT_PUBLISH_EVT;
|
||||
break;
|
||||
case 0x03:
|
||||
case BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT:
|
||||
act = ESP_BLE_MESH_GENERIC_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s, Unknown generic client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Generic client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -415,39 +418,43 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_mesh_generic_client_callback(&cb_params, act);
|
||||
btc_ble_mesh_generic_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_callback_generic_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_generic_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t generic_client_cb = {0};
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_generic_client_args_t *arg = NULL;
|
||||
struct bt_mesh_common_param common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
esp_ble_mesh_generic_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -456,12 +463,6 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE: {
|
||||
params = arg->generic_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -470,27 +471,18 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
generic_client_cb.params = arg->generic_client_get_state.params;
|
||||
generic_client_cb.error_code =
|
||||
bt_mesh_generic_client_get_state(&common,
|
||||
(void *)arg->generic_client_get_state.get_state,
|
||||
(void *)&generic_client_cb.status_cb);
|
||||
if (generic_client_cb.error_code) {
|
||||
cb.params = arg->generic_client_get_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_get_state(&common, arg->generic_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_generic_client_callback(&generic_client_cb,
|
||||
ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE: {
|
||||
params = arg->generic_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -499,16 +491,13 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
generic_client_cb.params = arg->generic_client_set_state.params;
|
||||
generic_client_cb.error_code =
|
||||
bt_mesh_generic_client_set_state(&common,
|
||||
(void *)arg->generic_client_set_state.set_state,
|
||||
(void *)&generic_client_cb.status_cb);
|
||||
if (generic_client_cb.error_code) {
|
||||
cb.params = arg->generic_client_set_state.params;
|
||||
cb.error_code = bt_mesh_generic_client_set_state(&common, arg->generic_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_generic_client_callback(&generic_client_cb,
|
||||
ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
|
||||
btc_ble_mesh_generic_client_callback(&cb, ESP_BLE_MESH_GENERIC_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -517,24 +506,253 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_generic_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_generic_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_generic_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_GENERIC_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_cb_to_app(msg->act, param);
|
||||
btc_ble_mesh_generic_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_free_req_data(msg);
|
||||
btc_ble_mesh_generic_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
esp_ble_mesh_generic_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_generic_server_cb_t)btc_profile_cb_get(BTC_PID_GENERIC_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_generic_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
|
||||
switch (p_src_data->ctx.recv_op) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
|
||||
if (p_src_data->value.state_change.user_property_set.value) {
|
||||
length = p_src_data->value.state_change.user_property_set.value->len;
|
||||
p_dest_data->value.state_change.user_property_set.value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.user_property_set.value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.user_property_set.value,
|
||||
p_src_data->value.state_change.user_property_set.value->data,
|
||||
p_src_data->value.state_change.user_property_set.value->len);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
|
||||
if (p_src_data->value.state_change.admin_property_set.value) {
|
||||
length = p_src_data->value.state_change.admin_property_set.value->len;
|
||||
p_dest_data->value.state_change.admin_property_set.value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.admin_property_set.value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.admin_property_set.value,
|
||||
p_src_data->value.state_change.admin_property_set.value->data,
|
||||
p_src_data->value.state_change.admin_property_set.value->len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
|
||||
switch (p_src_data->ctx.recv_op) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
|
||||
if (p_src_data->value.set.user_property.property_value) {
|
||||
length = p_src_data->value.set.user_property.property_value->len;
|
||||
p_dest_data->value.set.user_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.user_property.property_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.user_property.property_value,
|
||||
p_src_data->value.set.user_property.property_value->data,
|
||||
p_src_data->value.set.user_property.property_value->len);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
|
||||
if (p_src_data->value.set.admin_property.property_value) {
|
||||
length = p_src_data->value.set.admin_property.property_value->len;
|
||||
p_dest_data->value.set.admin_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.admin_property.property_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.admin_property.property_value,
|
||||
p_src_data->value.set.admin_property.property_value->data,
|
||||
p_src_data->value.set.admin_property.property_value->len);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_generic_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT:
|
||||
switch (arg->ctx.recv_op) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
|
||||
bt_mesh_free_buf(arg->value.state_change.user_property_set.value);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
|
||||
bt_mesh_free_buf(arg->value.state_change.admin_property_set.value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT:
|
||||
switch (arg->ctx.recv_op) {
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_USER_PROPERTY_SET_UNACK:
|
||||
bt_mesh_free_buf(arg->value.set.user_property.property_value);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_GEN_ADMIN_PROPERTY_SET_UNACK:
|
||||
bt_mesh_free_buf(arg->value.set.admin_property.property_value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_generic_server_callback(esp_ble_mesh_generic_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_GENERIC_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GENERIC_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_generic_server_cb_param_t),
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_GENERIC_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG:
|
||||
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_GET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG:
|
||||
act = ESP_BLE_MESH_GENERIC_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Generic Server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_generic_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_generic_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_GENERIC_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_generic_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -15,34 +15,21 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "foundation.h"
|
||||
#include "health_srv.h"
|
||||
#include "health_cli.h"
|
||||
#include "mesh_common.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
#include "btc_ble_mesh_health_model.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
extern s32_t health_msg_timeout;
|
||||
/* 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,
|
||||
esp_ble_mesh_health_client_cb_param_t *param)
|
||||
esp_ble_mesh_health_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_t btc_mesh_cb = (esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void btc_ble_mesh_health_server_cb_to_app(esp_ble_mesh_health_server_cb_event_t event,
|
||||
esp_ble_mesh_health_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_t btc_mesh_cb = (esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
esp_ble_mesh_health_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_health_client_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,39 +39,46 @@ void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
btc_ble_mesh_health_client_args_t *src = (btc_ble_mesh_health_client_args_t *)p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
|
||||
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
|
||||
if (dst->health_client_get_state.params && dst->health_client_get_state.get_state) {
|
||||
dst->health_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->health_client_get_state.params) {
|
||||
memcpy(dst->health_client_get_state.params, src->health_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_health_client_get_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->health_client_get_state.get_state) {
|
||||
dst->health_client_get_state.get_state = (esp_ble_mesh_health_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_get_state_t));
|
||||
if (dst->health_client_get_state.get_state) {
|
||||
memcpy(dst->health_client_get_state.get_state, src->health_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_health_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
|
||||
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
|
||||
dst->health_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->health_client_set_state.set_state = (esp_ble_mesh_health_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_health_client_set_state_t));
|
||||
if (dst->health_client_set_state.params && dst->health_client_set_state.set_state) {
|
||||
memcpy(dst->health_client_set_state.params, src->health_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->health_client_set_state.set_state, src->health_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_health_client_set_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -94,7 +88,7 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
|
||||
btc_ble_mesh_health_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,82 +97,58 @@ static void btc_ble_mesh_health_client_arg_deep_free(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE:
|
||||
if (arg->health_client_get_state.params) {
|
||||
osi_free(arg->health_client_get_state.params);
|
||||
bt_mesh_free(arg->health_client_get_state.params);
|
||||
}
|
||||
if (arg->health_client_get_state.get_state) {
|
||||
osi_free(arg->health_client_get_state.get_state);
|
||||
bt_mesh_free(arg->health_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE:
|
||||
if (arg->health_client_set_state.params) {
|
||||
osi_free(arg->health_client_set_state.params);
|
||||
bt_mesh_free(arg->health_client_set_state.params);
|
||||
}
|
||||
if (arg->health_client_set_state.set_state) {
|
||||
osi_free(arg->health_client_set_state.set_state);
|
||||
bt_mesh_free(arg->health_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
if (!msg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
opcode = p_src_data->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case OP_HEALTH_CURRENT_STATUS:
|
||||
if (p_src_data->status_cb.current_status.fault_array) {
|
||||
length = p_src_data->status_cb.current_status.fault_array->len;
|
||||
p_dest_data->status_cb.current_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.current_status.fault_array) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
|
||||
@ -194,7 +164,7 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
length = p_src_data->status_cb.fault_status.fault_array->len;
|
||||
p_dest_data->status_cb.fault_status.fault_array = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.fault_status.fault_array) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
|
||||
@ -207,14 +177,6 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -224,10 +186,9 @@ static void btc_ble_mesh_health_client_copy_req_data(btc_msg_t *msg, void *p_des
|
||||
static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t *arg = NULL;
|
||||
u32_t opcode;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -238,8 +199,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
opcode = arg->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (arg->params->opcode) {
|
||||
case OP_HEALTH_CURRENT_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.current_status.fault_array);
|
||||
break;
|
||||
@ -255,7 +215,7 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
case ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
osi_free(arg->params);
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -263,180 +223,54 @@ static void btc_ble_mesh_health_client_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
if (!msg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
|
||||
static void btc_ble_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_HEALTH_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_HEALTH_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_client_cb_param_t), btc_ble_mesh_health_client_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_client_cb_param_t),
|
||||
btc_ble_mesh_health_client_copy_req_data);
|
||||
}
|
||||
|
||||
static void btc_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_HEALTH_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_health_server_cb_param_t), btc_ble_mesh_health_server_copy_req_data);
|
||||
}
|
||||
|
||||
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state,
|
||||
esp_ble_mesh_health_client_cb_param_t *client_cb)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (!params || !client_cb) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
return (client_cb->error_code = bt_mesh_health_attention_get(&ctx));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return (client_cb->error_code = bt_mesh_health_period_get(&ctx));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return (client_cb->error_code = bt_mesh_health_fault_get(&ctx, get_state->fault_get.company_id));
|
||||
default:
|
||||
BT_WARN("%s, invalid opcode 0x%x", __func__, params->opcode);
|
||||
return (client_cb->error_code = -EINVAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state,
|
||||
esp_ble_mesh_health_client_cb_param_t *client_cb)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (!params || !set_state || !client_cb) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx.net_idx = params->ctx.net_idx;
|
||||
ctx.app_idx = params->ctx.app_idx;
|
||||
ctx.addr = params->ctx.addr;
|
||||
ctx.send_rel = params->ctx.send_rel;
|
||||
ctx.send_ttl = params->ctx.send_ttl;
|
||||
|
||||
health_msg_timeout = params->msg_timeout;
|
||||
|
||||
switch (params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_attention_set(&ctx, set_state->attention_set.attention, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_period_set(&ctx, set_state->period_set.fast_period_divisor, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_fault_test(&ctx, set_state->fault_test.company_id, set_state->fault_test.test_id, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return (client_cb->error_code =
|
||||
bt_mesh_health_fault_clear(&ctx, set_state->fault_clear.company_id, false));
|
||||
default:
|
||||
BT_WARN("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return (client_cb->error_code = -EINVAL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len)
|
||||
void bt_mesh_health_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t cb_params = {0};
|
||||
esp_ble_mesh_client_common_param_t params = {0};
|
||||
size_t length;
|
||||
uint8_t act;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case 0x00:
|
||||
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE:
|
||||
act = ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT;
|
||||
break;
|
||||
case 0x01:
|
||||
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE:
|
||||
act = ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT;
|
||||
break;
|
||||
case 0x02:
|
||||
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH:
|
||||
act = ESP_BLE_MESH_HEALTH_CLIENT_PUBLISH_EVT;
|
||||
break;
|
||||
case 0x03:
|
||||
case BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT:
|
||||
act = ESP_BLE_MESH_HEALTH_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s, Unknown health client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Health client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -448,37 +282,126 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_mesh_health_client_callback(&cb_params, act);
|
||||
btc_ble_mesh_health_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_callback_health_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_health_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
static int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
|
||||
BT_ERR("Invalid Health Get");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_GET:
|
||||
return bt_mesh_health_attention_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return bt_mesh_health_period_get(¶m);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return bt_mesh_health_fault_get(¶m, get->fault_get.company_id);
|
||||
default:
|
||||
BT_ERR("Invalid Health Get opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set)
|
||||
{
|
||||
bt_mesh_client_common_param_t param = {0};
|
||||
|
||||
if (params == NULL || set == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
param.opcode = params->opcode;
|
||||
param.model = (struct bt_mesh_model *)params->model;
|
||||
param.ctx.net_idx = params->ctx.net_idx;
|
||||
param.ctx.app_idx = params->ctx.app_idx;
|
||||
param.ctx.addr = params->ctx.addr;
|
||||
param.ctx.send_rel = params->ctx.send_rel;
|
||||
param.ctx.send_ttl = params->ctx.send_ttl;
|
||||
param.msg_timeout = params->msg_timeout;
|
||||
param.msg_role = params->msg_role;
|
||||
|
||||
switch (param.opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET:
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return bt_mesh_health_attention_set(¶m, set->attention_set.attention, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return bt_mesh_health_period_set(¶m, set->period_set.fast_period_divisor, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
|
||||
return bt_mesh_health_fault_test(¶m, set->fault_test.company_id, set->fault_test.test_id, false);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, true);
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return bt_mesh_health_fault_clear(¶m, set->fault_clear.company_id, false);
|
||||
default:
|
||||
BT_ERR("Invalid Health Set opcode 0x%04x", param.opcode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_health_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_health_client_cb_param_t health_client_cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
esp_ble_mesh_health_client_cb_param_t cb = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -486,36 +409,22 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE: {
|
||||
health_client_cb.params = arg->health_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
|
||||
role_param.role = health_client_cb.params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
|
||||
arg->health_client_get_state.get_state,
|
||||
&health_client_cb);
|
||||
if (health_client_cb.error_code) {
|
||||
cb.params = arg->health_client_get_state.params;
|
||||
cb.error_code = btc_ble_mesh_health_client_get_state(arg->health_client_get_state.params,
|
||||
arg->health_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
|
||||
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE: {
|
||||
health_client_cb.params = arg->health_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)health_client_cb.params->model;
|
||||
role_param.role = health_client_cb.params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
|
||||
arg->health_client_set_state.set_state,
|
||||
&health_client_cb);
|
||||
if (health_client_cb.error_code) {
|
||||
cb.params = arg->health_client_set_state.params;
|
||||
cb.error_code = btc_ble_mesh_health_client_set_state(arg->health_client_set_state.params,
|
||||
arg->health_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_health_client_callback(&health_client_cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
|
||||
btc_ble_mesh_health_client_callback(&cb, ESP_BLE_MESH_HEALTH_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -527,12 +436,12 @@ void btc_mesh_health_client_call_handler(btc_msg_t *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_health_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -541,42 +450,137 @@ void btc_mesh_health_client_cb_handler(btc_msg_t *msg)
|
||||
if (msg->act < ESP_BLE_MESH_HEALTH_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_health_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_health_server_call_handler(btc_msg_t *msg)
|
||||
/* 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,
|
||||
esp_ble_mesh_health_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t health_server_cb = {0};
|
||||
esp_ble_mesh_health_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_health_server_cb_t)btc_profile_cb_get(BTC_PID_HEALTH_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
if (!msg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_health_server_callback(esp_ble_mesh_health_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_HEALTH_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_HEALTH_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_health_server_cb_param_t),
|
||||
btc_ble_mesh_health_server_copy_req_data);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
btc_ble_mesh_health_server_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_health_server_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE: {
|
||||
health_server_cb.error_code = bt_mesh_fault_update((struct bt_mesh_elem *)arg->fault_update.element);
|
||||
btc_mesh_health_server_callback(&health_server_cb, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMPLETE_EVT);
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE:
|
||||
param.fault_update_comp.element = arg->health_fault_update.element;
|
||||
param.fault_update_comp.error_code =
|
||||
bt_mesh_fault_update((struct bt_mesh_elem *)arg->health_fault_update.element);
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_UPDATE_COMP_EVT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -585,8 +589,50 @@ void btc_mesh_health_server_cb_handler(btc_msg_t *msg)
|
||||
if (msg->act < ESP_BLE_MESH_HEALTH_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_health_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_health_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
param.fault_clear.model = (esp_ble_mesh_model_t *)model;
|
||||
param.fault_clear.company_id = company_id;
|
||||
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_FAULT_CLEAR_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
param.fault_test.model = (esp_ble_mesh_model_t *)model;
|
||||
param.fault_test.test_id = test_id;
|
||||
param.fault_test.company_id = company_id;
|
||||
|
||||
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)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
param.attention_on.model = (esp_ble_mesh_model_t *)model;
|
||||
param.attention_on.time = time;
|
||||
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_ON_EVT);
|
||||
}
|
||||
|
||||
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model)
|
||||
{
|
||||
esp_ble_mesh_health_server_cb_param_t param = {0};
|
||||
|
||||
param.attention_off.model = (esp_ble_mesh_model_t *)model;
|
||||
|
||||
btc_ble_mesh_health_server_callback(¶m, ESP_BLE_MESH_HEALTH_SERVER_ATTENTION_OFF_EVT);
|
||||
}
|
||||
|
@ -15,84 +15,132 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "lighting_client.h"
|
||||
#include "btc_ble_mesh_lighting_model.h"
|
||||
#include "lighting_client.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_light_client_cb_event_t event,
|
||||
esp_ble_mesh_light_client_cb_param_t *param)
|
||||
/* 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,
|
||||
esp_ble_mesh_light_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_t btc_mesh_cb = (esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHT_CLIENT);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
esp_ble_mesh_light_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_light_client_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_mesh_light_client_args_t *dst = (btc_ble_mesh_light_client_args_t *)p_dest;
|
||||
btc_ble_mesh_light_client_args_t *src = (btc_ble_mesh_light_client_args_t *)p_src;
|
||||
btc_ble_mesh_lighting_client_args_t *dst = (btc_ble_mesh_lighting_client_args_t *)p_dest;
|
||||
btc_ble_mesh_lighting_client_args_t *src = (btc_ble_mesh_lighting_client_args_t *)p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: {
|
||||
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
|
||||
if (dst->light_client_get_state.params && dst->light_client_get_state.get_state) {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
|
||||
dst->light_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->light_client_get_state.params) {
|
||||
memcpy(dst->light_client_get_state.params, src->light_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_light_client_get_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->light_client_get_state.get_state) {
|
||||
dst->light_client_get_state.get_state = (esp_ble_mesh_light_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_get_state_t));
|
||||
if (dst->light_client_get_state.get_state) {
|
||||
memcpy(dst->light_client_get_state.get_state, src->light_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_light_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: {
|
||||
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
|
||||
dst->light_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->light_client_set_state.set_state = (esp_ble_mesh_light_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_light_client_set_state_t));
|
||||
if (dst->light_client_set_state.params && dst->light_client_set_state.set_state) {
|
||||
memcpy(dst->light_client_set_state.params, src->light_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->light_client_set_state.set_state, src->light_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_light_client_set_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
static void btc_ble_mesh_lighting_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE:
|
||||
if (arg->light_client_get_state.params) {
|
||||
bt_mesh_free(arg->light_client_get_state.params);
|
||||
}
|
||||
if (arg->light_client_get_state.get_state) {
|
||||
bt_mesh_free(arg->light_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE:
|
||||
if (arg->light_client_set_state.params) {
|
||||
bt_mesh_free(arg->light_client_set_state.params);
|
||||
}
|
||||
if (arg->light_client_set_state.set_state) {
|
||||
bt_mesh_free(arg->light_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lighting_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
opcode = p_src_data->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
|
||||
@ -100,7 +148,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.lc_property_status.property_value->len;
|
||||
p_dest_data->status_cb.lc_property_status.property_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.lc_property_status.property_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
|
||||
@ -113,27 +161,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
static void btc_ble_mesh_lighting_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t *arg = NULL;
|
||||
u32_t opcode;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -144,8 +183,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
opcode = arg->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET:
|
||||
case ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_STATUS:
|
||||
@ -157,7 +195,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
case ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
osi_free(arg->params);
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -165,85 +203,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_light_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_light_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE:
|
||||
if (arg->light_client_get_state.params) {
|
||||
osi_free(arg->light_client_get_state.params);
|
||||
}
|
||||
if (arg->light_client_get_state.get_state) {
|
||||
osi_free(arg->light_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE:
|
||||
if (arg->light_client_set_state.params) {
|
||||
osi_free(arg->light_client_set_state.params);
|
||||
}
|
||||
if (arg->light_client_set_state.set_state) {
|
||||
osi_free(arg->light_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_mesh_light_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
|
||||
static void btc_ble_mesh_lighting_client_callback(esp_ble_mesh_light_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LIGHTING_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_LIGHT_CLIENT;
|
||||
msg.pid = BTC_PID_LIGHTING_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_light_client_cb_param_t), btc_ble_mesh_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_light_client_cb_param_t),
|
||||
btc_ble_mesh_lighting_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_lighting_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_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};
|
||||
size_t length;
|
||||
uint8_t act;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case 0x00:
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE:
|
||||
act = ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT;
|
||||
break;
|
||||
case 0x01:
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE:
|
||||
act = ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT;
|
||||
break;
|
||||
case 0x02:
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH:
|
||||
act = ESP_BLE_MESH_LIGHT_CLIENT_PUBLISH_EVT;
|
||||
break;
|
||||
case 0x03:
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT:
|
||||
act = ESP_BLE_MESH_LIGHT_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s, Unknown lighting client event type", __func__);
|
||||
BT_ERR("Unknown Lighting client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -255,53 +262,51 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_mesh_light_client_callback(&cb_params, act);
|
||||
btc_ble_mesh_lighting_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_callback_light_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_lighting_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t light_client_cb = {0};
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_light_client_args_t *arg = NULL;
|
||||
struct bt_mesh_common_param common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
btc_ble_mesh_lighting_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_light_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_light_client_args_t *)(msg->arg);
|
||||
arg = (btc_ble_mesh_lighting_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE: {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE: {
|
||||
params = arg->light_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -310,27 +315,18 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
light_client_cb.params = arg->light_client_get_state.params;
|
||||
light_client_cb.error_code =
|
||||
bt_mesh_light_client_get_state(&common,
|
||||
(void *)arg->light_client_get_state.get_state,
|
||||
(void *)&light_client_cb.status_cb);
|
||||
if (light_client_cb.error_code) {
|
||||
cb.params = arg->light_client_get_state.params;
|
||||
cb.error_code = bt_mesh_light_client_get_state(&common, arg->light_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_light_client_callback(&light_client_cb,
|
||||
ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE: {
|
||||
case BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE: {
|
||||
params = arg->light_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -339,16 +335,13 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
light_client_cb.params = arg->light_client_set_state.params;
|
||||
light_client_cb.error_code =
|
||||
bt_mesh_light_client_set_state(&common,
|
||||
(void *)arg->light_client_set_state.set_state,
|
||||
(void *)&light_client_cb.status_cb);
|
||||
if (light_client_cb.error_code) {
|
||||
cb.params = arg->light_client_set_state.params;
|
||||
cb.error_code = bt_mesh_light_client_set_state(&common, arg->light_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_light_client_callback(&light_client_cb,
|
||||
ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
|
||||
btc_ble_mesh_lighting_client_callback(&cb, ESP_BLE_MESH_LIGHT_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -356,26 +349,225 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
|
||||
btc_ble_mesh_light_client_arg_deep_free(msg);
|
||||
btc_ble_mesh_lighting_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_light_client_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_light_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_light_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_LIGHT_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_cb_to_app(msg->act, param);
|
||||
btc_ble_mesh_lighting_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_free_req_data(msg);
|
||||
btc_ble_mesh_lighting_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_lighting_server_cb_t)btc_profile_cb_get(BTC_PID_LIGHTING_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lighting_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
if (p_src_data->value.state_change.lc_property_set.property_value) {
|
||||
length = p_src_data->value.state_change.lc_property_set.property_value->len;
|
||||
p_dest_data->value.state_change.lc_property_set.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.lc_property_set.property_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.lc_property_set.property_value,
|
||||
p_src_data->value.state_change.lc_property_set.property_value->data,
|
||||
p_src_data->value.state_change.lc_property_set.property_value->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
if (p_src_data->value.set.lc_property.property_value) {
|
||||
length = p_src_data->value.set.lc_property.property_value->len;
|
||||
p_dest_data->value.set.lc_property.property_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.lc_property.property_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.lc_property.property_value,
|
||||
p_src_data->value.set.lc_property.property_value->data,
|
||||
p_src_data->value.set.lc_property.property_value->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
|
||||
if (p_src_data->value.status.sensor_status.data) {
|
||||
length = p_src_data->value.status.sensor_status.data->len;
|
||||
p_dest_data->value.status.sensor_status.data = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.status.sensor_status.data == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.status.sensor_status.data,
|
||||
p_src_data->value.status.sensor_status.data->data,
|
||||
p_src_data->value.status.sensor_status.data->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lighting_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.state_change.lc_property_set.property_value);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.set.lc_property.property_value);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_STATUS) {
|
||||
bt_mesh_free_buf(arg->value.status.sensor_status.data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_lighting_server_callback(esp_ble_mesh_lighting_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_LIGHTING_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_LIGHTING_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_lighting_server_cb_param_t),
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_LIGHTING_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG:
|
||||
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_GET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG:
|
||||
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG:
|
||||
act = ESP_BLE_MESH_LIGHTING_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Lighting server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_lighting_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_lighting_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_LIGHTING_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_lighting_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_lighting_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -15,19 +15,19 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "sensor_client.h"
|
||||
#include "btc_ble_mesh_sensor_model.h"
|
||||
#include "sensor_client.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_sensor_client_cb_event_t event,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param)
|
||||
/* 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,
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_t btc_mesh_cb = (esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
esp_ble_mesh_sensor_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_sensor_client_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,32 +35,30 @@ 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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
|
||||
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
|
||||
dst->sensor_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->sensor_client_get_state.get_state = (esp_ble_mesh_sensor_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_get_state_t));
|
||||
if (dst->sensor_client_get_state.params && dst->sensor_client_get_state.get_state) {
|
||||
memcpy(dst->sensor_client_get_state.params, src->sensor_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->sensor_client_get_state.get_state, src->sensor_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_sensor_client_get_state_t));
|
||||
|
||||
opcode = src->sensor_client_get_state.params->opcode;
|
||||
switch (opcode) {
|
||||
switch (src->sensor_client_get_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
|
||||
if (src->sensor_client_get_state.get_state->column_get.raw_value_x) {
|
||||
length = src->sensor_client_get_state.get_state->column_get.raw_value_x->len;
|
||||
dst->sensor_client_get_state.get_state->column_get.raw_value_x = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->column_get.raw_value_x) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->column_get.raw_value_x,
|
||||
@ -73,7 +71,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_get_state.get_state->series_get.raw_value_x1->len;
|
||||
dst->sensor_client_get_state.get_state->series_get.raw_value_x1 = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x1) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x1,
|
||||
@ -84,7 +82,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_get_state.get_state->series_get.raw_value_x2->len;
|
||||
dst->sensor_client_get_state.get_state->series_get.raw_value_x2 = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_get_state.get_state->series_get.raw_value_x2) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_get_state.get_state->series_get.raw_value_x2,
|
||||
@ -96,27 +94,26 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
|
||||
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
|
||||
dst->sensor_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->sensor_client_set_state.set_state = (esp_ble_mesh_sensor_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_sensor_client_set_state_t));
|
||||
if (dst->sensor_client_set_state.params && dst->sensor_client_set_state.set_state) {
|
||||
memcpy(dst->sensor_client_set_state.params, src->sensor_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->sensor_client_set_state.set_state, src->sensor_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_sensor_client_set_state_t));
|
||||
|
||||
opcode = src->sensor_client_set_state.params->opcode;
|
||||
switch (opcode) {
|
||||
switch (src->sensor_client_set_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
|
||||
if (src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
|
||||
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down,
|
||||
@ -127,7 +124,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up,
|
||||
@ -138,7 +135,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_low->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_low,
|
||||
@ -149,7 +146,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_set_state.set_state->cadence_set.fast_cadence_high->len;
|
||||
dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->cadence_set.fast_cadence_high,
|
||||
@ -162,7 +159,7 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
length = src->sensor_client_set_state.set_state->setting_set.sensor_setting_raw->len;
|
||||
dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (!dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(dst->sensor_client_set_state.set_state->setting_set.sensor_setting_raw,
|
||||
@ -174,42 +171,111 @@ void btc_ble_mesh_sensor_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
|
||||
if (arg->sensor_client_get_state.get_state) {
|
||||
if (arg->sensor_client_get_state.params) {
|
||||
switch (arg->sensor_client_get_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
bt_mesh_free(arg->sensor_client_get_state.get_state);
|
||||
}
|
||||
if (arg->sensor_client_get_state.params) {
|
||||
bt_mesh_free(arg->sensor_client_get_state.params);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
|
||||
if (arg->sensor_client_set_state.set_state) {
|
||||
if (arg->sensor_client_set_state.params) {
|
||||
switch (arg->sensor_client_set_state.params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
bt_mesh_free(arg->sensor_client_set_state.set_state);
|
||||
}
|
||||
if (arg->sensor_client_set_state.params) {
|
||||
bt_mesh_free(arg->sensor_client_set_state.params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sensor_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
opcode = p_src_data->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
|
||||
if (p_src_data->status_cb.descriptor_status.descriptor) {
|
||||
length = p_src_data->status_cb.descriptor_status.descriptor->len;
|
||||
p_dest_data->status_cb.descriptor_status.descriptor = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.descriptor_status.descriptor) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.descriptor_status.descriptor,
|
||||
@ -224,7 +290,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.cadence_status.sensor_cadence_value->len;
|
||||
p_dest_data->status_cb.cadence_status.sensor_cadence_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.cadence_status.sensor_cadence_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.cadence_status.sensor_cadence_value,
|
||||
@ -238,7 +304,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.settings_status.sensor_setting_property_ids->len;
|
||||
p_dest_data->status_cb.settings_status.sensor_setting_property_ids = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.settings_status.sensor_setting_property_ids) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.settings_status.sensor_setting_property_ids,
|
||||
@ -253,7 +319,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.setting_status.sensor_setting_raw->len;
|
||||
p_dest_data->status_cb.setting_status.sensor_setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.setting_status.sensor_setting_raw) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.setting_status.sensor_setting_raw,
|
||||
@ -267,7 +333,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.sensor_status.marshalled_sensor_data->len;
|
||||
p_dest_data->status_cb.sensor_status.marshalled_sensor_data = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.sensor_status.marshalled_sensor_data) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.sensor_status.marshalled_sensor_data,
|
||||
@ -281,7 +347,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.column_status.sensor_column_value->len;
|
||||
p_dest_data->status_cb.column_status.sensor_column_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.column_status.sensor_column_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.column_status.sensor_column_value,
|
||||
@ -295,7 +361,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.series_status.sensor_series_value->len;
|
||||
p_dest_data->status_cb.series_status.sensor_series_value = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.series_status.sensor_series_value) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.series_status.sensor_series_value,
|
||||
@ -308,27 +374,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
static void btc_ble_mesh_sensor_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t *arg = NULL;
|
||||
u32_t opcode;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -339,8 +396,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
opcode = arg->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_DESCRIPTOR_STATUS:
|
||||
bt_mesh_free_buf(arg->status_cb.descriptor_status.descriptor);
|
||||
@ -377,7 +433,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
case ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
osi_free(arg->params);
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -385,116 +441,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
u32_t opcode = 0;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_sensor_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE:
|
||||
if (arg->sensor_client_get_state.params) {
|
||||
opcode = arg->sensor_client_get_state.params->opcode;
|
||||
osi_free(arg->sensor_client_get_state.params);
|
||||
}
|
||||
if (arg->sensor_client_get_state.get_state) {
|
||||
if (opcode) {
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET:
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->column_get.raw_value_x);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET:
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x1);
|
||||
bt_mesh_free_buf(arg->sensor_client_get_state.get_state->series_get.raw_value_x2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
osi_free(arg->sensor_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE:
|
||||
if (arg->sensor_client_set_state.params) {
|
||||
opcode = arg->sensor_client_set_state.params->opcode;
|
||||
osi_free(arg->sensor_client_set_state.params);
|
||||
}
|
||||
if (arg->sensor_client_set_state.set_state) {
|
||||
if (opcode) {
|
||||
switch (opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET:
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_down);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.status_trigger_delta_up);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_low);
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->cadence_set.fast_cadence_high);
|
||||
break;
|
||||
case ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET:
|
||||
bt_mesh_free_buf(arg->sensor_client_set_state.set_state->setting_set.sensor_setting_raw);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
osi_free(arg->sensor_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
|
||||
static void btc_ble_mesh_sensor_client_callback(esp_ble_mesh_sensor_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SENSOR_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SENSOR_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_sensor_client_cb_param_t), btc_ble_mesh_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_client_cb_param_t),
|
||||
btc_ble_mesh_sensor_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_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};
|
||||
size_t length;
|
||||
uint8_t act;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case 0x00:
|
||||
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE:
|
||||
act = ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT;
|
||||
break;
|
||||
case 0x01:
|
||||
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE:
|
||||
act = ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT;
|
||||
break;
|
||||
case 0x02:
|
||||
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH:
|
||||
act = ESP_BLE_MESH_SENSOR_CLIENT_PUBLISH_EVT;
|
||||
break;
|
||||
case 0x03:
|
||||
case BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT:
|
||||
act = ESP_BLE_MESH_SENSOR_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s, Unknown sensor client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Sensor client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -506,39 +500,43 @@ void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_mesh_sensor_client_callback(&cb_params, act);
|
||||
btc_ble_mesh_sensor_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_callback_sensor_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_sensor_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t sensor_client_cb = {0};
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
btc_ble_mesh_sensor_client_args_t *arg = NULL;
|
||||
struct bt_mesh_common_param common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
esp_ble_mesh_sensor_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -547,12 +545,6 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE: {
|
||||
params = arg->sensor_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -561,27 +553,18 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
sensor_client_cb.params = arg->sensor_client_get_state.params;
|
||||
sensor_client_cb.error_code =
|
||||
bt_mesh_sensor_client_get_state(&common,
|
||||
(void *)arg->sensor_client_get_state.get_state,
|
||||
(void *)&sensor_client_cb.status_cb);
|
||||
if (sensor_client_cb.error_code) {
|
||||
cb.params = arg->sensor_client_get_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_get_state(&common, arg->sensor_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_sensor_client_callback(&sensor_client_cb,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE: {
|
||||
params = arg->sensor_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -590,16 +573,13 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
sensor_client_cb.params = arg->sensor_client_set_state.params;
|
||||
sensor_client_cb.error_code =
|
||||
bt_mesh_sensor_client_set_state(&common,
|
||||
(void *)arg->sensor_client_set_state.set_state,
|
||||
(void *)&sensor_client_cb.status_cb);
|
||||
if (sensor_client_cb.error_code) {
|
||||
cb.params = arg->sensor_client_set_state.params;
|
||||
cb.error_code = bt_mesh_sensor_client_set_state(&common, arg->sensor_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_sensor_client_callback(&sensor_client_cb,
|
||||
ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
|
||||
btc_ble_mesh_sensor_client_callback(&cb, ESP_BLE_MESH_SENSOR_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -608,25 +588,303 @@ void btc_mesh_sensor_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_sensor_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sensor_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_sensor_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SENSOR_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_cb_to_app(msg->act, param);
|
||||
btc_ble_mesh_sensor_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_free_req_data(msg);
|
||||
btc_ble_mesh_sensor_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_sensor_server_cb_t)btc_profile_cb_get(BTC_PID_SENSOR_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sensor_server_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down) {
|
||||
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_down,
|
||||
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->data,
|
||||
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_down->len);
|
||||
}
|
||||
if (p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up) {
|
||||
length = p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.trigger_delta_up,
|
||||
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->data,
|
||||
p_src_data->value.state_change.sensor_cadence_set.trigger_delta_up->len);
|
||||
}
|
||||
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low) {
|
||||
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_low,
|
||||
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->data,
|
||||
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_low->len);
|
||||
}
|
||||
if (p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high) {
|
||||
length = p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len;
|
||||
p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_cadence_set.fast_cadence_high,
|
||||
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->data,
|
||||
p_src_data->value.state_change.sensor_cadence_set.fast_cadence_high->len);
|
||||
}
|
||||
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
|
||||
if (p_src_data->value.state_change.sensor_setting_set.setting_value) {
|
||||
length = p_src_data->value.state_change.sensor_setting_set.setting_value->len;
|
||||
p_dest_data->value.state_change.sensor_setting_set.setting_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.state_change.sensor_setting_set.setting_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.state_change.sensor_setting_set.setting_value,
|
||||
p_src_data->value.state_change.sensor_setting_set.setting_value->data,
|
||||
p_src_data->value.state_change.sensor_setting_set.setting_value->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
|
||||
if (p_src_data->value.get.sensor_column.raw_value_x) {
|
||||
length = p_src_data->value.get.sensor_column.raw_value_x->len;
|
||||
p_dest_data->value.get.sensor_column.raw_value_x = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.get.sensor_column.raw_value_x == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_column.raw_value_x,
|
||||
p_src_data->value.get.sensor_column.raw_value_x->data,
|
||||
p_src_data->value.get.sensor_column.raw_value_x->len);
|
||||
}
|
||||
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
|
||||
if (p_src_data->value.get.sensor_series.raw_value) {
|
||||
length = p_src_data->value.get.sensor_series.raw_value->len;
|
||||
p_dest_data->value.get.sensor_series.raw_value = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.get.sensor_series.raw_value == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.get.sensor_series.raw_value,
|
||||
p_src_data->value.get.sensor_series.raw_value->data,
|
||||
p_src_data->value.get.sensor_series.raw_value->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
|
||||
if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
if (p_src_data->value.set.sensor_cadence.cadence) {
|
||||
length = p_src_data->value.set.sensor_cadence.cadence->len;
|
||||
p_dest_data->value.set.sensor_cadence.cadence = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.sensor_cadence.cadence == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_cadence.cadence,
|
||||
p_src_data->value.set.sensor_cadence.cadence->data,
|
||||
p_src_data->value.set.sensor_cadence.cadence->len);
|
||||
}
|
||||
} else if (p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
|
||||
p_src_data->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
|
||||
if (p_src_data->value.set.sensor_setting.setting_raw) {
|
||||
length = p_src_data->value.set.sensor_setting.setting_raw->len;
|
||||
p_dest_data->value.set.sensor_setting.setting_raw = bt_mesh_alloc_buf(length);
|
||||
if (p_dest_data->value.set.sensor_setting.setting_raw == NULL) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->value.set.sensor_setting.setting_raw,
|
||||
p_src_data->value.set.sensor_setting.setting_raw->data,
|
||||
p_src_data->value.set.sensor_setting.setting_raw->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sensor_server_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_down);
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.trigger_delta_up);
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_low);
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_cadence_set.fast_cadence_high);
|
||||
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.state_change.sensor_setting_set.setting_value);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_COLUMN_GET) {
|
||||
bt_mesh_free_buf(arg->value.get.sensor_column.raw_value_x);
|
||||
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SERIES_GET) {
|
||||
bt_mesh_free_buf(arg->value.get.sensor_series.raw_value);
|
||||
}
|
||||
break;
|
||||
case ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT:
|
||||
if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_CADENCE_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.set.sensor_cadence.cadence);
|
||||
} else if (arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET ||
|
||||
arg->ctx.recv_op == ESP_BLE_MESH_MODEL_OP_SENSOR_SETTING_SET_UNACK) {
|
||||
bt_mesh_free_buf(arg->value.set.sensor_setting.setting_raw);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_sensor_server_callback(esp_ble_mesh_sensor_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_SENSOR_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_SENSOR_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_sensor_server_cb_param_t),
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_SENSOR_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG:
|
||||
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_GET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG:
|
||||
act = ESP_BLE_MESH_SENSOR_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Sensor server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_sensor_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_sensor_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_SENSOR_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_sensor_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_sensor_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
@ -15,19 +15,19 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "time_scene_client.h"
|
||||
#include "btc_ble_mesh_time_scene_model.h"
|
||||
#include "time_scene_client.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
static inline void btc_ble_mesh_cb_to_app(esp_ble_mesh_time_scene_client_cb_event_t event,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param)
|
||||
/* 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,
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_t btc_mesh_cb = (esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
|
||||
if (btc_mesh_cb) {
|
||||
btc_mesh_cb(event, param);
|
||||
esp_ble_mesh_time_scene_client_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_time_scene_client_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,62 +37,110 @@ void btc_ble_mesh_time_scene_client_arg_deep_copy(btc_msg_t *msg, void *p_dest,
|
||||
btc_ble_mesh_time_scene_client_args_t *src = (btc_ble_mesh_time_scene_client_args_t *)p_src;
|
||||
|
||||
if (!msg || !dst || !src) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
|
||||
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
|
||||
if (dst->time_scene_client_get_state.params && dst->time_scene_client_get_state.get_state) {
|
||||
dst->time_scene_client_get_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (dst->time_scene_client_get_state.params) {
|
||||
memcpy(dst->time_scene_client_get_state.params, src->time_scene_client_get_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
if (src->time_scene_client_get_state.get_state) {
|
||||
dst->time_scene_client_get_state.get_state = (esp_ble_mesh_time_scene_client_get_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_get_state_t));
|
||||
if (dst->time_scene_client_get_state.get_state) {
|
||||
memcpy(dst->time_scene_client_get_state.get_state, src->time_scene_client_get_state.get_state,
|
||||
sizeof(esp_ble_mesh_time_scene_client_get_state_t));
|
||||
} else {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
|
||||
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)osi_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
|
||||
dst->time_scene_client_set_state.params = (esp_ble_mesh_client_common_param_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
dst->time_scene_client_set_state.set_state = (esp_ble_mesh_time_scene_client_set_state_t *)bt_mesh_malloc(sizeof(esp_ble_mesh_time_scene_client_set_state_t));
|
||||
if (dst->time_scene_client_set_state.params && dst->time_scene_client_set_state.set_state) {
|
||||
memcpy(dst->time_scene_client_set_state.params, src->time_scene_client_set_state.params,
|
||||
sizeof(esp_ble_mesh_client_common_param_t));
|
||||
memcpy(dst->time_scene_client_set_state.set_state, src->time_scene_client_set_state.set_state,
|
||||
sizeof(esp_ble_mesh_time_scene_client_set_state_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
|
||||
if (arg->time_scene_client_get_state.params) {
|
||||
bt_mesh_free(arg->time_scene_client_get_state.params);
|
||||
}
|
||||
if (arg->time_scene_client_get_state.get_state) {
|
||||
bt_mesh_free(arg->time_scene_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
|
||||
if (arg->time_scene_client_set_state.params) {
|
||||
bt_mesh_free(arg->time_scene_client_set_state.params);
|
||||
}
|
||||
if (arg->time_scene_client_set_state.set_state) {
|
||||
bt_mesh_free(arg->time_scene_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_time_scene_client_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
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;
|
||||
u32_t opcode;
|
||||
u16_t length;
|
||||
u16_t length = 0U;
|
||||
|
||||
if (!msg || !p_src_data || !p_dest_data) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = bt_mesh_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (!p_dest_data->params) {
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
}
|
||||
|
||||
switch (msg->act) {
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT:
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
|
||||
if (p_src_data->params) {
|
||||
opcode = p_src_data->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (p_src_data->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
|
||||
@ -101,7 +149,7 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
length = p_src_data->status_cb.scene_register_status.scenes->len;
|
||||
p_dest_data->status_cb.scene_register_status.scenes = bt_mesh_alloc_buf(length);
|
||||
if (!p_dest_data->status_cb.scene_register_status.scenes) {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
BT_ERR("%s, Out of memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.scene_register_status.scenes,
|
||||
@ -114,27 +162,18 @@ static void btc_ble_mesh_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src
|
||||
}
|
||||
}
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
|
||||
if (p_src_data->params) {
|
||||
p_dest_data->params = osi_malloc(sizeof(esp_ble_mesh_client_common_param_t));
|
||||
if (p_dest_data->params) {
|
||||
memcpy(p_dest_data->params, p_src_data->params, sizeof(esp_ble_mesh_client_common_param_t));
|
||||
} else {
|
||||
LOG_ERROR("%s, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
static void btc_ble_mesh_time_scene_client_free_req_data(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *arg = NULL;
|
||||
u32_t opcode;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -145,8 +184,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT:
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT:
|
||||
if (arg->params) {
|
||||
opcode = arg->params->opcode;
|
||||
switch (opcode) {
|
||||
switch (arg->params->opcode) {
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_STORE:
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_REGISTER_GET:
|
||||
case ESP_BLE_MESH_MODEL_OP_SCENE_DELETE:
|
||||
@ -159,7 +197,7 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
case ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT:
|
||||
if (arg->params) {
|
||||
osi_free(arg->params);
|
||||
bt_mesh_free(arg->params);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -167,85 +205,54 @@ static void btc_ble_mesh_free_req_data(btc_msg_t *msg)
|
||||
}
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_client_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
arg = (btc_ble_mesh_time_scene_client_args_t *)(msg->arg);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE:
|
||||
if (arg->time_scene_client_get_state.params) {
|
||||
osi_free(arg->time_scene_client_get_state.params);
|
||||
}
|
||||
if (arg->time_scene_client_get_state.get_state) {
|
||||
osi_free(arg->time_scene_client_get_state.get_state);
|
||||
}
|
||||
break;
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE:
|
||||
if (arg->time_scene_client_set_state.params) {
|
||||
osi_free(arg->time_scene_client_set_state.params);
|
||||
}
|
||||
if (arg->time_scene_client_set_state.set_state) {
|
||||
osi_free(arg->time_scene_client_set_state.set_state);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void btc_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
|
||||
static void btc_ble_mesh_time_scene_client_callback(esp_ble_mesh_time_scene_client_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
LOG_DEBUG("%s", __func__);
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_CLIENT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_TIME_SCENE_CLIENT;
|
||||
msg.act = act;
|
||||
|
||||
btc_transfer_context(&msg, cb_params,
|
||||
sizeof(esp_ble_mesh_time_scene_client_cb_param_t), btc_ble_mesh_copy_req_data);
|
||||
btc_transfer_context(&msg, cb_params, sizeof(esp_ble_mesh_time_scene_client_cb_param_t),
|
||||
btc_ble_mesh_time_scene_client_copy_req_data);
|
||||
}
|
||||
|
||||
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_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};
|
||||
size_t length;
|
||||
uint8_t act;
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (!model || !ctx) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case 0x00:
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT;
|
||||
break;
|
||||
case 0x01:
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT;
|
||||
break;
|
||||
case 0x02:
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_PUBLISH_EVT;
|
||||
break;
|
||||
case 0x03:
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_CLIENT_TIMEOUT_EVT;
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s, Unknown time scene client event type %d", __func__, evt_type);
|
||||
BT_ERR("Unknown Time Scene client event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -257,39 +264,43 @@ void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
params.ctx.recv_op = ctx->recv_op;
|
||||
params.ctx.recv_dst = ctx->recv_dst;
|
||||
params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
cb_params.error_code = 0;
|
||||
cb_params.params = ¶ms;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.status_cb)) ? len : sizeof(cb_params.status_cb);
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
memcpy(&cb_params.status_cb, val, MIN(len, sizeof(cb_params.status_cb)));
|
||||
}
|
||||
|
||||
btc_mesh_time_scene_client_callback(&cb_params, act);
|
||||
btc_ble_mesh_time_scene_client_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf)
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
if (!model || !ctx || !buf) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
bt_mesh_callback_time_scene_status_to_btc(opcode, 0x02, model, ctx, buf->data, buf->len);
|
||||
bt_mesh_time_scene_client_cb_evt_to_btc(opcode, BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
|
||||
model, ctx, buf->data, buf->len);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t time_scene_client_cb = {0};
|
||||
btc_ble_mesh_time_scene_client_args_t *arg = NULL;
|
||||
esp_ble_mesh_client_common_param_t *params = NULL;
|
||||
struct bt_mesh_common_param common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
esp_ble_mesh_time_scene_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -298,12 +309,6 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
switch (msg->act) {
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE: {
|
||||
params = arg->time_scene_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -312,27 +317,18 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
time_scene_client_cb.params = arg->time_scene_client_get_state.params;
|
||||
time_scene_client_cb.error_code =
|
||||
bt_mesh_time_scene_client_get_state(&common,
|
||||
(void *)arg->time_scene_client_get_state.get_state,
|
||||
(void *)&time_scene_client_cb.status_cb);
|
||||
if (time_scene_client_cb.error_code) {
|
||||
cb.params = arg->time_scene_client_get_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_get_state(&common, arg->time_scene_client_get_state.get_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_time_scene_client_callback(&time_scene_client_cb,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_GET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE: {
|
||||
params = arg->time_scene_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)params->model;
|
||||
role_param.role = params->msg_role;
|
||||
if (bt_mesh_set_model_role(&role_param)) {
|
||||
LOG_ERROR("%s, Failed to set model role", __func__);
|
||||
return;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
common.ctx.net_idx = params->ctx.net_idx;
|
||||
@ -341,16 +337,13 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_rel = params->ctx.send_rel;
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
common.msg_role = params->msg_role;
|
||||
|
||||
time_scene_client_cb.params = arg->time_scene_client_set_state.params;
|
||||
time_scene_client_cb.error_code =
|
||||
bt_mesh_time_scene_client_set_state(&common,
|
||||
(void *)arg->time_scene_client_set_state.set_state,
|
||||
(void *)&time_scene_client_cb.status_cb);
|
||||
if (time_scene_client_cb.error_code) {
|
||||
cb.params = arg->time_scene_client_set_state.params;
|
||||
cb.error_code = bt_mesh_time_scene_client_set_state(&common, arg->time_scene_client_set_state.set_state);
|
||||
if (cb.error_code) {
|
||||
/* If send failed, callback error_code to app layer immediately */
|
||||
btc_mesh_time_scene_client_callback(&time_scene_client_cb,
|
||||
ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
|
||||
btc_ble_mesh_time_scene_client_callback(&cb, ESP_BLE_MESH_TIME_SCENE_CLIENT_SET_STATE_EVT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -359,25 +352,125 @@ void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_client_arg_deep_free(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
void btc_ble_mesh_time_scene_client_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_client_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_time_scene_client_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_TIME_SCENE_CLIENT_EVT_MAX) {
|
||||
btc_ble_mesh_cb_to_app(msg->act, param);
|
||||
btc_ble_mesh_time_scene_client_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
LOG_ERROR("%s, Unknown msg->act = %d", __func__, msg->act);
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_free_req_data(msg);
|
||||
btc_ble_mesh_time_scene_client_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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,
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_t btc_ble_mesh_cb =
|
||||
(esp_ble_mesh_time_scene_server_cb_t)btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER);
|
||||
if (btc_ble_mesh_cb) {
|
||||
btc_ble_mesh_cb(event, param);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_ble_mesh_time_scene_server_callback(esp_ble_mesh_time_scene_server_cb_param_t *cb_params, uint8_t act)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
BT_DBG("%s", __func__);
|
||||
|
||||
/* If corresponding callback is not registered, event will not be posted. */
|
||||
if (!btc_profile_cb_get(BTC_PID_TIME_SCENE_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_TIME_SCENE_SERVER;
|
||||
msg.act = act;
|
||||
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_param_t cb_params = {0};
|
||||
uint8_t act = 0U;
|
||||
|
||||
if (model == NULL || ctx == NULL) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt_type) {
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_STATE_CHANGE_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_GET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_SET_MSG_EVT;
|
||||
break;
|
||||
case BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG:
|
||||
act = ESP_BLE_MESH_TIME_SCENE_SERVER_RECV_STATUS_MSG_EVT;
|
||||
break;
|
||||
default:
|
||||
BT_ERR("Unknown Time Scene server event type %d", evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
cb_params.model = (esp_ble_mesh_model_t *)model;
|
||||
cb_params.ctx.net_idx = ctx->net_idx;
|
||||
cb_params.ctx.app_idx = ctx->app_idx;
|
||||
cb_params.ctx.addr = ctx->addr;
|
||||
cb_params.ctx.recv_ttl = ctx->recv_ttl;
|
||||
cb_params.ctx.recv_op = ctx->recv_op;
|
||||
cb_params.ctx.recv_dst = ctx->recv_dst;
|
||||
cb_params.ctx.recv_rssi = ctx->recv_rssi;
|
||||
cb_params.ctx.send_ttl = ctx->send_ttl;
|
||||
|
||||
if (val && len) {
|
||||
memcpy(&cb_params.value, val, MIN(len, sizeof(cb_params.value)));
|
||||
}
|
||||
|
||||
btc_ble_mesh_time_scene_server_callback(&cb_params, act);
|
||||
return;
|
||||
}
|
||||
|
||||
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_mesh_time_scene_server_cb_param_t *param = NULL;
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
param = (esp_ble_mesh_time_scene_server_cb_param_t *)(msg->arg);
|
||||
|
||||
if (msg->act < ESP_BLE_MESH_TIME_SCENE_SERVER_EVT_MAX) {
|
||||
btc_ble_mesh_time_scene_server_cb_to_app(msg->act, param);
|
||||
} else {
|
||||
BT_ERR("%s, Unknown act %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -15,50 +15,66 @@
|
||||
#ifndef _BTC_BLE_MESH_CONFIG_MODEL_H_
|
||||
#define _BTC_BLE_MESH_CONFIG_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_config_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_CONFIG_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_CONFIG_CLIENT_SET_STATE,
|
||||
} btc_ble_mesh_cfg_client_act_t;
|
||||
BTC_BLE_MESH_ACT_CONFIG_CLIENT_MAX,
|
||||
} btc_ble_mesh_config_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct ble_mesh_clg_client_get_state_reg_args {
|
||||
struct ble_mesh_cfg_client_get_state_reg_args {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_cfg_client_get_state_t *get_state;
|
||||
} cfg_client_get_state;
|
||||
struct ble_mesh_clg_client_set_state_reg_args {
|
||||
struct ble_mesh_cfg_client_set_state_reg_args {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_cfg_client_set_state_t *set_state;
|
||||
} cfg_client_set_state;
|
||||
} btc_ble_mesh_cfg_client_args_t;
|
||||
} btc_ble_mesh_config_client_args_t;
|
||||
|
||||
void btc_mesh_cfg_client_call_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_CONFIG_CLIENT_MAX,
|
||||
} btc_ble_mesh_config_client_evt_t;
|
||||
|
||||
void btc_mesh_cfg_client_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_config_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_cfg_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_ble_mesh_config_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
int btc_ble_mesh_config_client_get_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_get_state_t *get_state,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
|
||||
void btc_ble_mesh_config_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
int btc_ble_mesh_config_client_set_state(esp_ble_mesh_client_common_param_t *params, esp_ble_mesh_cfg_client_set_state_t *set_state,
|
||||
esp_ble_mesh_cfg_client_cb_param_t *cfg_client_cb);
|
||||
void btc_ble_mesh_config_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void btc_mesh_cfg_client_publish_callback(u32_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,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void bt_mesh_callback_config_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void btc_ble_mesh_config_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_cfg_server_cb_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_CONFIG_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_CONFIG_SERVER_MAX,
|
||||
} btc_ble_mesh_config_server_evt_t;
|
||||
|
||||
void bt_mesh_callback_cfg_server_event_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_config_server_cb_evt_to_btc(u8_t evt_type, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_CONFIG_MODEL_H_ */
|
||||
|
@ -15,13 +15,17 @@
|
||||
#ifndef _BTC_BLE_MESH_GENERIC_MODEL_H_
|
||||
#define _BTC_BLE_MESH_GENERIC_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_generic_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_GENERIC_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_GENERIC_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_GENERIC_CLIENT_MAX,
|
||||
} btc_ble_mesh_generic_client_act_t;
|
||||
|
||||
typedef union {
|
||||
@ -35,18 +39,44 @@ typedef union {
|
||||
} generic_client_set_state;
|
||||
} btc_ble_mesh_generic_client_args_t;
|
||||
|
||||
void btc_mesh_generic_client_call_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_GENERIC_CLIENT_MAX,
|
||||
} btc_ble_mesh_generic_client_evt_t;
|
||||
|
||||
void btc_mesh_generic_client_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_generic_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
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_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_generic_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_generic_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_GET_MSG,
|
||||
BTC_BLE_MESH_EVT_GENERIC_SERVER_RECV_SET_MSG,
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_generic_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_GENERIC_MODEL_H_ */
|
||||
|
@ -15,21 +15,19 @@
|
||||
#ifndef _BTC_BLE_MESH_HEALTH_MODEL_H_
|
||||
#define _BTC_BLE_MESH_HEALTH_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_health_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_HEALTH_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_HEALTH_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_HEALTH_CLIENT_MAX,
|
||||
} btc_ble_mesh_health_client_act_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
|
||||
} btc_ble_mesh_health_server_act_t;
|
||||
|
||||
typedef union {
|
||||
struct ble_mesh_health_client_get_state_reg_args {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
@ -41,38 +39,57 @@ typedef union {
|
||||
} health_client_set_state;
|
||||
} btc_ble_mesh_health_client_args_t;
|
||||
|
||||
typedef union {
|
||||
struct ble_mesh_health_server_fault_update_args {
|
||||
esp_ble_mesh_elem_t *element;
|
||||
} fault_update;
|
||||
} btc_ble_mesh_health_server_args_t;
|
||||
|
||||
void btc_mesh_health_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_health_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_health_server_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_health_server_cb_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_HEALTH_CLIENT_MAX,
|
||||
} btc_ble_mesh_health_client_evt_t;
|
||||
|
||||
void btc_ble_mesh_health_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
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,
|
||||
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,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_FAULT_UPDATE,
|
||||
BTC_BLE_MESH_ACT_HEALTH_SERVER_MAX,
|
||||
} btc_ble_mesh_health_server_act_t;
|
||||
|
||||
typedef union {
|
||||
struct ble_mesh_health_server_fault_update_args {
|
||||
esp_ble_mesh_elem_t *element;
|
||||
} health_fault_update;
|
||||
} btc_ble_mesh_health_server_args_t;
|
||||
|
||||
void btc_ble_mesh_health_server_call_handler(btc_msg_t *msg);
|
||||
|
||||
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);
|
||||
|
||||
int btc_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_get_state_t *get_state,
|
||||
esp_ble_mesh_health_client_cb_param_t *client_cb);
|
||||
void btc_ble_mesh_health_server_fault_clear(struct bt_mesh_model *model, u16_t company_id);
|
||||
|
||||
int btc_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_t *params,
|
||||
esp_ble_mesh_health_client_set_state_t *set_state,
|
||||
esp_ble_mesh_health_client_cb_param_t *client_cb);
|
||||
void btc_ble_mesh_health_server_fault_test(struct bt_mesh_model *model,
|
||||
u8_t test_id, u16_t company_id);
|
||||
|
||||
void btc_mesh_health_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_health_server_attention_on(struct bt_mesh_model *model, u8_t time);
|
||||
|
||||
void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, u16_t len);
|
||||
void btc_ble_mesh_health_server_attention_off(struct bt_mesh_model *model);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_HEALTH_MODEL_H_ */
|
||||
|
@ -15,14 +15,18 @@
|
||||
#ifndef _BTC_BLE_MESH_LIGHTING_MODEL_H_
|
||||
#define _BTC_BLE_MESH_LIGHTING_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_lighting_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_LIGHT_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_LIGHT_CLIENT_SET_STATE,
|
||||
} btc_ble_mesh_light_client_act_t;
|
||||
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_LIGHTING_CLIENT_MAX,
|
||||
} btc_ble_mesh_lighting_client_act_t;
|
||||
|
||||
typedef union {
|
||||
struct ble_mesh_light_client_get_state_reg_args {
|
||||
@ -33,21 +37,48 @@ typedef union {
|
||||
esp_ble_mesh_client_common_param_t *params;
|
||||
esp_ble_mesh_light_client_set_state_t *set_state;
|
||||
} light_client_set_state;
|
||||
} btc_ble_mesh_light_client_args_t;
|
||||
} btc_ble_mesh_lighting_client_args_t;
|
||||
|
||||
void btc_mesh_light_client_call_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_CLIENT_MAX,
|
||||
} btc_ble_mesh_lighting_client_evt_t;
|
||||
|
||||
void btc_mesh_light_client_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_lighting_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_light_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_ble_mesh_lighting_client_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_light_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_lighting_client_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void btc_ble_mesh_lighting_client_publish_callback(u32_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,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_GET_MSG,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_SET_MSG,
|
||||
BTC_BLE_MESH_EVT_LIGHTING_SERVER_RECV_STATUS_MSG,
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_lighting_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_LIGHTING_MODEL_H_ */
|
||||
|
||||
|
@ -15,20 +15,17 @@
|
||||
#ifndef _BTC_BLE_MESH_PROV_H_
|
||||
#define _BTC_BLE_MESH_PROV_H_
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "btc/btc_task.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#include "mesh_access.h"
|
||||
#include "mesh_buf.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_main.h"
|
||||
#include "fast_prov.h"
|
||||
#include "provisioner_prov.h"
|
||||
#include "esp_ble_mesh_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_MESH_INIT = 0,
|
||||
BTC_BLE_MESH_ACT_PROV_ENABLE,
|
||||
@ -47,21 +44,43 @@ typedef enum {
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_ENABLE,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DISABLE,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DEV_ADD,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_PROV_DEV_WITH_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_DEV_DEL,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_DEV_UUID_MATCH,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_PROV_DATA_INFO,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_STATIC_OOB_VAL,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_PRIMARY_ELEM_ADDR,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_NODE_NAME,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_SET_LOCAL_APP_KEY,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_APP_KEY,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_APP_KEY,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_BIND_LOCAL_MOD_APP,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_ADD_LOCAL_NET_KEY,
|
||||
BTC_BLE_MESH_ACT_PROVISIONER_UPDATE_LOCAL_NET_KEY,
|
||||
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_SET_FAST_PROV_INFO,
|
||||
BTC_BLE_MESH_ACT_SET_FAST_PROV_ACTION,
|
||||
BTC_BLE_MESH_ACT_LPN_ENABLE,
|
||||
BTC_BLE_MESH_ACT_LPN_DISABLE,
|
||||
BTC_BLE_MESH_ACT_LPN_POLL,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_CONNECT,
|
||||
BTC_BLE_MESH_ACT_PROXY_CLIENT_DISCONNECT,
|
||||
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,
|
||||
} btc_ble_mesh_prov_act_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_MODEL_PUBLISH,
|
||||
BTC_BLE_MESH_ACT_SERVER_MODEL_SEND,
|
||||
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND
|
||||
BTC_BLE_MESH_ACT_CLIENT_MODEL_SEND,
|
||||
BTC_BLE_MESH_ACT_SERVER_MODEL_UPDATE_STATE,
|
||||
} btc_ble_mesh_model_act_t;
|
||||
|
||||
typedef union {
|
||||
@ -88,7 +107,7 @@ typedef union {
|
||||
char string[8];
|
||||
} input_string;
|
||||
struct ble_mesh_set_device_name_args {
|
||||
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN];
|
||||
char name[ESP_BLE_MESH_DEVICE_NAME_MAX_LEN + 1];
|
||||
} set_device_name;
|
||||
struct ble_mesh_provisioner_read_oob_pub_key_args {
|
||||
uint8_t link_idx;
|
||||
@ -113,6 +132,14 @@ typedef union {
|
||||
esp_ble_mesh_unprov_dev_add_t add_dev;
|
||||
esp_ble_mesh_dev_add_flag_t flags;
|
||||
} provisioner_dev_add;
|
||||
struct ble_mesh_provisioner_prov_dev_with_addr_args {
|
||||
uint8_t uuid[16];
|
||||
esp_ble_mesh_bd_addr_t addr;
|
||||
esp_ble_mesh_addr_type_t addr_type;
|
||||
esp_ble_mesh_prov_bearer_t bearer;
|
||||
uint16_t oob_info;
|
||||
uint16_t unicast_addr;
|
||||
} provisioner_prov_dev_with_addr;
|
||||
struct ble_mesh_provisioner_dev_del_args {
|
||||
esp_ble_mesh_device_delete_t del_dev;
|
||||
} provisioner_dev_del;
|
||||
@ -125,15 +152,27 @@ typedef union {
|
||||
struct ble_mesh_provisioner_set_prov_net_idx_args {
|
||||
esp_ble_mesh_prov_data_info_t prov_data;
|
||||
} set_prov_data_info;
|
||||
struct ble_mesh_provisioner_set_static_oob_val_args {
|
||||
uint8_t value[16];
|
||||
uint8_t length;
|
||||
} set_static_oob_val;
|
||||
struct ble_mesh_provisioner_set_primary_elem_addr_args {
|
||||
uint16_t addr;
|
||||
} set_primary_elem_addr;
|
||||
struct ble_mesh_provisioner_set_node_name_args {
|
||||
int index;
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN];
|
||||
uint16_t index;
|
||||
char name[ESP_BLE_MESH_NODE_NAME_MAX_LEN + 1];
|
||||
} set_node_name;
|
||||
struct ble_mesh_provisioner_add_local_app_key_args {
|
||||
uint8_t app_key[16];
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
} add_local_app_key;
|
||||
struct ble_mesh_provisioner_update_local_app_key_args {
|
||||
uint8_t app_key[16];
|
||||
uint16_t net_idx;
|
||||
uint16_t app_idx;
|
||||
} update_local_app_key;
|
||||
struct ble_mesh_provisioner_bind_local_mod_app_args {
|
||||
uint16_t elem_addr;
|
||||
uint16_t model_id;
|
||||
@ -144,6 +183,21 @@ typedef union {
|
||||
uint8_t net_key[16];
|
||||
uint16_t net_idx;
|
||||
} add_local_net_key;
|
||||
struct ble_mesh_provisioner_update_local_net_key_args {
|
||||
uint8_t net_key[16];
|
||||
uint16_t net_idx;
|
||||
} update_local_net_key;
|
||||
struct ble_mesh_provisioner_store_node_comp_data_args {
|
||||
uint16_t unicast_addr;
|
||||
uint16_t length;
|
||||
uint8_t *data;
|
||||
} store_node_comp_data;
|
||||
struct ble_mesh_provisioner_delete_node_with_uuid_args {
|
||||
uint8_t uuid[16];
|
||||
} delete_node_with_uuid;
|
||||
struct ble_mesh_provisioner_delete_node_with_addr_args {
|
||||
uint16_t unicast_addr;
|
||||
} delete_node_with_addr;
|
||||
struct ble_mesh_set_fast_prov_info_args {
|
||||
uint16_t unicast_min;
|
||||
uint16_t unicast_max;
|
||||
@ -157,6 +211,62 @@ typedef union {
|
||||
struct ble_mesh_set_fast_prov_action_args {
|
||||
uint8_t action;
|
||||
} set_fast_prov_action;
|
||||
struct ble_mesh_lpn_enable_args {
|
||||
/* RFU */
|
||||
} lpn_enable;
|
||||
struct ble_mesh_lpn_disable_args {
|
||||
bool force;
|
||||
} lpn_disable;
|
||||
struct ble_mesh_lpn_poll_args {
|
||||
/* RFU */
|
||||
} lpn_poll;
|
||||
struct ble_mesh_proxy_client_connect_args {
|
||||
uint8_t addr[6];
|
||||
uint8_t addr_type;
|
||||
uint16_t net_idx;
|
||||
} proxy_client_connect;
|
||||
struct ble_mesh_proxy_client_disconnect_args {
|
||||
uint8_t conn_handle;
|
||||
} proxy_client_disconnect;
|
||||
struct ble_mesh_proxy_client_set_filter_type_args {
|
||||
uint8_t conn_handle;
|
||||
uint16_t net_idx;
|
||||
uint8_t filter_type;
|
||||
} proxy_client_set_filter_type;
|
||||
struct ble_mesh_proxy_client_add_filter_addr_args {
|
||||
uint8_t conn_handle;
|
||||
uint16_t net_idx;
|
||||
uint16_t addr_num;
|
||||
uint16_t *addr;
|
||||
} proxy_client_add_filter_addr;
|
||||
struct ble_mesh_proxy_client_remove_filter_addr_args {
|
||||
uint8_t conn_handle;
|
||||
uint16_t net_idx;
|
||||
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;
|
||||
uint16_t model_id;
|
||||
uint16_t group_addr;
|
||||
} model_sub_group_addr;
|
||||
struct ble_mesh_model_unsub_group_addr_args {
|
||||
uint16_t element_addr;
|
||||
uint16_t company_id;
|
||||
uint16_t model_id;
|
||||
uint16_t group_addr;
|
||||
} model_unsub_group_addr;
|
||||
struct ble_mesh_deinit_args {
|
||||
esp_ble_mesh_deinit_param_t param;
|
||||
} mesh_deinit;
|
||||
} btc_ble_mesh_prov_args_t;
|
||||
|
||||
typedef union {
|
||||
@ -174,13 +284,30 @@ typedef union {
|
||||
uint8_t device_role;
|
||||
int32_t msg_timeout;
|
||||
} model_send;
|
||||
struct ble_mesh_server_model_update_state_args {
|
||||
esp_ble_mesh_model_t *model;
|
||||
esp_ble_mesh_server_state_type_t type;
|
||||
esp_ble_mesh_server_state_value_t *value;
|
||||
} model_update_state;
|
||||
} btc_ble_mesh_model_args_t;
|
||||
|
||||
void btc_ble_mesh_prov_arg_deep_free(btc_msg_t *msg);
|
||||
|
||||
void btc_ble_mesh_prov_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
int btc_ble_mesh_client_init(esp_ble_mesh_model_t *model);
|
||||
void btc_ble_mesh_model_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
|
||||
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);
|
||||
|
||||
const esp_ble_mesh_node_t **btc_ble_mesh_provisioner_get_node_table_entry(void);
|
||||
|
||||
int btc_ble_mesh_client_model_init(esp_ble_mesh_model_t *model);
|
||||
|
||||
int btc_ble_mesh_client_model_deinit(esp_ble_mesh_model_t *model);
|
||||
|
||||
int32_t btc_ble_mesh_model_pub_period_get(esp_ble_mesh_model_t *mod);
|
||||
|
||||
@ -193,18 +320,20 @@ esp_ble_mesh_elem_t *btc_ble_mesh_elem_find(u16_t addr);
|
||||
uint8_t btc_ble_mesh_elem_count(void);
|
||||
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find_vnd(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t company, uint16_t id);
|
||||
uint16_t company, uint16_t id);
|
||||
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem,
|
||||
uint16_t id);
|
||||
esp_ble_mesh_model_t *btc_ble_mesh_model_find(const esp_ble_mesh_elem_t *elem, uint16_t id);
|
||||
|
||||
const esp_ble_mesh_comp_t *btc_ble_mesh_comp_get(void);
|
||||
|
||||
void btc_mesh_model_call_handler(btc_msg_t *msg);
|
||||
void btc_mesh_model_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_model_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_model_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_prov_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_prov_call_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_prov_cb_handler(btc_msg_t *msg);
|
||||
|
||||
void btc_mesh_prov_cb_handler(btc_msg_t *msg);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_PROV_H_ */
|
||||
|
@ -15,13 +15,17 @@
|
||||
#ifndef _BTC_BLE_MESH_SENSOR_MODEL_H_
|
||||
#define _BTC_BLE_MESH_SENSOR_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_sensor_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_SENSOR_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_SENSOR_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_SENSOR_CLIENT_MAX,
|
||||
} btc_ble_mesh_sensor_client_act_t;
|
||||
|
||||
typedef union {
|
||||
@ -35,19 +39,45 @@ typedef union {
|
||||
} sensor_client_set_state;
|
||||
} btc_ble_mesh_sensor_client_args_t;
|
||||
|
||||
void btc_mesh_sensor_client_call_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_SENSOR_CLIENT_MAX,
|
||||
} btc_ble_mesh_sensor_client_evt_t;
|
||||
|
||||
void btc_mesh_sensor_client_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_sensor_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
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_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_sensor_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_callback_sensor_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_sensor_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_GET_MSG,
|
||||
BTC_BLE_MESH_EVT_SENSOR_SERVER_RECV_SET_MSG,
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_sensor_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_SENSOR_MODEL_H_ */
|
||||
|
||||
|
@ -15,13 +15,17 @@
|
||||
#ifndef _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
|
||||
#define _BTC_BLE_MESH_TIME_SCENE_MODEL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "btc/btc_task.h"
|
||||
#include "btc/btc_manage.h"
|
||||
#include "esp_ble_mesh_time_scene_model_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_ACT_TIME_SCENE_CLIENT_MAX,
|
||||
} btc_ble_mesh_time_scene_client_act_t;
|
||||
|
||||
typedef union {
|
||||
@ -35,19 +39,46 @@ typedef union {
|
||||
} time_scene_client_set_state;
|
||||
} btc_ble_mesh_time_scene_client_args_t;
|
||||
|
||||
void btc_mesh_time_scene_client_call_handler(btc_msg_t *msg);
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_GET_STATE,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_SET_STATE,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_PUBLISH,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_TIMEOUT,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_CLIENT_MAX,
|
||||
} btc_ble_mesh_time_scene_client_evt_t;
|
||||
|
||||
void btc_mesh_time_scene_client_cb_handler(btc_msg_t *msg);
|
||||
void btc_ble_mesh_time_scene_client_call_handler(btc_msg_t *msg);
|
||||
|
||||
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_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||
void btc_ble_mesh_time_scene_client_publish_callback(u32_t opcode, struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf);
|
||||
|
||||
void bt_mesh_callback_time_scene_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
void bt_mesh_time_scene_client_cb_evt_to_btc(u32_t opcode, u8_t evt_type,
|
||||
struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
typedef enum {
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_STATE_CHANGE,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_GET_MSG,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_SET_MSG,
|
||||
BTC_BLE_MESH_EVT_TIME_SCENE_SERVER_RECV_STATUS_MSG,
|
||||
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,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const u8_t *val, size_t len);
|
||||
|
||||
void btc_ble_mesh_time_scene_server_cb_handler(btc_msg_t *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BTC_BLE_MESH_TIME_SCENE_MODEL_H_ */
|
||||
|
||||
|
@ -11,12 +11,9 @@
|
||||
#ifndef _BLE_MESH_BUF_H_
|
||||
#define _BLE_MESH_BUF_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "sys/cdefs.h"
|
||||
#include "mesh_types.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh_util.h"
|
||||
#include "mesh_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -155,6 +152,18 @@ static inline void net_buf_simple_init(struct net_buf_simple *buf,
|
||||
buf->len = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize a net_buf_simple object with data.
|
||||
*
|
||||
* Initialized buffer object with external data.
|
||||
*
|
||||
* @param buf Buffer to initialize.
|
||||
* @param data External data pointer
|
||||
* @param size Amount of data the pointed data buffer if able to fit.
|
||||
*/
|
||||
void net_buf_simple_init_with_data(struct net_buf_simple *buf,
|
||||
void *data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Reset buffer
|
||||
*
|
||||
@ -168,6 +177,19 @@ static inline void net_buf_simple_reset(struct net_buf_simple *buf)
|
||||
buf->data = buf->__buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone buffer state, using the same data buffer.
|
||||
*
|
||||
* Initializes a buffer to point to the same data as an existing buffer.
|
||||
* Allows operations on the same data without altering the length and
|
||||
* offset of the original.
|
||||
*
|
||||
* @param original Buffer to clone.
|
||||
* @param clone The new clone.
|
||||
*/
|
||||
void net_buf_simple_clone(const struct net_buf_simple *original,
|
||||
struct net_buf_simple *clone);
|
||||
|
||||
/**
|
||||
* @brief Prepare data to be added at the end of the buffer
|
||||
*
|
||||
@ -233,6 +255,30 @@ void net_buf_simple_add_le16(struct net_buf_simple *buf, u16_t val);
|
||||
*/
|
||||
void net_buf_simple_add_be16(struct net_buf_simple *buf, u16_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 24-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 24-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Add 32-bit value at the end of the buffer
|
||||
*
|
||||
@ -257,6 +303,54 @@ void net_buf_simple_add_le32(struct net_buf_simple *buf, u32_t val);
|
||||
*/
|
||||
void net_buf_simple_add_be32(struct net_buf_simple *buf, u32_t val);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 64-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 64-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push data to the beginning of the buffer.
|
||||
*
|
||||
@ -302,6 +396,94 @@ void net_buf_simple_push_be16(struct net_buf_simple *buf, u16_t val);
|
||||
*/
|
||||
void net_buf_simple_push_u8(struct net_buf_simple *buf, u8_t val);
|
||||
|
||||
/**
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 24-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 24-bit value in big endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 32-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 32-bit value in big endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 48-bit value in big endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 64-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 64-bit value in big endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Remove data from the beginning of the buffer.
|
||||
*
|
||||
@ -364,6 +546,30 @@ u16_t net_buf_simple_pull_le16(struct net_buf_simple *buf);
|
||||
*/
|
||||
u16_t net_buf_simple_pull_be16(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 24-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 24-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_le24(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 24-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 24-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u32_t net_buf_simple_pull_be24(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 32 bits from the beginning of the buffer.
|
||||
*
|
||||
@ -388,6 +594,54 @@ u32_t net_buf_simple_pull_le32(struct net_buf_simple *buf);
|
||||
*/
|
||||
u32_t net_buf_simple_pull_be32(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 48-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_le48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 48-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_be48(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 64-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 64-bit value converted from little endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_le64(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_simple_pull(), but a helper for operating
|
||||
* on 64-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 64-bit value converted from big endian to host endian.
|
||||
*/
|
||||
u64_t net_buf_simple_pull_be64(struct net_buf_simple *buf);
|
||||
|
||||
/**
|
||||
* @brief Get the tail pointer for a buffer.
|
||||
*
|
||||
@ -544,8 +798,8 @@ struct net_buf {
|
||||
};
|
||||
|
||||
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);
|
||||
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);
|
||||
};
|
||||
|
||||
@ -709,7 +963,7 @@ int net_buf_id(struct net_buf *buf);
|
||||
*/
|
||||
#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);
|
||||
const char *func, int line);
|
||||
#define net_buf_alloc_fixed(_pool, _timeout) \
|
||||
net_buf_alloc_fixed_debug(_pool, _timeout, __func__, __LINE__)
|
||||
#else
|
||||
@ -874,6 +1128,32 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_add_be16(buf, val) net_buf_simple_add_be16(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_le24
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 24-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_le24(buf, val) net_buf_simple_add_le24(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_be24
|
||||
* @brief Add 24-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 24-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_be24(buf, val) net_buf_simple_add_be24(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_le32
|
||||
* @brief Add 32-bit value at the end of the buffer
|
||||
@ -900,6 +1180,58 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_add_be32(buf, val) net_buf_simple_add_be32(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_le48
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_le48(buf, val) net_buf_simple_add_le48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_be48
|
||||
* @brief Add 48-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 48-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_be48(buf, val) net_buf_simple_add_be48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_le64
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 64-bit value in little endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_le64(buf, val) net_buf_simple_add_le64(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_add_be64
|
||||
* @brief Add 64-bit value at the end of the buffer
|
||||
*
|
||||
* Adds 64-bit value in big endian format at the end of buffer.
|
||||
* Increments the data length of a buffer to account for more data
|
||||
* at the end.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be added.
|
||||
*/
|
||||
#define net_buf_add_be64(buf, val) net_buf_simple_add_be64(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push
|
||||
* @brief Push data to the beginning of the buffer.
|
||||
@ -949,6 +1281,102 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_push_u8(buf, val) net_buf_simple_push_u8(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_le24
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 24-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_le24(buf, val) net_buf_simple_push_le24(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_be24
|
||||
* @brief Push 24-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 24-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 24-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_be24(buf, val) net_buf_simple_push_be24(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_le32
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 32-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_le32(buf, val) net_buf_simple_push_le32(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_be32
|
||||
* @brief Push 32-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 32-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 32-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_be32(buf, val) net_buf_simple_push_be32(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_le48
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_le48(buf, val) net_buf_simple_push_le48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_be48
|
||||
* @brief Push 48-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 48-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 48-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_be48(buf, val) net_buf_simple_push_be48(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_le64
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 64-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_le64(buf, val) net_buf_simple_push_le64(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_push_be64
|
||||
* @brief Push 64-bit value to the beginning of the buffer
|
||||
*
|
||||
* Adds 64-bit value in little endian format to the beginning of the
|
||||
* buffer.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param val 64-bit value to be pushed to the buffer.
|
||||
*/
|
||||
#define net_buf_push_be64(buf, val) net_buf_simple_push_be64(&(buf)->b, val)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull
|
||||
* @brief Remove data from the beginning of the buffer.
|
||||
@ -963,6 +1391,20 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_pull(buf, len) net_buf_simple_pull(&(buf)->b, len)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_mem
|
||||
* @brief Remove data from the beginning of the buffer.
|
||||
*
|
||||
* Removes data from the beginning of the buffer by modifying the data
|
||||
* pointer and buffer length.
|
||||
*
|
||||
* @param buf Buffer to update.
|
||||
* @param len Number of bytes to remove.
|
||||
*
|
||||
* @return Pointer to the old beginning of the buffer data.
|
||||
*/
|
||||
#define net_buf_pull_mem(buf, len) net_buf_simple_pull_mem(&(buf)->b, len)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_u8
|
||||
* @brief Remove a 8-bit value from the beginning of the buffer
|
||||
@ -1002,6 +1444,32 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_pull_be16(buf) net_buf_simple_pull_be16(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_le24
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 24-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 24-bit value converted from little endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_le24(buf) net_buf_simple_pull_le24(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_be24
|
||||
* @brief Remove and convert 24 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 24-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 24-bit value converted from big endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_be24(buf) net_buf_simple_pull_be24(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_le32
|
||||
* @brief Remove and convert 32 bits from the beginning of the buffer.
|
||||
@ -1028,6 +1496,58 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_pull_be32(buf) net_buf_simple_pull_be32(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_le48
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 48-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 48-bit value converted from little endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_le48(buf) net_buf_simple_pull_le48(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_be48
|
||||
* @brief Remove and convert 48 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 48-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer
|
||||
*
|
||||
* @return 48-bit value converted from big endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_be48(buf) net_buf_simple_pull_be48(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_le64
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 64-bit little endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer.
|
||||
*
|
||||
* @return 64-bit value converted from little endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_le64(buf) net_buf_simple_pull_le64(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_pull_be64
|
||||
* @brief Remove and convert 64 bits from the beginning of the buffer.
|
||||
*
|
||||
* Same idea as with net_buf_pull(), but a helper for operating on
|
||||
* 64-bit big endian data.
|
||||
*
|
||||
* @param buf A valid pointer on a buffer
|
||||
*
|
||||
* @return 64-bit value converted from big endian to host endian.
|
||||
*/
|
||||
#define net_buf_pull_be64(buf) net_buf_simple_pull_be64(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_tailroom
|
||||
* @brief Check buffer tailroom.
|
||||
@ -1052,6 +1572,180 @@ static inline void *net_buf_user_data(struct net_buf *buf)
|
||||
*/
|
||||
#define net_buf_headroom(buf) net_buf_simple_headroom(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @def net_buf_tail
|
||||
* @brief Get the tail pointer for a buffer.
|
||||
*
|
||||
* Get a pointer to the end of the data in a buffer.
|
||||
*
|
||||
* @param buf Buffer.
|
||||
*
|
||||
* @return Tail pointer for the buffer.
|
||||
*/
|
||||
#define net_buf_tail(buf) net_buf_simple_tail(&(buf)->b)
|
||||
|
||||
/**
|
||||
* @brief Find the last fragment in the fragment list.
|
||||
*
|
||||
* @return Pointer to last fragment in the list.
|
||||
*/
|
||||
struct net_buf *net_buf_frag_last(struct net_buf *frags);
|
||||
|
||||
/**
|
||||
* @brief Insert a new fragment to a chain of bufs.
|
||||
*
|
||||
* Insert a new fragment into the buffer fragments list after the parent.
|
||||
*
|
||||
* Note: This function takes ownership of the fragment reference so the
|
||||
* caller is not required to unref.
|
||||
*
|
||||
* @param parent Parent buffer/fragment.
|
||||
* @param frag Fragment to insert.
|
||||
*/
|
||||
void net_buf_frag_insert(struct net_buf *parent, struct net_buf *frag);
|
||||
|
||||
/**
|
||||
* @brief Add a new fragment to the end of a chain of bufs.
|
||||
*
|
||||
* Append a new fragment into the buffer fragments list.
|
||||
*
|
||||
* Note: This function takes ownership of the fragment reference so the
|
||||
* caller is not required to unref.
|
||||
*
|
||||
* @param head Head of the fragment chain.
|
||||
* @param frag Fragment to add.
|
||||
*
|
||||
* @return New head of the fragment chain. Either head (if head
|
||||
* was non-NULL) or frag (if head was NULL).
|
||||
*/
|
||||
struct net_buf *net_buf_frag_add(struct net_buf *head, struct net_buf *frag);
|
||||
|
||||
/**
|
||||
* @brief Delete existing fragment from a chain of bufs.
|
||||
*
|
||||
* @param parent Parent buffer/fragment, or NULL if there is no parent.
|
||||
* @param frag Fragment to delete.
|
||||
*
|
||||
* @return Pointer to the buffer following the fragment, or NULL if it
|
||||
* had no further fragments.
|
||||
*/
|
||||
#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);
|
||||
#define net_buf_frag_del(_parent, _frag) \
|
||||
net_buf_frag_del_debug(_parent, _frag, __func__, __LINE__)
|
||||
#else
|
||||
struct net_buf *net_buf_frag_del(struct net_buf *parent, struct net_buf *frag);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Copy bytes from net_buf chain starting at offset to linear buffer
|
||||
*
|
||||
* Copy (extract) @a len bytes from @a src net_buf chain, starting from @a
|
||||
* offset in it, to a linear buffer @a dst. Return number of bytes actually
|
||||
* copied, which may be less than requested, if net_buf chain doesn't have
|
||||
* enough data, or destination buffer is too small.
|
||||
*
|
||||
* @param dst Destination buffer
|
||||
* @param dst_len Destination buffer length
|
||||
* @param src Source net_buf chain
|
||||
* @param offset Starting offset to copy from
|
||||
* @param len Number of bytes to copy
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @typedef net_buf_allocator_cb
|
||||
* @brief Network buffer allocator callback.
|
||||
*
|
||||
* @details The allocator callback is called when net_buf_append_bytes
|
||||
* needs to allocate a new net_buf.
|
||||
*
|
||||
* @param timeout Affects the action taken should the net buf pool be empty.
|
||||
* If K_NO_WAIT, then return immediately. If K_FOREVER, then
|
||||
* wait as long as necessary. Otherwise, wait up to the specified
|
||||
* number of milliseconds before timing out.
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* @brief Append data to a list of net_buf
|
||||
*
|
||||
* @details Append data to a net_buf. If there is not enough space in the
|
||||
* net_buf then more net_buf will be added, unless there are no free net_buf
|
||||
* and timeout occurs.
|
||||
*
|
||||
* @param buf Network buffer.
|
||||
* @param len Total length of input data
|
||||
* @param value Data to be added
|
||||
* @param timeout Timeout is passed to the net_buf allocator callback.
|
||||
* @param allocate_cb When a new net_buf is required, use this callback.
|
||||
* @param user_data A user data pointer to be supplied to the allocate_cb.
|
||||
* This pointer is can be anything from a mem_pool or a net_pkt, the
|
||||
* logic is left up to the allocate_cb function.
|
||||
*
|
||||
* @return Length of data actually added. This may be less than input
|
||||
* length if other timeout than K_FOREVER was used, and there
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* @brief Skip N number of bytes in a net_buf
|
||||
*
|
||||
* @details Skip N number of bytes starting from fragment's offset. If the total
|
||||
* length of data is placed in multiple fragments, this function will skip from
|
||||
* all fragments until it reaches N number of bytes. Any fully skipped buffers
|
||||
* are removed from the net_buf list.
|
||||
*
|
||||
* @param buf Network buffer.
|
||||
* @param len Total length of data to be skipped.
|
||||
*
|
||||
* @return Pointer to the fragment or
|
||||
* NULL and pos is 0 after successful skip,
|
||||
* NULL and pos is 0xffff otherwise.
|
||||
*/
|
||||
static inline struct net_buf *net_buf_skip(struct net_buf *buf, size_t len)
|
||||
{
|
||||
while (buf && len--) {
|
||||
net_buf_pull_u8(buf);
|
||||
if (!buf->len) {
|
||||
buf = net_buf_frag_del(NULL, buf);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calculate amount of bytes stored in fragments.
|
||||
*
|
||||
* Calculates the total amount of data stored in the given buffer and the
|
||||
* fragments linked to it.
|
||||
*
|
||||
* @param buf Buffer to start off with.
|
||||
*
|
||||
* @return Number of bytes in the buffer and its fragments.
|
||||
*/
|
||||
static inline size_t net_buf_frags_len(struct net_buf *buf)
|
||||
{
|
||||
size_t bytes = 0;
|
||||
|
||||
while (buf) {
|
||||
bytes += buf->len;
|
||||
buf = buf->frags;
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
599
components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h
Normal file
599
components/bt/esp_ble_mesh/mesh_common/include/mesh_byteorder.h
Normal file
@ -0,0 +1,599 @@
|
||||
/*
|
||||
* Copyright (c) 2015-2016, Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_BYTEORDER_H_
|
||||
#define _BLE_MESH_BYTEORDER_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_trace.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 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)))
|
||||
#endif
|
||||
|
||||
#ifndef __bswap_24
|
||||
#define __bswap_24(x) ((u32_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)))
|
||||
#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)))
|
||||
#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)))
|
||||
#endif
|
||||
|
||||
/** @def sys_le16_to_cpu
|
||||
* @brief Convert 16-bit integer from little-endian to host endianness.
|
||||
*
|
||||
* @param val 16-bit integer in little-endian format.
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_le16
|
||||
* @brief Convert 16-bit integer from host endianness to little-endian.
|
||||
*
|
||||
* @param val 16-bit integer in host endianness.
|
||||
*
|
||||
* @return 16-bit integer in little-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_le24_to_cpu
|
||||
* @brief Convert 24-bit integer from little-endian to host endianness.
|
||||
*
|
||||
* @param val 24-bit integer in little-endian format.
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_le24
|
||||
* @brief Convert 24-bit integer from host endianness to little-endian.
|
||||
*
|
||||
* @param val 24-bit integer in host endianness.
|
||||
*
|
||||
* @return 24-bit integer in little-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_le32_to_cpu
|
||||
* @brief Convert 32-bit integer from little-endian to host endianness.
|
||||
*
|
||||
* @param val 32-bit integer in little-endian format.
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_le32
|
||||
* @brief Convert 32-bit integer from host endianness to little-endian.
|
||||
*
|
||||
* @param val 32-bit integer in host endianness.
|
||||
*
|
||||
* @return 32-bit integer in little-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_le48_to_cpu
|
||||
* @brief Convert 48-bit integer from little-endian to host endianness.
|
||||
*
|
||||
* @param val 48-bit integer in little-endian format.
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_le48
|
||||
* @brief Convert 48-bit integer from host endianness to little-endian.
|
||||
*
|
||||
* @param val 48-bit integer in host endianness.
|
||||
*
|
||||
* @return 48-bit integer in little-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_be16_to_cpu
|
||||
* @brief Convert 16-bit integer from big-endian to host endianness.
|
||||
*
|
||||
* @param val 16-bit integer in big-endian format.
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_be16
|
||||
* @brief Convert 16-bit integer from host endianness to big-endian.
|
||||
*
|
||||
* @param val 16-bit integer in host endianness.
|
||||
*
|
||||
* @return 16-bit integer in big-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_be24_to_cpu
|
||||
* @brief Convert 24-bit integer from big-endian to host endianness.
|
||||
*
|
||||
* @param val 24-bit integer in big-endian format.
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_be24
|
||||
* @brief Convert 24-bit integer from host endianness to big-endian.
|
||||
*
|
||||
* @param val 24-bit integer in host endianness.
|
||||
*
|
||||
* @return 24-bit integer in big-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_be32_to_cpu
|
||||
* @brief Convert 32-bit integer from big-endian to host endianness.
|
||||
*
|
||||
* @param val 32-bit integer in big-endian format.
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_be32
|
||||
* @brief Convert 32-bit integer from host endianness to big-endian.
|
||||
*
|
||||
* @param val 32-bit integer in host endianness.
|
||||
*
|
||||
* @return 32-bit integer in big-endian format.
|
||||
*/
|
||||
|
||||
/** @def sys_be48_to_cpu
|
||||
* @brief Convert 48-bit integer from big-endian to host endianness.
|
||||
*
|
||||
* @param val 48-bit integer in big-endian format.
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
|
||||
/** @def sys_cpu_to_be48
|
||||
* @brief Convert 48-bit integer from host endianness to big-endian.
|
||||
*
|
||||
* @param val 48-bit integer in host endianness.
|
||||
*
|
||||
* @return 48-bit integer in big-endian format.
|
||||
*/
|
||||
|
||||
#ifndef sys_le16_to_cpu
|
||||
#define sys_le16_to_cpu(val) (val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_le16
|
||||
#define sys_cpu_to_le16(val) (val)
|
||||
#endif
|
||||
#ifndef sys_le24_to_cpu
|
||||
#define sys_le24_to_cpu(val) (val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_le24
|
||||
#define sys_cpu_to_le24(val) (val)
|
||||
#endif
|
||||
#ifndef sys_le32_to_cpu
|
||||
#define sys_le32_to_cpu(val) (val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_le32
|
||||
#define sys_cpu_to_le32(val) (val)
|
||||
#endif
|
||||
#ifndef sys_le48_to_cpu
|
||||
#define sys_le48_to_cpu(val) (val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_le48
|
||||
#define sys_cpu_to_le48(val) (val)
|
||||
#endif
|
||||
#ifndef sys_le64_to_cpu
|
||||
#define sys_le64_to_cpu(val) (val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_le64
|
||||
#define sys_cpu_to_le64(val) (val)
|
||||
#endif
|
||||
#ifndef sys_be16_to_cpu
|
||||
#define sys_be16_to_cpu(val) __bswap_16(val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_be16
|
||||
#define sys_cpu_to_be16(val) __bswap_16(val)
|
||||
#endif
|
||||
#ifndef sys_be24_to_cpu
|
||||
#define sys_be24_to_cpu(val) __bswap_24(val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_be24
|
||||
#define sys_cpu_to_be24(val) __bswap_24(val)
|
||||
#endif
|
||||
#ifndef sys_be32_to_cpu
|
||||
#define sys_be32_to_cpu(val) __bswap_32(val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_be32
|
||||
#define sys_cpu_to_be32(val) __bswap_32(val)
|
||||
#endif
|
||||
#ifndef sys_be48_to_cpu
|
||||
#define sys_be48_to_cpu(val) __bswap_48(val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_be48
|
||||
#define sys_cpu_to_be48(val) __bswap_48(val)
|
||||
#endif
|
||||
#ifndef sys_be64_to_cpu
|
||||
#define sys_be64_to_cpu(val) __bswap_64(val)
|
||||
#endif
|
||||
#ifndef sys_cpu_to_be64
|
||||
#define sys_cpu_to_be64(val) __bswap_64(val)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Put a 16-bit integer as big-endian to arbitrary location.
|
||||
*
|
||||
* Put a 16-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in big-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
dst[0] = val >> 8;
|
||||
dst[1] = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 24-bit integer as big-endian to arbitrary location.
|
||||
*
|
||||
* Put a 24-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in big-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
dst[0] = val >> 16;
|
||||
sys_put_be16(val, &dst[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 32-bit integer as big-endian to arbitrary location.
|
||||
*
|
||||
* Put a 32-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in big-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_be16(val >> 16, dst);
|
||||
sys_put_be16(val, &dst[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 48-bit integer as big-endian to arbitrary location.
|
||||
*
|
||||
* Put a 48-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in big-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_be16(val >> 32, dst);
|
||||
sys_put_be32(val, &dst[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 64-bit integer as big-endian to arbitrary location.
|
||||
*
|
||||
* Put a 64-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in big-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_be32(val >> 32, dst);
|
||||
sys_put_be32(val, &dst[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 16-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 16-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in little-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
dst[0] = val;
|
||||
dst[1] = val >> 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 24-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 24-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in littel-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_le16(val, dst);
|
||||
dst[2] = val >> 16;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 32-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 32-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in little-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_le16(val, dst);
|
||||
sys_put_le16(val >> 16, &dst[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 48-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 48-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in little-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_le32(val, dst);
|
||||
sys_put_le16(val >> 32, &dst[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Put a 64-bit integer as little-endian to arbitrary location.
|
||||
*
|
||||
* Put a 64-bit integer, originally in host endianness, to a
|
||||
* potentially unaligned memory location in little-endian format.
|
||||
*
|
||||
* @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])
|
||||
{
|
||||
sys_put_le32(val, dst);
|
||||
sys_put_le32(val >> 32, &dst[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 16-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 16-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 16-bit integer to get.
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
static inline u16_t sys_get_be16(const u8_t src[2])
|
||||
{
|
||||
return ((u16_t)src[0] << 8) | src[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 24-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 24-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 24-bit integer to get.
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_be24(const u8_t src[3])
|
||||
{
|
||||
return ((u32_t)src[0] << 16) | sys_get_be16(&src[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 32-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 32-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 32-bit integer to get.
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_be32(const u8_t src[4])
|
||||
{
|
||||
return ((u32_t)sys_get_be16(&src[0]) << 16) | sys_get_be16(&src[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 48-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 48-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 48-bit integer to get.
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_be48(const u8_t src[6])
|
||||
{
|
||||
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be16(&src[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 64-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 64-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 64-bit integer to get.
|
||||
*
|
||||
* @return 64-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_be64(const u8_t src[8])
|
||||
{
|
||||
return ((u64_t)sys_get_be32(&src[0]) << 32) | sys_get_be32(&src[4]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 16-bit integer stored in little-endian format.
|
||||
*
|
||||
* Get a 16-bit integer, stored in little-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the little-endian 16-bit integer to get.
|
||||
*
|
||||
* @return 16-bit integer in host endianness.
|
||||
*/
|
||||
static inline u16_t sys_get_le16(const u8_t src[2])
|
||||
{
|
||||
return ((u16_t)src[1] << 8) | src[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 24-bit integer stored in big-endian format.
|
||||
*
|
||||
* Get a 24-bit integer, stored in big-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the big-endian 24-bit integer to get.
|
||||
*
|
||||
* @return 24-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_le24(const u8_t src[3])
|
||||
{
|
||||
return ((u32_t)src[2] << 16) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 32-bit integer stored in little-endian format.
|
||||
*
|
||||
* Get a 32-bit integer, stored in little-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the little-endian 32-bit integer to get.
|
||||
*
|
||||
* @return 32-bit integer in host endianness.
|
||||
*/
|
||||
static inline u32_t sys_get_le32(const u8_t src[4])
|
||||
{
|
||||
return ((u32_t)sys_get_le16(&src[2]) << 16) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 48-bit integer stored in little-endian format.
|
||||
*
|
||||
* Get a 48-bit integer, stored in little-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the little-endian 48-bit integer to get.
|
||||
*
|
||||
* @return 48-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_le48(const u8_t src[6])
|
||||
{
|
||||
return ((u64_t)sys_get_le32(&src[2]) << 32) | sys_get_le16(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a 64-bit integer stored in little-endian format.
|
||||
*
|
||||
* Get a 64-bit integer, stored in little-endian format in a potentially
|
||||
* unaligned memory location, and convert it to the host endianness.
|
||||
*
|
||||
* @param src Location of the little-endian 64-bit integer to get.
|
||||
*
|
||||
* @return 64-bit integer in host endianness.
|
||||
*/
|
||||
static inline u64_t sys_get_le64(const u8_t src[8])
|
||||
{
|
||||
return ((u64_t)sys_get_le32(&src[4]) << 32) | sys_get_le32(&src[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap one buffer content into another
|
||||
*
|
||||
* Copy the content of src buffer into dst buffer in reversed order,
|
||||
* i.e.: src[n] will be put in dst[end-n]
|
||||
* Where n is an index and 'end' the last index in both arrays.
|
||||
* The 2 memory pointers must be pointing to different areas, and have
|
||||
* a minimum size of given length.
|
||||
*
|
||||
* @param dst A valid pointer on a memory area where to copy the data in
|
||||
* @param src A valid pointer on a memory area where to copy the data from
|
||||
* @param length Size of both dst and src memory areas
|
||||
*/
|
||||
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;
|
||||
|
||||
__ASSERT(((psrc < pdst && (psrc + length) <= pdst) ||
|
||||
(psrc > pdst && (pdst + length) <= psrc)),
|
||||
"Source and destination buffers must not overlap");
|
||||
|
||||
psrc += length - 1;
|
||||
|
||||
for (; length > 0; length--) {
|
||||
*pdst++ = *psrc--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Swap buffer content
|
||||
*
|
||||
* In-place memory swap, where final content will be reversed.
|
||||
* I.e.: buf[n] will be put in buf[end-n]
|
||||
* Where n is an index and 'end' the last index of buf.
|
||||
*
|
||||
* @param buf A valid pointer on a memory area to swap
|
||||
* @param length Size of buf memory area
|
||||
*/
|
||||
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];
|
||||
|
||||
((u8_t *)buf)[i] = ((u8_t *)buf)[length - 1 - i];
|
||||
((u8_t *)buf)[length - 1 - i] = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_BYTEORDER_H_ */
|
@ -16,14 +16,30 @@
|
||||
* @brief Bluetooth Mesh Model Common APIs.
|
||||
*/
|
||||
|
||||
#ifndef _MESH_COMMON_H_
|
||||
#define _MESH_COMMON_H_
|
||||
#ifndef _BLE_MESH_COMMON_H_
|
||||
#define _BLE_MESH_COMMON_H_
|
||||
|
||||
#include "osi/allocator.h"
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_buf.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
#include "mesh_byteorder.h"
|
||||
#include "mesh_ffs.h"
|
||||
#include "mesh_trace.h"
|
||||
#include "mesh_mutex.h"
|
||||
#include "mesh_access.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
IRAM_ATTR void *bt_mesh_malloc(size_t size);
|
||||
|
||||
IRAM_ATTR void *bt_mesh_calloc(size_t size);
|
||||
|
||||
IRAM_ATTR void bt_mesh_free(void *ptr);
|
||||
|
||||
/**
|
||||
* @brief This function allocates memory to store outgoing message.
|
||||
@ -43,4 +59,22 @@ struct net_buf_simple *bt_mesh_alloc_buf(u16_t size);
|
||||
*/
|
||||
void bt_mesh_free_buf(struct net_buf_simple *buf);
|
||||
|
||||
#endif /* _MESH_COMMON_H_ */
|
||||
/**
|
||||
* @brief This function gets device role for stack internal use.
|
||||
*
|
||||
* @Note Currently Provisioner only support client models, Node supports
|
||||
* client models and server models. Hence if srv_send is set to be
|
||||
* TRUE, then role NODE will be returned.
|
||||
*
|
||||
* @param[in] model: Pointer to the model structure
|
||||
* @param[in] srv_send: Indicate if the message is sent by a server model
|
||||
*
|
||||
* @return 0 - Node, 1 - Provisioner
|
||||
*/
|
||||
u8_t bt_mesh_get_device_role(struct bt_mesh_model *model, bool srv_send);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_COMMON_H_ */
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2010-2014,2017 Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_COMPILER_H_
|
||||
#define _BLE_MESH_COMPILER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ___in_section(a, b, c)
|
||||
|
||||
#define __in_section(a, b, c) ___in_section(a, b, c)
|
||||
|
||||
#define __in_section_unique(seg) ___in_section(seg, __FILE__, __COUNTER__)
|
||||
|
||||
#ifndef __packed
|
||||
#define __packed __attribute__((__packed__))
|
||||
#endif
|
||||
|
||||
#ifndef __aligned
|
||||
#define __aligned(x) __attribute__((__aligned__(x)))
|
||||
#endif
|
||||
|
||||
#ifndef __used
|
||||
#define __used __attribute__((__used__))
|
||||
#endif
|
||||
|
||||
#ifndef ARG_UNUSED
|
||||
#define ARG_UNUSED(x) (void)(x)
|
||||
#endif
|
||||
|
||||
#ifndef popcount
|
||||
#define popcount(x) __builtin_popcount(x)
|
||||
#endif
|
||||
|
||||
#ifndef ALWAYS_INLINE
|
||||
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* This is meant to be used in conjunction with __in_section() and similar
|
||||
* where scattered structure instances are concatened together by the linker
|
||||
* and walked by the code at run time just like a contiguous array of such
|
||||
* structures.
|
||||
*
|
||||
* Assemblers and linkers may insert alignment padding by default whose
|
||||
* size is larger than the natural alignment for those structures when
|
||||
* gathering various section segments together, messing up the array walk.
|
||||
* To prevent this, we need to provide an explicit alignment not to rely
|
||||
* on the default that might just work by luck.
|
||||
*
|
||||
* Alignment statements in linker scripts are not sufficient as
|
||||
* the assembler may add padding by itself to each segment when switching
|
||||
* between sections within the same file even if it merges many such segments
|
||||
* into a single section in the end.
|
||||
*/
|
||||
#ifndef Z_DECL_ALIGN
|
||||
#define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Convenience helper combining __in_section() and Z_DECL_ALIGN().
|
||||
* The section name is the struct type prepended with an underscore.
|
||||
* The subsection is "static" and the subsubsection is the variable name.
|
||||
*/
|
||||
#ifndef Z_STRUCT_SECTION_ITERABLE
|
||||
#define Z_STRUCT_SECTION_ITERABLE(struct_type, name) \
|
||||
Z_DECL_ALIGN(struct struct_type) name
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_COMPILER_H_ */
|
60
components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h
Normal file
60
components/bt/esp_ble_mesh/mesh_common/include/mesh_ffs.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Wind River Systems, Inc.
|
||||
* Copyright (c) 2017, Oticon A/S
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_FFS_H_
|
||||
#define _BLE_MESH_FFS_H_
|
||||
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief find most significant bit set in a 32-bit word
|
||||
*
|
||||
* This routine finds the first bit set starting from the most significant bit
|
||||
* in the argument passed in and returns the index of that bit. Bits are
|
||||
* numbered starting at 1 from the least significant bit. A return value of
|
||||
* zero indicates that the value passed is zero.
|
||||
*
|
||||
* @return most significant bit set, 0 if @a op is 0
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE unsigned int find_msb_set(u32_t op)
|
||||
{
|
||||
if (op == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 32 - __builtin_clz(op);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief find least significant bit set in a 32-bit word
|
||||
*
|
||||
* This routine finds the first bit set starting from the least significant bit
|
||||
* in the argument passed in and returns the index of that bit. Bits are
|
||||
* numbered starting at 1 from the least significant bit. A return value of
|
||||
* zero indicates that the value passed is zero.
|
||||
*
|
||||
* @return least significant bit set, 0 if @a op is 0
|
||||
*/
|
||||
|
||||
static ALWAYS_INLINE unsigned int find_lsb_set(u32_t op)
|
||||
{
|
||||
return __builtin_ffs(op);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_FFS_H_ */
|
60
components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h
Normal file
60
components/bt/esp_ble_mesh/mesh_common/include/mesh_kernel.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Wind River Systems, Inc.
|
||||
* Additional Copyright (c) 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_KERNEL_H_
|
||||
#define _BLE_MESH_KERNEL_H_
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_BLUEDROID_ENABLED
|
||||
#ifdef CONFIG_BT_BLUEDROID_PINNED_TO_CORE
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_BLUEDROID_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_BLUEDROID_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#else
|
||||
#define BLE_MESH_ADV_TASK_CORE (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_ENABLED
|
||||
#ifdef CONFIG_BT_NIMBLE_PINNED_TO_CORE
|
||||
#define BLE_MESH_ADV_TASK_CORE (CONFIG_BT_NIMBLE_PINNED_TO_CORE < portNUM_PROCESSORS ? CONFIG_BT_NIMBLE_PINNED_TO_CORE : tskNO_AFFINITY)
|
||||
#else
|
||||
#define BLE_MESH_ADV_TASK_CORE (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define BLE_MESH_ADV_TASK_STACK_SIZE 3072
|
||||
#define BLE_MESH_ADV_TASK_NAME "mesh_adv_task"
|
||||
#define BLE_MESH_ADV_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
|
||||
/**
|
||||
* @brief Put the current thread to sleep.
|
||||
*
|
||||
* This routine puts the current thread to sleep for @a duration
|
||||
* milliseconds.
|
||||
*
|
||||
* @param duration Number of milliseconds to sleep.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
void k_sleep(s32_t duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_KERNEL_H_ */
|
||||
|
58
components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h
Normal file
58
components/bt/esp_ble_mesh/mesh_common/include/mesh_mutex.h
Normal file
@ -0,0 +1,58 @@
|
||||
// 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.
|
||||
// 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_MUTEX_H_
|
||||
#define _BLE_MESH_MUTEX_H_
|
||||
|
||||
#include "mesh_kernel.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_atomic.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
SemaphoreHandle_t mutex;
|
||||
#if CONFIG_BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
StaticQueue_t *buffer;
|
||||
#endif
|
||||
} bt_mesh_mutex_t;
|
||||
|
||||
void bt_mesh_mutex_create(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_mutex_free(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_mutex_lock(bt_mesh_mutex_t *mutex);
|
||||
void bt_mesh_mutex_unlock(bt_mesh_mutex_t *mutex);
|
||||
|
||||
void bt_mesh_alarm_lock(void);
|
||||
void bt_mesh_alarm_unlock(void);
|
||||
|
||||
void bt_mesh_list_lock(void);
|
||||
void bt_mesh_list_unlock(void);
|
||||
|
||||
void bt_mesh_buf_lock(void);
|
||||
void bt_mesh_buf_unlock(void);
|
||||
|
||||
void bt_mesh_atomic_lock(void);
|
||||
void bt_mesh_atomic_unlock(void);
|
||||
|
||||
void bt_mesh_mutex_init(void);
|
||||
void bt_mesh_mutex_deinit(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_MUTEX_H_ */
|
||||
|
@ -5,14 +5,16 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_KERNEL_H_
|
||||
#define _BLE_MESH_KERNEL_H_
|
||||
#ifndef _BLE_MESH_TIMER_H_
|
||||
#define _BLE_MESH_TIMER_H_
|
||||
|
||||
#include "osi/mutex.h"
|
||||
#include "mesh_types.h"
|
||||
#include "mesh_slist.h"
|
||||
#include "mesh_atomic.h"
|
||||
#include "mesh_dlist.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* number of nsec per usec */
|
||||
#define NSEC_PER_USEC 1000
|
||||
@ -47,8 +49,6 @@ struct k_work;
|
||||
*/
|
||||
typedef void (*k_work_handler_t)(struct k_work *work);
|
||||
|
||||
typedef sys_dlist_t _wait_q_t;
|
||||
|
||||
struct k_work {
|
||||
void *_reserved;
|
||||
k_work_handler_t handler;
|
||||
@ -182,6 +182,8 @@ struct k_delayed_work {
|
||||
*/
|
||||
int k_delayed_work_submit(struct k_delayed_work *work, s32_t delay);
|
||||
|
||||
int k_delayed_work_submit_periodic(struct k_delayed_work *work, s32_t period);
|
||||
|
||||
/**
|
||||
* @brief Get time remaining before a delayed work gets scheduled.
|
||||
*
|
||||
@ -242,7 +244,7 @@ int k_delayed_work_cancel(struct k_delayed_work *work);
|
||||
|
||||
int k_delayed_work_free(struct k_delayed_work *work);
|
||||
|
||||
void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
|
||||
int k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
|
||||
|
||||
/**
|
||||
* @brief Get system uptime.
|
||||
@ -254,22 +256,12 @@ void k_delayed_work_init(struct k_delayed_work *work, k_work_handler_t handler);
|
||||
*/
|
||||
s64_t k_uptime_get(void);
|
||||
|
||||
/**
|
||||
* @brief Put the current thread to sleep.
|
||||
*
|
||||
* This routine puts the current thread to sleep for @a duration
|
||||
* milliseconds.
|
||||
*
|
||||
* @param duration Number of milliseconds to sleep.
|
||||
*
|
||||
* @return N/A
|
||||
*/
|
||||
void k_sleep(s32_t duration);
|
||||
void bt_mesh_timer_init(void);
|
||||
void bt_mesh_timer_deinit(void);
|
||||
|
||||
unsigned int bt_mesh_irq_lock(void);
|
||||
void bt_mesh_irq_unlock(unsigned int key);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
void bt_mesh_k_init(void);
|
||||
|
||||
#endif /* _BLE_MESH_KERNEL_H_ */
|
||||
#endif /* _BLE_MESH_TIMER_H_ */
|
||||
|
@ -10,7 +10,11 @@
|
||||
#define _BLE_MESH_TRACE_H_
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "mesh_util.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Define common tracing for all */
|
||||
#ifndef LOG_LEVEL_ERROR
|
||||
@ -53,10 +57,6 @@
|
||||
#define BLE_MESH_LOG_LOCAL_LEVEL_MAPPING LOG_LOCAL_LEVEL
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif /* MAX(a, b) */
|
||||
|
||||
#define BLE_MESH_LOG_LEVEL_CHECK(LAYER, LEVEL) (MAX(LAYER##_LOG_LEVEL, BLE_MESH_LOG_LOCAL_LEVEL_MAPPING) >= 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__); }
|
||||
@ -128,4 +128,8 @@
|
||||
#define NET_BUF_SIMPLE_ASSERT(cond)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_TRACE_H_ */
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -27,16 +28,12 @@ typedef unsigned long long u64_t;
|
||||
|
||||
typedef int bt_mesh_atomic_t;
|
||||
|
||||
#ifndef bool
|
||||
#define bool int8_t
|
||||
#ifndef PRIu64
|
||||
#define PRIu64 "llu"
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#ifndef PRIx64
|
||||
#define PRIx64 "llx"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
193
components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h
Normal file
193
components/bt/esp_ble_mesh/mesh_common/include/mesh_util.h
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2014, Wind River Systems, Inc.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Misc utilities
|
||||
*
|
||||
* Misc utilities usable by the kernel and application code.
|
||||
*/
|
||||
|
||||
#ifndef _BLE_MESH_UTIL_H_
|
||||
#define _BLE_MESH_UTIL_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include "soc/soc.h"
|
||||
#include "mesh_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Helper to pass a int as a pointer or vice-versa.
|
||||
* Those are available for 32 bits architectures:
|
||||
*/
|
||||
#ifndef POINTER_TO_UINT
|
||||
#define POINTER_TO_UINT(x) ((u32_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))
|
||||
#endif
|
||||
#ifndef INT_TO_POINTER
|
||||
#define INT_TO_POINTER(x) ((void *) (x))
|
||||
#endif
|
||||
|
||||
/* Evaluates to 0 if cond is true-ish; compile error otherwise */
|
||||
#ifndef ZERO_OR_COMPILE_ERROR
|
||||
#define ZERO_OR_COMPILE_ERROR(cond) ((int) sizeof(char[1 - 2 * !(cond)]) - 1)
|
||||
#endif
|
||||
|
||||
/* Evaluates to 0 if array is an array; compile error if not array (e.g.
|
||||
* pointer)
|
||||
*/
|
||||
#ifndef IS_ARRAY
|
||||
#define IS_ARRAY(array) \
|
||||
ZERO_OR_COMPILE_ERROR( \
|
||||
!__builtin_types_compatible_p(__typeof__(array), \
|
||||
__typeof__(&(array)[0])))
|
||||
#endif
|
||||
|
||||
/* Evaluates to number of elements in an array; compile error if not
|
||||
* an array (e.g. pointer)
|
||||
*/
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(array) \
|
||||
((unsigned long) (IS_ARRAY(array) + \
|
||||
(sizeof(array) / sizeof((array)[0]))))
|
||||
#endif
|
||||
|
||||
/* Evaluates to 1 if ptr is part of array, 0 otherwise; compile error if
|
||||
* "array" argument is not an array (e.g. "ptr" and "array" mixed up)
|
||||
*/
|
||||
#ifndef PART_OF_ARRAY
|
||||
#define PART_OF_ARRAY(array, ptr) \
|
||||
((ptr) && ((ptr) >= &array[0] && (ptr) < &array[ARRAY_SIZE(array)]))
|
||||
#endif
|
||||
|
||||
#ifndef CONTAINER_OF
|
||||
#define CONTAINER_OF(ptr, type, field) \
|
||||
((type *)(((char *)(ptr)) - offsetof(type, field)))
|
||||
#endif
|
||||
|
||||
/* round "x" up/down to next multiple of "align" (which must be a power of 2) */
|
||||
#ifndef ROUND_UP
|
||||
#define ROUND_UP(x, align) \
|
||||
(((unsigned long)(x) + ((unsigned long)align - 1)) & \
|
||||
~((unsigned long)align - 1))
|
||||
#endif
|
||||
|
||||
#ifndef ROUND_DOWN
|
||||
#define ROUND_DOWN(x, align) ((unsigned long)(x) & ~((unsigned long)align - 1))
|
||||
#endif
|
||||
|
||||
/* round up/down to the next word boundary */
|
||||
#ifndef WB_UP
|
||||
#define WB_UP(x) ROUND_UP(x, sizeof(void *))
|
||||
#endif
|
||||
|
||||
#ifndef WB_DN
|
||||
#define WB_DN(x) ROUND_DOWN(x, sizeof(void *))
|
||||
#endif
|
||||
|
||||
#ifndef ceiling_fraction
|
||||
#define ceiling_fraction(numerator, divider) \
|
||||
(((numerator) + ((divider) - 1)) / (divider))
|
||||
#endif
|
||||
|
||||
#ifndef CHECKIF
|
||||
#define CHECKIF(expr) if (expr)
|
||||
#endif
|
||||
|
||||
/** @brief Return larger value of two provided expressions.
|
||||
*
|
||||
* @note Arguments are evaluated twice. See Z_MAX for GCC only, single
|
||||
* evaluation version.
|
||||
*/
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/** @brief Return smaller value of two provided expressions.
|
||||
*
|
||||
* @note Arguments are evaluated twice. See Z_MIN for GCC only, single
|
||||
* evaluation version.
|
||||
*/
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(n) (1UL << (n))
|
||||
#endif
|
||||
|
||||
#ifndef BIT_MASK
|
||||
#define BIT_MASK(n) (BIT(n) - 1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Check for macro definition in compiler-visible expressions
|
||||
*
|
||||
* This trick was pioneered in Linux as the config_enabled() macro.
|
||||
* The madness has the effect of taking a macro value that may be
|
||||
* defined to "1" (e.g. CONFIG_MYFEATURE), or may not be defined at
|
||||
* all and turning it into a literal expression that can be used at
|
||||
* "runtime". That is, it works similarly to
|
||||
* "defined(CONFIG_MYFEATURE)" does except that it is an expansion
|
||||
* that can exist in a standard expression and be seen by the compiler
|
||||
* and optimizer. Thus much ifdef usage can be replaced with cleaner
|
||||
* expressions like:
|
||||
*
|
||||
* if (IS_ENABLED(CONFIG_MYFEATURE))
|
||||
* myfeature_enable();
|
||||
*
|
||||
* INTERNAL
|
||||
* First pass just to expand any existing macros, we need the macro
|
||||
* value to be e.g. a literal "1" at expansion time in the next macro,
|
||||
* not "(1)", etc... Standard recursive expansion does not work.
|
||||
*/
|
||||
#define IS_ENABLED(config_macro) Z_IS_ENABLED1(config_macro)
|
||||
|
||||
/* Now stick on a "_XXXX" prefix, it will now be "_XXXX1" if config_macro
|
||||
* is "1", or just "_XXXX" if it's undefined.
|
||||
* ENABLED: Z_IS_ENABLED2(_XXXX1)
|
||||
* DISABLED Z_IS_ENABLED2(_XXXX)
|
||||
*/
|
||||
#define Z_IS_ENABLED1(config_macro) Z_IS_ENABLED2(_XXXX##config_macro)
|
||||
|
||||
/* Here's the core trick, we map "_XXXX1" to "_YYYY," (i.e. a string
|
||||
* with a trailing comma), so it has the effect of making this a
|
||||
* two-argument tuple to the preprocessor only in the case where the
|
||||
* value is defined to "1"
|
||||
* ENABLED: _YYYY, <--- note comma!
|
||||
* DISABLED: _XXXX
|
||||
*/
|
||||
#define _XXXX1 _YYYY,
|
||||
|
||||
/* Then we append an extra argument to fool the gcc preprocessor into
|
||||
* accepting it as a varargs macro.
|
||||
* arg1 arg2 arg3
|
||||
* ENABLED: Z_IS_ENABLED3(_YYYY, 1, 0)
|
||||
* DISABLED Z_IS_ENABLED3(_XXXX 1, 0)
|
||||
*/
|
||||
#define Z_IS_ENABLED2(one_or_two_args) Z_IS_ENABLED3(one_or_two_args true, false)
|
||||
|
||||
/* And our second argument is thus now cooked to be 1 in the case
|
||||
* where the value is defined to 1, and 0 if not:
|
||||
*/
|
||||
#define Z_IS_ENABLED3(ignore_this, val, ...) val
|
||||
|
||||
const char *bt_hex(const void *buf, size_t len);
|
||||
|
||||
void mem_rcopy(u8_t *dst, u8_t const *src, u16_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _BLE_MESH_UTIL_H_ */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user