forked from espressif/esp-idf
Compare commits
1029 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c81978a3e | ||
|
|
6153026f22 | ||
|
|
fc2199c5d6 | ||
|
|
4695eeddee | ||
|
|
748720a466 | ||
|
|
6ee978c6aa | ||
|
|
d231b25bc4 | ||
|
|
456c8bdbdf | ||
|
|
94917184be | ||
|
|
3c882991b5 | ||
|
|
4d35a99c12 | ||
|
|
6442184dd8 | ||
|
|
02c47360f1 | ||
|
|
db5f01429f | ||
|
|
b938846de6 | ||
|
|
7d295e18bc | ||
|
|
6a6de506b1 | ||
|
|
12a65aaac1 | ||
|
|
6bfad8a47d | ||
|
|
0863de4a69 | ||
|
|
398dc28a4e | ||
|
|
b0f053d82d | ||
|
|
4242519894 | ||
|
|
08bcb587ec | ||
|
|
c5a8dc85b7 | ||
|
|
a7ca14b064 | ||
|
|
4557c686b8 | ||
|
|
5e33a351f1 | ||
|
|
1fc54cfad8 | ||
|
|
bc7a34b494 | ||
|
|
ab81940982 | ||
|
|
6d6b7b09e8 | ||
|
|
d36663b798 | ||
|
|
6b76228fcb | ||
|
|
8f5f828ad6 | ||
|
|
5c5ae96be2 | ||
|
|
1b7f3fee5c | ||
|
|
b7dc47108f | ||
|
|
8cd210b38b | ||
|
|
19e840aa53 | ||
|
|
39acf9c4dd | ||
|
|
2da4ffa2aa | ||
|
|
b9fa6b0b1a | ||
|
|
5f71ec3640 | ||
|
|
a44f473d4a | ||
|
|
beb64a1af4 | ||
|
|
7b8356ee2f | ||
|
|
7fbfb1aa03 | ||
|
|
b97d4c617b | ||
|
|
765bd76ba3 | ||
|
|
9370264cac | ||
|
|
8bfa01cc28 | ||
|
|
90a9444696 | ||
|
|
b9fd2673a7 | ||
|
|
7595116353 | ||
|
|
9aae0f2dee | ||
|
|
f137546a4b | ||
|
|
388043c203 | ||
|
|
c496fa79de | ||
|
|
2af16b92e5 | ||
|
|
27da86fb6e | ||
|
|
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 | ||
|
|
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 |
22
.github/main.workflow
vendored
Normal file
22
.github/main.workflow
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
workflow "Sync issues to JIRA" {
|
||||
on = "issues"
|
||||
resolves = ["Sync to JIRA"]
|
||||
}
|
||||
|
||||
workflow "Sync issue and PR comments to JIRA" {
|
||||
on = "issue_comment"
|
||||
resolves = ["Sync to JIRA"]
|
||||
}
|
||||
|
||||
workflow "Sync PRs to JIRA" {
|
||||
on = "pull_request"
|
||||
resolves = ["Sync to JIRA"]
|
||||
}
|
||||
|
||||
action "Sync to JIRA" {
|
||||
uses = "espressif/github-actions/sync_issues_to_jira@master"
|
||||
secrets = ["GITHUB_TOKEN", "JIRA_URL", "JIRA_USER", "JIRA_PASS"]
|
||||
env = {
|
||||
JIRA_PROJECT = "IDFGH"
|
||||
}
|
||||
}
|
||||
16
.github/workflows/issue_comment.yml
vendored
16
.github/workflows/issue_comment.yml
vendored
@@ -1,16 +0,0 @@
|
||||
on: issue_comment
|
||||
name: Sync issue and PR comments to JIRA
|
||||
jobs:
|
||||
syncToJIRA:
|
||||
name: Sync to JIRA
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync to JIRA
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: IDFGH
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
16
.github/workflows/issues.yml
vendored
16
.github/workflows/issues.yml
vendored
@@ -1,16 +0,0 @@
|
||||
on: issues
|
||||
name: Sync issues to JIRA
|
||||
jobs:
|
||||
syncToJIRA:
|
||||
name: Sync to JIRA
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync to JIRA
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: IDFGH
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
16
.github/workflows/pull_request.yml
vendored
16
.github/workflows/pull_request.yml
vendored
@@ -1,16 +0,0 @@
|
||||
on: pull_request
|
||||
name: Sync PRs to JIRA
|
||||
jobs:
|
||||
syncToJIRA:
|
||||
name: Sync to JIRA
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync to JIRA
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: IDFGH
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -63,12 +63,8 @@ test_multi_heap_host
|
||||
# VS Code Settings
|
||||
.vscode/
|
||||
|
||||
# Clion IDE CMake build & config
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
|
||||
# Results for the checking of the Python coding style
|
||||
flake8_output.txt
|
||||
|
||||
# ESP-IDF default build directory name
|
||||
# ESP-IDF library
|
||||
build
|
||||
|
||||
@@ -15,26 +15,29 @@ 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
|
||||
BOT_DOCKER_IMAGE_TAG: ":latest"
|
||||
@@ -42,40 +45,20 @@ variables:
|
||||
CI_TARGET_TEST_CONFIG_FILE: "$CI_PROJECT_DIR/tools/ci/config/target-test.yml"
|
||||
|
||||
|
||||
|
||||
# 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 +71,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 +83,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 +94,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
|
||||
|
||||
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.
|
||||
@@ -360,7 +360,7 @@ static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
}
|
||||
};
|
||||
|
||||
static inline int esp_apptrace_log_lock(void)
|
||||
static inline int esp_apptrace_log_lock()
|
||||
{
|
||||
#if ESP_APPTRACE_PRINT_LOCK
|
||||
esp_apptrace_tmo_t tmo;
|
||||
@@ -372,22 +372,22 @@ static inline int esp_apptrace_log_lock(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void esp_apptrace_log_unlock(void)
|
||||
static inline void esp_apptrace_log_unlock()
|
||||
{
|
||||
#if ESP_APPTRACE_PRINT_LOCK
|
||||
esp_apptrace_lock_give(&s_log_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline esp_err_t esp_apptrace_lock_initialize(esp_apptrace_lock_t *lock)
|
||||
static inline esp_err_t esp_apptrace_lock_initialize()
|
||||
{
|
||||
#if CONFIG_ESP32_APPTRACE_LOCK_ENABLE
|
||||
esp_apptrace_lock_init(lock);
|
||||
esp_apptrace_lock_init(&s_trace_buf.lock);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static inline esp_err_t esp_apptrace_lock_cleanup(void)
|
||||
static inline esp_err_t esp_apptrace_lock_cleanup()
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ esp_err_t esp_apptrace_lock(esp_apptrace_tmo_t *tmo)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_unlock(void)
|
||||
esp_err_t esp_apptrace_unlock()
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
#if CONFIG_ESP32_APPTRACE_LOCK_ENABLE
|
||||
@@ -413,7 +413,7 @@ esp_err_t esp_apptrace_unlock(void)
|
||||
}
|
||||
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
static void esp_apptrace_trax_init(void)
|
||||
static void esp_apptrace_trax_init()
|
||||
{
|
||||
// Stop trace, if any (on the current CPU)
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TRSTP);
|
||||
@@ -449,7 +449,7 @@ static void esp_apptrace_trax_pend_chunk_sz_update(uint16_t size)
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t esp_apptrace_trax_pend_chunk_sz_get(void)
|
||||
static uint16_t esp_apptrace_trax_pend_chunk_sz_get()
|
||||
{
|
||||
uint16_t ch_sz;
|
||||
ESP_APPTRACE_LOGD("Get chunk enter %d w-r-s %d-%d-%d", s_trace_buf.trax.cur_pending_chunk_sz,
|
||||
@@ -467,7 +467,7 @@ static uint16_t esp_apptrace_trax_pend_chunk_sz_get(void)
|
||||
#endif
|
||||
|
||||
// assumed to be protected by caller from multi-core/thread access
|
||||
static esp_err_t esp_apptrace_trax_block_switch(void)
|
||||
static esp_err_t esp_apptrace_trax_block_switch()
|
||||
{
|
||||
int prev_block_num = s_trace_buf.trax.state.in_block % 2;
|
||||
int new_block_num = prev_block_num ? (0) : (1);
|
||||
@@ -845,7 +845,7 @@ static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_dest_init(void)
|
||||
static esp_err_t esp_apptrace_trax_dest_init()
|
||||
{
|
||||
for (int i = 0; i < ESP_APPTRACE_TRAX_BLOCKS_NUM; i++) {
|
||||
s_trace_buf.trax.blocks[i].start = (uint8_t *)s_trax_blocks[i];
|
||||
@@ -874,7 +874,7 @@ static esp_err_t esp_apptrace_trax_dest_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_apptrace_init(void)
|
||||
esp_err_t esp_apptrace_init()
|
||||
{
|
||||
int res;
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ static int esp_dbg_stub_gcov_entry(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void esp_gcov_dump(void)
|
||||
void esp_gcov_dump()
|
||||
{
|
||||
// disable IRQs on this CPU, other CPU is halted by OpenOCD
|
||||
unsigned irq_state = portENTER_CRITICAL_NESTED();
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
static bool s_tracing;
|
||||
|
||||
esp_err_t heap_trace_init_tohost(void)
|
||||
esp_err_t heap_trace_init_tohost()
|
||||
{
|
||||
if (s_tracing) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
|
||||
@@ -33,7 +33,7 @@ typedef enum {
|
||||
*
|
||||
* @return ESP_OK on success, otherwise see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_apptrace_init(void);
|
||||
esp_err_t esp_apptrace_init();
|
||||
|
||||
/**
|
||||
* @brief Configures down buffer.
|
||||
|
||||
@@ -285,12 +285,12 @@ Revision: $Rev: 5626 $
|
||||
* RTT lock configuration fallback
|
||||
*/
|
||||
#ifndef SEGGER_RTT_LOCK
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock(void);
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock();
|
||||
#define SEGGER_RTT_LOCK() SEGGER_SYSVIEW_X_RTT_Lock() // Lock RTT (nestable) (i.e. disable interrupts)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_UNLOCK
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock(void);
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock();
|
||||
#define SEGGER_RTT_UNLOCK() SEGGER_SYSVIEW_X_RTT_Unlock() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ Revision: $Rev: 5927 $
|
||||
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function.
|
||||
#endif
|
||||
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void);
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock();
|
||||
void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state);
|
||||
// to be recursive save IRQ status on the stack of the caller
|
||||
#define SEGGER_SYSVIEW_LOCK() unsigned _SYSVIEW_int_state = SEGGER_SYSVIEW_X_SysView_Lock()
|
||||
|
||||
@@ -244,7 +244,7 @@ static void _cbSendSystemDesc(void) {
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
static void SEGGER_SYSVIEW_TS_Init(void)
|
||||
static void SEGGER_SYSVIEW_TS_Init()
|
||||
{
|
||||
/* We only need to initialize something if we use Timer Group.
|
||||
* esp_timer and ccount can be used as is.
|
||||
@@ -316,7 +316,7 @@ void SEGGER_SYSVIEW_Conf(void) {
|
||||
SEGGER_SYSVIEW_DisableEvents(disable_evts);
|
||||
}
|
||||
|
||||
U32 SEGGER_SYSVIEW_X_GetTimestamp(void)
|
||||
U32 SEGGER_SYSVIEW_X_GetTimestamp()
|
||||
{
|
||||
#if TS_USE_TIMERGROUP
|
||||
uint64_t ts = 0;
|
||||
@@ -329,15 +329,15 @@ U32 SEGGER_SYSVIEW_X_GetTimestamp(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock(void)
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock()
|
||||
{
|
||||
}
|
||||
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock(void)
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void)
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock()
|
||||
{
|
||||
esp_apptrace_tmo_t tmo;
|
||||
esp_apptrace_tmo_init(&tmo, SEGGER_LOCK_WAIT_TMO);
|
||||
|
||||
@@ -125,7 +125,7 @@ typedef struct {
|
||||
static SemaphoreHandle_t s_print_lock;
|
||||
#endif
|
||||
|
||||
static uint64_t esp_apptrace_test_ts_get(void);
|
||||
static uint64_t esp_apptrace_test_ts_get();
|
||||
|
||||
static void esp_apptrace_test_timer_isr(void *arg)
|
||||
{
|
||||
@@ -383,7 +383,7 @@ static void esp_apptrace_test_task_crash(void *p)
|
||||
|
||||
static int s_ts_timer_group, s_ts_timer_idx;
|
||||
|
||||
static uint64_t esp_apptrace_test_ts_get(void)
|
||||
static uint64_t esp_apptrace_test_ts_get()
|
||||
{
|
||||
uint64_t ts = 0;
|
||||
timer_get_counter_value(s_ts_timer_group, s_ts_timer_idx, &ts);
|
||||
@@ -413,7 +413,7 @@ static void esp_apptrace_test_ts_init(int timer_group, int timer_idx)
|
||||
timer_start(timer_group, timer_idx);
|
||||
}
|
||||
|
||||
static void esp_apptrace_test_ts_cleanup(void)
|
||||
static void esp_apptrace_test_ts_cleanup()
|
||||
{
|
||||
timer_config_t config;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -687,12 +688,12 @@ static esp_err_t esp_ota_current_ota_is_workable(bool valid)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback(void)
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback()
|
||||
{
|
||||
return esp_ota_current_ota_is_workable(true);
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void)
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot()
|
||||
{
|
||||
return esp_ota_current_ota_is_workable(false);
|
||||
}
|
||||
@@ -715,7 +716,7 @@ static int get_last_invalid_otadata(const esp_ota_select_entry_t *two_otadata)
|
||||
return num_invalid_otadata;
|
||||
}
|
||||
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition(void)
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition()
|
||||
{
|
||||
esp_ota_select_entry_t otadata[2];
|
||||
if (read_otadata(otadata) == NULL) {
|
||||
|
||||
@@ -221,7 +221,7 @@ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, es
|
||||
* @return
|
||||
* - ESP_OK: if successful.
|
||||
*/
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback(void);
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback();
|
||||
|
||||
/**
|
||||
* @brief This function is called to roll back to the previously workable app with reboot.
|
||||
@@ -233,14 +233,14 @@ esp_err_t esp_ota_mark_app_valid_cancel_rollback(void);
|
||||
* - ESP_FAIL: if not successful.
|
||||
* - ESP_ERR_OTA_ROLLBACK_FAILED: The rollback is not possible due to flash does not have any apps.
|
||||
*/
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void);
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||
|
||||
/**
|
||||
* @brief Returns last partition with invalid state (ESP_OTA_IMG_INVALID or ESP_OTA_IMG_ABORTED).
|
||||
*
|
||||
* @return partition.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition(void);
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition();
|
||||
|
||||
/**
|
||||
* @brief Returns state for given partition.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -118,7 +118,7 @@ static void reboot_as_deep_sleep(void)
|
||||
|
||||
/* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx.
|
||||
*/
|
||||
static void copy_current_app_to_next_part_and_reboot(void)
|
||||
static void copy_current_app_to_next_part_and_reboot()
|
||||
{
|
||||
const esp_partition_t *cur_app = esp_ota_get_running_partition();
|
||||
copy_current_app_to_next_part(cur_app, get_next_update_partition());
|
||||
@@ -264,19 +264,19 @@ static void test_flow1(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 4:
|
||||
ESP_LOGI(TAG, "OTA1");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 5:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
@@ -307,7 +307,7 @@ static void test_flow2(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
@@ -344,13 +344,13 @@ static void test_flow3(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 4:
|
||||
ESP_LOGI(TAG, "OTA1");
|
||||
@@ -402,7 +402,7 @@ static void test_flow4(void)
|
||||
nvs_close(handle);
|
||||
nvs_flash_deinit();
|
||||
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
@@ -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";
|
||||
|
||||
@@ -34,7 +35,7 @@ static int selected_boot_partition(const bootloader_state_t *bs);
|
||||
* The hardware is mostly uninitialized, flash cache is down and the app CPU is in reset.
|
||||
* We do have a stack, so we can do the initialization in C.
|
||||
*/
|
||||
void __attribute__((noreturn)) call_start_cpu0(void)
|
||||
void __attribute__((noreturn)) call_start_cpu0()
|
||||
{
|
||||
// 1. Hardware initialization
|
||||
if (bootloader_init() != ESP_OK) {
|
||||
@@ -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) {
|
||||
@@ -113,7 +115,7 @@ static int selected_boot_partition(const bootloader_state_t *bs)
|
||||
}
|
||||
|
||||
// Return global reent struct if any newlib functions are linked to bootloader
|
||||
struct _reent* __getreent(void) {
|
||||
struct _reent* __getreent() {
|
||||
return _GLOBAL_REENT;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,10 +147,28 @@ 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.
|
||||
*/
|
||||
void bootloader_common_vddsdio_configure(void);
|
||||
void bootloader_common_vddsdio_configure();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_update_id(void);
|
||||
void bootloader_flash_update_id();
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
@@ -35,7 +35,7 @@ void bootloader_flash_update_id(void);
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_cs_timing_config(void);
|
||||
void bootloader_flash_cs_timing_config();
|
||||
|
||||
/**
|
||||
* @brief Configure SPI flash clock.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -122,7 +122,7 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length);
|
||||
* serial re-flashing of an unauthorised code in absence of secure boot.
|
||||
*
|
||||
*/
|
||||
void esp_flash_write_protect_crypt_cnt(void);
|
||||
void esp_flash_write_protect_crypt_cnt();
|
||||
|
||||
/** @brief Return the flash encryption mode
|
||||
*
|
||||
@@ -131,7 +131,22 @@ void esp_flash_write_protect_crypt_cnt(void);
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void);
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages(void);
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
|
||||
/**
|
||||
* @brief Map a region of flash to data memory
|
||||
|
||||
@@ -25,4 +25,4 @@
|
||||
* @return ESP_OK - If the setting is successful.
|
||||
* ESP_FAIL - If the setting is not successful.
|
||||
*/
|
||||
esp_err_t bootloader_init(void);
|
||||
esp_err_t bootloader_init();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
typedef void *bootloader_sha256_handle_t;
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void);
|
||||
bootloader_sha256_handle_t bootloader_sha256_start();
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void bootloader_enable_qio_mode(void);
|
||||
* mfg_id = (ID >> 16) & 0xFF;
|
||||
flash_id = ID & 0xffff;
|
||||
*/
|
||||
uint32_t bootloader_read_flash_id(void);
|
||||
uint32_t bootloader_read_flash_id();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
|
||||
void bootloader_clock_configure(void)
|
||||
void bootloader_clock_configure()
|
||||
{
|
||||
// ROM bootloader may have put a lot of text into UART0 FIFO.
|
||||
// Wait for it to be printed.
|
||||
@@ -58,3 +58,12 @@ void bootloader_clock_configure(void)
|
||||
}
|
||||
#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"
|
||||
@@ -256,7 +258,7 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bootloader_common_vddsdio_configure(void)
|
||||
void bootloader_common_vddsdio_configure()
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
@@ -270,3 +272,51 @@ void bootloader_common_vddsdio_configure(void)
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ static const char *TAG = "bootloader_mmap";
|
||||
|
||||
static spi_flash_mmap_handle_t map;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages(void)
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
{
|
||||
return spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ static bool mapped;
|
||||
// Current bootloader mapping (ab)used for bootloader_read()
|
||||
static uint32_t current_read_mapping = UINT32_MAX;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages(void)
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
{
|
||||
/**
|
||||
* Allow mapping up to 50 of the 51 available MMU blocks (last one used for reads)
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
void bootloader_flash_update_id(void)
|
||||
void bootloader_flash_update_id()
|
||||
{
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config(void)
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
|
||||
@@ -61,7 +61,7 @@ extern int _data_end;
|
||||
|
||||
static const char* TAG = "boot";
|
||||
|
||||
static esp_err_t bootloader_main(void);
|
||||
static esp_err_t bootloader_main();
|
||||
static void print_flash_info(const esp_image_header_t* pfhdr);
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr);
|
||||
static void bootloader_init_flash_configure(const esp_image_header_t* pfhdr);
|
||||
@@ -69,7 +69,7 @@ static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
|
||||
esp_err_t bootloader_init(void)
|
||||
esp_err_t bootloader_init()
|
||||
{
|
||||
cpu_configure_region_protection();
|
||||
cpu_init_memctl();
|
||||
@@ -117,7 +117,7 @@ esp_err_t bootloader_init(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t bootloader_main(void)
|
||||
static esp_err_t bootloader_main()
|
||||
{
|
||||
bootloader_common_vddsdio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
@@ -127,6 +127,14 @@ static esp_err_t bootloader_main(void)
|
||||
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
|
||||
@@ -434,7 +442,7 @@ void __assert_func(const char *file, int line, const char *func, const char *exp
|
||||
while(1) {}
|
||||
}
|
||||
|
||||
void abort(void)
|
||||
void abort()
|
||||
{
|
||||
#if !CONFIG_ESP32_PANIC_SILENT_REBOOT
|
||||
ets_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -27,7 +27,7 @@ static const size_t BLOCK_WORDS = (64 / sizeof(uint32_t));
|
||||
// Words in final SHA256 digest
|
||||
static const size_t DIGEST_WORDS = (32 / sizeof(uint32_t));
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
|
||||
@@ -37,8 +37,8 @@ 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_bootloader(void);
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +229,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t encrypt_bootloader(void)
|
||||
static esp_err_t encrypt_bootloader()
|
||||
{
|
||||
esp_err_t err;
|
||||
uint32_t image_length;
|
||||
|
||||
@@ -95,7 +95,7 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
}
|
||||
|
||||
/* Burn values written to the efuse write registers */
|
||||
static inline void burn_efuses(void)
|
||||
static inline void burn_efuses()
|
||||
{
|
||||
esp_efuse_burn_new_values();
|
||||
}
|
||||
|
||||
@@ -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,11 +13,53 @@
|
||||
// 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"
|
||||
|
||||
void esp_flash_write_protect_crypt_cnt(void)
|
||||
#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_EARLY_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_EARLY_LOGE(TAG, "Flash encryption settings error: app is configured for RELEASE but efuses are set for DEVELOPMENT");
|
||||
ESP_EARLY_LOGE(TAG, "Mismatch found in security options in bootloader menuconfig and efuse settings. Device is not secure.");
|
||||
#else
|
||||
ESP_EARLY_LOGW(TAG, "Flash encryption mode is DEVELOPMENT (not secure)");
|
||||
#endif
|
||||
} else if (mode == ESP_FLASH_ENC_MODE_RELEASE) {
|
||||
ESP_EARLY_LOGI(TAG, "Flash encryption mode is RELEASE");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void esp_flash_write_protect_crypt_cnt()
|
||||
{
|
||||
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);
|
||||
@@ -26,7 +68,7 @@ void esp_flash_write_protect_crypt_cnt(void)
|
||||
}
|
||||
}
|
||||
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode()
|
||||
{
|
||||
uint8_t efuse_flash_crypt_cnt_wr_protected = 0;
|
||||
uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
|
||||
typedef unsigned (*read_status_fn_t)(void);
|
||||
typedef unsigned (*read_status_fn_t)();
|
||||
typedef void (*write_status_fn_t)(unsigned);
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
@@ -53,11 +53,11 @@ typedef struct __attribute__((packed)) {
|
||||
} qio_info_t;
|
||||
|
||||
/* Read 8 bit status using RDSR command */
|
||||
static unsigned read_status_8b_rdsr(void);
|
||||
static unsigned read_status_8b_rdsr();
|
||||
/* Read 8 bit status (second byte) using RDSR2 command */
|
||||
static unsigned read_status_8b_rdsr2(void);
|
||||
static unsigned read_status_8b_rdsr2();
|
||||
/* read 16 bit status using RDSR & RDSR2 (low and high bytes) */
|
||||
static unsigned read_status_16b_rdsr_rdsr2(void);
|
||||
static unsigned read_status_16b_rdsr_rdsr2();
|
||||
|
||||
/* Write 8 bit status using WRSR */
|
||||
static void write_status_8b_wrsr(unsigned new_status);
|
||||
@@ -67,7 +67,7 @@ static void write_status_8b_wrsr2(unsigned new_status);
|
||||
static void write_status_16b_wrsr(unsigned new_status);
|
||||
|
||||
/* Read 8 bit status of XM25QU64A */
|
||||
static unsigned read_status_8b_xmc25qu64a(void);
|
||||
static unsigned read_status_8b_xmc25qu64a();
|
||||
/* Write 8 bit status of XM25QU64A */
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status);
|
||||
|
||||
@@ -121,7 +121,7 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
uint32_t bootloader_read_flash_id(void)
|
||||
uint32_t bootloader_read_flash_id()
|
||||
{
|
||||
uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
@@ -223,17 +223,17 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr(void)
|
||||
static unsigned read_status_8b_rdsr()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr2(void)
|
||||
static unsigned read_status_8b_rdsr2()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR2, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_16b_rdsr_rdsr2(void)
|
||||
static unsigned read_status_16b_rdsr_rdsr2()
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8) | (execute_flash_command(CMD_RDSR2, 0, 0, 8) << 8);
|
||||
}
|
||||
@@ -253,7 +253,7 @@ static void write_status_16b_wrsr(unsigned new_status)
|
||||
execute_flash_command(CMD_WRSR, new_status, 16, 0);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_xmc25qu64a(void)
|
||||
static unsigned read_status_8b_xmc25qu64a()
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <mbedtls/sha256.h>
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
{
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
|
||||
if (!ctx) {
|
||||
|
||||
@@ -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,29 @@ 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_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,7 +330,13 @@ 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/mesh_aes_encrypt.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_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"
|
||||
@@ -332,30 +347,29 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/mesh_core/health_cli.c"
|
||||
"esp_ble_mesh/mesh_core/health_srv.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 +390,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 +411,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 +465,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 +481,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,20 @@ 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_BLE_MAX_CONN_EFF
|
||||
int
|
||||
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
|
||||
@@ -318,8 +332,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 +372,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 +407,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 +431,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
|
||||
|
||||
/**********************************************************
|
||||
|
||||
@@ -389,7 +389,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 +409,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 +427,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 +544,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,39 @@ 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_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_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 +176,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 +196,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);
|
||||
@@ -225,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;
|
||||
@@ -288,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
|
||||
***************************************************************************
|
||||
@@ -335,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,
|
||||
@@ -382,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)
|
||||
{
|
||||
@@ -741,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)
|
||||
@@ -755,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])
|
||||
@@ -887,13 +895,24 @@ 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()) {
|
||||
@@ -904,13 +923,57 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
#endif
|
||||
do_wakeup_request = true;
|
||||
btdm_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) {
|
||||
btdm_wakeup_request_end();
|
||||
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_HCI);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -970,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;
|
||||
@@ -1128,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;
|
||||
}
|
||||
@@ -1153,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) {
|
||||
@@ -1191,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;
|
||||
@@ -1230,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);
|
||||
@@ -1274,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
|
||||
|
||||
@@ -1314,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;
|
||||
@@ -1357,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
|
||||
|
||||
|
||||
Submodule components/bt/controller/lib updated: 717f0c6ec7...2575a67bc7
@@ -8,12 +8,22 @@ if BLE_MESH
|
||||
|
||||
config BLE_MESH_USE_DUPLICATE_SCAN
|
||||
bool "Support Duplicate Scan in BLE Mesh"
|
||||
depends on BT_BLUEDROID_ENABLED
|
||||
select BLE_SCAN_DUPLICATE
|
||||
select BLE_MESH_SCAN_DUPLICATE_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".
|
||||
|
||||
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
bool "BLE Mesh will first allocate memory from PSRAM"
|
||||
default n
|
||||
help
|
||||
When this option is enabled, BLE Mesh stack will try to allocate memory
|
||||
from PSRAM firstly. This will save the internal RAM if PSRAM exists.
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
@@ -23,75 +33,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 +134,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 +143,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 +154,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 +174,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 +250,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 +274,17 @@ 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.
|
||||
|
||||
endif # if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SUBNET_COUNT
|
||||
@@ -217,6 +293,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 +301,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 +325,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 +334,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 +351,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 +366,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 +416,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 +428,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 +444,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 +468,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 +543,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 +556,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 +566,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 +598,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 +627,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 +650,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 +659,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 +669,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 +689,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 +766,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 +773,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"
|
||||
|
||||
@@ -716,6 +883,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 +894,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 whilte 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 +989,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,9 @@
|
||||
#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 +29,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("%s, Failed to allocate memory for the semaphore", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
@@ -56,7 +59,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("%s, BLE Mesh initialise failed", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -68,3 +71,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,10 @@
|
||||
// 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"
|
||||
|
||||
@@ -14,13 +14,52 @@
|
||||
|
||||
#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,40 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.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_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("%s, Invalid destination address 0x0000", __func__);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (device_role > ROLE_FAST_PROV) {
|
||||
BT_ERR("%s, Invalid device role 0x%02x", __func__, device_role);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -62,7 +65,7 @@ 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("%s, Model publication msg size %d is too small", __func__, model->pub->msg->size);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
@@ -74,7 +77,7 @@ static esp_err_t ble_mesh_send_msg(esp_ble_mesh_model_t *model,
|
||||
}
|
||||
|
||||
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("%s, Data length %d is too large", __func__, length);
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -82,7 +85,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 +111,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,7 +160,21 @@ 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,
|
||||
@@ -167,8 +184,8 @@ esp_err_t esp_ble_mesh_server_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
if (!model || !ctx) {
|
||||
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,
|
||||
@@ -179,8 +196,8 @@ esp_err_t esp_ble_mesh_client_model_send_msg(esp_ble_mesh_model_t *model,
|
||||
if (!model || !ctx) {
|
||||
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,
|
||||
@@ -190,15 +207,40 @@ esp_err_t esp_ble_mesh_model_publish(esp_ble_mesh_model_t *model, uint32_t opcod
|
||||
if (!model || !model->pub || !model->pub->msg) {
|
||||
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 +251,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 +260,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;
|
||||
@@ -231,31 +273,113 @@ esp_err_t esp_ble_mesh_provisioner_set_node_name(int index, const char *name)
|
||||
== 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_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};
|
||||
|
||||
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_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_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_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_SET_LOCAL_APP_KEY;
|
||||
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,6 +392,29 @@ 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);
|
||||
@@ -283,7 +430,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 +453,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 +469,37 @@ 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);
|
||||
}
|
||||
|
||||
uint16_t esp_ble_mesh_provisioner_get_prov_node_count(void)
|
||||
{
|
||||
return btc_ble_mesh_provisioner_get_prov_node_count();
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BLE_MESH_PROVISIONER */
|
||||
|
||||
#if (CONFIG_BLE_MESH_FAST_PROV)
|
||||
|
||||
@@ -13,13 +13,11 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.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_provisioning_api.h"
|
||||
@@ -29,7 +27,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);
|
||||
}
|
||||
@@ -44,7 +42,7 @@ 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);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@@ -60,7 +58,7 @@ 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);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@@ -72,7 +70,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 +79,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 +102,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;
|
||||
@@ -124,7 +122,7 @@ esp_err_t esp_ble_mesh_node_input_string(const char *string)
|
||||
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;
|
||||
@@ -145,7 +143,7 @@ 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;
|
||||
@@ -159,7 +157,7 @@ esp_err_t esp_ble_mesh_set_unprovisioned_device_name(const char *name)
|
||||
|
||||
#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 +166,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;
|
||||
@@ -191,7 +189,7 @@ esp_err_t esp_ble_mesh_provisioner_input_string(const char *string, uint8_t link
|
||||
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;
|
||||
@@ -214,7 +212,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 +230,7 @@ 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);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@@ -249,7 +247,7 @@ 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);
|
||||
ESP_BLE_HOST_STATUS_CHECK(ESP_BLE_HOST_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_PROV;
|
||||
@@ -271,7 +269,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 +278,45 @@ 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 +327,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 +336,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);
|
||||
}
|
||||
@@ -320,7 +350,7 @@ esp_err_t esp_ble_mesh_provisioner_set_dev_uuid_match(const uint8_t *match_val,
|
||||
btc_ble_mesh_prov_args_t arg = {0};
|
||||
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;
|
||||
@@ -346,7 +376,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 +394,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 */
|
||||
@@ -379,7 +450,7 @@ esp_err_t esp_ble_mesh_set_fast_prov_info(esp_ble_mesh_fast_prov_info_t *fast_pr
|
||||
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 +479,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,11 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.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"
|
||||
@@ -28,7 +26,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 +39,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 +52,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 +61,117 @@ 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.
|
||||
*
|
||||
@@ -104,4 +108,8 @@ 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);
|
||||
|
||||
#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,6 +17,10 @@
|
||||
|
||||
#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);
|
||||
@@ -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).
|
||||
*
|
||||
@@ -134,6 +150,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 +192,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 +204,76 @@ 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 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.
|
||||
@@ -198,6 +289,19 @@ int esp_ble_mesh_provisioner_get_node_index(const char *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);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
@@ -241,6 +345,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.
|
||||
*
|
||||
@@ -251,6 +366,14 @@ esp_err_t esp_ble_mesh_provisioner_add_local_net_key(const uint8_t net_key[16],
|
||||
*/
|
||||
const uint8_t *esp_ble_mesh_provisioner_get_local_net_key(uint16_t net_idx);
|
||||
|
||||
/**
|
||||
* @brief This function is called by Provisioner to 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 to get fast provisioning application key.
|
||||
*
|
||||
@@ -262,4 +385,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.
|
||||
@@ -230,6 +234,32 @@ 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);
|
||||
|
||||
/** @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,7 +289,7 @@ 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,
|
||||
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);
|
||||
|
||||
@@ -290,6 +320,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 +371,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,74 @@ 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,86 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
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 || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(config_client_get_need_param(params->opcode) && !get_state)) {
|
||||
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)
|
||||
{
|
||||
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 || !params->model || !ESP_BLE_MESH_ADDR_IS_UNICAST(params->ctx.addr) ||
|
||||
(params->opcode != ESP_BLE_MESH_MODEL_OP_NODE_RESET && !set_state)) {
|
||||
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,43 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
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 || !params->model || !params->ctx.addr ||
|
||||
(generic_client_get_need_param(params->opcode) && !get_state)) {
|
||||
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;
|
||||
@@ -62,7 +72,7 @@ esp_err_t esp_ble_mesh_generic_client_set_state(esp_ble_mesh_client_common_param
|
||||
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 +83,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,25 +14,21 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -43,11 +39,12 @@ esp_err_t esp_ble_mesh_health_client_get_state(esp_ble_mesh_client_common_param_
|
||||
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 || !params->model || !params->ctx.addr || (!get_state &&
|
||||
params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET)) {
|
||||
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;
|
||||
@@ -69,7 +66,7 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
|
||||
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 +83,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,66 @@
|
||||
|
||||
#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)
|
||||
{
|
||||
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 || !params->model || !params->ctx.addr || (!get_state &&
|
||||
params->opcode == ESP_BLE_MESH_MODEL_OP_LIGHT_LC_PROPERTY_GET)) {
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
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,18 +14,14 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -40,7 +36,7 @@ esp_err_t esp_ble_mesh_sensor_client_get_state(esp_ble_mesh_client_common_param_
|
||||
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;
|
||||
@@ -62,7 +58,7 @@ esp_err_t esp_ble_mesh_sensor_client_set_state(esp_ble_mesh_client_common_param_
|
||||
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 +70,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,18 +14,14 @@
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -36,11 +32,12 @@ esp_err_t esp_ble_mesh_time_scene_client_get_state(esp_ble_mesh_client_common_pa
|
||||
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 || !params->model || !params->ctx.addr || (!get_state &&
|
||||
params->opcode == ESP_BLE_MESH_MODEL_OP_SCHEDULER_ACT_GET)) {
|
||||
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;
|
||||
@@ -62,7 +59,7 @@ esp_err_t esp_ble_mesh_time_scene_client_set_state(esp_ble_mesh_client_common_pa
|
||||
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 +71,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;
|
||||
|
||||
@@ -707,5 +818,9 @@ 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);
|
||||
|
||||
#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;
|
||||
|
||||
@@ -524,6 +527,779 @@ 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);
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
@@ -270,7 +398,7 @@ esp_err_t esp_ble_mesh_health_client_set_state(esp_ble_mesh_client_common_param_
|
||||
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;
|
||||
|
||||
@@ -256,6 +259,376 @@ 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);
|
||||
|
||||
/**
|
||||
* @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
|
||||
|
||||
/** 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;
|
||||
|
||||
/**
|
||||
@@ -315,5 +318,603 @@ 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);
|
||||
|
||||
/**
|
||||
* @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,21 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
#include "mesh_common.h"
|
||||
#include "generic_client.h"
|
||||
|
||||
#include "cfg_cli.h"
|
||||
#include "btc_ble_mesh_generic_model.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,
|
||||
/* 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 +37,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, Failed to allocate 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, Failed to allocate 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, Failed to allocate 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 +93,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, Failed to allocate 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 +105,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Failed to allocate 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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_properties_status.property_ids,
|
||||
@@ -148,7 +208,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.user_property_status.property_value,
|
||||
@@ -162,7 +222,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_properties_status.property_ids,
|
||||
@@ -177,7 +237,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.admin_property_status.property_value,
|
||||
@@ -191,7 +251,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_properties_status.property_ids,
|
||||
@@ -206,7 +266,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.manufacturer_property_status.property_value,
|
||||
@@ -220,7 +280,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.client_properties_status.property_ids,
|
||||
@@ -233,27 +293,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 +315,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 +353,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 +361,55 @@ 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);
|
||||
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,
|
||||
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;
|
||||
size_t length = 0U;
|
||||
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("%s, Unknown generic client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -424,30 +430,35 @@ void bt_mesh_callback_generic_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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};
|
||||
esp_ble_mesh_generic_client_cb_param_t cb = {0};
|
||||
bt_mesh_client_common_param_t common = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -458,9 +469,9 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
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;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
@@ -471,15 +482,12 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
|
||||
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,
|
||||
(void *)arg->generic_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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;
|
||||
}
|
||||
@@ -487,9 +495,9 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
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;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
@@ -500,15 +508,12 @@ void btc_mesh_generic_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
|
||||
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,
|
||||
(void *)arg->generic_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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 +522,255 @@ 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 msg->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, Failed to allocate 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, Failed to allocate 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, Failed to allocate 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, Failed to allocate 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};
|
||||
size_t length = 0U;
|
||||
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("%s, Unknown Generic Server event type", __func__);
|
||||
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;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
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 msg->act = %d", __func__, msg->act);
|
||||
}
|
||||
|
||||
btc_ble_mesh_generic_server_free_req_data(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,34 +15,25 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "btc/btc_task.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "foundation.h"
|
||||
#include "mesh_common.h"
|
||||
#include "health_srv.h"
|
||||
#include "health_cli.h"
|
||||
#include "mesh_common.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_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 +43,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, Failed to allocate 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, Failed to allocate 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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +92,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 +101,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, Failed to allocate 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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.current_status.fault_array,
|
||||
@@ -194,7 +168,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.fault_status.fault_array,
|
||||
@@ -207,14 +181,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 +190,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 +203,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 +219,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,41 +227,16 @@ 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;
|
||||
@@ -307,136 +246,36 @@ static void btc_mesh_health_client_callback(esp_ble_mesh_health_client_cb_param_
|
||||
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,
|
||||
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;
|
||||
size_t length = 0U;
|
||||
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("%s, Unknown health client event type %d", __func__, evt_type);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,28 +296,124 @@ void bt_mesh_callback_health_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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,
|
||||
esp_ble_mesh_health_client_cb_param_t *cb)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (!params || !cb) {
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (params->opcode == ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET && get == NULL) {
|
||||
BT_ERR("%s, Invalid health client get", __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 (cb->error_code = bt_mesh_health_attention_get(&ctx));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_GET:
|
||||
return (cb->error_code = bt_mesh_health_period_get(&ctx));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_GET:
|
||||
return (cb->error_code = bt_mesh_health_fault_get(&ctx, get->fault_get.company_id));
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return (cb->error_code = -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,
|
||||
esp_ble_mesh_health_client_cb_param_t *cb)
|
||||
{
|
||||
struct bt_mesh_msg_ctx ctx = {0};
|
||||
|
||||
if (!params || !set || !cb) {
|
||||
BT_ERR("%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 (cb->error_code =
|
||||
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_ATTENTION_SET_UNACK:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_attention_set(&ctx, set->attention_set.attention, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_PERIOD_SET_UNACK:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_period_set(&ctx, set->period_set.fast_period_divisor, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_TEST_UNACK:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_fault_test(&ctx, set->fault_test.company_id, set->fault_test.test_id, false));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, true));
|
||||
case ESP_BLE_MESH_MODEL_OP_HEALTH_FAULT_CLEAR_UNACK:
|
||||
return (cb->error_code =
|
||||
bt_mesh_health_fault_clear(&ctx, set->fault_clear.company_id, false));
|
||||
default:
|
||||
BT_ERR("%s, Invalid opcode 0x%x", __func__, params->opcode);
|
||||
return (cb->error_code = -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};
|
||||
esp_ble_mesh_health_client_cb_param_t cb = {0};
|
||||
bt_mesh_role_param_t role_param = {0};
|
||||
|
||||
if (!msg || !msg->arg) {
|
||||
LOG_ERROR("%s, Invalid parameter", __func__);
|
||||
BT_ERR("%s, Invalid parameter", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -486,36 +421,34 @@ 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;
|
||||
cb.params = arg->health_client_get_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
arg->health_client_get_state.get_state, &cb);
|
||||
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;
|
||||
cb.params = arg->health_client_set_state.params;
|
||||
role_param.model = (struct bt_mesh_model *)cb.params->model;
|
||||
role_param.role = cb.params->msg_role;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
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) {
|
||||
arg->health_client_set_state.set_state, &cb);
|
||||
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 +460,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 +474,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 msg->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 +613,49 @@ 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 msg->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,134 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "btc/btc_manage.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "mesh_common.h"
|
||||
#include "lighting_client.h"
|
||||
|
||||
#include "btc_ble_mesh_lighting_model.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,
|
||||
/* 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, Failed to allocate 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, Failed to allocate 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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s, Unknown deep copy act %d", __func__, msg->act);
|
||||
BT_DBG("%s, Unknown deep copy 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, Failed to allocate 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 +150,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, Failed to allocate memory, act %d", __func__, msg->act);
|
||||
return;
|
||||
}
|
||||
net_buf_simple_add_mem(p_dest_data->status_cb.lc_property_status.property_value,
|
||||
@@ -113,27 +163,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 +185,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 +197,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 +205,55 @@ 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);
|
||||
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,
|
||||
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;
|
||||
size_t length = 0U;
|
||||
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("%s, Unknown lighting client event type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -264,43 +274,48 @@ void bt_mesh_callback_light_status_to_btc(u32_t opcode, u8_t evt_type,
|
||||
memcpy(&cb_params.status_cb, val, length);
|
||||
}
|
||||
|
||||
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};
|
||||
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};
|
||||
bt_mesh_role_param_t role_param = {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;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
@@ -311,25 +326,22 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
|
||||
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,
|
||||
(void *)arg->light_client_get_state.get_state, (void *)&cb.status_cb);
|
||||
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;
|
||||
if (bt_mesh_set_client_model_role(&role_param)) {
|
||||
BT_ERR("%s, Failed to set model role", __func__);
|
||||
break;
|
||||
}
|
||||
common.opcode = params->opcode;
|
||||
common.model = (struct bt_mesh_model *)params->model;
|
||||
@@ -340,15 +352,12 @@ void btc_mesh_light_client_call_handler(btc_msg_t *msg)
|
||||
common.ctx.send_ttl = params->ctx.send_ttl;
|
||||
common.msg_timeout = params->msg_timeout;
|
||||
|
||||
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,
|
||||
(void *)arg->light_client_set_state.set_state, (void *)&cb.status_cb);
|
||||
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 +365,227 @@ 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 msg->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, Failed to allocate 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, Failed to allocate 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, Failed to allocate 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};
|
||||
size_t length = 0U;
|
||||
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("%s, Unknown Lighting Server event type", __func__);
|
||||
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;
|
||||
|
||||
if (val && len) {
|
||||
length = (len <= sizeof(cb_params.value)) ? len : sizeof(cb_params.value);
|
||||
memcpy(&cb_params.value, val, length);
|
||||
}
|
||||
|
||||
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 msg->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
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user