mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-08 19:07:26 +00:00
Compare commits
945 Commits
v1.3.40.e8
...
v2.0.9.6ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ea0963f4b | ||
|
|
63cf01223c | ||
|
|
2505bdbc21 | ||
|
|
14be4ee9f0 | ||
|
|
d0243d2cd0 | ||
|
|
796e58161d | ||
|
|
e56f17c658 | ||
|
|
b808ffa9ab | ||
|
|
506bae4a8b | ||
|
|
f6ee6265e6 | ||
|
|
7539d92857 | ||
|
|
21fff392b4 | ||
|
|
580ec590fa | ||
|
|
5c9996dfa1 | ||
|
|
2f7c18303d | ||
|
|
b9df41c55f | ||
|
|
4801260440 | ||
|
|
606262e55d | ||
|
|
090e1660fe | ||
|
|
92c9b34d4f | ||
|
|
3f50371ff3 | ||
|
|
815f9bfc5f | ||
|
|
86ff23d13c | ||
|
|
201b786f77 | ||
|
|
755c0b7008 | ||
|
|
7396d0f241 | ||
|
|
220859d0aa | ||
|
|
941786669b | ||
|
|
4eb620d47b | ||
|
|
9794995d7a | ||
|
|
055146602a | ||
|
|
86d7860d86 | ||
|
|
0f2d0d1f07 | ||
|
|
ab6a5a5e07 | ||
|
|
44a33ed463 | ||
|
|
fab08b6451 | ||
|
|
d9cd3dd3e1 | ||
|
|
c75ea87f6b | ||
|
|
706ddf6e95 | ||
|
|
aec091e7aa | ||
|
|
cea8393a7f | ||
|
|
8f94463eac | ||
|
|
a0f5e44967 | ||
|
|
feb7181767 | ||
|
|
a0c1e9cdc6 | ||
|
|
7d1b6f63b5 | ||
|
|
ab6b6514cb | ||
|
|
0e6285edf2 | ||
|
|
8b58eaac20 | ||
|
|
8cbf292373 | ||
|
|
80d0b63c3a | ||
|
|
f5120a29ec | ||
|
|
efc3f4c0ee | ||
|
|
bd2bfd6822 | ||
|
|
88c3ab2636 | ||
|
|
6a5dd26907 | ||
|
|
4de557b4db | ||
|
|
af9d4328eb | ||
|
|
8c66940b78 | ||
|
|
72f1416b30 | ||
|
|
05f81922e6 | ||
|
|
72504a5e8b | ||
|
|
e8c034e988 | ||
|
|
aa19718ba4 | ||
|
|
088ab106dd | ||
|
|
110c3f619a | ||
|
|
d1cc503ca8 | ||
|
|
d3b3a4c148 | ||
|
|
46f1cee2a8 | ||
|
|
0386af721d | ||
|
|
de6b752db8 | ||
|
|
92fd5511ec | ||
|
|
59ec7f31ab | ||
|
|
779d2352bd | ||
|
|
0162db12b8 | ||
|
|
91ff7b9032 | ||
|
|
643f99f577 | ||
|
|
152288b4cc | ||
|
|
45b518baf2 | ||
|
|
0c65c73f90 | ||
|
|
0f0dbc3274 | ||
|
|
06d34daeab | ||
|
|
ba1f68d758 | ||
|
|
d4c0977a70 | ||
|
|
1a19d71e95 | ||
|
|
21c10934fc | ||
|
|
13cca91097 | ||
|
|
b335b1c66b | ||
|
|
cc2653bfb5 | ||
|
|
fc5bf5a68f | ||
|
|
63d7338311 | ||
|
|
37f716d27b | ||
|
|
0f2a835359 | ||
|
|
2a84d39e40 | ||
|
|
b14289e976 | ||
|
|
1fef6f0656 | ||
|
|
183ec2124f | ||
|
|
aeb9bfa063 | ||
|
|
b84c7ae49b | ||
|
|
61598c5942 | ||
|
|
a3a24e0216 | ||
|
|
31ec2da0e9 | ||
|
|
27a10b395f | ||
|
|
7570cdbd22 | ||
|
|
c857474116 | ||
|
|
8ff5dacc3c | ||
|
|
f1179d31ba | ||
|
|
abe60b96f1 | ||
|
|
206520f179 | ||
|
|
97fd5cf2ab | ||
|
|
d13a095516 | ||
|
|
4dc7d92cf1 | ||
|
|
e7dbbeb606 | ||
|
|
3e892fc391 | ||
|
|
dfec37dfd0 | ||
|
|
b82ab34f85 | ||
|
|
18a2cfeda4 | ||
|
|
082aa07e7f | ||
|
|
a703ab4418 | ||
|
|
185ceac9df | ||
|
|
7c9cada50e | ||
|
|
a5ba3dd445 | ||
|
|
63838a1632 | ||
|
|
30d7f188e2 | ||
|
|
47a47f1e69 | ||
|
|
daac79f314 | ||
|
|
1864216e78 | ||
|
|
71c0cf9b9a | ||
|
|
ef87ddb798 | ||
|
|
711c748b44 | ||
|
|
6eff09a260 | ||
|
|
c5fe878a6f | ||
|
|
39948c76de | ||
|
|
10f14d27b7 | ||
|
|
5e9d722b7d | ||
|
|
b324c04097 | ||
|
|
84a9d95b1f | ||
|
|
cdd499f147 | ||
|
|
c45a85547e | ||
|
|
8815746006 | ||
|
|
32a1e8ef0d | ||
|
|
0dff4538f3 | ||
|
|
6507683909 | ||
|
|
c71e32970c | ||
|
|
fcf21da843 | ||
|
|
ab464fe038 | ||
|
|
fd546af2a5 | ||
|
|
acfbe202b6 | ||
|
|
29fb283daf | ||
|
|
51ef9b7fbe | ||
|
|
025d2264a2 | ||
|
|
b2284b2097 | ||
|
|
5f8267c956 | ||
|
|
cf783a5bae | ||
|
|
32e5ced814 | ||
|
|
605fadabcf | ||
|
|
e91ace7329 | ||
|
|
c87cd136d4 | ||
|
|
0d7d59609a | ||
|
|
75ed0e5906 | ||
|
|
8e3b500307 | ||
|
|
d6f77bf07e | ||
|
|
65e8209d51 | ||
|
|
aae5247caa | ||
|
|
2fedb6b774 | ||
|
|
02d18d4831 | ||
|
|
b70c2d088d | ||
|
|
b3c396683e | ||
|
|
f08874dd37 | ||
|
|
648054da9b | ||
|
|
70bf7c490c | ||
|
|
adbed5de95 | ||
|
|
fe989f0bff | ||
|
|
679e346bcb | ||
|
|
832439b336 | ||
|
|
71c2af04ec | ||
|
|
0f4261d02f | ||
|
|
23466d8eee | ||
|
|
8edbba2180 | ||
|
|
5417671332 | ||
|
|
35d7e11678 | ||
|
|
7a63ba827b | ||
|
|
71c163a8ee | ||
|
|
5d8e661807 | ||
|
|
24244e8474 | ||
|
|
fb4f9bdc40 | ||
|
|
668c46e0cf | ||
|
|
abf8fdb661 | ||
|
|
a28a04b7a0 | ||
|
|
cd9671650b | ||
|
|
00bc762bf1 | ||
|
|
9a065bce03 | ||
|
|
3b2b0bdc97 | ||
|
|
53cd6bdf15 | ||
|
|
edc97c1c07 | ||
|
|
6a24ef2263 | ||
|
|
50ba523fb4 | ||
|
|
a33325f90f | ||
|
|
a173b7159a | ||
|
|
91295d3772 | ||
|
|
9c1c04a8db | ||
|
|
51d0d0d779 | ||
|
|
9cdf627ae3 | ||
|
|
4b9c482384 | ||
|
|
b1ba807ec9 | ||
|
|
c844f153e1 | ||
|
|
4a2b02347f | ||
|
|
e8a05d1874 | ||
|
|
08c4e3fbd6 | ||
|
|
1c5292ac86 | ||
|
|
aa553ea5d8 | ||
|
|
a00bd59e27 | ||
|
|
f02c6c49ee | ||
|
|
e54e37a600 | ||
|
|
b95103cab0 | ||
|
|
9b43e49116 | ||
|
|
457538c8f6 | ||
|
|
da48f0704b | ||
|
|
cf8d953bba | ||
|
|
5f2b859e38 | ||
|
|
3187b5abda | ||
|
|
ce16b50d5f | ||
|
|
4295720770 | ||
|
|
4392df0676 | ||
|
|
4ec3b025f0 | ||
|
|
f4704181e9 | ||
|
|
0e04bea39e | ||
|
|
b54044fd00 | ||
|
|
08c69c09c8 | ||
|
|
681ea420c1 | ||
|
|
48ea54748f | ||
|
|
4b7627595a | ||
|
|
6299e5483b | ||
|
|
6118a966a6 | ||
|
|
1fac9ee1f2 | ||
|
|
1e06b2d51e | ||
|
|
f3a6ed9d61 | ||
|
|
f71cbb6f6e | ||
|
|
23ea22c741 | ||
|
|
8be65bb0ab | ||
|
|
57e2e75d24 | ||
|
|
29cd7568f5 | ||
|
|
581076a5a1 | ||
|
|
27401bb9b8 | ||
|
|
10837ce549 | ||
|
|
1dcd411d00 | ||
|
|
0533fd9227 | ||
|
|
5ce7ffc888 | ||
|
|
9e914de995 | ||
|
|
0cc653263e | ||
|
|
d2d2f278cf | ||
|
|
eb34a95ab7 | ||
|
|
eb1f6c0de6 | ||
|
|
8de79e8fb6 | ||
|
|
fe00f0c369 | ||
|
|
f9ee8583b0 | ||
|
|
a4d5f8c717 | ||
|
|
35c50f074b | ||
|
|
dcfa226509 | ||
|
|
a9fde30a58 | ||
|
|
7ceb52103e | ||
|
|
8da5d37888 | ||
|
|
95cc328b5c | ||
|
|
990c0119a7 | ||
|
|
144afee29e | ||
|
|
9665c08b59 | ||
|
|
20ee6a509d | ||
|
|
70d44b8838 | ||
|
|
b260c8b058 | ||
|
|
5991b59ba3 | ||
|
|
bc1fed0fb4 | ||
|
|
b23c364fc0 | ||
|
|
28b428c5a0 | ||
|
|
5bfc58ed64 | ||
|
|
e9a34fca7b | ||
|
|
6ce9734ddd | ||
|
|
d42797ffeb | ||
|
|
b5ebfa9cc3 | ||
|
|
79eff42c3c | ||
|
|
7022807fa3 | ||
|
|
50a301899e | ||
|
|
351db5f6ef | ||
|
|
09fe616ac5 | ||
|
|
2d7ff39ecc | ||
|
|
6e856efd0e | ||
|
|
c3c899bc85 | ||
|
|
916f3cac41 | ||
|
|
9b5f358823 | ||
|
|
22119c272d | ||
|
|
8d4c526d16 | ||
|
|
83aebb7a00 | ||
|
|
33cd5ce6c1 | ||
|
|
f22c2e768e | ||
|
|
3d7dea0606 | ||
|
|
263a421c4a | ||
|
|
401b92bdbb | ||
|
|
6a696af8f6 | ||
|
|
037d6c253b | ||
|
|
b6de79b21a | ||
|
|
52cf530356 | ||
|
|
861ded37db | ||
|
|
7a67388a97 | ||
|
|
4f60fad3f6 | ||
|
|
67efd8172a | ||
|
|
60fdf9fcb2 | ||
|
|
a606e9b7b5 | ||
|
|
65197a8e48 | ||
|
|
43f769ebac | ||
|
|
dff6eeb90e | ||
|
|
61ebdb3367 | ||
|
|
cd95d0865f | ||
|
|
b68a026627 | ||
|
|
68ccebafbf | ||
|
|
3737252d39 | ||
|
|
888a8d05c4 | ||
|
|
f25f902c20 | ||
|
|
a6ea5496b4 | ||
|
|
222424a80c | ||
|
|
74f31d7d68 | ||
|
|
5c59c8d701 | ||
|
|
30a87e3145 | ||
|
|
87f7a60f71 | ||
|
|
f7d8885257 | ||
|
|
77410dc3c3 | ||
|
|
d1acf02ee8 | ||
|
|
de0954f307 | ||
|
|
7da1e5c3e8 | ||
|
|
3c11e87197 | ||
|
|
b004706eff | ||
|
|
2247e71a52 | ||
|
|
8146e84200 | ||
|
|
1213ec2d57 | ||
|
|
30b6cca366 | ||
|
|
4dd140a887 | ||
|
|
87c555bde3 | ||
|
|
c4951b1236 | ||
|
|
0249eb1307 | ||
|
|
f0279e7f92 | ||
|
|
1a50181ace | ||
|
|
d77bc239c1 | ||
|
|
cb283f4c57 | ||
|
|
803858ab0a | ||
|
|
728fc8cbad | ||
|
|
ad05b91f89 | ||
|
|
671e6cde44 | ||
|
|
7a3ad0afba | ||
|
|
d9f1704e36 | ||
|
|
32223a818c | ||
|
|
31e13d4de3 | ||
|
|
815bd6321b | ||
|
|
9f9bd40343 | ||
|
|
2331226bb6 | ||
|
|
80ff118f0f | ||
|
|
d6eeda7136 | ||
|
|
fb92e498f0 | ||
|
|
bf8d8886fd | ||
|
|
a695726f2a | ||
|
|
6dc4172110 | ||
|
|
25a9ee8eb6 | ||
|
|
e122232761 | ||
|
|
b13eaee6b3 | ||
|
|
f0f5107a5d | ||
|
|
0832cc50a8 | ||
|
|
962a3d0c55 | ||
|
|
6934e0bce7 | ||
|
|
3492d64177 | ||
|
|
057109dcac | ||
|
|
12fa08007d | ||
|
|
3562d34555 | ||
|
|
3ca6f645d4 | ||
|
|
6694d31d07 | ||
|
|
d15edf1955 | ||
|
|
e1ce037550 | ||
|
|
f9c376a524 | ||
|
|
26a907444c | ||
|
|
5c214bf4d8 | ||
|
|
5151a5641e | ||
|
|
9513209b70 | ||
|
|
f1416ac9f7 | ||
|
|
631db56a44 | ||
|
|
7b378d36cc | ||
|
|
8ab269e1b3 | ||
|
|
7652253b8d | ||
|
|
9805319940 | ||
|
|
e1e607cba3 | ||
|
|
d74bcd3583 | ||
|
|
9c0483975c | ||
|
|
2fb85dc129 | ||
|
|
d641adc0fc | ||
|
|
a7a020f431 | ||
|
|
a08ac5a47e | ||
|
|
30e5706eaa | ||
|
|
16444c190d | ||
|
|
3d9633a56c | ||
|
|
c0e630522c | ||
|
|
9422d31f55 | ||
|
|
087c7c19af | ||
|
|
3476b35fca | ||
|
|
950d5defda | ||
|
|
c6f060a24f | ||
|
|
1716c4d6f9 | ||
|
|
cda7a60734 | ||
|
|
ed26ab801c | ||
|
|
8874a6e488 | ||
|
|
657ae44b6f | ||
|
|
01381057c5 | ||
|
|
3dc6ed5672 | ||
|
|
764b48e04a | ||
|
|
4c931967c7 | ||
|
|
a547a791ba | ||
|
|
176072801b | ||
|
|
b941c51cf7 | ||
|
|
8a9fd6846e | ||
|
|
a49355133c | ||
|
|
09cdc20440 | ||
|
|
1c0dfe47c8 | ||
|
|
66623693eb | ||
|
|
7c692444e5 | ||
|
|
4ccb4393c5 | ||
|
|
b2e540b114 | ||
|
|
a5d1165c54 | ||
|
|
aa321e06dd | ||
|
|
8b84ac8a6c | ||
|
|
6c07fbfc12 | ||
|
|
04a478a5ad | ||
|
|
acfa186d44 | ||
|
|
3db504c470 | ||
|
|
3e5955be44 | ||
|
|
f1afbf2c0f | ||
|
|
20c559382d | ||
|
|
a3f1c02347 | ||
|
|
f5945d429e | ||
|
|
a3eced53bb | ||
|
|
20686cc66a | ||
|
|
5608fa32f7 | ||
|
|
a0c5defda6 | ||
|
|
25a3a09d5f | ||
|
|
593301146e | ||
|
|
5715ddc361 | ||
|
|
09ddde177c | ||
|
|
ef18b173cd | ||
|
|
ac4e88e0d2 | ||
|
|
3e82cd7dd4 | ||
|
|
b1f2025558 | ||
|
|
57ca5fea81 | ||
|
|
0ce018cf97 | ||
|
|
15a8710e69 | ||
|
|
cae75dcb6d | ||
|
|
d5e2b70b71 | ||
|
|
05b9fd04c6 | ||
|
|
4650989774 | ||
|
|
bcc77efb88 | ||
|
|
39c1637030 | ||
|
|
6d3028f213 | ||
|
|
b2969b2faf | ||
|
|
d07350e4a4 | ||
|
|
12df55c3d4 | ||
|
|
85b541bfd9 | ||
|
|
a9c6d6a80c | ||
|
|
32ad8aaa4e | ||
|
|
3d8e6aead2 | ||
|
|
2747600a3a | ||
|
|
b7ef63230b | ||
|
|
b4d6c8f37b | ||
|
|
6a907348b4 | ||
|
|
18ab8749ff | ||
|
|
a1ed5cdffc | ||
|
|
760d463bf5 | ||
|
|
5ed2a4e8bb | ||
|
|
60e95ef3bd | ||
|
|
5b648be2a5 | ||
|
|
0149171e1a | ||
|
|
b24caa1e06 | ||
|
|
8fa71afb72 | ||
|
|
309a3d5396 | ||
|
|
afafb3ba32 | ||
|
|
311835a231 | ||
|
|
1f9db0a8fe | ||
|
|
d6c9327aef | ||
|
|
0091863888 | ||
|
|
051ce5e09f | ||
|
|
6146b773cf | ||
|
|
8a4341fec4 | ||
|
|
154b7d256c | ||
|
|
548b0d0b53 | ||
|
|
e59361425f | ||
|
|
713e0f4260 | ||
|
|
8a1bf8cd86 | ||
|
|
f474953b51 | ||
|
|
d5ded53f05 | ||
|
|
82bcd391cd | ||
|
|
058689709f | ||
|
|
23c9fa0b56 | ||
|
|
eb29f10634 | ||
|
|
d5a9e3114a | ||
|
|
7417729482 | ||
|
|
d5c407c098 | ||
|
|
a1256818d9 | ||
|
|
689cec14aa | ||
|
|
04225826f6 | ||
|
|
86787e60f3 | ||
|
|
0c3ec9254d | ||
|
|
c0770402ce | ||
|
|
d7c98062ce | ||
|
|
497c0b7a47 | ||
|
|
d588dde007 | ||
|
|
3de0a3adfc | ||
|
|
b7ebe03ca8 | ||
|
|
a7fb88e293 | ||
|
|
6e1b1e3ed7 | ||
|
|
a66538fe55 | ||
|
|
b2913be086 | ||
|
|
602e65d898 | ||
|
|
338c9c1e0c | ||
|
|
9fac57b713 | ||
|
|
761804b17a | ||
|
|
c47401d729 | ||
|
|
aab52f1e8d | ||
|
|
4d2e44d64b | ||
|
|
41267a42f7 | ||
|
|
568434d0fa | ||
|
|
2c1bbf1ac6 | ||
|
|
1e97dcbb4c | ||
|
|
103c82bc2c | ||
|
|
f3fee5f4fb | ||
|
|
564feadc0d | ||
|
|
f05e0f3a81 | ||
|
|
cb26bc3871 | ||
|
|
f6251eef27 | ||
|
|
a9d6ef5990 | ||
|
|
60da55d6dd | ||
|
|
05147c016c | ||
|
|
f7655f3abe | ||
|
|
62b3509009 | ||
|
|
d817889255 | ||
|
|
d4ddcdd91e | ||
|
|
0bda4c2f76 | ||
|
|
da2279c295 | ||
|
|
be8da851a6 | ||
|
|
d4459a48b9 | ||
|
|
197bd2c3e1 | ||
|
|
d4ea9568ac | ||
|
|
97968213ff | ||
|
|
995885962d | ||
|
|
ddc1928bbb | ||
|
|
056a93f0c9 | ||
|
|
3d9845ff6d | ||
|
|
b615463981 | ||
|
|
d3540e82ff | ||
|
|
15ec8ba6a3 | ||
|
|
db12eab083 | ||
|
|
7d8c77a4b2 | ||
|
|
7c8c479b96 | ||
|
|
e29ae1cc91 | ||
|
|
089dd5b4d7 | ||
|
|
06285b599c | ||
|
|
1b6395b4e4 | ||
|
|
2236f74a55 | ||
|
|
43c9ab1faa | ||
|
|
b56f9b3b16 | ||
|
|
303396dfc3 | ||
|
|
075a53ced0 | ||
|
|
18ccb38824 | ||
|
|
c97831963b | ||
|
|
7c3dc076d2 | ||
|
|
b859347ecd | ||
|
|
ea87193c8f | ||
|
|
c1381b9ebd | ||
|
|
227cd93e67 | ||
|
|
f68f8e5547 | ||
|
|
943e6f02d4 | ||
|
|
01298a7b01 | ||
|
|
46aee8274f | ||
|
|
f76a2eeb9e | ||
|
|
3b7c0be842 | ||
|
|
49378a9145 | ||
|
|
139f61d03e | ||
|
|
f10d04591d | ||
|
|
e65d9e8ccd | ||
|
|
1fc3c0af70 | ||
|
|
e4751e34ae | ||
|
|
e922169e72 | ||
|
|
2b851ef6ae | ||
|
|
5f4b93aba2 | ||
|
|
b66d1a5dab | ||
|
|
867525eff8 | ||
|
|
7dcc981a2c | ||
|
|
38fed8a61e | ||
|
|
31c2c8a7a3 | ||
|
|
a081d28e36 | ||
|
|
93bb4f84f9 | ||
|
|
72e04edd7f | ||
|
|
b0d05522c0 | ||
|
|
f6119639bb | ||
|
|
fc57a9daa4 | ||
|
|
d8f44d7b1b | ||
|
|
efe2e90a03 | ||
|
|
45f9dee89a | ||
|
|
cc73d2c2f2 | ||
|
|
b1f789dddd | ||
|
|
d3e9dbf6a9 | ||
|
|
44529620ad | ||
|
|
7a9673dc37 | ||
|
|
27bcf67c0c | ||
|
|
7fde56b8ac | ||
|
|
6b614a2d6a | ||
|
|
1e1509fbf5 | ||
|
|
a3e67f8e4b | ||
|
|
028b25cfe8 | ||
|
|
2555e082d6 | ||
|
|
f8fa721c72 | ||
|
|
a7e0127793 | ||
|
|
603f60d86a | ||
|
|
6febf6b17c | ||
|
|
53aaf766dd | ||
|
|
4fa8d02b08 | ||
|
|
efa423c8ad | ||
|
|
43fb0d80f1 | ||
|
|
b25ace14e5 | ||
|
|
8734751bc4 | ||
|
|
5559a1edb0 | ||
|
|
bf503354f3 | ||
|
|
7b10441a28 | ||
|
|
994e396c00 | ||
|
|
6e22ee9061 | ||
|
|
b5fb0f60b0 | ||
|
|
a7fe69ed6b | ||
|
|
7f05298172 | ||
|
|
92a2505056 | ||
|
|
aae9d2fcf6 | ||
|
|
b59e928589 | ||
|
|
1db08b3b0e | ||
|
|
2cf3c105a1 | ||
|
|
505e4e8176 | ||
|
|
49a9973548 | ||
|
|
18af9d734d | ||
|
|
3e22aafea8 | ||
|
|
434db4347b | ||
|
|
b2c3b405b1 | ||
|
|
4bc8f6a6b9 | ||
|
|
4534d17d79 | ||
|
|
f88dde2f60 | ||
|
|
f8982ddaf8 | ||
|
|
784cd8c6f1 | ||
|
|
c3ab8f12cf | ||
|
|
b5adb7babc | ||
|
|
62c809a596 | ||
|
|
d2fe4426c1 | ||
|
|
984f0ca12c | ||
|
|
9d3eba9ea4 | ||
|
|
323f81eaba | ||
|
|
13e635b74e | ||
|
|
8d0e25fd82 | ||
|
|
20eaddee58 | ||
|
|
30b1bd85d9 | ||
|
|
09cce094d1 | ||
|
|
33a208e3c4 | ||
|
|
dd4c4fba80 | ||
|
|
a17c40ad09 | ||
|
|
9d73e606ac | ||
|
|
da12360105 | ||
|
|
ee1ae627a3 | ||
|
|
137a8dcfdf | ||
|
|
b2d753ed86 | ||
|
|
6e40102f26 | ||
|
|
511fe23b8a | ||
|
|
e433895873 | ||
|
|
5572195af9 | ||
|
|
cb956cd35b | ||
|
|
b551c7738e | ||
|
|
3d45c4dbd8 | ||
|
|
8681489cb7 | ||
|
|
ed328766b2 | ||
|
|
fb852ee6eb | ||
|
|
a6ee708b90 | ||
|
|
c9398e7b8a | ||
|
|
b591e35442 | ||
|
|
e50e15dc04 | ||
|
|
d4e65d8607 | ||
|
|
63ced7da7c | ||
|
|
03868d05db | ||
|
|
186374525a | ||
|
|
f116585c2a | ||
|
|
f4945729bc | ||
|
|
a3c76232c8 | ||
|
|
5bc41118e2 | ||
|
|
9445a96b3a | ||
|
|
a5761069ca | ||
|
|
2d4bfe183c | ||
|
|
bf4115a80f | ||
|
|
b2e84dfd29 | ||
|
|
004f6fa4d6 | ||
|
|
cefd4cd647 | ||
|
|
fd2ae61e3e | ||
|
|
7cda61ca01 | ||
|
|
98e1d52eaa | ||
|
|
1d09beb8a7 | ||
|
|
d44cce2928 | ||
|
|
51b3d4d06e | ||
|
|
a17ddaa951 | ||
|
|
9bd925226c | ||
|
|
e34ada3ff1 | ||
|
|
1ec1ff0773 | ||
|
|
7f935717db | ||
|
|
5b1d3a0c51 | ||
|
|
484f340023 | ||
|
|
ab0cf025c5 | ||
|
|
b384d9ea88 | ||
|
|
bb2094c4de | ||
|
|
6708121ba6 | ||
|
|
46a9bb3f7d | ||
|
|
62498d0935 | ||
|
|
c70184fbed | ||
|
|
4d2cb45f9f | ||
|
|
e5605cc6fe | ||
|
|
f7331a2e41 | ||
|
|
838271a14f | ||
|
|
b6b23907ed | ||
|
|
b240b9a088 | ||
|
|
b3a484f1e5 | ||
|
|
f3042ddf37 | ||
|
|
54816231e9 | ||
|
|
1c168d7d62 | ||
|
|
063c4904ff | ||
|
|
fefcbb147b | ||
|
|
53d48e8f61 | ||
|
|
ce5bce5cdc | ||
|
|
3597685b23 | ||
|
|
dc097c7230 | ||
|
|
b148781e4b | ||
|
|
5d8826e8ef | ||
|
|
39a51c7fbb | ||
|
|
129edde338 | ||
|
|
93cc278eee | ||
|
|
c34198264a | ||
|
|
054b12325d | ||
|
|
0f7a126828 | ||
|
|
7ff72fb981 | ||
|
|
0fe99595a9 | ||
|
|
b2ff628cec | ||
|
|
86a3bd6db8 | ||
|
|
73a5357d0e | ||
|
|
2faf507c0d | ||
|
|
cf124d97b8 | ||
|
|
482c0766af | ||
|
|
7e5a26fde5 | ||
|
|
e85af2f732 | ||
|
|
4df81008bc | ||
|
|
803dc69ccd | ||
|
|
42308cca5b | ||
|
|
ea991a4eee | ||
|
|
04db2d4410 | ||
|
|
076c1ed2ee | ||
|
|
75aa4ea325 | ||
|
|
e54be07dc0 | ||
|
|
d439d00e25 | ||
|
|
c4bea793af | ||
|
|
b53dcb932e | ||
|
|
371428d6ab | ||
|
|
1970d0c00f | ||
|
|
1dd7aa935f | ||
|
|
6b40f9d95c | ||
|
|
b3717d0396 | ||
|
|
82ba95833b | ||
|
|
28384df702 | ||
|
|
aee06f4738 | ||
|
|
ab282765d4 | ||
|
|
5d464badc8 | ||
|
|
68282682de | ||
|
|
2696b04138 | ||
|
|
31dc37150b | ||
|
|
e66d9d0add | ||
|
|
067bde321b | ||
|
|
84ec364ac2 | ||
|
|
32990856e3 | ||
|
|
a1bd5c9ea0 | ||
|
|
51f0e7879a | ||
|
|
0bdb90d133 | ||
|
|
e98c11ff89 | ||
|
|
8f84d7089c | ||
|
|
b0712c4186 | ||
|
|
8f92383ce4 | ||
|
|
c571fc9e24 | ||
|
|
05126bc6dc | ||
|
|
de56a370c6 | ||
|
|
daf189bf4b | ||
|
|
d95ec7e6b9 | ||
|
|
ac235bcabb | ||
|
|
ab4b3a50ee | ||
|
|
7f0fb2a2b6 | ||
|
|
ade1edfdfc | ||
|
|
4723faa95f | ||
|
|
93f83b0fcb | ||
|
|
8f84f7c0a5 | ||
|
|
48e4101f1c | ||
|
|
e6bb79f4c1 | ||
|
|
0bef3464f5 | ||
|
|
3c038a8c50 | ||
|
|
b8eb751316 | ||
|
|
5332db1eca | ||
|
|
9deda962aa | ||
|
|
c53434539b | ||
|
|
7f179deaf3 | ||
|
|
da29fa139f | ||
|
|
1d8a562fd9 | ||
|
|
0dbf97afab | ||
|
|
e5720fba3e | ||
|
|
498ac00b92 | ||
|
|
226a2dfe04 | ||
|
|
7e9a233296 | ||
|
|
ae311c838e | ||
|
|
de769db3bc | ||
|
|
5fa96c7fd1 | ||
|
|
2ee0c9a67a | ||
|
|
347af0210e | ||
|
|
d8455d687c | ||
|
|
34fef4c4e7 | ||
|
|
18bb373219 | ||
|
|
2f74f9ca15 | ||
|
|
5775c390f3 | ||
|
|
80826b8712 | ||
|
|
664d18cf58 | ||
|
|
bc2cddcb11 | ||
|
|
4949bda606 | ||
|
|
b4f75ad042 | ||
|
|
af4d11e17b | ||
|
|
e8f4a8b739 | ||
|
|
fae6693f8f | ||
|
|
0646ecdec4 | ||
|
|
544c89460f | ||
|
|
15089f5b01 | ||
|
|
8ef510035d | ||
|
|
864b1f754c | ||
|
|
883a2ebac0 | ||
|
|
bbe5b2e42c | ||
|
|
1b316b111f | ||
|
|
d0720620e8 | ||
|
|
cf4947d898 | ||
|
|
b5a8efa16b | ||
|
|
b38ae783b9 | ||
|
|
cbd8346c93 | ||
|
|
c0bfb979fd | ||
|
|
7c5a36ce38 | ||
|
|
fc729b0cbb | ||
|
|
0b81a25fda | ||
|
|
011db443ba | ||
|
|
b73e240f4d | ||
|
|
6de77ee310 | ||
|
|
0a8293a2d6 | ||
|
|
d0ad5dd4cf | ||
|
|
ab342ce904 | ||
|
|
140250ef03 | ||
|
|
ed90275370 | ||
|
|
e8b28faaf1 | ||
|
|
afcc7b6a56 | ||
|
|
e27a507a28 | ||
|
|
207f701f0a | ||
|
|
dd8cb1c7fb | ||
|
|
ccf93b8c23 | ||
|
|
4c6f3ead60 | ||
|
|
2d81d359b8 | ||
|
|
1f96d5d957 | ||
|
|
033f45d4da | ||
|
|
ae2c514ee7 | ||
|
|
80ddb81fac | ||
|
|
4bc29200be | ||
|
|
55c55fb705 | ||
|
|
0e2ab75bb0 | ||
|
|
128d20b290 | ||
|
|
ad9cc40b97 | ||
|
|
e0d3ac01b0 | ||
|
|
0f87adad7b | ||
|
|
9481461145 | ||
|
|
accd23eddc | ||
|
|
7c202b6069 | ||
|
|
e93b98ff98 | ||
|
|
b1ac2cf821 | ||
|
|
bfd1fecc2a | ||
|
|
c622a9b4be | ||
|
|
ade66cd8f4 | ||
|
|
397030b5a6 | ||
|
|
adc50f40b1 | ||
|
|
32d92d9b75 | ||
|
|
18f37981bb | ||
|
|
a8711bc54a | ||
|
|
eac2613743 | ||
|
|
4a0c18c4cd | ||
|
|
e376a3a28e | ||
|
|
a6bdff53c9 | ||
|
|
b5c5483ced | ||
|
|
601422e92b | ||
|
|
dbbe5e59ae | ||
|
|
b96dd6d36d | ||
|
|
e6b6e175b8 | ||
|
|
2ff549d458 | ||
|
|
a1230500fd | ||
|
|
17db87e042 | ||
|
|
42d2986cb8 | ||
|
|
cc054a13e2 | ||
|
|
60b4dbfdcd | ||
|
|
c446a0f222 | ||
|
|
f98e96cf1b | ||
|
|
3102777a71 | ||
|
|
ed95f382cf | ||
|
|
7f18c0fb77 | ||
|
|
52e4f93760 | ||
|
|
0167304300 | ||
|
|
7aaca3d486 | ||
|
|
bf3306fbc8 | ||
|
|
e375a8460b | ||
|
|
ff88900982 | ||
|
|
7f293bfda3 | ||
|
|
99de0a76a5 | ||
|
|
47ffb9c70d | ||
|
|
1231f926ea | ||
|
|
e05e888fca | ||
|
|
03580f5be8 | ||
|
|
90dabfea30 | ||
|
|
c8d7b1aba0 | ||
|
|
6065ef3a54 | ||
|
|
86c7eefc91 | ||
|
|
f7b12f0695 | ||
|
|
0c46ad91ef | ||
|
|
96cab75ccd | ||
|
|
a7138b7213 | ||
|
|
11590e33d3 | ||
|
|
a3a92d2d13 | ||
|
|
2088036521 | ||
|
|
7d0e16d1b6 | ||
|
|
35c77ef99c | ||
|
|
9244d03cf9 | ||
|
|
a50a461675 | ||
|
|
f78911666e | ||
|
|
f1e6585726 | ||
|
|
b8f862ac46 | ||
|
|
94a572aee6 | ||
|
|
a9e7a33473 | ||
|
|
5621719eef | ||
|
|
a27a07956f | ||
|
|
f54f60c31c | ||
|
|
f767fd5075 | ||
|
|
8d5ffb7262 | ||
|
|
84f1edab18 | ||
|
|
0063ae6512 | ||
|
|
1b25ea714d |
27
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
27
.github/ISSUE_TEMPLATE/feature.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Feature Request
|
||||||
|
description: Request a new feature
|
||||||
|
title: "[Feature Request]: "
|
||||||
|
labels: ["enhancement"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for your request this will not gurantee that we will implement it, but it will be reviewed.
|
||||||
|
- type: dropdown
|
||||||
|
id: soc
|
||||||
|
attributes:
|
||||||
|
label: Platform
|
||||||
|
description: What device platform will support your feature?
|
||||||
|
multiple: true
|
||||||
|
options:
|
||||||
|
- NRF52
|
||||||
|
- ESP32
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: body
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: Please provide details about your enhancement.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
41
.github/actions/setup-base/action.yml
vendored
Normal file
41
.github/actions/setup-base/action.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: 'Setup Build Base Composite Action'
|
||||||
|
description: 'Base build actions for Meshtastic Platform IO steps'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
submodules: "recursive"
|
||||||
|
ref: ${{github.event.pull_request.head.ref}}
|
||||||
|
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||||
|
|
||||||
|
- name: Install cppcheck
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sudo apt-get install -y cppcheck
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
|
||||||
|
- name: Cache python libs
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: cache-pip # needed in if test
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pip
|
||||||
|
key: ${{ runner.os }}-pip
|
||||||
|
|
||||||
|
- name: Upgrade python tools
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -U platformio adafruit-nrfutil
|
||||||
|
pip install -U meshtastic --pre
|
||||||
|
|
||||||
|
- name: Upgrade platformio
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pio upgrade
|
||||||
54
.github/workflows/build_esp32.yml
vendored
Normal file
54
.github/workflows/build_esp32.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: Build ESP32
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
board:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-esp32:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build base
|
||||||
|
id: base
|
||||||
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
|
- name: Pull web ui
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@master
|
||||||
|
with:
|
||||||
|
repo: "meshtastic/web"
|
||||||
|
file: "build.tar"
|
||||||
|
target: "build.tar"
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Unpack web ui
|
||||||
|
run: |
|
||||||
|
tar -xf build.tar -C data/static
|
||||||
|
rm build.tar
|
||||||
|
|
||||||
|
- name: Build ESP32
|
||||||
|
run: bin/build-esp32.sh ${{ inputs.board }}
|
||||||
|
|
||||||
|
- name: Pull OTA Firmware
|
||||||
|
uses: dsaltares/fetch-gh-release-asset@master
|
||||||
|
with:
|
||||||
|
repo: "meshtastic/firmware-ota"
|
||||||
|
file: "firmware.bin"
|
||||||
|
target: "release/bleota.bin"
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
shell: bash
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
||||||
|
path: |
|
||||||
|
release/*.bin
|
||||||
|
release/*.elf
|
||||||
33
.github/workflows/build_nrf52.yml
vendored
Normal file
33
.github/workflows/build_nrf52.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: Build NRF52
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
board:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-nrf52:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build base
|
||||||
|
id: base
|
||||||
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
|
- name: Build NRF52
|
||||||
|
run: bin/build-nrf52.sh ${{ inputs.board }}
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
||||||
|
path: |
|
||||||
|
release/*.uf2
|
||||||
|
release/*.elf
|
||||||
|
release/*.zip
|
||||||
32
.github/workflows/build_rpi2040.yml
vendored
Normal file
32
.github/workflows/build_rpi2040.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
name: Build RPI2040
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
board:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-rpi2040:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Build base
|
||||||
|
id: base
|
||||||
|
uses: ./.github/actions/setup-base
|
||||||
|
|
||||||
|
- name: Build Raspberry Pi 2040
|
||||||
|
run: ./bin/build-rpi2040.sh ${{ inputs.board }}
|
||||||
|
|
||||||
|
- name: Get release version string
|
||||||
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
|
||||||
|
- name: Store binaries as an artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: firmware-${{ inputs.board }}-${{ steps.version.outputs.version }}.zip
|
||||||
|
path: |
|
||||||
|
release/*.uf2
|
||||||
|
release/*.elf
|
||||||
323
.github/workflows/main_matrix.yml
vendored
323
.github/workflows/main_matrix.yml
vendored
@@ -2,18 +2,17 @@ name: CI
|
|||||||
on:
|
on:
|
||||||
# # Triggers the workflow on push but only for the master branch
|
# # Triggers the workflow on push but only for the master branch
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master, develop]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
- "**.yml"
|
|
||||||
- "version.properties"
|
- "version.properties"
|
||||||
|
|
||||||
# Note: This is different from "pull_request". Need to specify ref when doing checkouts.
|
# Note: This is different from "pull_request". Need to specify ref when doing checkouts.
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
branches: [master]
|
branches: [master, develop]
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- "**.md"
|
- "**.md"
|
||||||
- "**.yml"
|
#- "**.yml"
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
@@ -24,58 +23,22 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- board: rak11200
|
- board: rak11200
|
||||||
- board: tlora-v2
|
|
||||||
- board: tlora-v1
|
|
||||||
- board: tlora_v1_3
|
|
||||||
- board: tlora-v2-1-1.6
|
- board: tlora-v2-1-1.6
|
||||||
- board: tbeam
|
- board: tbeam
|
||||||
- board: heltec-v1
|
|
||||||
- board: heltec-v2.0
|
|
||||||
- board: heltec-v2.1
|
- board: heltec-v2.1
|
||||||
- board: tbeam0.7
|
|
||||||
- board: meshtastic-diy-v1
|
- board: meshtastic-diy-v1
|
||||||
- board: rak4631
|
- board: rak4631
|
||||||
- board: rak4631_eink
|
|
||||||
- board: t-echo
|
- board: t-echo
|
||||||
- board: nano-g1
|
|
||||||
- board: station-g1
|
- board: station-g1
|
||||||
- board: m5stack-core
|
|
||||||
- board: m5stack-coreink
|
- board: m5stack-coreink
|
||||||
# - board: pico
|
- board: tbeam-s3-core
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v3
|
- name: Build base
|
||||||
with:
|
id: base
|
||||||
submodules: "recursive"
|
uses: ./.github/actions/setup-base
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Install cppcheck
|
|
||||||
run: |
|
|
||||||
sudo apt-get install -y cppcheck
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools and install platformio
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Check ${{ matrix.board }}
|
- name: Check ${{ matrix.board }}
|
||||||
run: bin/check-all.sh ${{ matrix.board }}
|
run: bin/check-all.sh ${{ matrix.board }}
|
||||||
@@ -94,71 +57,19 @@ jobs:
|
|||||||
- board: heltec-v1
|
- board: heltec-v1
|
||||||
- board: heltec-v2.0
|
- board: heltec-v2.0
|
||||||
- board: heltec-v2.1
|
- board: heltec-v2.1
|
||||||
|
- board: heltec-v3
|
||||||
|
- board: heltec-wsl-v3
|
||||||
- board: tbeam0.7
|
- board: tbeam0.7
|
||||||
- board: meshtastic-diy-v1
|
- board: meshtastic-diy-v1
|
||||||
|
- board: meshtastic-dr-dev
|
||||||
- board: nano-g1
|
- board: nano-g1
|
||||||
- board: station-g1
|
- board: station-g1
|
||||||
- board: m5stack-core
|
- board: m5stack-core
|
||||||
- board: m5stack-coreink
|
- board: m5stack-coreink
|
||||||
|
- board: tbeam-s3-core
|
||||||
runs-on: ubuntu-latest
|
uses: ./.github/workflows/build_esp32.yml
|
||||||
steps:
|
with:
|
||||||
- name: Checkout code
|
board: ${{ matrix.board }}
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio adafruit-nrfutil littlefs-python
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Pull web ui
|
|
||||||
uses: dsaltares/fetch-gh-release-asset@master
|
|
||||||
with:
|
|
||||||
repo: "meshtastic/meshtastic-web"
|
|
||||||
file: "build.tar"
|
|
||||||
target: "build.tar"
|
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Unpack web ui
|
|
||||||
run: |
|
|
||||||
tar -xf build.tar -C data/static
|
|
||||||
rm build.tar
|
|
||||||
|
|
||||||
- name: Build ESP32
|
|
||||||
run: bin/build-esp32.sh ${{ matrix.board }}
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
path: |
|
|
||||||
release/*.bin
|
|
||||||
release/*.elf
|
|
||||||
retention-days: 90
|
|
||||||
|
|
||||||
build-nrf52:
|
build-nrf52:
|
||||||
strategy:
|
strategy:
|
||||||
@@ -170,52 +81,10 @@ jobs:
|
|||||||
- board: rak4631_eink
|
- board: rak4631_eink
|
||||||
- board: t-echo
|
- board: t-echo
|
||||||
- board: pca10059_diy_eink
|
- board: pca10059_diy_eink
|
||||||
|
- board: feather_diy
|
||||||
runs-on: ubuntu-latest
|
uses: ./.github/workflows/build_nrf52.yml
|
||||||
steps:
|
with:
|
||||||
- name: Checkout code
|
board: ${{ matrix.board }}
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio adafruit-nrfutil
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Build NRF52
|
|
||||||
run: bin/build-nrf52.sh ${{ matrix.board }}
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
path: |
|
|
||||||
release/*.uf2
|
|
||||||
release/*.elf
|
|
||||||
retention-days: 90
|
|
||||||
|
|
||||||
build-rpi2040:
|
build-rpi2040:
|
||||||
strategy:
|
strategy:
|
||||||
@@ -224,84 +93,17 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- board: pico
|
- board: pico
|
||||||
|
uses: ./.github/workflows/build_rpi2040.yml
|
||||||
runs-on: ubuntu-latest
|
with:
|
||||||
steps:
|
board: ${{ matrix.board }}
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
submodules: "recursive"
|
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio adafruit-nrfutil
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
- name: Build Raspberry Pi 2040
|
|
||||||
run: ./bin/build-rpi2040.sh ${{ matrix.board }}
|
|
||||||
|
|
||||||
- name: Get release version string
|
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
|
||||||
id: version
|
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: firmware-${{ matrix.board }}-${{ steps.version.outputs.version }}.zip
|
|
||||||
path: |
|
|
||||||
release/*.uf2
|
|
||||||
release/*.elf
|
|
||||||
retention-days: 90
|
|
||||||
|
|
||||||
build-native:
|
build-native:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v3
|
||||||
uses: actions/checkout@v3
|
- name: Build base
|
||||||
with:
|
id: base
|
||||||
submodules: "recursive"
|
uses: ./.github/actions/setup-base
|
||||||
ref: ${{github.event.pull_request.head.ref}}
|
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.x
|
|
||||||
|
|
||||||
- name: Cache python libs
|
|
||||||
uses: actions/cache@v1
|
|
||||||
id: cache-pip # needed in if test
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip
|
|
||||||
|
|
||||||
- name: Upgrade python tools
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -U platformio adafruit-nrfutil
|
|
||||||
pip install -U --pre meshtastic
|
|
||||||
|
|
||||||
- name: Upgrade platformio
|
|
||||||
run: |
|
|
||||||
pio upgrade
|
|
||||||
|
|
||||||
# We now run integration test before other build steps (to quickly see runtime failures)
|
# We now run integration test before other build steps (to quickly see runtime failures)
|
||||||
- name: Build for native
|
- name: Build for native
|
||||||
@@ -317,19 +119,37 @@ jobs:
|
|||||||
run: bin/build-native.sh
|
run: bin/build-native.sh
|
||||||
|
|
||||||
- name: Get release version string
|
- name: Get release version string
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
id: version
|
id: version
|
||||||
|
|
||||||
- name: Store binaries as an artifact
|
- name: Store binaries as an artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: firmware-native-${{ steps.version.outputs.version }}.zip
|
name: firmware-native-${{ steps.version.outputs.version }}.zip
|
||||||
path: |
|
path: |
|
||||||
release/meshtasticd_linux_amd64
|
|
||||||
release/device-*.sh
|
release/device-*.sh
|
||||||
release/device-*.bat
|
release/device-*.bat
|
||||||
retention-days: 90
|
|
||||||
|
- name: Docker login
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: meshtastic
|
||||||
|
password: ${{ secrets.DOCKER_TOKEN }}
|
||||||
|
|
||||||
|
- name: Docker setup
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Docker build and push
|
||||||
|
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: meshtastic/device-simulator:latest
|
||||||
|
|
||||||
after-checks:
|
after-checks:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [check]
|
needs: [check]
|
||||||
@@ -350,30 +170,30 @@ jobs:
|
|||||||
ref: ${{github.event.pull_request.head.ref}}
|
ref: ${{github.event.pull_request.head.ref}}
|
||||||
repository: ${{github.event.pull_request.head.repo.full_name}}
|
repository: ${{github.event.pull_request.head.repo.full_name}}
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ./
|
path: ./
|
||||||
|
|
||||||
- name: Get release version string
|
- name: Get release version string
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
id: version
|
id: version
|
||||||
|
|
||||||
- name: Move files up
|
- name: Move files up
|
||||||
run: mv -b -t ./ ./*tbeam-*/littlefs*.bin ./*tbeam-*/system-info.bin ./**/firmware*.bin ./**/*.uf2 ./**/*.elf ./**/meshtasticd_linux_amd64 ./*native*/*device-*.sh ./*native*/*device-*.bat
|
run: mv -b -t ./ ./*tbeam-2*/littlefs*.bin ./*tbeam-2*/bleota.bin ./**/firmware*.bin ./*t-echo*/Meshtastic_nRF52_factory_erase.uf2 ./**/firmware-*.uf2 ./**/firmware-*-ota.zip ./**/*.elf ./*native*/*device-*.sh ./*native*/*device-*.bat
|
||||||
|
|
||||||
- name: Repackage in single firmware zip
|
- name: Repackage in single firmware zip
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ steps.version.outputs.version }}
|
name: firmware-${{ steps.version.outputs.version }}
|
||||||
path: |
|
path: |
|
||||||
./*.bin
|
./*.bin
|
||||||
./*.uf2
|
./*.uf2
|
||||||
./meshtasticd_linux_amd64
|
./firmware-*-ota.zip
|
||||||
./device-*.sh
|
./device-*.sh
|
||||||
./device-*.bat
|
./device-*.bat
|
||||||
retention-days: 90
|
retention-days: 90
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ steps.version.outputs.version }}
|
name: firmware-${{ steps.version.outputs.version }}
|
||||||
path: ./output
|
path: ./output
|
||||||
@@ -381,21 +201,21 @@ jobs:
|
|||||||
# For diagnostics
|
# For diagnostics
|
||||||
- name: Show artifacts
|
- name: Show artifacts
|
||||||
run: ls -lR
|
run: ls -lR
|
||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{ steps.version.outputs.version }}.zip ./output
|
||||||
|
|
||||||
- name: Repackage in single elfs zip
|
- name: Repackage in single elfs zip
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
||||||
path: ./*.elf
|
path: ./*.elf
|
||||||
retention-days: 90
|
retention-days: 30
|
||||||
|
|
||||||
- name: Create request artifacts
|
- name: Create request artifacts
|
||||||
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request_target' || github.event_name == 'pull_request' }}
|
||||||
@@ -415,37 +235,37 @@ jobs:
|
|||||||
needs: [gather-artifacts, after-checks]
|
needs: [gather-artifacts, after-checks]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.x
|
python-version: 3.x
|
||||||
|
|
||||||
- name: Get release version string
|
- name: Get release version string
|
||||||
run: echo "::set-output name=version::$(./bin/buildinfo.py long)"
|
run: echo "version=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
|
||||||
id: version
|
id: version
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: firmware-${{ steps.version.outputs.version }}
|
name: firmware-${{ steps.version.outputs.version }}
|
||||||
path: ./output
|
path: ./output
|
||||||
|
|
||||||
- name: Device scripts permissions
|
- name: Device scripts permissions
|
||||||
run: |
|
run: |
|
||||||
chmod +x ./output/device-install.sh
|
chmod +x ./output/device-install.sh
|
||||||
chmod +x ./output/device-update.sh
|
chmod +x ./output/device-update.sh
|
||||||
|
|
||||||
- name: Zip firmware
|
- name: Zip firmware
|
||||||
run: zip -j -r ./firmware-${{ steps.version.outputs.version }}.zip ./output
|
run: zip -j -9 -r ./firmware-${{ steps.version.outputs.version }}.zip ./output
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
name: debug-elfs-${{ steps.version.outputs.version }}.zip
|
||||||
path: ./elfs
|
path: ./elfs
|
||||||
|
|
||||||
- name: Zip Elfs
|
- name: Zip Elfs
|
||||||
run: zip -j -r ./debug-elfs-${{ steps.version.outputs.version }}.zip ./elfs
|
run: zip -j -9 -r ./debug-elfs-${{ steps.version.outputs.version }}.zip ./elfs
|
||||||
|
|
||||||
# For diagnostics
|
# For diagnostics
|
||||||
- name: Show artifacts
|
- name: Show artifacts
|
||||||
@@ -457,7 +277,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
draft: true
|
draft: true
|
||||||
prerelease: true
|
prerelease: true
|
||||||
release_name: Meshtastic Device ${{ steps.version.outputs.version }} alpha - Public Preview
|
release_name: Meshtastic Firmware ${{ steps.version.outputs.version }}
|
||||||
tag_name: v${{ steps.version.outputs.version }}
|
tag_name: v${{ steps.version.outputs.version }}
|
||||||
body: |
|
body: |
|
||||||
Autogenerated by github action, developer should edit as required before publishing...
|
Autogenerated by github action, developer should edit as required before publishing...
|
||||||
@@ -487,10 +307,9 @@ jobs:
|
|||||||
- name: Bump version.properties
|
- name: Bump version.properties
|
||||||
run: >-
|
run: >-
|
||||||
bin/bump_version.py
|
bin/bump_version.py
|
||||||
|
|
||||||
- name: Create version.properties pull request
|
- name: Create version.properties pull request
|
||||||
uses: peter-evans/create-pull-request@v3
|
uses: peter-evans/create-pull-request@v3
|
||||||
with:
|
with:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
version.properties
|
version.properties
|
||||||
|
|
||||||
|
|||||||
40
.github/workflows/sec_sast_flawfinder.yml
vendored
Normal file
40
.github/workflows/sec_sast_flawfinder.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
name: Flawfinder Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master, develop]
|
||||||
|
paths-ignore:
|
||||||
|
- "**.md"
|
||||||
|
- "version.properties"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
flawfinder:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Flawfinder
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# step 1
|
||||||
|
- name: clone application source code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# step 2
|
||||||
|
- name: flawfinder_scan
|
||||||
|
uses: david-a-wheeler/flawfinder@2.0.19
|
||||||
|
with:
|
||||||
|
arguments: '--sarif ./'
|
||||||
|
output: 'flawfinder_report.sarif'
|
||||||
|
|
||||||
|
# step 3
|
||||||
|
- name: save report as pipeline artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: flawfinder_report.sarif
|
||||||
|
path: flawfinder_report.sarif
|
||||||
|
|
||||||
|
# step 4
|
||||||
|
- name: publish code scanning alerts
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: flawfinder_report.sarif
|
||||||
|
category: flawfinder
|
||||||
44
.github/workflows/sec_sast_semgrep_cron.yml
vendored
Normal file
44
.github/workflows/sec_sast_semgrep_cron.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
name: Semgrep Full Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
schedule:
|
||||||
|
- cron: '0 1 * * 6'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
semgrep-full:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: returntocorp/semgrep
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
# step 1
|
||||||
|
- name: clone application source code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# step 2
|
||||||
|
- name: full scan
|
||||||
|
run: |
|
||||||
|
semgrep \
|
||||||
|
--sarif --output report.sarif \
|
||||||
|
--metrics=off \
|
||||||
|
--config="p/default"
|
||||||
|
|
||||||
|
# step 3
|
||||||
|
- name: save report as pipeline artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: report.sarif
|
||||||
|
path: report.sarif
|
||||||
|
|
||||||
|
# step 4
|
||||||
|
- name: publish code scanning alerts
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: report.sarif
|
||||||
|
category: semgrep
|
||||||
28
.github/workflows/sec_sast_semgrep_pull.yml
vendored
Normal file
28
.github/workflows/sec_sast_semgrep_pull.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
name: Semgrep Differential Scan
|
||||||
|
on:
|
||||||
|
pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
semgrep-diff:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: returntocorp/semgrep
|
||||||
|
|
||||||
|
steps:
|
||||||
|
|
||||||
|
# step 1
|
||||||
|
- name: clone application source code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# step 2
|
||||||
|
- name: differential scan
|
||||||
|
run: |
|
||||||
|
semgrep scan \
|
||||||
|
--error \
|
||||||
|
--metrics=off \
|
||||||
|
--baseline-commit ${{ github.event.pull_request.base.sha }} \
|
||||||
|
--config="p/default"
|
||||||
6
.github/workflows/update_protobufs.yml
vendored
6
.github/workflows/update_protobufs.yml
vendored
@@ -17,9 +17,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Download nanopb
|
- name: Download nanopb
|
||||||
run: |
|
run: |
|
||||||
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.6-linux-x86.tar.gz
|
wget https://jpa.kapsi.fi/nanopb/download/nanopb-0.4.7-linux-x86.tar.gz
|
||||||
tar xvzf nanopb-0.4.6-linux-x86.tar.gz
|
tar xvzf nanopb-0.4.7-linux-x86.tar.gz
|
||||||
mv nanopb-0.4.6-linux-x86 nanopb-0.4.6
|
mv nanopb-0.4.7-linux-x86 nanopb-0.4.7
|
||||||
|
|
||||||
- name: Re-generate protocol buffers
|
- name: Re-generate protocol buffers
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -29,3 +29,4 @@ __pycache__
|
|||||||
|
|
||||||
venv/
|
venv/
|
||||||
release/
|
release/
|
||||||
|
.vscode/extensions.json
|
||||||
|
|||||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "protobufs"]
|
[submodule "protobufs"]
|
||||||
path = protobufs
|
path = protobufs
|
||||||
url = https://github.com/meshtastic/Meshtastic-protobufs.git
|
url = https://github.com/meshtastic/protobufs.git
|
||||||
|
|||||||
2
.semgrepignore
Normal file
2
.semgrepignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.github/workflows/main_matrix.yml
|
||||||
|
src/mesh/compression/unishox2.c
|
||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -53,7 +53,8 @@
|
|||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
"esp_nimble_hci.h": "c",
|
"esp_nimble_hci.h": "c",
|
||||||
"map": "cpp",
|
"map": "cpp",
|
||||||
"random": "cpp"
|
"random": "cpp",
|
||||||
|
"*.tpp": "cpp"
|
||||||
},
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Blox",
|
"Blox",
|
||||||
|
|||||||
41
Dockerfile
Normal file
41
Dockerfile
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
FROM debian:bullseye-slim AS builder
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
ENV TZ=Etc/UTC
|
||||||
|
|
||||||
|
# http://bugs.python.org/issue19846
|
||||||
|
# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK.
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
|
# Install build deps
|
||||||
|
USER root
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get -y install wget python3 g++ zip python3-venv git vim ca-certificates
|
||||||
|
|
||||||
|
# create a non-priveleged user & group
|
||||||
|
RUN groupadd -g 1000 mesh && useradd -ml -u 1000 -g 1000 mesh
|
||||||
|
|
||||||
|
USER mesh
|
||||||
|
RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -qO /tmp/get-platformio.py && \
|
||||||
|
chmod +x /tmp/get-platformio.py && \
|
||||||
|
python3 /tmp/get-platformio.py && \
|
||||||
|
git clone https://github.com/meshtastic/firmware --recurse-submodules /tmp/firmware && \
|
||||||
|
cd /tmp/firmware && \
|
||||||
|
chmod +x /tmp/firmware/bin/build-native.sh && \
|
||||||
|
source ~/.platformio/penv/bin/activate && \
|
||||||
|
./bin/build-native.sh
|
||||||
|
|
||||||
|
FROM frolvlad/alpine-glibc
|
||||||
|
|
||||||
|
RUN apk --update add --no-cache g++ shadow && \
|
||||||
|
groupadd -g 1000 mesh && useradd -ml -u 1000 -g 1000 mesh
|
||||||
|
|
||||||
|
COPY --from=builder /tmp/firmware/release/meshtasticd_linux_amd64 /home/mesh/
|
||||||
|
|
||||||
|
USER mesh
|
||||||
|
WORKDIR /home/mesh
|
||||||
|
CMD sh -cx "./meshtasticd_linux_amd64 --hwid '$RANDOM'"
|
||||||
|
|
||||||
|
HEALTHCHECK NONE
|
||||||
11
README.md
11
README.md
@@ -1,8 +1,8 @@
|
|||||||
# Meshtastic Firmware
|
# Meshtastic Firmware
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/meshtastic/repo/actions/workflows/main_matrix.yml)
|
[](https://github.com/meshtastic/firmware/actions/workflows/main_matrix.yml)
|
||||||
[](https://cla-assistant.io/meshtastic/Meshtastic-device)
|
[](https://cla-assistant.io/meshtastic/firmware)
|
||||||
[](https://opencollective.com/meshtastic/)
|
[](https://opencollective.com/meshtastic/)
|
||||||
[](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)
|
[](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)
|
||||||
|
|
||||||
@@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
This repository contains the device firmware for the Meshtastic project.
|
This repository contains the device firmware for the Meshtastic project.
|
||||||
|
|
||||||
|
**[Building Instructions](https://meshtastic.org/docs/development/firmware/build)**
|
||||||
**[Building Instructions](https://meshtastic.org/docs/developers/Firmware/build)**
|
|
||||||
**[Flashing Instructions](https://meshtastic.org/docs/getting-started/flashing-firmware/)**
|
**[Flashing Instructions](https://meshtastic.org/docs/getting-started/flashing-firmware/)**
|
||||||
|
|
||||||
## Stats
|
## Stats
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
54
arch/esp32/esp32.ini
Normal file
54
arch/esp32/esp32.ini
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
; Common settings for ESP targes, mixin with extends = esp32_base
|
||||||
|
[esp32_base]
|
||||||
|
extends = arduino_base
|
||||||
|
platform = platformio/espressif32@^5.2.0
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
|
||||||
|
upload_speed = 921600
|
||||||
|
debug_init_break = tbreak setup
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
|
||||||
|
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||||
|
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||||
|
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags}
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Isrc/platform/esp32
|
||||||
|
-std=c++11
|
||||||
|
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
|
||||||
|
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
|
-DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
||||||
|
-DAXP_DEBUG_PORT=Serial
|
||||||
|
-DCONFIG_BT_NIMBLE_ENABLED
|
||||||
|
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
|
||||||
|
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
|
||||||
|
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
|
||||||
|
-DDEBUG_HEAP
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${networking_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
|
||||||
|
h2zero/NimBLE-Arduino@^1.4.0
|
||||||
|
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
|
||||||
|
caveman99/ESP32 Codec2@^1.0.1
|
||||||
|
|
||||||
|
lib_ignore =
|
||||||
|
segger_rtt
|
||||||
|
ESP32 BLE Arduino
|
||||||
|
|
||||||
|
; leave this commented out to avoid breaking Windows
|
||||||
|
;upload_port = /dev/ttyUSB0
|
||||||
|
;monitor_port = /dev/ttyUSB0
|
||||||
|
|
||||||
|
; Please don't delete these lines. JM uses them.
|
||||||
|
;upload_port = /dev/cu.SLAB_USBtoUART
|
||||||
|
;monitor_port = /dev/cu.SLAB_USBtoUART
|
||||||
|
|
||||||
|
; customize the partition table
|
||||||
|
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
|
||||||
|
board_build.partitions = partition-table.csv
|
||||||
47
arch/esp32/esp32s2.ini
Normal file
47
arch/esp32/esp32s2.ini
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
[esp32s2_base]
|
||||||
|
extends = arduino_base
|
||||||
|
platform = platformio/espressif32@^5.2.0
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/> -<nimble/>
|
||||||
|
upload_speed = 961200
|
||||||
|
monitor_speed = 115200
|
||||||
|
debug_init_break = tbreak setup
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
|
||||||
|
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||||
|
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||||
|
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags}
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Isrc/platform/esp32
|
||||||
|
-std=c++11
|
||||||
|
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
|
||||||
|
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
|
-DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
||||||
|
-DAXP_DEBUG_PORT=Serial
|
||||||
|
-DCONFIG_BT_NIMBLE_ENABLED
|
||||||
|
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
|
||||||
|
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
|
||||||
|
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
|
||||||
|
-DHAS_BLUETOOTH=0
|
||||||
|
-DDEBUG_HEAP
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${networking_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
|
||||||
|
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
|
||||||
|
caveman99/ESP32 Codec2@^1.0.1
|
||||||
|
|
||||||
|
lib_ignore =
|
||||||
|
segger_rtt
|
||||||
|
ESP32 BLE Arduino
|
||||||
|
|
||||||
|
; customize the partition table
|
||||||
|
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
|
||||||
|
board_build.partitions = partition-table.csv
|
||||||
|
|
||||||
47
arch/esp32/esp32s3.ini
Normal file
47
arch/esp32/esp32s3.ini
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
[esp32s3_base]
|
||||||
|
extends = arduino_base
|
||||||
|
platform = platformio/espressif32@^5.2.0
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040> -<mesh/eth/>
|
||||||
|
upload_speed = 961200
|
||||||
|
monitor_speed = 115200
|
||||||
|
debug_init_break = tbreak setup
|
||||||
|
monitor_filters = esp32_exception_decoder
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
|
||||||
|
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
||||||
|
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
||||||
|
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags}
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Isrc/platform/esp32
|
||||||
|
-std=c++11
|
||||||
|
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
|
||||||
|
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||||
|
-DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
||||||
|
-DAXP_DEBUG_PORT=Serial
|
||||||
|
-DCONFIG_BT_NIMBLE_ENABLED
|
||||||
|
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
|
||||||
|
-DCONFIG_BT_NIMBLE_MAX_CCCDS=20
|
||||||
|
-DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
|
||||||
|
-DDEBUG_HEAP
|
||||||
|
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${networking_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
|
||||||
|
h2zero/NimBLE-Arduino@^1.4.0
|
||||||
|
https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
|
||||||
|
caveman99/ESP32 Codec2@^1.0.1
|
||||||
|
|
||||||
|
lib_ignore =
|
||||||
|
segger_rtt
|
||||||
|
ESP32 BLE Arduino
|
||||||
|
|
||||||
|
; customize the partition table
|
||||||
|
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
|
||||||
|
board_build.partitions = partition-table.csv
|
||||||
|
|
||||||
18
arch/nrf52/nrf52.ini
Normal file
18
arch/nrf52/nrf52.ini
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[nrf52_base]
|
||||||
|
; Instead of the standard nordicnrf52 platform, we use our fork which has our added variant files
|
||||||
|
platform = platformio/nordicnrf52@^9.4.0
|
||||||
|
|
||||||
|
extends = arduino_base
|
||||||
|
build_type = debug ; I'm debugging with ICE a lot now
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags} -Wno-unused-variable
|
||||||
|
-Isrc/platform/nrf52
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<platform/rp2040> -<mesh/eth/>
|
||||||
|
lib_ignore =
|
||||||
|
BluetoothOTA
|
||||||
|
|
||||||
|
; Note: By default no lora device is created for this build - it uses a simulated interface
|
||||||
|
[env:feather_nrf52832]
|
||||||
|
extends = nrf52_base
|
||||||
|
board = adafruit_feather_nrf52832
|
||||||
14
arch/nrf52/nrf52840.ini
Normal file
14
arch/nrf52/nrf52840.ini
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[nrf52840_base]
|
||||||
|
extends = nrf52_base
|
||||||
|
build_flags = ${nrf52_base.build_flags}
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/Kongduino/Adafruit_nRFCrypto.git#e31a8825ea3300b163a0a3c1ddd5de34e10e1371
|
||||||
|
|
||||||
|
; Note: By default no lora device is created for this build - it uses a simulated interface
|
||||||
|
[env:nrf52840dk]
|
||||||
|
extends = nrf52840_base
|
||||||
|
board = nrf52840_dk
|
||||||
|
|
||||||
|
|
||||||
21
arch/portduino/portduino.ini
Normal file
21
arch/portduino/portduino.ini
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
; The Portduino based sim environment on top of any host OS, all hardware will be simulated
|
||||||
|
[portduino_base]
|
||||||
|
platform = https://github.com/meshtastic/platform-native.git#096b3c3e9c5c8e19d4c3b6cd803fffef2a9be4c5
|
||||||
|
framework = arduino
|
||||||
|
build_src_filter =
|
||||||
|
${env.build_src_filter}
|
||||||
|
-<platform/esp32/>
|
||||||
|
-<nimble/>
|
||||||
|
-<platform/nrf52/>
|
||||||
|
-<platform/stm32wl/>
|
||||||
|
-<platform/rp2040>
|
||||||
|
-<mesh/http/>
|
||||||
|
-<mesh/eth/>
|
||||||
|
-<modules/esp32>
|
||||||
|
-<modules/Telemetry>
|
||||||
|
+<../variants/portduino>
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
${networking_base.lib_deps}
|
||||||
|
rweather/Crypto@^0.4.0
|
||||||
|
build_flags = ${arduino_base.build_flags} -Isrc/platform/portduino
|
||||||
21
arch/rp2040/rp2040.ini
Normal file
21
arch/rp2040/rp2040.ini
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
; Common settings for rp2040 Processor based targets
|
||||||
|
[rp2040_base]
|
||||||
|
platform = https://github.com/maxgerhardt/platform-raspberrypi.git#20c7dbfcfe6677c5305fa28ecf5e3870321cb157
|
||||||
|
platform_packages =
|
||||||
|
earlephilhower/toolchain-rp2040-earlephilhower@^5.100300.221223
|
||||||
|
extends = arduino_base
|
||||||
|
board_build.core = earlephilhower
|
||||||
|
board_build.filesystem_size = 0.5m
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags} -Wno-unused-variable
|
||||||
|
-Isrc/platform/rp2040
|
||||||
|
-D__PLAT_RP2040__
|
||||||
|
# -D _POSIX_THREADS
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<platform/nrf52/> -<platform/stm32wl> -<mesh/eth/>
|
||||||
|
lib_ignore =
|
||||||
|
BluetoothOTA
|
||||||
|
lib_deps =
|
||||||
|
${arduino_base.lib_deps}
|
||||||
|
${environmental_base.lib_deps}
|
||||||
|
https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b
|
||||||
18
arch/stm32/stm32wl5e.ini
Normal file
18
arch/stm32/stm32wl5e.ini
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[stm32wl5e_base]
|
||||||
|
platform = platformio/ststm32@^15.4.1
|
||||||
|
board = generic_wl5e
|
||||||
|
framework = arduino
|
||||||
|
build_type = debug
|
||||||
|
build_flags =
|
||||||
|
${arduino_base.build_flags}
|
||||||
|
-Isrc/platform/stm32wl -g
|
||||||
|
-DHAL_SUBGHZ_MODULE_ENABLED
|
||||||
|
# Arduino/PlatformIO framework-arduinoststm32 package does not presently have SUBGHZSPI support
|
||||||
|
# -DPIN_SPI_MOSI=PINSUBGHZSPIMOSI -DPIN_SPI_MISO=PINSUBGHZSPIMISO -DPIN_SPI_SCK=PINSUBGHZSPISCK
|
||||||
|
build_src_filter =
|
||||||
|
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mesh/eth/> -<mqtt/> -<graphics> -<input> -<buzz> -<modules/Telemetry> -<platform/nrf52> -<platform/portduino> -<platform/rp2040>
|
||||||
|
lib_deps =
|
||||||
|
${env.lib_deps}
|
||||||
|
https://github.com/kokke/tiny-AES-c.git#f06ac37fc31dfdaca2e0d9bec83f90d5663c319b
|
||||||
|
lib_ignore =
|
||||||
|
mathertel/OneButton@^2.0.3
|
||||||
BIN
bin/Meshtastic_nRF52_factory_erase.uf2
Normal file
BIN
bin/Meshtastic_nRF52_factory_erase.uf2
Normal file
Binary file not shown.
@@ -1,109 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
VERSION=`bin/buildinfo.py long`
|
|
||||||
SHORT_VERSION=`bin/buildinfo.py short`
|
|
||||||
|
|
||||||
BOARDS_ESP32="rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink"
|
|
||||||
#BOARDS_ESP32=tbeam
|
|
||||||
|
|
||||||
# FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine
|
|
||||||
BOARDS_NRF52="rak4631 rak4631_eink t-echo pca10059_diy_eink"
|
|
||||||
#BOARDS_NRF52=""
|
|
||||||
|
|
||||||
OUTDIR=release/latest
|
|
||||||
|
|
||||||
# We keep all old builds (and their map files in the archive dir)
|
|
||||||
ARCHIVEDIR=release/archive
|
|
||||||
|
|
||||||
rm -f $OUTDIR/firmware*
|
|
||||||
|
|
||||||
mkdir -p $OUTDIR/bins $ARCHIVEDIR
|
|
||||||
rm -r $OUTDIR/bins/* || true
|
|
||||||
mkdir -p $OUTDIR/bins/universal $OUTDIR/elfs/universal
|
|
||||||
|
|
||||||
# build the named environment and copy the bins to the release directory
|
|
||||||
function do_build() {
|
|
||||||
BOARD=$1
|
|
||||||
isNrf=$3
|
|
||||||
|
|
||||||
echo "Building for $BOARD ($isNrf) with $PLATFORMIO_BUILD_FLAGS"
|
|
||||||
rm -f .pio/build/$BOARD/firmware.*
|
|
||||||
|
|
||||||
# The shell vars the build tool expects to find
|
|
||||||
export APP_VERSION=$VERSION
|
|
||||||
|
|
||||||
basename=universal/firmware-$BOARD-$VERSION
|
|
||||||
|
|
||||||
pio run --environment $BOARD # -v
|
|
||||||
SRCELF=.pio/build/$BOARD/firmware.elf
|
|
||||||
cp $SRCELF $OUTDIR/elfs/$basename.elf
|
|
||||||
|
|
||||||
if [ "$isNrf" = "false" ]
|
|
||||||
then
|
|
||||||
echo "Copying ESP32 bin file"
|
|
||||||
SRCBIN=.pio/build/$BOARD/firmware.bin
|
|
||||||
cp $SRCBIN $OUTDIR/bins/$basename.bin
|
|
||||||
else
|
|
||||||
echo "Generating NRF52 uf2 file"
|
|
||||||
SRCHEX=.pio/build/$BOARD/firmware.hex
|
|
||||||
bin/uf2conv.py $SRCHEX -c -o $OUTDIR/bins/$basename.uf2 -f 0xADA52840
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function do_boards() {
|
|
||||||
declare boards=$1
|
|
||||||
declare isNrf=$2
|
|
||||||
for board in $boards; do
|
|
||||||
# Build universal
|
|
||||||
echo "about to build $board $isNrf"
|
|
||||||
do_build $board "" "$isNrf"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Make sure our submodules are current
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
|
||||||
platformio lib update
|
|
||||||
|
|
||||||
do_boards "$BOARDS_ESP32" "false"
|
|
||||||
do_boards "$BOARDS_NRF52" "true"
|
|
||||||
|
|
||||||
pio run --environment native
|
|
||||||
cp .pio/build/native/program $OUTDIR/bins/universal/meshtasticd_linux_amd64
|
|
||||||
|
|
||||||
echo "Building Filesystem for ESP32 targets"
|
|
||||||
pio run --environment tbeam -t buildfs
|
|
||||||
cp .pio/build/tbeam/spiffs.bin $OUTDIR/bins/universal/littlefs-$VERSION.bin
|
|
||||||
|
|
||||||
# keep the bins in archive also
|
|
||||||
cp $OUTDIR/bins/universal/littlefs* $OUTDIR/bins/universal/firmware* $OUTDIR/elfs/universal/firmware* $ARCHIVEDIR
|
|
||||||
|
|
||||||
echo Updating android bins $OUTDIR/forandroid
|
|
||||||
rm -rf $OUTDIR/forandroid
|
|
||||||
mkdir -p $OUTDIR/forandroid
|
|
||||||
cp -a $OUTDIR/bins/universal/*.bin $OUTDIR/forandroid/
|
|
||||||
|
|
||||||
cat >$OUTDIR/curfirmwareversion.xml <<XML
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<!-- This file is kept in source control because it reflects the last stable
|
|
||||||
release. It is used by the android app for forcing software updates. Do not edit.
|
|
||||||
Generated by bin/buildall.sh -->
|
|
||||||
|
|
||||||
<resources>
|
|
||||||
<string name="cur_firmware_version" translatable="false">$VERSION</string>
|
|
||||||
<string name="short_firmware_version" translatable="false">$SHORT_VERSION</string>
|
|
||||||
</resources>
|
|
||||||
XML
|
|
||||||
|
|
||||||
echo Generating $ARCHIVEDIR/firmware-$VERSION.zip
|
|
||||||
rm -f $ARCHIVEDIR/firmware-$VERSION.zip
|
|
||||||
zip --junk-paths $ARCHIVEDIR/firmware-$VERSION.zip $ARCHIVEDIR/littlefs-$VERSION.bin $OUTDIR/bins/universal/firmware-*-$VERSION.* $OUTDIR/bins/universal/meshtasticd* images/system-info.bin bin/device-install.* bin/device-update.*
|
|
||||||
echo Generating $ARCHIVEDIR/elfs-$VERSION.zip
|
|
||||||
rm -f $ARCHIVEDIR/elfs-$VERSION.zip
|
|
||||||
zip --junk-paths $ARCHIVEDIR/elfs-$VERSION.zip $OUTDIR/elfs/universal/firmware-*-$VERSION.*
|
|
||||||
|
|
||||||
echo BUILT ALL
|
|
||||||
@@ -10,11 +10,8 @@ OUTDIR=release/
|
|||||||
rm -f $OUTDIR/firmware*
|
rm -f $OUTDIR/firmware*
|
||||||
rm -r $OUTDIR/* || true
|
rm -r $OUTDIR/* || true
|
||||||
|
|
||||||
# Make sure our submodules are current
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||||
platformio lib update
|
platformio pkg update
|
||||||
|
|
||||||
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
||||||
rm -f .pio/build/$1/firmware.*
|
rm -f .pio/build/$1/firmware.*
|
||||||
@@ -29,13 +26,15 @@ SRCELF=.pio/build/$1/firmware.elf
|
|||||||
cp $SRCELF $OUTDIR/$basename.elf
|
cp $SRCELF $OUTDIR/$basename.elf
|
||||||
|
|
||||||
echo "Copying ESP32 bin file"
|
echo "Copying ESP32 bin file"
|
||||||
SRCBIN=.pio/build/$1/firmware.bin
|
SRCBIN=.pio/build/$1/firmware.factory.bin
|
||||||
cp $SRCBIN $OUTDIR/$basename.bin
|
cp $SRCBIN $OUTDIR/$basename.bin
|
||||||
|
|
||||||
|
echo "Copying ESP32 update bin file"
|
||||||
|
SRCBIN=.pio/build/$1/firmware.bin
|
||||||
|
cp $SRCBIN $OUTDIR/$basename-update.bin
|
||||||
|
|
||||||
echo "Building Filesystem for ESP32 targets"
|
echo "Building Filesystem for ESP32 targets"
|
||||||
pio run --environment tbeam -t buildfs
|
pio run --environment tbeam -t buildfs
|
||||||
cp .pio/build/tbeam/spiffs.bin $OUTDIR/littlefs-$VERSION.bin
|
cp .pio/build/tbeam/littlefs.bin $OUTDIR/littlefs-$VERSION.bin
|
||||||
cp images/system-info.bin $OUTDIR/system-info.bin
|
|
||||||
|
|
||||||
cp bin/device-install.* $OUTDIR
|
cp bin/device-install.* $OUTDIR
|
||||||
cp bin/device-update.* $OUTDIR
|
cp bin/device-update.* $OUTDIR
|
||||||
|
|||||||
@@ -12,11 +12,8 @@ rm -f $OUTDIR/firmware*
|
|||||||
mkdir -p $OUTDIR/
|
mkdir -p $OUTDIR/
|
||||||
rm -r $OUTDIR/* || true
|
rm -r $OUTDIR/* || true
|
||||||
|
|
||||||
# Make sure our submodules are current
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||||
platformio lib update
|
platformio pkg update
|
||||||
|
|
||||||
pio run --environment native
|
pio run --environment native
|
||||||
cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64
|
cp .pio/build/native/program $OUTDIR/meshtasticd_linux_amd64
|
||||||
|
|||||||
@@ -10,11 +10,8 @@ OUTDIR=release/
|
|||||||
rm -f $OUTDIR/firmware*
|
rm -f $OUTDIR/firmware*
|
||||||
rm -r $OUTDIR/* || true
|
rm -r $OUTDIR/* || true
|
||||||
|
|
||||||
# Make sure our submodules are current
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||||
platformio lib update
|
platformio pkg update
|
||||||
|
|
||||||
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
||||||
rm -f .pio/build/$1/firmware.*
|
rm -f .pio/build/$1/firmware.*
|
||||||
@@ -26,7 +23,9 @@ basename=firmware-$1-$VERSION
|
|||||||
|
|
||||||
pio run --environment $1 # -v
|
pio run --environment $1 # -v
|
||||||
SRCELF=.pio/build/$1/firmware.elf
|
SRCELF=.pio/build/$1/firmware.elf
|
||||||
|
DFUPKG=.pio/build/$1/firmware.zip
|
||||||
cp $SRCELF $OUTDIR/$basename.elf
|
cp $SRCELF $OUTDIR/$basename.elf
|
||||||
|
cp $DFUPKG $OUTDIR/$basename-ota.zip
|
||||||
|
|
||||||
echo "Generating NRF52 uf2 file"
|
echo "Generating NRF52 uf2 file"
|
||||||
SRCHEX=.pio/build/$1/firmware.hex
|
SRCHEX=.pio/build/$1/firmware.hex
|
||||||
@@ -34,3 +33,4 @@ bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840
|
|||||||
|
|
||||||
cp bin/device-install.* $OUTDIR
|
cp bin/device-install.* $OUTDIR
|
||||||
cp bin/device-update.* $OUTDIR
|
cp bin/device-update.* $OUTDIR
|
||||||
|
cp bin/*.uf2 $OUTDIR
|
||||||
|
|||||||
@@ -10,11 +10,8 @@ OUTDIR=release/
|
|||||||
rm -f $OUTDIR/firmware*
|
rm -f $OUTDIR/firmware*
|
||||||
rm -r $OUTDIR/* || true
|
rm -r $OUTDIR/* || true
|
||||||
|
|
||||||
# Make sure our submodules are current
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
|
||||||
platformio lib update
|
platformio pkg update
|
||||||
|
|
||||||
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
|
||||||
rm -f .pio/build/$1/firmware.*
|
rm -f .pio/build/$1/firmware.*
|
||||||
|
|||||||
23
bin/check-dependencies.sh
Normal file
23
bin/check-dependencies.sh
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Note: This is a prototype for how we could add static code analysis to the CI.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ $# -gt 0 ]]; then
|
||||||
|
# can override which environment by passing arg
|
||||||
|
BOARDS="$@"
|
||||||
|
else
|
||||||
|
BOARDS="rak4631 rak4631_eink t-echo pca10059_diy_eink pico rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink tbeam-s3-core"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "BOARDS:${BOARDS}"
|
||||||
|
|
||||||
|
CHECK=""
|
||||||
|
for BOARD in $BOARDS; do
|
||||||
|
CHECK="${CHECK} -e ${BOARD}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $CHECK
|
||||||
|
|
||||||
|
pio pkg outdated -e $CHECK
|
||||||
@@ -26,14 +26,17 @@ IF "__%FILENAME%__" == "____" (
|
|||||||
echo "Missing FILENAME"
|
echo "Missing FILENAME"
|
||||||
goto HELP
|
goto HELP
|
||||||
)
|
)
|
||||||
IF EXIST %FILENAME% (
|
IF EXIST %FILENAME% IF x%FILENAME:update=%==x%FILENAME% (
|
||||||
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
echo Trying to flash update %FILENAME%, but first erasing and writing system information"
|
||||||
%PYTHON% -m esptool --baud 115200 erase_flash
|
%PYTHON% -m esptool --baud 115200 erase_flash
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x1000 system-info.bin
|
%PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME%
|
||||||
|
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota.bin
|
||||||
for %%f in (littlefs-*.bin) do (
|
for %%f in (littlefs-*.bin) do (
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x2B0000 %%f
|
%PYTHON% -m esptool --baud 115200 write_flash 0x300000 %%f
|
||||||
)
|
)
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
|
) else (
|
||||||
|
echo "Invalid file: %FILENAME%"
|
||||||
|
goto HELP
|
||||||
) else (
|
) else (
|
||||||
echo "Invalid file: %FILENAME%"
|
echo "Invalid file: %FILENAME%"
|
||||||
goto HELP
|
goto HELP
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Flash image file to device, but first erasing and writing system information"
|
|||||||
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerous).
|
||||||
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
||||||
-f FILENAME The .bin file to flash. Custom to your device type and region.
|
-f FILENAME The .bin file to flash. Custom to your device type and region.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,15 +45,16 @@ shift "$((OPTIND-1))"
|
|||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ]; then
|
if [ -f "${FILENAME}" ] && [ ! -z "${FILENAME##*"update"*}" ]; then
|
||||||
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
||||||
"$PYTHON" -m esptool erase_flash
|
"$PYTHON" -m esptool erase_flash
|
||||||
"$PYTHON" -m esptool write_flash 0x1000 system-info.bin
|
"$PYTHON" -m esptool write_flash 0x00 ${FILENAME}
|
||||||
"$PYTHON" -m esptool write_flash 0x2B0000 littlefs-*.bin
|
"$PYTHON" -m esptool write_flash 0x260000 bleota.bin
|
||||||
"$PYTHON" -m esptool write_flash 0x10000 ${FILENAME}
|
"$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Invalid file: ${FILENAME}"
|
|
||||||
show_help
|
show_help
|
||||||
|
echo "Invalid file: ${FILENAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ echo.
|
|||||||
echo -h Display this help and exit
|
echo -h Display this help and exit
|
||||||
echo -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous).
|
echo -p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous).
|
||||||
echo -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: %PYTHON%)
|
echo -P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: %PYTHON%)
|
||||||
echo -f FILENAME The .bin file to flash. Custom to your device type and region.
|
echo -f FILENAME The *update.bin file to flash. Custom to your device type.
|
||||||
goto EOF
|
goto EOF
|
||||||
|
|
||||||
:GETOPTS
|
:GETOPTS
|
||||||
@@ -26,12 +26,15 @@ IF "__%FILENAME%__" == "____" (
|
|||||||
echo "Missing FILENAME"
|
echo "Missing FILENAME"
|
||||||
goto HELP
|
goto HELP
|
||||||
)
|
)
|
||||||
IF EXIST %FILENAME% (
|
IF EXIST %FILENAME% IF NOT x%FILENAME:update=%==x%FILENAME% (
|
||||||
echo Trying to flash update %FILENAME%
|
echo Trying to flash update %FILENAME%
|
||||||
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
|
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
|
||||||
) else (
|
) else (
|
||||||
echo "Invalid file: %FILENAME%"
|
echo "Invalid file: %FILENAME%"
|
||||||
goto HELP
|
goto HELP
|
||||||
|
) else (
|
||||||
|
echo "Invalid file: %FILENAME%"
|
||||||
|
goto HELP
|
||||||
)
|
)
|
||||||
|
|
||||||
:EOF
|
:EOF
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ Flash image file to device, leave existing system intact."
|
|||||||
-h Display this help and exit
|
-h Display this help and exit
|
||||||
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous).
|
-p ESPTOOL_PORT Set the environment variable for ESPTOOL_PORT. If not set, ESPTOOL iterates all ports (Dangerrous).
|
||||||
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
-P PYTHON Specify alternate python interpreter to use to invoke esptool. (Default: "$PYTHON")
|
||||||
-f FILENAME The .bin file to flash. Custom to your device type and region.
|
-f FILENAME The *update.bin file to flash. Custom to your device type.
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,12 +43,12 @@ shift "$((OPTIND-1))"
|
|||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ]; then
|
if [ -f "${FILENAME}" ] && [ -z "${FILENAME##*"update"*}" ]; then
|
||||||
echo "Trying to flash update ${FILENAME}."
|
printf "Trying to flash update ${FILENAME}"
|
||||||
$PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME}
|
$PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME}
|
||||||
else
|
else
|
||||||
echo "Invalid file: ${FILENAME}"
|
|
||||||
show_help
|
show_help
|
||||||
|
echo "Invalid file: ${FILENAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import getopt
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from littlefs import LittleFS
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
print( "Building LittleFS image..." )
|
|
||||||
|
|
||||||
argList = sys.argv[1:]
|
|
||||||
arxx = { argList[i]: argList[i+1] for i in range(0, len(argList)-1, 2) }
|
|
||||||
|
|
||||||
dataPath = arxx["-c"]
|
|
||||||
blockSize = int(arxx["-b"])
|
|
||||||
blockCount = int(arxx["-s"]) / blockSize
|
|
||||||
|
|
||||||
cwd = os.getcwd()
|
|
||||||
|
|
||||||
os.chdir(dataPath)
|
|
||||||
|
|
||||||
fileList = []
|
|
||||||
dirList = []
|
|
||||||
|
|
||||||
for (dirpath, dirnames, filenames) in os.walk('.'):
|
|
||||||
for f in filenames:
|
|
||||||
if (f[:1] != '.'):
|
|
||||||
fileList.append( os.path.join(dirpath, f) )
|
|
||||||
for d in dirnames:
|
|
||||||
if (d[:1] != '.'):
|
|
||||||
dirList.append( os.path.join(dirpath, d) )
|
|
||||||
|
|
||||||
fs = LittleFS(block_size=blockSize, block_count=blockCount) # create a 448kB partition
|
|
||||||
|
|
||||||
for curDir in dirList:
|
|
||||||
print( "Creating dir " + curDir )
|
|
||||||
fs.mkdir( curDir )
|
|
||||||
|
|
||||||
for curFile in fileList:
|
|
||||||
print( "Adding file " + curFile )
|
|
||||||
with open( curFile, 'rb' ) as f:
|
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
with fs.open( curFile, 'wb') as fh:
|
|
||||||
fh.write( data )
|
|
||||||
|
|
||||||
outName = argList[-1]
|
|
||||||
|
|
||||||
os.chdir(cwd)
|
|
||||||
|
|
||||||
with open(outName, 'wb') as fh:
|
|
||||||
fh.write(fs.context.buffer)
|
|
||||||
@@ -1,24 +1,70 @@
|
|||||||
|
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import configparser
|
import configparser
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
from os.path import join
|
||||||
from readprops import readProps
|
from readprops import readProps
|
||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
env.Replace( MKSPIFFSTOOL=env.get("PROJECT_DIR") + '/bin/mklittlefs.py' )
|
platform = env.PioPlatform()
|
||||||
try:
|
|
||||||
import littlefs
|
def esp32_create_combined_bin(source, target, env):
|
||||||
except ImportError:
|
# this sub is borrowed from ESPEasy build toolchain. It's licensed under GPL V3
|
||||||
env.Execute("$PYTHONEXE -m pip install littlefs-python")
|
# https://github.com/letscontrolit/ESPEasy/blob/mega/tools/pio/post_esp32.py
|
||||||
|
print("Generating combined binary for serial flashing")
|
||||||
|
|
||||||
|
app_offset = 0x10000
|
||||||
|
|
||||||
|
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
|
||||||
|
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
|
||||||
|
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
|
||||||
|
chip = env.get("BOARD_MCU")
|
||||||
|
flash_size = env.BoardConfig().get("upload.flash_size")
|
||||||
|
flash_freq = env.BoardConfig().get("build.f_flash", '40m')
|
||||||
|
flash_freq = flash_freq.replace('000000L', 'm')
|
||||||
|
flash_mode = env.BoardConfig().get("build.flash_mode", "dio")
|
||||||
|
memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi")
|
||||||
|
if flash_mode == "qio" or flash_mode == "qout":
|
||||||
|
flash_mode = "dio"
|
||||||
|
if memory_type == "opi_opi" or memory_type == "opi_qspi":
|
||||||
|
flash_mode = "dout"
|
||||||
|
cmd = [
|
||||||
|
"--chip",
|
||||||
|
chip,
|
||||||
|
"merge_bin",
|
||||||
|
"-o",
|
||||||
|
new_file_name,
|
||||||
|
"--flash_mode",
|
||||||
|
flash_mode,
|
||||||
|
"--flash_freq",
|
||||||
|
flash_freq,
|
||||||
|
"--flash_size",
|
||||||
|
flash_size,
|
||||||
|
]
|
||||||
|
|
||||||
|
print(" Offset | File")
|
||||||
|
for section in sections:
|
||||||
|
sect_adr, sect_file = section.split(" ", 1)
|
||||||
|
print(f" - {sect_adr} | {sect_file}")
|
||||||
|
cmd += [sect_adr, sect_file]
|
||||||
|
|
||||||
|
print(f" - {hex(app_offset)} | {firmware_name}")
|
||||||
|
cmd += [hex(app_offset), firmware_name]
|
||||||
|
|
||||||
|
print('Using esptool.py arguments: %s' % ' '.join(cmd))
|
||||||
|
|
||||||
|
esptool.main(cmd)
|
||||||
|
|
||||||
|
if (platform.name == "espressif32"):
|
||||||
|
sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
|
||||||
|
import esptool
|
||||||
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)
|
||||||
|
|
||||||
Import("projenv")
|
Import("projenv")
|
||||||
|
|
||||||
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
|
||||||
verObj = readProps(prefsLoc)
|
verObj = readProps(prefsLoc)
|
||||||
print("Using meshtastic platformio-custom.py, firmware version " + verObj['long'])
|
print("Using meshtastic platformio-custom.py, firmware version " + verObj['long'])
|
||||||
# print("path is" + ','.join(sys.path))
|
|
||||||
|
|
||||||
# General options that are passed to the C and C++ compilers
|
# General options that are passed to the C and C++ compilers
|
||||||
projenv.Append(CCFLAGS=[
|
projenv.Append(CCFLAGS=[
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ VERSION=`bin/buildinfo.py long`
|
|||||||
# Must have a V prefix to trigger github
|
# Must have a V prefix to trigger github
|
||||||
git tag "v${VERSION}"
|
git tag "v${VERSION}"
|
||||||
|
|
||||||
# Commented out per https://github.com/meshtastic/Meshtastic-device/issues/947
|
|
||||||
#git push root "v${VERSION}" # push the tag
|
|
||||||
|
|
||||||
git push origin "v${VERSION}" # push the tag
|
git push origin "v${VERSION}" # push the tag
|
||||||
|
|
||||||
echo "Tag ${VERSION} pushed to github, github actions should now be building the draft release. If it seems good, click to publish it"
|
echo "Tag ${VERSION} pushed to github, github actions should now be building the draft release. If it seems good, click to publish it"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
cd protobufs && ..\nanopb-0.4.6\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs *.proto
|
cd protobufs && ..\nanopb-0.4.7\generator-bin\protoc.exe --nanopb_out=-v:..\src\mesh\generated -I=..\protobufs *.proto
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.6 to be located in the"
|
echo "This script requires https://jpa.kapsi.fi/nanopb/download/ version 0.4.7 to be located in the"
|
||||||
echo "meshtastic-device root directory if the following step fails, you should download the correct"
|
echo "firmware root directory if the following step fails, you should download the correct"
|
||||||
echo "prebuilt binaries for your computer into nanopb-0.4.6"
|
echo "prebuilt binaries for your computer into nanopb-0.4.7"
|
||||||
|
|
||||||
# the nanopb tool seems to require that the .options file be in the current directory!
|
# the nanopb tool seems to require that the .options file be in the current directory!
|
||||||
cd protobufs
|
cd protobufs
|
||||||
../nanopb-0.4.6/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated -I=../protobufs *.proto
|
../nanopb-0.4.7/generator-bin/protoc --nanopb_out=-v:../src/mesh/generated -I=../protobufs *.proto
|
||||||
|
|
||||||
#echo "Regenerating protobuf documentation - if you see an error message"
|
#echo "Regenerating protobuf documentation - if you see an error message"
|
||||||
#echo "you can ignore it unless doing a new protobuf release to github."
|
#echo "you can ignore it unless doing a new protobuf release to github."
|
||||||
|
|||||||
46
boards/tbeam-s3-core.json
Normal file
46
boards/tbeam-s3-core.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"arduino": {
|
||||||
|
"ldscript": "esp32s3_out.ld"
|
||||||
|
},
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": [
|
||||||
|
"-DBOARD_HAS_PSRAM",
|
||||||
|
"-DLILYGO_TBEAM_S3_CORE",
|
||||||
|
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||||
|
"-DARDUINO_USB_MODE=0",
|
||||||
|
"-DARDUINO_RUNNING_CORE=1",
|
||||||
|
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||||
|
],
|
||||||
|
"f_cpu": "240000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "dio",
|
||||||
|
"hwids": [
|
||||||
|
[
|
||||||
|
"0X303A",
|
||||||
|
"0x1001"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"mcu": "esp32s3",
|
||||||
|
"variant": "tbeam-s3-core"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32s3.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino"
|
||||||
|
],
|
||||||
|
"name": "LilyGo TBeam-S3-Core",
|
||||||
|
"upload": {
|
||||||
|
"flash_size": "8MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 8388608,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 921600
|
||||||
|
},
|
||||||
|
"url": "http://www.lilygo.cn/",
|
||||||
|
"vendor": "LilyGo"
|
||||||
|
}
|
||||||
47
boards/tlora-t3s3-v1.json
Normal file
47
boards/tlora-t3s3-v1.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"arduino": {
|
||||||
|
"ldscript": "esp32s3_out.ld"
|
||||||
|
},
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": [
|
||||||
|
"-DLILYGO_T3S3_V1",
|
||||||
|
"-DARDUINO_USB_CDC_ON_BOOT=1",
|
||||||
|
"-DARDUINO_USB_MODE=0",
|
||||||
|
"-DARDUINO_RUNNING_CORE=1",
|
||||||
|
"-DARDUINO_EVENT_RUNNING_CORE=1"
|
||||||
|
],
|
||||||
|
"f_cpu": "240000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "dio",
|
||||||
|
"hwids": [
|
||||||
|
[
|
||||||
|
"0X303A",
|
||||||
|
"0x1001"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"mcu": "esp32s3",
|
||||||
|
"variant": "tlora-t3s3-v1"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32s3.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "LilyGo TLora-T3S3-V1",
|
||||||
|
"upload": {
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"wait_for_upload_port": true,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 921600
|
||||||
|
},
|
||||||
|
"url": "http://www.lilygo.cn/",
|
||||||
|
"vendor": "LilyGo"
|
||||||
|
}
|
||||||
13
docker-compose.yml
Normal file
13
docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: "3.7"
|
||||||
|
|
||||||
|
services:
|
||||||
|
meshtastic-node:
|
||||||
|
build: .
|
||||||
|
deploy:
|
||||||
|
mode: replicated
|
||||||
|
replicas: 4
|
||||||
|
networks:
|
||||||
|
- mesh
|
||||||
|
|
||||||
|
networks:
|
||||||
|
mesh:
|
||||||
Binary file not shown.
@@ -1,7 +1,8 @@
|
|||||||
# FIXME! using the genpartitions based table doesn't work on TTGO so for now I stay with my old memory map
|
# FIXME! using the genpartitions based table doesn't work on TTGO so for now I stay with my old memory map
|
||||||
# This is a layout for 4MB of flash
|
# This is a layout for 4MB of flash
|
||||||
# Name, Type, SubType, Offset, Size, Flags
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
nvs, data, nvs, 0x9000, 0x5000,
|
nvs, data, nvs, 0x009000, 0x005000,
|
||||||
otadata, data, ota, 0xe000, 0x2000,
|
otadata, data, ota, 0x00e000, 0x002000,
|
||||||
app0, app, ota_0, 0x10000, 0x2A0000,
|
app, app, ota_0, 0x010000, 0x250000,
|
||||||
spiffs, data, spiffs, 0x2B0000,0x150000,
|
flashApp, app, ota_1, 0x260000, 0x0A0000,
|
||||||
|
spiffs, data, spiffs, 0x300000, 0x100000,
|
||||||
|
170
platformio.ini
170
platformio.ini
@@ -2,13 +2,14 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = tbeam
|
;default_envs = tbeam
|
||||||
|
;default_envs = pico
|
||||||
|
;default_envs = tbeam-s3-core
|
||||||
;default_envs = tbeam0.7
|
;default_envs = tbeam0.7
|
||||||
;default_envs = heltec-v1
|
;default_envs = heltec-v1
|
||||||
;default_envs = heltec-v2.0
|
;default_envs = heltec-v2.0
|
||||||
;default_envs = heltec-v2.1
|
;default_envs = heltec-v2.1
|
||||||
;default_envs = tlora-v1
|
;default_envs = tlora-v1
|
||||||
;default_envs = tlora-v1
|
|
||||||
;default_envs = tlora_v1_3
|
;default_envs = tlora_v1_3
|
||||||
;default_envs = tlora-v2
|
;default_envs = tlora-v2
|
||||||
;default_envs = tlora-v2-1-1.6
|
;default_envs = tlora-v2-1-1.6
|
||||||
@@ -20,10 +21,13 @@ default_envs = tbeam
|
|||||||
;default_envs = pca10059_diy_eink
|
;default_envs = pca10059_diy_eink
|
||||||
;default_envs = meshtastic-diy-v1
|
;default_envs = meshtastic-diy-v1
|
||||||
;default_envs = meshtastic-diy-v1.1
|
;default_envs = meshtastic-diy-v1.1
|
||||||
|
;default_envs = meshtastic-dr-dev
|
||||||
;default_envs = m5stack-coreink
|
;default_envs = m5stack-coreink
|
||||||
;default_envs = rak4631
|
;default_envs = rak4631
|
||||||
|
|
||||||
extra_configs = variants/*/platformio.ini
|
extra_configs =
|
||||||
|
arch/*/*.ini
|
||||||
|
variants/*/platformio.ini
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
extra_scripts = bin/platformio-custom.py
|
extra_scripts = bin/platformio-custom.py
|
||||||
@@ -32,47 +36,63 @@ extra_scripts = bin/platformio-custom.py
|
|||||||
; note: TINYGPS_OPTION_NO_CUSTOM_FIELDS is VERY important. We don't use custom fields and somewhere in that pile
|
; note: TINYGPS_OPTION_NO_CUSTOM_FIELDS is VERY important. We don't use custom fields and somewhere in that pile
|
||||||
; of code is a heap corruption bug!
|
; of code is a heap corruption bug!
|
||||||
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
|
; FIXME: fix lib/BluetoothOTA dependency back on src/ so we can remove -Isrc
|
||||||
|
; The Radiolib stuff will speed up building considerably. Exclud all the stuff we dont need.
|
||||||
build_flags = -Wno-missing-field-initializers
|
build_flags = -Wno-missing-field-initializers
|
||||||
-Wno-format
|
-Wno-format
|
||||||
-Isrc -Isrc/mesh -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map
|
-Isrc -Isrc/mesh -Isrc/gps -Isrc/buzz -Wl,-Map,.pio/build/output.map
|
||||||
-DUSE_THREAD_NAMES
|
-DUSE_THREAD_NAMES
|
||||||
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
|
-DTINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
-DPB_ENABLE_MALLOC=1
|
-DPB_ENABLE_MALLOC=1
|
||||||
|
-DRADIOLIB_EXCLUDE_CC1101
|
||||||
|
-DRADIOLIB_EXCLUDE_NRF24
|
||||||
|
-DRADIOLIB_EXCLUDE_RF69
|
||||||
|
-DRADIOLIB_EXCLUDE_SX1231
|
||||||
|
-DRADIOLIB_EXCLUDE_SI443X
|
||||||
|
-DRADIOLIB_EXCLUDE_RFM2X
|
||||||
|
-DRADIOLIB_EXCLUDE_AFSK
|
||||||
|
-DRADIOLIB_EXCLUDE_HELLSCHREIBER
|
||||||
|
-DRADIOLIB_EXCLUDE_MORSE
|
||||||
|
-DRADIOLIB_EXCLUDE_RTTY
|
||||||
|
-DRADIOLIB_EXCLUDE_SSTV
|
||||||
|
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git#53580644255b48ebb7a737343c6b4e71c7e11cf2 ; ESP8266_SSD1306
|
https://github.com/meshtastic/esp8266-oled-ssd1306.git#53580644255b48ebb7a737343c6b4e71c7e11cf2 ; ESP8266_SSD1306
|
||||||
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
||||||
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159
|
||||||
https://github.com/meshtastic/arduino-fsm.git
|
https://github.com/meshtastic/TinyGPSPlus.git#127ad674ef85f0201cb68a065879653ed94792c4
|
||||||
https://github.com/meshtastic/TinyGPSPlus.git
|
|
||||||
Wire ; explicitly needed here because the AXP202 library forgets to add it
|
|
||||||
SPI
|
|
||||||
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
https://github.com/meshtastic/ArduinoThread.git#72921ac222eed6f526ba1682023cee290d9aa1b3
|
||||||
nanopb/Nanopb@^0.4.6
|
nanopb/Nanopb@^0.4.6
|
||||||
|
erriez/ErriezCRC32@^1.0.1
|
||||||
|
; jgromes/RadioLib@^5.5.1
|
||||||
|
https://github.com/jgromes/RadioLib.git#395844922c5d88d5db0481a9c91479931172428d
|
||||||
|
|
||||||
; Used for the code analysis in PIO Home / Inspect
|
; Used for the code analysis in PIO Home / Inspect
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_skip_packages = yes
|
check_skip_packages = yes
|
||||||
|
check_flags =
|
||||||
|
-DAPP_VERSION=1.0.0
|
||||||
|
--suppressions-list=suppressions.txt
|
||||||
|
--inline-suppr
|
||||||
|
|
||||||
; Common settings for conventional (non Portduino) Arduino targets
|
; Common settings for conventional (non Portduino) Arduino targets
|
||||||
[arduino_base]
|
[arduino_base]
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.lib_deps}
|
${env.lib_deps}
|
||||||
; Portduino is using meshtastic fork for now
|
mprograms/QMC5883LCompass@^1.1.1
|
||||||
https://github.com/jgromes/RadioLib.git
|
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||||
|
https://github.com/meshtastic/SparkFun_ATECCX08a_Arduino_Library.git#52b5282639d08a8cbd4b748363089eed6102dc76
|
||||||
|
|
||||||
build_flags = ${env.build_flags} -Os
|
build_flags = ${env.build_flags} -Os -DRADIOLIB_SPI_PARANOID=0
|
||||||
# -DRADIOLIB_GODMODE
|
|
||||||
build_src_filter = ${env.build_src_filter} -<platform/portduino/>
|
build_src_filter = ${env.build_src_filter} -<platform/portduino/>
|
||||||
|
|
||||||
; Common libs for communicating over TCP/IP networks such as MQTT
|
; Common libs for communicating over TCP/IP networks such as MQTT
|
||||||
[networking_base]
|
[networking_base]
|
||||||
lib_deps =
|
lib_deps =
|
||||||
PubSubClient
|
knolleary/PubSubClient@^2.8
|
||||||
meshtastic/json11@^1.0.2
|
arduino-libraries/NTPClient@^3.1.0
|
||||||
|
|
||||||
; Common libs for environmental measurements in telemetry module
|
; Common libs for environmental measurements in telemetry module
|
||||||
; (not included in native / portduino)
|
; (not included in native / portduino)
|
||||||
@@ -80,126 +100,12 @@ lib_deps =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
adafruit/Adafruit BusIO@^1.11.4
|
adafruit/Adafruit BusIO@^1.11.4
|
||||||
adafruit/Adafruit Unified Sensor@^1.1.4
|
adafruit/Adafruit Unified Sensor@^1.1.4
|
||||||
adafruit/Adafruit BMP280 Library@^2.6.3
|
adafruit/Adafruit BMP280 Library@^2.6.6
|
||||||
adafruit/Adafruit BME280 Library@^2.2.2
|
adafruit/Adafruit BME280 Library@^2.2.2
|
||||||
adafruit/Adafruit BME680 Library@^2.0.1
|
adafruit/Adafruit BME680 Library@^2.0.1
|
||||||
adafruit/Adafruit MCP9808 Library@^2.0.0
|
adafruit/Adafruit MCP9808 Library@^2.0.0
|
||||||
adafruit/Adafruit INA260 Library@^1.5.0
|
adafruit/Adafruit INA260 Library@^1.5.0
|
||||||
adafruit/Adafruit INA219@^1.2.0
|
adafruit/Adafruit INA219@^1.2.0
|
||||||
; Common settings for ESP targes, mixin with extends = esp32_base
|
adafruit/Adafruit SHTC3 Library@^1.0.0
|
||||||
[esp32_base]
|
adafruit/Adafruit LPS2X@^2.0.4
|
||||||
extends = arduino_base
|
adafruit/Adafruit SHT31 Library@^2.2.0
|
||||||
platform = espressif32@3.5.0
|
|
||||||
build_src_filter =
|
|
||||||
${arduino_base.build_src_filter} -<platform/nrf52/> -<platform/stm32wl> -<platform/rp2040>
|
|
||||||
upload_speed = 115200
|
|
||||||
debug_init_break = tbreak setup
|
|
||||||
|
|
||||||
# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
|
|
||||||
# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
|
|
||||||
# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
|
|
||||||
build_flags =
|
|
||||||
${arduino_base.build_flags} -Wall -Wextra -Isrc/platform/esp32 -lnimble -std=c++11
|
|
||||||
-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
|
|
||||||
-DAXP_DEBUG_PORT=Serial -DCONFIG_BT_NIMBLE_ENABLED -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2 -DCONFIG_BT_NIMBLE_MAX_CCCDS=20
|
|
||||||
lib_deps =
|
|
||||||
${arduino_base.lib_deps}
|
|
||||||
${networking_base.lib_deps}
|
|
||||||
${environmental_base.lib_deps}
|
|
||||||
https://github.com/meshtastic/esp32_https_server.git
|
|
||||||
h2zero/NimBLE-Arduino@1.4.0
|
|
||||||
arduino-libraries/NTPClient@^3.1.0
|
|
||||||
lorol/LittleFS_esp32@^1.0.6
|
|
||||||
https://github.com/meshtastic/AXP202X_Library.git#8404abb6d4b486748636bc6ad72d2a47baaf5460
|
|
||||||
|
|
||||||
lib_ignore =
|
|
||||||
segger_rtt
|
|
||||||
ESP32 BLE Arduino
|
|
||||||
platform_packages =
|
|
||||||
framework-arduinoespressif32@https://github.com/meshtastic/arduino-esp32.git#4cde0f5d412d2695184f32e8a47e9bea57b45276
|
|
||||||
|
|
||||||
; leave this commented out to avoid breaking Windows
|
|
||||||
;upload_port = /dev/ttyUSB0
|
|
||||||
;monitor_port = /dev/ttyUSB0
|
|
||||||
|
|
||||||
; Please don't delete these lines. JM uses them.
|
|
||||||
;upload_port = /dev/cu.SLAB_USBtoUART
|
|
||||||
;monitor_port = /dev/cu.SLAB_USBtoUART
|
|
||||||
|
|
||||||
; customize the partition table
|
|
||||||
; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
|
|
||||||
board_build.partitions = partition-table.csv
|
|
||||||
|
|
||||||
[nrf52_base]
|
|
||||||
; Instead of the standard nordicnrf52 platform, we use our fork which has our added variant files
|
|
||||||
; platform = nordicnrf52 ;pending https://github.com/platformio/builder-framework-arduino-nrf5/pull/7
|
|
||||||
platform = https://github.com/meshtastic/platform-nordicnrf52.git#merge
|
|
||||||
|
|
||||||
extends = arduino_base
|
|
||||||
build_type = debug ; I'm debugging with ICE a lot now
|
|
||||||
; note: liboberon provides the AES256 implementation for NRF52 (though not using the hardware acceleration of the NRF52840 - FIXME)
|
|
||||||
build_flags =
|
|
||||||
${arduino_base.build_flags} -Wno-unused-variable
|
|
||||||
-Isrc/platform/nrf52
|
|
||||||
build_src_filter =
|
|
||||||
${arduino_base.build_src_filter} -<platform/esp32/> -<platform/stm32wl> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<platform/rp2040>
|
|
||||||
lib_ignore =
|
|
||||||
BluetoothOTA
|
|
||||||
|
|
||||||
[nrf52840_base]
|
|
||||||
extends = nrf52_base
|
|
||||||
build_flags = ${nrf52_base.build_flags}
|
|
||||||
lib_deps =
|
|
||||||
${arduino_base.lib_deps}
|
|
||||||
${environmental_base.lib_deps}
|
|
||||||
https://github.com/Kongduino/Adafruit_nRFCrypto.git
|
|
||||||
|
|
||||||
; Note: By default no lora device is created for this build - it uses a simulated interface
|
|
||||||
[env:nrf52840dk]
|
|
||||||
extends = nrf52840_base
|
|
||||||
board = nrf52840_dk
|
|
||||||
|
|
||||||
; Note: By default no lora device is created for this build - it uses a simulated interface
|
|
||||||
[env:feather_nrf52832]
|
|
||||||
extends = nrf52_base
|
|
||||||
board = adafruit_feather_nrf52832
|
|
||||||
|
|
||||||
; Common settings for rp2040 Processor based targets
|
|
||||||
[rp2040_base]
|
|
||||||
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
|
|
||||||
extends = arduino_base
|
|
||||||
board_build.core = earlephilhower
|
|
||||||
board_build.filesystem_size = 0.5m
|
|
||||||
build_flags =
|
|
||||||
${arduino_base.build_flags} -Wno-unused-variable
|
|
||||||
-Isrc/platform/rp2040
|
|
||||||
-D__PLAT_RP2040__
|
|
||||||
# -D _POSIX_THREADS
|
|
||||||
build_src_filter =
|
|
||||||
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<platform/nrf52/> -<platform/stm32wl>
|
|
||||||
lib_ignore =
|
|
||||||
BluetoothOTA
|
|
||||||
lib_deps =
|
|
||||||
${arduino_base.lib_deps}
|
|
||||||
${environmental_base.lib_deps}
|
|
||||||
https://github.com/kokke/tiny-AES-c.git
|
|
||||||
|
|
||||||
[stm32wl5e_base]
|
|
||||||
platform = ststm32
|
|
||||||
board = generic_wl5e
|
|
||||||
framework = arduino
|
|
||||||
build_type = debug
|
|
||||||
build_flags =
|
|
||||||
${arduino_base.build_flags}
|
|
||||||
-Isrc/platform/stm32wl -g
|
|
||||||
-DHAL_SUBGHZ_MODULE_ENABLED
|
|
||||||
# Arduino/PlatformIO framework-arduinoststm32 package does not presently have SUBGHZSPI support
|
|
||||||
# -DPIN_SPI_MOSI=PINSUBGHZSPIMOSI -DPIN_SPI_MISO=PINSUBGHZSPIMISO -DPIN_SPI_SCK=PINSUBGHZSPISCK
|
|
||||||
build_src_filter =
|
|
||||||
${arduino_base.build_src_filter} -<platform/esp32/> -<nimble/> -<mesh/wifi/> -<mesh/http/> -<modules/esp32> -<mqtt/> -<graphics> -<input> -<buzz> -<modules/Telemetry> -<platform/nrf52> -<platform/portduino> -<platform/rp2040>
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
https://github.com/jgromes/RadioLib.git
|
|
||||||
https://github.com/kokke/tiny-AES-c.git
|
|
||||||
lib_ignore =
|
|
||||||
mathertel/OneButton@^2.0.3
|
|
||||||
|
|||||||
Submodule protobufs updated: a72983993c...79e213fbcc
@@ -7,7 +7,7 @@ const uint8_t MESH_SERVICE_UUID_16[16u] = {0xfd, 0xea, 0x73, 0xe2, 0xca, 0x5d, 0
|
|||||||
0x1f, 0x46, 0xa8, 0x15, 0x18, 0xb2, 0xa1, 0x6b};
|
0x1f, 0x46, 0xa8, 0x15, 0x18, 0xb2, 0xa1, 0x6b};
|
||||||
const uint8_t TORADIO_UUID_16[16u] = {0xe7, 0x01, 0x44, 0x12, 0x66, 0x78, 0xdd, 0xa1,
|
const uint8_t TORADIO_UUID_16[16u] = {0xe7, 0x01, 0x44, 0x12, 0x66, 0x78, 0xdd, 0xa1,
|
||||||
0xad, 0x4d, 0x9e, 0x12, 0xd2, 0x76, 0x5c, 0xf7};
|
0xad, 0x4d, 0x9e, 0x12, 0xd2, 0x76, 0x5c, 0xf7};
|
||||||
const uint8_t FROMRADIO_UUID_16[16u] = {0xd5, 0x54, 0xe4, 0xc5, 0x25, 0xc5, 0x31, 0xa5,
|
const uint8_t FROMRADIO_UUID_16[16u] = {0x02, 0x00, 0x12, 0xac, 0x42, 0x02, 0x78, 0xb8,
|
||||||
0x55, 0x4a, 0x02, 0xee, 0xc2, 0xbc, 0xa2, 0x8b};
|
0xed, 0x11, 0x93, 0x49, 0x9e, 0xe6, 0x55, 0x2c};
|
||||||
const uint8_t FROMNUM_UUID_16[16u] = {0x53, 0x44, 0xe3, 0x47, 0x75, 0xaa, 0x70, 0xa6,
|
const uint8_t FROMNUM_UUID_16[16u] = {0x53, 0x44, 0xe3, 0x47, 0x75, 0xaa, 0x70, 0xa6,
|
||||||
0x66, 0x4f, 0x00, 0xa8, 0x8c, 0xa1, 0x9d, 0xed};
|
0x66, 0x4f, 0x00, 0xa8, 0x8c, 0xa1, 0x9d, 0xed};
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#define MESH_SERVICE_UUID "6ba1b218-15a8-461f-9fa8-5dcae273eafd"
|
#define MESH_SERVICE_UUID "6ba1b218-15a8-461f-9fa8-5dcae273eafd"
|
||||||
|
|
||||||
#define TORADIO_UUID "f75c76d2-129e-4dad-a1dd-7866124401e7"
|
#define TORADIO_UUID "f75c76d2-129e-4dad-a1dd-7866124401e7"
|
||||||
#define FROMRADIO_UUID "8ba2bcc2-ee02-4a55-a531-c525c5e454d5"
|
#define FROMRADIO_UUID "2c55e69e-4993-11ed-b878-0242ac120002"
|
||||||
#define FROMNUM_UUID "ed9da18c-a800-4f66-a670-aa7547e34453"
|
#define FROMNUM_UUID "ed9da18c-a800-4f66-a670-aa7547e34453"
|
||||||
|
|
||||||
// NRF52 wants these constants as byte arrays
|
// NRF52 wants these constants as byte arrays
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
pinMode(BUTTON_PIN, INPUT_PULLUP_SENSE);
|
pinMode(BUTTON_PIN, INPUT_PULLUP_SENSE);
|
||||||
#endif
|
#endif
|
||||||
userButton.attachClick(userButtonPressed);
|
userButton.attachClick(userButtonPressed);
|
||||||
|
userButton.setClickTicks(300);
|
||||||
userButton.attachDuringLongPress(userButtonPressedLong);
|
userButton.attachDuringLongPress(userButtonPressedLong);
|
||||||
userButton.attachDoubleClick(userButtonDoublePressed);
|
userButton.attachDoubleClick(userButtonDoublePressed);
|
||||||
userButton.attachMultiClick(userButtonMultiPressed);
|
userButton.attachMultiClick(userButtonMultiPressed);
|
||||||
@@ -128,8 +129,8 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
#endif
|
#endif
|
||||||
// If user button is held down for 5 seconds, shutdown the device.
|
// If user button is held down for 5 seconds, shutdown the device.
|
||||||
if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
|
if ((millis() - longPressTime > 5 * 1000) && (longPressTime > 0)) {
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_PMU
|
||||||
if (axp192_found == true) {
|
if (pmu_found == true) {
|
||||||
setLed(false);
|
setLed(false);
|
||||||
power->shutdown();
|
power->shutdown();
|
||||||
}
|
}
|
||||||
@@ -159,21 +160,28 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
|
|
||||||
static void userButtonDoublePressed()
|
static void userButtonDoublePressed()
|
||||||
{
|
{
|
||||||
#ifdef ARCH_ESP32
|
#if defined(USE_EINK) && defined(PIN_EINK_EN)
|
||||||
disablePin();
|
|
||||||
#elif defined(USE_EINK)
|
|
||||||
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
digitalWrite(PIN_EINK_EN, digitalRead(PIN_EINK_EN) == LOW);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(GPS_POWER_TOGGLE)
|
||||||
|
if(config.position.gps_enabled)
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Flag set to false for gps power\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG_MSG("Flag set to true to restore power\n");
|
||||||
|
}
|
||||||
|
config.position.gps_enabled = !(config.position.gps_enabled);
|
||||||
|
doGPSpowersave(config.position.gps_enabled);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void userButtonMultiPressed()
|
static void userButtonMultiPressed()
|
||||||
{
|
{
|
||||||
#ifdef ARCH_ESP32
|
screen->print("Sent ad-hoc ping\n");
|
||||||
clearNVS();
|
service.refreshMyNodeInfo();
|
||||||
#endif
|
service.sendNetworkPing(NODENUM_BROADCAST, true);
|
||||||
#ifdef ARCH_NRF52
|
|
||||||
clearBonds();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void userButtonPressedLongStart()
|
static void userButtonPressedLongStart()
|
||||||
|
|||||||
180
src/FSCommon.cpp
180
src/FSCommon.cpp
@@ -1,6 +1,18 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
|
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <SD.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SDCARD_USE_SPI1
|
||||||
|
SPIClass SPI1(HSPI);
|
||||||
|
#define SDHandler SPI1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //HAS_SDCARD
|
||||||
|
|
||||||
bool copyFile(const char* from, const char* to)
|
bool copyFile(const char* from, const char* to)
|
||||||
{
|
{
|
||||||
@@ -9,13 +21,13 @@ bool copyFile(const char* from, const char* to)
|
|||||||
|
|
||||||
File f1 = FSCom.open(from, FILE_O_READ);
|
File f1 = FSCom.open(from, FILE_O_READ);
|
||||||
if (!f1){
|
if (!f1){
|
||||||
DEBUG_MSG("Failed to open file");
|
DEBUG_MSG("Failed to open source file %s\n", from);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
File f2 = FSCom.open(to, FILE_O_WRITE);
|
File f2 = FSCom.open(to, FILE_O_WRITE);
|
||||||
if (!f2) {
|
if (!f2) {
|
||||||
DEBUG_MSG("Failed to open file");
|
DEBUG_MSG("Failed to open destination file %s\n", to);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,17 +45,25 @@ bool copyFile(const char* from, const char* to)
|
|||||||
bool renameFile(const char* pathFrom, const char* pathTo)
|
bool renameFile(const char* pathFrom, const char* pathTo)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
// rename was fixed for ESP32 IDF LittleFS in April
|
||||||
|
return FSCom.rename(pathFrom, pathTo);
|
||||||
|
#else
|
||||||
if (copyFile(pathFrom, pathTo) && FSCom.remove(pathFrom) ) {
|
if (copyFile(pathFrom, pathTo) && FSCom.remove(pathFrom) ) {
|
||||||
return true;
|
return true;
|
||||||
} else{
|
} else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void listDir(const char * dirname, uint8_t levels)
|
void listDir(const char * dirname, uint8_t levels, boolean del = false)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
|
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
char buffer[255];
|
||||||
|
#endif
|
||||||
File root = FSCom.open(dirname, FILE_O_READ);
|
File root = FSCom.open(dirname, FILE_O_READ);
|
||||||
if(!root){
|
if(!root){
|
||||||
return;
|
return;
|
||||||
@@ -56,55 +76,92 @@ void listDir(const char * dirname, uint8_t levels)
|
|||||||
while(file){
|
while(file){
|
||||||
if(file.isDirectory() && !String(file.name()).endsWith(".")) {
|
if(file.isDirectory() && !String(file.name()).endsWith(".")) {
|
||||||
if(levels){
|
if(levels){
|
||||||
listDir(file.name(), levels -1);
|
#ifdef ARCH_ESP32
|
||||||
|
listDir(file.path(), levels -1, del);
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", file.path());
|
||||||
|
strcpy(buffer, file.path());
|
||||||
|
file.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
listDir(file.name(), levels -1, del);
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", file.name());
|
||||||
|
strcpy(buffer, file.name());
|
||||||
|
file.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
listDir(file.name(), levels -1, del);
|
||||||
|
file.close();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
#ifdef ARCH_ESP32
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Deleting %s\n", file.path());
|
||||||
|
strcpy(buffer, file.path());
|
||||||
|
file.close();
|
||||||
|
FSCom.remove(buffer);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG(" %s (%i Bytes)\n", file.path(), file.size());
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Deleting %s\n", file.name());
|
||||||
|
strcpy(buffer, file.name());
|
||||||
|
file.close();
|
||||||
|
FSCom.remove(buffer);
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
DEBUG_MSG(" %s (%i Bytes)\n", file.name(), file.size());
|
||||||
|
file.close();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
file.close();
|
|
||||||
file = root.openNextFile();
|
file = root.openNextFile();
|
||||||
}
|
}
|
||||||
file.close();
|
#ifdef ARCH_ESP32
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", root.path());
|
||||||
|
strcpy(buffer, root.path());
|
||||||
|
root.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
|
#elif (defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
|
if(del) {
|
||||||
|
DEBUG_MSG("Removing %s\n", root.name());
|
||||||
|
strcpy(buffer, root.name());
|
||||||
|
root.close();
|
||||||
|
FSCom.rmdir(buffer);
|
||||||
|
} else {
|
||||||
|
root.close();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
root.close();
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void rmDir(const char * dirname)
|
void rmDir(const char * dirname)
|
||||||
{
|
{
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
File file = FSCom.open(dirname, FILE_O_READ);
|
#if (defined(ARCH_ESP32) || defined(ARCH_RP2040) || defined(ARCH_PORTDUINO))
|
||||||
if(!file){
|
listDir(dirname, 10, true);
|
||||||
return;
|
#elif defined(ARCH_NRF52)
|
||||||
}
|
// nRF52 implementation of LittleFS has a recursive delete function
|
||||||
if(!file.isDirectory()){
|
FSCom.rmdir_r(dirname);
|
||||||
file.close();
|
#endif
|
||||||
FSCom.remove(file.name());
|
|
||||||
// DEBUG_MSG("Remove FILE %s\n", file.name());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.rewindDirectory();
|
|
||||||
while (true) {
|
|
||||||
File entry = file.openNextFile();
|
|
||||||
if (!entry) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
char dirpath[100]; // array to hold the result.
|
|
||||||
strcpy(dirpath, dirname); // copy string one into the result.
|
|
||||||
strcat(dirpath,"/"); // append string two to the result.
|
|
||||||
strcat(dirpath,entry.name()); // append string two to the result.
|
|
||||||
if(entry.isDirectory() && !String(entry.name()).endsWith(".")) {
|
|
||||||
entry.close();
|
|
||||||
// DEBUG_MSG("Descend DIR %s\n", dirpath);
|
|
||||||
rmDir(dirpath);
|
|
||||||
} else {
|
|
||||||
entry.close();
|
|
||||||
// DEBUG_MSG("Remove FILE %s\n", entry.name());
|
|
||||||
FSCom.remove(entry.name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FSCom.rmdir(dirname);
|
|
||||||
// DEBUG_MSG("Remove DIR %s\n", dirname);
|
|
||||||
file.close();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,8 +173,47 @@ void fsInit()
|
|||||||
DEBUG_MSG("ERROR filesystem mount Failed. Formatting...\n");
|
DEBUG_MSG("ERROR filesystem mount Failed. Formatting...\n");
|
||||||
assert(0); // FIXME - report failure to phone
|
assert(0); // FIXME - report failure to phone
|
||||||
}
|
}
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
DEBUG_MSG("Filesystem files (%d/%d Bytes):\n", FSCom.usedBytes(), FSCom.totalBytes());
|
||||||
|
#else
|
||||||
DEBUG_MSG("Filesystem files:\n");
|
DEBUG_MSG("Filesystem files:\n");
|
||||||
|
#endif
|
||||||
listDir("/", 10);
|
listDir("/", 10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setupSDCard()
|
||||||
|
{
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
SDHandler.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
|
||||||
|
|
||||||
|
if (!SD.begin(SDCARD_CS, SDHandler)) {
|
||||||
|
DEBUG_MSG("No SD_MMC card detected\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
uint8_t cardType = SD.cardType();
|
||||||
|
if (cardType == CARD_NONE) {
|
||||||
|
DEBUG_MSG("No SD_MMC card attached\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
DEBUG_MSG("SD_MMC Card Type: ");
|
||||||
|
if (cardType == CARD_MMC) {
|
||||||
|
DEBUG_MSG("MMC\n");
|
||||||
|
} else if (cardType == CARD_SD) {
|
||||||
|
DEBUG_MSG("SDSC\n");
|
||||||
|
} else if (cardType == CARD_SDHC) {
|
||||||
|
DEBUG_MSG("SDHC\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("UNKNOWN\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||||
|
DEBUG_MSG("SD Card Size: %lluMB\n", cardSize);
|
||||||
|
DEBUG_MSG("Total space: %llu MB\n", SD.totalBytes() / (1024 * 1024));
|
||||||
|
DEBUG_MSG("Used space: %llu MB\n", SD.usedBytes() / (1024 * 1024));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
#if defined(ARCH_ESP32)
|
#if defined(ARCH_ESP32)
|
||||||
// ESP32 version
|
// ESP32 version
|
||||||
#include "LITTLEFS.h"
|
#include "LittleFS.h"
|
||||||
#define FSCom LITTLEFS
|
#define FSCom LittleFS
|
||||||
#define FSBegin() FSCom.begin(true)
|
#define FSBegin() FSCom.begin(true)
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
@@ -40,6 +40,8 @@ using namespace Adafruit_LittleFS_Namespace;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void fsInit();
|
void fsInit();
|
||||||
|
bool copyFile(const char* from, const char* to);
|
||||||
bool renameFile(const char* pathFrom, const char* pathTo);
|
bool renameFile(const char* pathFrom, const char* pathTo);
|
||||||
void listDir(const char * dirname, uint8_t levels);
|
void listDir(const char * dirname, uint8_t levels, boolean del);
|
||||||
void rmDir(const char * dirname);
|
void rmDir(const char * dirname);
|
||||||
|
void setupSDCard();
|
||||||
@@ -20,32 +20,19 @@ class GPSStatus : public Status
|
|||||||
bool hasLock = false; // default to false, until we complete our first read
|
bool hasLock = false; // default to false, until we complete our first read
|
||||||
bool isConnected = false; // Do we have a GPS we are talking to
|
bool isConnected = false; // Do we have a GPS we are talking to
|
||||||
|
|
||||||
|
bool isPowerSaving = false; //Are we in power saving state
|
||||||
|
|
||||||
Position p = Position_init_default;
|
Position p = Position_init_default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GPSStatus() { statusType = STATUS_TYPE_GPS; }
|
GPSStatus() { statusType = STATUS_TYPE_GPS; }
|
||||||
|
|
||||||
// proposed for deprecation
|
|
||||||
GPSStatus(bool hasLock, bool isConnected, int32_t latitude, int32_t longitude, int32_t altitude, uint32_t dop,
|
|
||||||
uint32_t heading, uint32_t numSatellites)
|
|
||||||
: Status()
|
|
||||||
{
|
|
||||||
this->hasLock = hasLock;
|
|
||||||
this->isConnected = isConnected;
|
|
||||||
|
|
||||||
this->p.latitude_i = latitude;
|
|
||||||
this->p.longitude_i = longitude;
|
|
||||||
this->p.altitude = altitude;
|
|
||||||
this->p.PDOP = dop;
|
|
||||||
this->p.ground_track = heading;
|
|
||||||
this->p.sats_in_view = numSatellites;
|
|
||||||
}
|
|
||||||
|
|
||||||
// preferred method
|
// preferred method
|
||||||
GPSStatus(bool hasLock, bool isConnected, const Position &pos) : Status()
|
GPSStatus(bool hasLock, bool isConnected, bool isPowerSaving, const Position &pos) : Status()
|
||||||
{
|
{
|
||||||
this->hasLock = hasLock;
|
this->hasLock = hasLock;
|
||||||
this->isConnected = isConnected;
|
this->isConnected = isConnected;
|
||||||
|
this->isPowerSaving = isPowerSaving;
|
||||||
|
|
||||||
// all-in-one struct copy
|
// all-in-one struct copy
|
||||||
this->p = pos;
|
this->p = pos;
|
||||||
@@ -60,6 +47,8 @@ class GPSStatus : public Status
|
|||||||
|
|
||||||
bool getIsConnected() const { return isConnected; }
|
bool getIsConnected() const { return isConnected; }
|
||||||
|
|
||||||
|
bool getIsPowerSaving() const { return isPowerSaving;}
|
||||||
|
|
||||||
int32_t getLatitude() const
|
int32_t getLatitude() const
|
||||||
{
|
{
|
||||||
if (config.position.fixed_position) {
|
if (config.position.fixed_position) {
|
||||||
@@ -110,10 +99,11 @@ class GPSStatus : public Status
|
|||||||
#ifdef GPS_EXTRAVERBOSE
|
#ifdef GPS_EXTRAVERBOSE
|
||||||
DEBUG_MSG("GPSStatus.match() new pos@%x to old pos@%x\n", newStatus->p.pos_timestamp, p.pos_timestamp);
|
DEBUG_MSG("GPSStatus.match() new pos@%x to old pos@%x\n", newStatus->p.pos_timestamp, p.pos_timestamp);
|
||||||
#endif
|
#endif
|
||||||
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected ||
|
return (newStatus->hasLock != hasLock || newStatus->isConnected != isConnected || newStatus->isPowerSaving !=isPowerSaving ||
|
||||||
newStatus->p.latitude_i != p.latitude_i || newStatus->p.longitude_i != p.longitude_i ||
|
newStatus->p.latitude_i != p.latitude_i || newStatus->p.longitude_i != p.longitude_i ||
|
||||||
newStatus->p.altitude != p.altitude || newStatus->p.altitude_hae != p.altitude_hae ||
|
newStatus->p.altitude != p.altitude || newStatus->p.altitude_hae != p.altitude_hae ||
|
||||||
newStatus->p.PDOP != p.PDOP || newStatus->p.ground_track != p.ground_track ||
|
newStatus->p.PDOP != p.PDOP || newStatus->p.ground_track != p.ground_track ||
|
||||||
|
newStatus->p.ground_speed != p.ground_speed ||
|
||||||
newStatus->p.sats_in_view != p.sats_in_view);
|
newStatus->p.sats_in_view != p.sats_in_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +112,7 @@ class GPSStatus : public Status
|
|||||||
// Only update the status if values have actually changed
|
// Only update the status if values have actually changed
|
||||||
bool isDirty = matches(newStatus);
|
bool isDirty = matches(newStatus);
|
||||||
|
|
||||||
if (isDirty && p.pos_timestamp && (newStatus->p.pos_timestamp == p.pos_timestamp)) {
|
if (isDirty && p.timestamp && (newStatus->p.timestamp == p.timestamp)) {
|
||||||
// We can NEVER be in two locations at the same time! (also PR #886)
|
// We can NEVER be in two locations at the same time! (also PR #886)
|
||||||
DEBUG_MSG("BUG!! positional timestamp unchanged from prev solution\n");
|
DEBUG_MSG("BUG!! positional timestamp unchanged from prev solution\n");
|
||||||
}
|
}
|
||||||
@@ -136,9 +126,9 @@ class GPSStatus : public Status
|
|||||||
if (isDirty) {
|
if (isDirty) {
|
||||||
if (hasLock) {
|
if (hasLock) {
|
||||||
// In debug logs, identify position by @timestamp:stage (stage 3 = notify)
|
// In debug logs, identify position by @timestamp:stage (stage 3 = notify)
|
||||||
DEBUG_MSG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, sats=%d\n", p.pos_timestamp,
|
DEBUG_MSG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, speed=%.2f, sats=%d\n", p.timestamp,
|
||||||
p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5,
|
p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5,
|
||||||
p.sats_in_view);
|
p.ground_speed * 1e-2, p.sats_in_view);
|
||||||
} else
|
} else
|
||||||
DEBUG_MSG("No GPS lock\n");
|
DEBUG_MSG("No GPS lock\n");
|
||||||
onNewStatus.notifyObservers(this);
|
onNewStatus.notifyObservers(this);
|
||||||
|
|||||||
481
src/Power.cpp
481
src/Power.cpp
@@ -7,10 +7,11 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "buzz/buzz.h"
|
#include "buzz/buzz.h"
|
||||||
|
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_PMU
|
||||||
#include "axp20x.h"
|
#include "XPowersLibInterface.hpp"
|
||||||
|
#include "XPowersAXP2101.tpp"
|
||||||
AXP20X_Class axp;
|
#include "XPowersAXP192.tpp"
|
||||||
|
XPowersLibInterface *PMU = NULL;
|
||||||
#else
|
#else
|
||||||
// Copy of the base class defined in axp20x.h.
|
// Copy of the base class defined in axp20x.h.
|
||||||
// I'd rather not inlude axp20x.h as it brings Wire dependency.
|
// I'd rather not inlude axp20x.h as it brings Wire dependency.
|
||||||
@@ -20,20 +21,20 @@ class HasBatteryLevel
|
|||||||
/**
|
/**
|
||||||
* Battery state of charge, from 0 to 100 or -1 for unknown
|
* Battery state of charge, from 0 to 100 or -1 for unknown
|
||||||
*/
|
*/
|
||||||
virtual int getBattPercentage() { return -1; }
|
virtual int getBatteryPercent() { return -1; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw voltage of the battery or NAN if unknown
|
* The raw voltage of the battery or NAN if unknown
|
||||||
*/
|
*/
|
||||||
virtual float getBattVoltage() { return NAN; }
|
virtual uint16_t getBattVoltage() { return 0; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if there is a battery installed in this unit
|
* return true if there is a battery installed in this unit
|
||||||
*/
|
*/
|
||||||
virtual bool isBatteryConnect() { return false; }
|
virtual bool isBatteryConnect() { return false; }
|
||||||
|
|
||||||
virtual bool isVBUSPlug() { return false; }
|
virtual bool isVbusIn() { return false; }
|
||||||
virtual bool isChargeing() { return false; }
|
virtual bool isCharging() { return false; }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
*
|
*
|
||||||
* FIXME - use a lipo lookup table, the current % full is super wrong
|
* FIXME - use a lipo lookup table, the current % full is super wrong
|
||||||
*/
|
*/
|
||||||
virtual int getBattPercentage() override
|
virtual int getBatteryPercent() override
|
||||||
{
|
{
|
||||||
float v = getBattVoltage();
|
float v = getBattVoltage();
|
||||||
|
|
||||||
@@ -94,13 +95,17 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
/**
|
/**
|
||||||
* The raw voltage of the batteryin millivolts or NAN if unknown
|
* The raw voltage of the batteryin millivolts or NAN if unknown
|
||||||
*/
|
*/
|
||||||
virtual float getBattVoltage() override
|
virtual uint16_t getBattVoltage() override
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifndef ADC_MULTIPLIER
|
#ifndef ADC_MULTIPLIER
|
||||||
#define ADC_MULTIPLIER 2.0
|
#define ADC_MULTIPLIER 2.0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BATTERY_SENSE_SAMPLES
|
||||||
|
#define BATTERY_SENSE_SAMPLES 30
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BATTERY_PIN
|
#ifdef BATTERY_PIN
|
||||||
// Override variant or default ADC_MULTIPLIER if we have the override pref
|
// Override variant or default ADC_MULTIPLIER if we have the override pref
|
||||||
float operativeAdcMultiplier = config.power.adc_multiplier_override > 0
|
float operativeAdcMultiplier = config.power.adc_multiplier_override > 0
|
||||||
@@ -111,16 +116,12 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
if (millis() - last_read_time_ms > min_read_interval) {
|
if (millis() - last_read_time_ms > min_read_interval) {
|
||||||
last_read_time_ms = millis();
|
last_read_time_ms = millis();
|
||||||
|
|
||||||
#ifdef BATTERY_SENSE_SAMPLES
|
|
||||||
//Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment.
|
//Set the number of samples, it has an effect of increasing sensitivity, especially in complex electromagnetic environment.
|
||||||
uint32_t raw = 0;
|
uint32_t raw = 0;
|
||||||
for(uint32_t i=0; i<BATTERY_SENSE_SAMPLES;i++){
|
for(uint32_t i=0; i<BATTERY_SENSE_SAMPLES; i++){
|
||||||
raw += analogRead(BATTERY_PIN);
|
raw += analogRead(BATTERY_PIN);
|
||||||
}
|
}
|
||||||
raw = raw/BATTERY_SENSE_SAMPLES;
|
raw = raw/BATTERY_SENSE_SAMPLES;
|
||||||
#else
|
|
||||||
uint32_t raw = analogRead(BATTERY_PIN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
float scaled;
|
float scaled;
|
||||||
#ifndef VBAT_RAW_TO_SCALED
|
#ifndef VBAT_RAW_TO_SCALED
|
||||||
@@ -135,22 +136,22 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
return last_read_value;
|
return last_read_value;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return NAN;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if there is a battery installed in this unit
|
* return true if there is a battery installed in this unit
|
||||||
*/
|
*/
|
||||||
virtual bool isBatteryConnect() override { return getBattPercentage() != -1; }
|
virtual bool isBatteryConnect() override { return getBatteryPercent() != -1; }
|
||||||
|
|
||||||
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
||||||
/// in power
|
/// in power
|
||||||
virtual bool isVBUSPlug() override { return getBattVoltage() > chargingVolt; }
|
virtual bool isVbusIn() override { return getBattVoltage() > chargingVolt; }
|
||||||
|
|
||||||
/// Assume charging if we have a battery and external power is connected.
|
/// Assume charging if we have a battery and external power is connected.
|
||||||
/// we can't be smart enough to say 'full'?
|
/// we can't be smart enough to say 'full'?
|
||||||
virtual bool isChargeing() override { return isBatteryConnect() && isVBUSPlug(); }
|
virtual bool isCharging() override { return isBatteryConnect() && isVbusIn(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
/// If we see a battery voltage higher than physics allows - assume charger is pumping
|
||||||
@@ -181,6 +182,9 @@ Power::Power() : OSThread("Power")
|
|||||||
{
|
{
|
||||||
statusHandler = {};
|
statusHandler = {};
|
||||||
low_voltage_counter = 0;
|
low_voltage_counter = 0;
|
||||||
|
#ifdef DEBUG_HEAP
|
||||||
|
lastheap = ESP.getFreeHeap();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Power::analogInit()
|
bool Power::analogInit()
|
||||||
@@ -219,7 +223,7 @@ bool Power::analogInit()
|
|||||||
|
|
||||||
bool Power::setup()
|
bool Power::setup()
|
||||||
{
|
{
|
||||||
bool found = axp192Init();
|
bool found = axpChipInit();
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = analogInit();
|
found = analogInit();
|
||||||
@@ -232,10 +236,17 @@ bool Power::setup()
|
|||||||
|
|
||||||
void Power::shutdown()
|
void Power::shutdown()
|
||||||
{
|
{
|
||||||
#ifdef HAS_AXP192
|
screen->setOn(false);
|
||||||
|
#if defined(USE_EINK) && defined(PIN_EINK_EN)
|
||||||
|
digitalWrite(PIN_EINK_EN, LOW); //power off backlight first
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_PMU
|
||||||
DEBUG_MSG("Shutting down\n");
|
DEBUG_MSG("Shutting down\n");
|
||||||
axp.setChgLEDMode(AXP20X_LED_OFF);
|
if(PMU) {
|
||||||
axp.shutdown();
|
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||||
|
PMU->shutdown();
|
||||||
|
}
|
||||||
#elif defined(ARCH_NRF52)
|
#elif defined(ARCH_NRF52)
|
||||||
playBeep();
|
playBeep();
|
||||||
ledOff(PIN_LED1);
|
ledOff(PIN_LED1);
|
||||||
@@ -256,8 +267,8 @@ void Power::readPowerStatus()
|
|||||||
if (hasBattery) {
|
if (hasBattery) {
|
||||||
batteryVoltageMv = batteryLevel->getBattVoltage();
|
batteryVoltageMv = batteryLevel->getBattVoltage();
|
||||||
// If the AXP192 returns a valid battery percentage, use it
|
// If the AXP192 returns a valid battery percentage, use it
|
||||||
if (batteryLevel->getBattPercentage() >= 0) {
|
if (batteryLevel->getBatteryPercent() >= 0) {
|
||||||
batteryChargePercent = batteryLevel->getBattPercentage();
|
batteryChargePercent = batteryLevel->getBatteryPercent();
|
||||||
} else {
|
} else {
|
||||||
// If the AXP192 returns a percentage less than 0, the feature is either not supported or there is an error
|
// If the AXP192 returns a percentage less than 0, the feature is either not supported or there is an error
|
||||||
// In that case, we compute an estimate of the charge percent based on maximum and minimum voltages defined in
|
// In that case, we compute an estimate of the charge percent based on maximum and minimum voltages defined in
|
||||||
@@ -270,11 +281,17 @@ void Power::readPowerStatus()
|
|||||||
|
|
||||||
// Notify any status instances that are observing us
|
// Notify any status instances that are observing us
|
||||||
const PowerStatus powerStatus2 =
|
const PowerStatus powerStatus2 =
|
||||||
PowerStatus(hasBattery ? OptTrue : OptFalse, batteryLevel->isVBUSPlug() ? OptTrue : OptFalse,
|
PowerStatus(hasBattery ? OptTrue : OptFalse, batteryLevel->isVbusIn() ? OptTrue : OptFalse,
|
||||||
batteryLevel->isChargeing() ? OptTrue : OptFalse, batteryVoltageMv, batteryChargePercent);
|
batteryLevel->isCharging() ? OptTrue : OptFalse, batteryVoltageMv, batteryChargePercent);
|
||||||
DEBUG_MSG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
|
DEBUG_MSG("Battery: usbPower=%d, isCharging=%d, batMv=%d, batPct=%d\n", powerStatus2.getHasUSB(),
|
||||||
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
powerStatus2.getIsCharging(), powerStatus2.getBatteryVoltageMv(), powerStatus2.getBatteryChargePercent());
|
||||||
newStatus.notifyObservers(&powerStatus2);
|
newStatus.notifyObservers(&powerStatus2);
|
||||||
|
#ifdef DEBUG_HEAP
|
||||||
|
if (lastheap != ESP.getFreeHeap()){
|
||||||
|
DEBUG_MSG("Heap status: %d/%d bytes free (%d), running %d threads\n", ESP.getFreeHeap(), ESP.getHeapSize(), ESP.getFreeHeap() - lastheap , concurrency::mainController.size(false));
|
||||||
|
lastheap = ESP.getFreeHeap();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
|
// If we have a battery at all and it is less than 10% full, force deep sleep if we have more than 3 low readings in a row
|
||||||
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
|
// Supect fluctuating voltage on the RAK4631 to force it to deep sleep even if battery is at 85% after only a few days
|
||||||
@@ -282,8 +299,12 @@ void Power::readPowerStatus()
|
|||||||
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
if (powerStatus2.getHasBattery() && !powerStatus2.getHasUSB()) {
|
||||||
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) {
|
if (batteryLevel->getBattVoltage() < MIN_BAT_MILLIVOLTS) {
|
||||||
low_voltage_counter++;
|
low_voltage_counter++;
|
||||||
if (low_voltage_counter > 3)
|
DEBUG_MSG("Warning RAK4631 Low voltage counter: %d/10\n", low_voltage_counter);
|
||||||
powerFSM.trigger(EVENT_LOW_BATTERY);
|
if (low_voltage_counter > 10) {
|
||||||
|
// We can't trigger deep sleep on NRF52, it's freezing the board
|
||||||
|
//powerFSM.trigger(EVENT_LOW_BATTERY);
|
||||||
|
DEBUG_MSG("Low voltage detected, but not triggering deep sleep\n");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
low_voltage_counter = 0;
|
low_voltage_counter = 0;
|
||||||
}
|
}
|
||||||
@@ -304,41 +325,47 @@ int32_t Power::runOnce()
|
|||||||
{
|
{
|
||||||
readPowerStatus();
|
readPowerStatus();
|
||||||
|
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_PMU
|
||||||
// WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll
|
// WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll
|
||||||
// the IRQ status by reading the registers over I2C
|
// the IRQ status by reading the registers over I2C
|
||||||
axp.readIRQ();
|
if(PMU) {
|
||||||
|
|
||||||
if (axp.isVbusRemoveIRQ()) {
|
PMU->getIrqStatus();
|
||||||
DEBUG_MSG("USB unplugged\n");
|
|
||||||
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
|
||||||
}
|
|
||||||
if (axp.isVbusPlugInIRQ()) {
|
|
||||||
DEBUG_MSG("USB plugged In\n");
|
|
||||||
powerFSM.trigger(EVENT_POWER_CONNECTED);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Other things we could check if we cared...
|
|
||||||
|
|
||||||
if (axp.isChargingIRQ()) {
|
if(PMU->isVbusRemoveIrq()){
|
||||||
DEBUG_MSG("Battery start charging\n");
|
DEBUG_MSG("USB unplugged\n");
|
||||||
|
powerFSM.trigger(EVENT_POWER_DISCONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PMU->isVbusInsertIrq()) {
|
||||||
|
DEBUG_MSG("USB plugged In\n");
|
||||||
|
powerFSM.trigger(EVENT_POWER_CONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Other things we could check if we cared...
|
||||||
|
|
||||||
|
if (PMU->isBatChagerStartIrq()) {
|
||||||
|
DEBUG_MSG("Battery start charging\n");
|
||||||
|
}
|
||||||
|
if (PMU->isBatChagerDoneIrq()) {
|
||||||
|
DEBUG_MSG("Battery fully charged\n");
|
||||||
|
}
|
||||||
|
if (PMU->isBatInsertIrq()) {
|
||||||
|
DEBUG_MSG("Battery inserted\n");
|
||||||
|
}
|
||||||
|
if (PMU->isBatRemoveIrq()) {
|
||||||
|
DEBUG_MSG("Battery removed\n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (PMU->isPekeyLongPressIrq()) {
|
||||||
|
DEBUG_MSG("PEK long button press\n");
|
||||||
|
screen->setOn(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
PMU->clearIrqStatus();
|
||||||
}
|
}
|
||||||
if (axp.isChargingDoneIRQ()) {
|
|
||||||
DEBUG_MSG("Battery fully charged\n");
|
|
||||||
}
|
|
||||||
if (axp.isBattPlugInIRQ()) {
|
|
||||||
DEBUG_MSG("Battery inserted\n");
|
|
||||||
}
|
|
||||||
if (axp.isBattRemoveIRQ()) {
|
|
||||||
DEBUG_MSG("Battery removed\n");
|
|
||||||
}
|
|
||||||
if (axp.isPEKShortPressIRQ()) {
|
|
||||||
DEBUG_MSG("PEK short button press\n");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
axp.clearIRQ();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Only read once every 20 seconds once the power status for the app has been initialized
|
// Only read once every 20 seconds once the power status for the app has been initialized
|
||||||
return (statusHandler && statusHandler->isInitialized()) ? (1000 * 20) : RUN_SAME;
|
return (statusHandler && statusHandler->isInitialized()) ? (1000 * 20) : RUN_SAME;
|
||||||
}
|
}
|
||||||
@@ -351,128 +378,244 @@ int32_t Power::runOnce()
|
|||||||
share the same i2c bus, instead use ssd1306 sleep mode DCDC2 -> unused DCDC3 0.7-3.5V @ 700mA max -> ESP32 (keep this on!) LDO1
|
share the same i2c bus, instead use ssd1306 sleep mode DCDC2 -> unused DCDC3 0.7-3.5V @ 700mA max -> ESP32 (keep this on!) LDO1
|
||||||
30mA -> charges GPS backup battery // charges the tiny J13 battery by the GPS to power the GPS ram (for a couple of days), can
|
30mA -> charges GPS backup battery // charges the tiny J13 battery by the GPS to power the GPS ram (for a couple of days), can
|
||||||
not be turned off LDO2 200mA -> LORA LDO3 200mA -> GPS
|
not be turned off LDO2 200mA -> LORA LDO3 200mA -> GPS
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
bool Power::axp192Init()
|
bool Power::axpChipInit()
|
||||||
{
|
{
|
||||||
#ifdef HAS_AXP192
|
|
||||||
if (axp192_found) {
|
|
||||||
if (!axp.begin(Wire, AXP192_SLAVE_ADDRESS)) {
|
|
||||||
batteryLevel = &axp;
|
|
||||||
|
|
||||||
DEBUG_MSG("AXP192 Begin PASS\n");
|
#ifdef HAS_PMU
|
||||||
|
|
||||||
// axp.setChgLEDMode(LED_BLINK_4HZ);
|
TwoWire * w = NULL;
|
||||||
DEBUG_MSG("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("----------------------------------------\n");
|
|
||||||
|
|
||||||
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); // LORA radio
|
// Use macro to distinguish which wire is used by PMU
|
||||||
// axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); // GPS main power - now turned on in setGpsPower
|
#ifdef PMU_USE_WIRE1
|
||||||
axp.setPowerOutPut(AXP192_DCDC2, AXP202_ON);
|
w = &Wire1;
|
||||||
axp.setPowerOutPut(AXP192_EXTEN, AXP202_ON);
|
#else
|
||||||
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
|
w = &Wire;
|
||||||
axp.setDCDC1Voltage(3300); // for the OLED power
|
|
||||||
|
|
||||||
DEBUG_MSG("DCDC1: %s\n", axp.isDCDC1Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("DCDC2: %s\n", axp.isDCDC2Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("LDO2: %s\n", axp.isLDO2Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("LDO3: %s\n", axp.isLDO3Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
|
|
||||||
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
|
|
||||||
|
|
||||||
switch (config.power.charge_current) {
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MAUnset:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA100:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_100MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA190:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_190MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA280:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_280MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA360:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_360MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA450:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA550:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_550MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA630:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_630MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA700:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_700MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA780:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_780MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA880:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_880MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA960:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_960MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA1000:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1000MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA1080:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1080MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA1160:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1160MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA1240:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1240MA);
|
|
||||||
break;
|
|
||||||
case Config_PowerConfig_ChargeCurrent_MA1320:
|
|
||||||
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1320MA);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
|
|
||||||
// Not connected
|
|
||||||
//val = 0xfc;
|
|
||||||
//axp._writeByte(AXP202_VHTF_CHGSET, 1, &val); // Set temperature protection
|
|
||||||
|
|
||||||
//not used
|
|
||||||
//val = 0x46;
|
|
||||||
//axp._writeByte(AXP202_OFF_CTL, 1, &val); // enable bat detection
|
|
||||||
#endif
|
#endif
|
||||||
axp.debugCharging();
|
|
||||||
|
|
||||||
#ifdef PMU_IRQ
|
/**
|
||||||
pinMode(PMU_IRQ, INPUT);
|
* It is not necessary to specify the wire pin,
|
||||||
attachInterrupt(
|
* just input the wire, because the wire has been initialized in main.cpp
|
||||||
PMU_IRQ, [] { pmu_irq = true; }, FALLING);
|
*/
|
||||||
|
if (!PMU) {
|
||||||
axp.adc1Enable(AXP202_BATT_CUR_ADC1, 1);
|
PMU = new XPowersAXP2101(*w);
|
||||||
// we do not look for AXP202_CHARGING_FINISHED_IRQ & AXP202_CHARGING_IRQ because it occurs repeatedly while there is
|
if (!PMU->init()) {
|
||||||
// no battery also it could cause inadvertent waking from light sleep just because the battery filled
|
DEBUG_MSG("Warning: Failed to find AXP2101 power management\n");
|
||||||
// we don't look for AXP202_BATT_REMOVED_IRQ because it occurs repeatedly while no battery installed
|
delete PMU;
|
||||||
// we don't look at AXP202_VBUS_REMOVED_IRQ because we don't have anything hooked to vbus
|
PMU = NULL;
|
||||||
axp.enableIRQ(AXP202_BATT_CONNECT_IRQ | AXP202_VBUS_CONNECT_IRQ | AXP202_PEK_SHORTPRESS_IRQ, 1);
|
|
||||||
|
|
||||||
axp.clearIRQ();
|
|
||||||
#endif
|
|
||||||
readPowerStatus();
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("AXP192 Begin FAIL\n");
|
DEBUG_MSG("AXP2101 PMU init succeeded, using AXP2101 PMU\n");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
DEBUG_MSG("AXP192 not found\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return axp192_found;
|
if (!PMU) {
|
||||||
|
PMU = new XPowersAXP192(*w);
|
||||||
|
if (!PMU->init()) {
|
||||||
|
DEBUG_MSG("Warning: Failed to find AXP192 power management\n");
|
||||||
|
delete PMU;
|
||||||
|
PMU = NULL;
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("AXP192 PMU init succeeded, using AXP192 PMU\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!PMU) {
|
||||||
|
/*
|
||||||
|
* In XPowersLib, if the XPowersAXPxxx object is released, Wire.end() will be called at the same time.
|
||||||
|
* In order not to affect other devices, if the initialization of the PMU fails, Wire needs to be re-initialized once,
|
||||||
|
* if there are multiple devices sharing the bus.
|
||||||
|
* * */
|
||||||
|
#ifndef PMU_USE_WIRE1
|
||||||
|
w->begin(I2C_SDA, I2C_SCL);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
batteryLevel = PMU;
|
||||||
|
|
||||||
|
if (PMU->getChipModel() == XPOWERS_AXP192) {
|
||||||
|
|
||||||
|
// lora radio power channel
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_LDO2, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_LDO2);
|
||||||
|
|
||||||
|
|
||||||
|
// oled module power channel,
|
||||||
|
// disable it will cause abnormal communication between boot and AXP power supply,
|
||||||
|
// do not turn it off
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_DCDC1, 3300);
|
||||||
|
// enable oled power
|
||||||
|
PMU->enablePowerOutput(XPOWERS_DCDC1);
|
||||||
|
|
||||||
|
|
||||||
|
// gnss module power channel - now turned on in setGpsPower
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_LDO3, 3300);
|
||||||
|
// PMU->enablePowerOutput(XPOWERS_LDO3);
|
||||||
|
|
||||||
|
|
||||||
|
//protected oled power source
|
||||||
|
PMU->setProtectedChannel(XPOWERS_DCDC1);
|
||||||
|
//protected esp32 power source
|
||||||
|
PMU->setProtectedChannel(XPOWERS_DCDC3);
|
||||||
|
|
||||||
|
//disable not use channel
|
||||||
|
PMU->disablePowerOutput(XPOWERS_DCDC2);
|
||||||
|
|
||||||
|
//disable all axp chip interrupt
|
||||||
|
PMU->disableIRQ(XPOWERS_AXP192_ALL_IRQ);
|
||||||
|
|
||||||
|
// Set constant current charging current
|
||||||
|
PMU->setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_450MA);
|
||||||
|
|
||||||
|
//Set up the charging voltage
|
||||||
|
PMU->setChargeTargetVoltage(XPOWERS_AXP192_CHG_VOL_4V2);
|
||||||
|
|
||||||
|
} else if (PMU->getChipModel() == XPOWERS_AXP2101) {
|
||||||
|
|
||||||
|
// t-beam s3 core
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gnss module power channel
|
||||||
|
* The default ALDO4 is off, you need to turn on the GNSS power first, otherwise it will be invalid during initialization
|
||||||
|
*/
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_ALDO4, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_ALDO4);
|
||||||
|
|
||||||
|
// lora radio power channel
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_ALDO3, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_ALDO3);
|
||||||
|
|
||||||
|
// m.2 interface
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_DCDC3, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_DCDC3);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ALDO2 cannot be turned off.
|
||||||
|
* It is a necessary condition for sensor communication.
|
||||||
|
* It must be turned on to properly access the sensor and screen
|
||||||
|
* It is also responsible for the power supply of PCF8563
|
||||||
|
*/
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_ALDO2, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_ALDO2);
|
||||||
|
|
||||||
|
// 6-axis , magnetometer ,bme280 , oled screen power channel
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_ALDO1, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_ALDO1);
|
||||||
|
|
||||||
|
// sdcard power channle
|
||||||
|
PMU->setPowerChannelVoltage(XPOWERS_BLDO1, 3300);
|
||||||
|
PMU->enablePowerOutput(XPOWERS_BLDO1);
|
||||||
|
|
||||||
|
// PMU->setPowerChannelVoltage(XPOWERS_DCDC4, 3300);
|
||||||
|
// PMU->enablePowerOutput(XPOWERS_DCDC4);
|
||||||
|
|
||||||
|
//not use channel
|
||||||
|
PMU->disablePowerOutput(XPOWERS_DCDC2); //not elicited
|
||||||
|
PMU->disablePowerOutput(XPOWERS_DCDC5); //not elicited
|
||||||
|
PMU->disablePowerOutput(XPOWERS_DLDO1); //Invalid power channel, it does not exist
|
||||||
|
PMU->disablePowerOutput(XPOWERS_DLDO2); //Invalid power channel, it does not exist
|
||||||
|
PMU->disablePowerOutput(XPOWERS_VBACKUP);
|
||||||
|
|
||||||
|
//disable all axp chip interrupt
|
||||||
|
PMU->disableIRQ(XPOWERS_AXP2101_ALL_IRQ);
|
||||||
|
|
||||||
|
//Set the constant current charging current of AXP2101, temporarily use 500mA by default
|
||||||
|
PMU->setChargerConstantCurr(XPOWERS_AXP2101_CHG_CUR_500MA);
|
||||||
|
|
||||||
|
//Set up the charging voltage
|
||||||
|
PMU->setChargeTargetVoltage(XPOWERS_AXP2101_CHG_VOL_4V2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PMU->clearIrqStatus();
|
||||||
|
|
||||||
|
// TBeam1.1 /T-Beam S3-Core has no external TS detection,
|
||||||
|
// it needs to be disabled, otherwise it will cause abnormal charging
|
||||||
|
PMU->disableTSPinMeasure();
|
||||||
|
|
||||||
|
// PMU->enableSystemVoltageMeasure();
|
||||||
|
PMU->enableVbusVoltageMeasure();
|
||||||
|
PMU->enableBattVoltageMeasure();
|
||||||
|
|
||||||
|
DEBUG_MSG("=======================================================================\n");
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_DCDC1)) {
|
||||||
|
DEBUG_MSG("DC1 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC1));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_DCDC2)) {
|
||||||
|
DEBUG_MSG("DC2 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC2));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_DCDC3)) {
|
||||||
|
DEBUG_MSG("DC3 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC3));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_DCDC4)) {
|
||||||
|
DEBUG_MSG("DC4 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_DCDC4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_DCDC4));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_LDO2)) {
|
||||||
|
DEBUG_MSG("LDO2 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO2));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_LDO3)) {
|
||||||
|
DEBUG_MSG("LDO3 : %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_LDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_LDO3));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_ALDO1)) {
|
||||||
|
DEBUG_MSG("ALDO1: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO1));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_ALDO2)) {
|
||||||
|
DEBUG_MSG("ALDO2: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO2));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_ALDO3)) {
|
||||||
|
DEBUG_MSG("ALDO3: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO3) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO3));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_ALDO4)) {
|
||||||
|
DEBUG_MSG("ALDO4: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_ALDO4) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_ALDO4));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_BLDO1)) {
|
||||||
|
DEBUG_MSG("BLDO1: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO1) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO1));
|
||||||
|
}
|
||||||
|
if (PMU->isChannelAvailable(XPOWERS_BLDO2)) {
|
||||||
|
DEBUG_MSG("BLDO2: %s Voltage:%u mV \n", PMU->isPowerChannelEnable(XPOWERS_BLDO2) ? "+" : "-", PMU->getPowerChannelVoltage(XPOWERS_BLDO2));
|
||||||
|
}
|
||||||
|
DEBUG_MSG("=======================================================================\n");
|
||||||
|
|
||||||
|
// We can safely ignore this approach for most (or all) boards because MCU turned off
|
||||||
|
// earlier than battery discharged to 2.6V.
|
||||||
|
//
|
||||||
|
// Unfortanly for now we can't use this killswitch for RAK4630-based boards because they have a bug with
|
||||||
|
// battery voltage measurement. Probably it sometimes drops to low values.
|
||||||
|
#ifndef RAK4630
|
||||||
|
// Set PMU shutdown voltage at 2.6V to maximize battery utilization
|
||||||
|
PMU->setSysPowerDownVoltage(2600);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef PMU_IRQ
|
||||||
|
uint64_t pmuIrqMask = 0;
|
||||||
|
|
||||||
|
if (PMU->getChipModel() == XPOWERS_AXP192) {
|
||||||
|
pmuIrqMask = XPOWERS_AXP192_VBUS_INSERT_IRQ | XPOWERS_AXP192_BAT_INSERT_IRQ | XPOWERS_AXP192_PKEY_SHORT_IRQ;
|
||||||
|
} else if (PMU->getChipModel() == XPOWERS_AXP2101) {
|
||||||
|
pmuIrqMask = XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_PKEY_SHORT_IRQ;
|
||||||
|
}
|
||||||
|
|
||||||
|
pinMode(PMU_IRQ, INPUT);
|
||||||
|
attachInterrupt(
|
||||||
|
PMU_IRQ, [] { pmu_irq = true; }, FALLING);
|
||||||
|
|
||||||
|
// we do not look for AXPXXX_CHARGING_FINISHED_IRQ & AXPXXX_CHARGING_IRQ because it occurs repeatedly while there is
|
||||||
|
// no battery also it could cause inadvertent waking from light sleep just because the battery filled
|
||||||
|
// we don't look for AXPXXX_BATT_REMOVED_IRQ because it occurs repeatedly while no battery installed
|
||||||
|
// we don't look at AXPXXX_VBUS_REMOVED_IRQ because we don't have anything hooked to vbus
|
||||||
|
PMU->enableIRQ(pmuIrqMask);
|
||||||
|
|
||||||
|
PMU->clearIrqStatus();
|
||||||
|
#endif /*PMU_IRQ*/
|
||||||
|
|
||||||
|
readPowerStatus();
|
||||||
|
|
||||||
|
pmu_found = true;
|
||||||
|
|
||||||
|
return pmu_found;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
static bool isPowered()
|
static bool isPowered()
|
||||||
{
|
{
|
||||||
// Circumvent the battery sensing logic and assumes constant power if no battery pin or power mgmt IC
|
// Circumvent the battery sensing logic and assumes constant power if no battery pin or power mgmt IC
|
||||||
#if !defined(BATTERY_PIN) && !defined(HAS_AXP192)
|
#if !defined(BATTERY_PIN) && !defined(HAS_AXP192) && !defined(HAS_AXP2101)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
|
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER ? 1 : 0);
|
||||||
|
|
||||||
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
|
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
|
||||||
// We assume routers might be powered all the time, but from a low current (solar) source
|
// We assume routers might be powered all the time, but from a low current (solar) source
|
||||||
@@ -34,7 +34,7 @@ static void sdsEnter()
|
|||||||
{
|
{
|
||||||
DEBUG_MSG("Enter state: SDS\n");
|
DEBUG_MSG("Enter state: SDS\n");
|
||||||
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
|
// FIXME - make sure GPS and LORA radio are off first - because we want close to zero current draw
|
||||||
doDeepSleep(config.power.sds_secs ? config.power.sds_secs : default_sds_secs * 1000LL);
|
doDeepSleep(getConfiguredOrDefaultMs(config.power.sds_secs));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern Power *power;
|
extern Power *power;
|
||||||
@@ -51,7 +51,7 @@ static uint32_t secsSlept;
|
|||||||
|
|
||||||
static void lsEnter()
|
static void lsEnter()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", config.power.ls_secs > 0 ? config.power.ls_secs : default_ls_secs);
|
DEBUG_MSG("lsEnter begin, ls_secs=%u\n", config.power.ls_secs);
|
||||||
screen->setOn(false);
|
screen->setOn(false);
|
||||||
secsSlept = 0; // How long have we been sleeping this time
|
secsSlept = 0; // How long have we been sleeping this time
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ static void lsIdle()
|
|||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
// Do we have more sleeping to do?
|
// Do we have more sleeping to do?
|
||||||
if (secsSlept < config.power.ls_secs ? config.power.ls_secs : default_ls_secs) {
|
if (secsSlept < config.power.ls_secs) {
|
||||||
// Briefly come out of sleep long enough to blink the led once every few seconds
|
// Briefly come out of sleep long enough to blink the led once every few seconds
|
||||||
uint32_t sleepTime = 30;
|
uint32_t sleepTime = 30;
|
||||||
|
|
||||||
@@ -237,10 +237,10 @@ Fsm powerFSM(&stateBOOT);
|
|||||||
|
|
||||||
void PowerFSM_setup()
|
void PowerFSM_setup()
|
||||||
{
|
{
|
||||||
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0);
|
bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER ? 1 : 0);
|
||||||
bool hasPower = isPowered();
|
bool hasPower = isPowered();
|
||||||
|
|
||||||
DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower);
|
DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower ? 1 : 0);
|
||||||
powerFSM.add_timed_transition(&stateBOOT, hasPower ? &statePOWER : &stateON, 3 * 1000, NULL, "boot timeout");
|
powerFSM.add_timed_transition(&stateBOOT, hasPower ? &statePOWER : &stateON, 3 * 1000, NULL, "boot timeout");
|
||||||
|
|
||||||
// wake timer expired or a packet arrived
|
// wake timer expired or a packet arrived
|
||||||
@@ -324,39 +324,22 @@ void PowerFSM_setup()
|
|||||||
|
|
||||||
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_CONTACT_FROM_PHONE, NULL, "Contact from phone");
|
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_CONTACT_FROM_PHONE, NULL, "Contact from phone");
|
||||||
|
|
||||||
// each time we get a new update packet make sure we are staying in the ON state so the screen stays awake (also we don't
|
|
||||||
// shutdown bluetooth if is_router)
|
|
||||||
powerFSM.add_transition(&stateDARK, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
|
|
||||||
powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
|
|
||||||
|
|
||||||
powerFSM.add_timed_transition(&stateON, &stateDARK, getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL, "Screen-on timeout");
|
powerFSM.add_timed_transition(&stateON, &stateDARK, getConfiguredOrDefaultMs(config.display.screen_on_secs, default_screen_on_secs), NULL, "Screen-on timeout");
|
||||||
|
|
||||||
// On most boards we use light-sleep to be our main state, but on NRF52 we just stay in DARK
|
|
||||||
State *lowPowerState = &stateLS;
|
|
||||||
|
|
||||||
uint32_t meshSds = 0;
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
State *lowPowerState = &stateLS;
|
||||||
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
|
// We never enter light-sleep or NB states on NRF52 (because the CPU uses so little power normally)
|
||||||
|
|
||||||
// See: https://github.com/meshtastic/Meshtastic-device/issues/1071
|
// See: https://github.com/meshtastic/firmware/issues/1071
|
||||||
if (isRouter || config.power.is_power_saving) {
|
if (isRouter || config.power.is_power_saving) {
|
||||||
powerFSM.add_timed_transition(&stateNB, &stateLS, getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, "Min wake timeout");
|
powerFSM.add_timed_transition(&stateNB, &stateLS, getConfiguredOrDefaultMs(config.power.min_wake_secs, default_min_wake_secs), NULL, "Min wake timeout");
|
||||||
powerFSM.add_timed_transition(&stateDARK, &stateLS, getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), NULL, "Bluetooth timeout");
|
powerFSM.add_timed_transition(&stateDARK, &stateLS, getConfiguredOrDefaultMs(config.power.wait_bluetooth_secs, default_wait_bluetooth_secs), NULL, "Bluetooth timeout");
|
||||||
meshSds = config.power.mesh_sds_timeout_secs ? config.power.mesh_sds_timeout_secs : default_mesh_sds_timeout_secs;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
meshSds = UINT32_MAX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
if (config.power.sds_secs != UINT32_MAX)
|
||||||
lowPowerState = &stateDARK;
|
powerFSM.add_timed_transition(lowPowerState, &stateSDS, getConfiguredOrDefaultMs(config.power.sds_secs), NULL, "mesh timeout");
|
||||||
meshSds = UINT32_MAX; // Workaround for now: Don't go into deep sleep on the RAK4631
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (meshSds != UINT32_MAX)
|
|
||||||
powerFSM.add_timed_transition(lowPowerState, &stateSDS, meshSds * 1000, NULL, "mesh timeout");
|
|
||||||
|
|
||||||
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
powerFSM.run_machine(); // run one interation of the state machine, so we run our on enter tasks for the initial DARK state
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,9 @@ class PowerFSMThread : public OSThread
|
|||||||
|
|
||||||
if (powerStatus->getHasUSB()) {
|
if (powerStatus->getHasUSB()) {
|
||||||
timeLastPowered = millis();
|
timeLastPowered = millis();
|
||||||
} else if (config.power.on_battery_shutdown_after_secs > 0 &&
|
} else if (config.power.on_battery_shutdown_after_secs > 0 &&
|
||||||
millis() >
|
config.power.on_battery_shutdown_after_secs != UINT32_MAX &&
|
||||||
timeLastPowered +
|
millis() > (timeLastPowered + getConfiguredOrDefaultMs(config.power.on_battery_shutdown_after_secs))) { // shutdown after 30 minutes unpowered
|
||||||
(1000 *
|
|
||||||
config.power.on_battery_shutdown_after_secs)) { // shutdown after 30 minutes unpowered
|
|
||||||
powerFSM.trigger(EVENT_SHUTDOWN);
|
powerFSM.trigger(EVENT_SHUTDOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "RedirectablePrint.h"
|
#include "RedirectablePrint.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
// #include "wifi/WiFiServerAPI.h"
|
// #include "wifi/WiFiServerAPI.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -30,7 +31,9 @@ size_t RedirectablePrint::write(uint8_t c)
|
|||||||
// optionally send chars to TCP also
|
// optionally send chars to TCP also
|
||||||
//WiFiServerPort::debugOut(c);
|
//WiFiServerPort::debugOut(c);
|
||||||
|
|
||||||
dest->write(c);
|
if (!config.has_lora || config.device.serial_enabled)
|
||||||
|
dest->write(c);
|
||||||
|
|
||||||
return 1; // We always claim one was written, rather than trusting what the
|
return 1; // We always claim one was written, rather than trusting what the
|
||||||
// serial port said (which could be zero)
|
// serial port said (which could be zero)
|
||||||
}
|
}
|
||||||
@@ -41,10 +44,15 @@ size_t RedirectablePrint::vprintf(const char *format, va_list arg)
|
|||||||
static char printBuf[160];
|
static char printBuf[160];
|
||||||
|
|
||||||
va_copy(copy, arg);
|
va_copy(copy, arg);
|
||||||
int len = vsnprintf(printBuf, sizeof(printBuf), format, copy);
|
size_t len = vsnprintf(printBuf, sizeof(printBuf), format, copy);
|
||||||
va_end(copy);
|
va_end(copy);
|
||||||
|
|
||||||
if (len < 0) return 0;
|
// If the resulting string is longer than sizeof(printBuf)-1 characters, the remaining characters are still counted for the return value
|
||||||
|
|
||||||
|
if (len > sizeof(printBuf) - 1) {
|
||||||
|
len = sizeof(printBuf) - 1;
|
||||||
|
printBuf[sizeof(printBuf) - 2] = '\n';
|
||||||
|
}
|
||||||
|
|
||||||
len = Print::write(printBuf, len);
|
len = Print::write(printBuf, len);
|
||||||
return len;
|
return len;
|
||||||
@@ -100,4 +108,4 @@ size_t RedirectablePrint::logDebug(const char *format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,12 @@ void consolePrintf(const char *format, ...)
|
|||||||
va_start(arg, format);
|
va_start(arg, format);
|
||||||
console->vprintf(format, arg);
|
console->vprintf(format, arg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
console->flush();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port), concurrency::OSThread("SerialConsole")
|
||||||
{
|
{
|
||||||
assert(!console);
|
assert(!console);
|
||||||
console = this;
|
console = this;
|
||||||
@@ -43,6 +46,10 @@ SerialConsole::SerialConsole() : StreamAPI(&Port), RedirectablePrint(&Port)
|
|||||||
emitRebooted();
|
emitRebooted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SerialConsole::runOnce()
|
||||||
|
{
|
||||||
|
return runOncePart();
|
||||||
|
}
|
||||||
|
|
||||||
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
// For the serial port we can't really detect if any client is on the other side, so instead just look for recent messages
|
||||||
bool SerialConsole::checkIsConnected()
|
bool SerialConsole::checkIsConnected()
|
||||||
@@ -57,10 +64,15 @@ bool SerialConsole::checkIsConnected()
|
|||||||
*/
|
*/
|
||||||
bool SerialConsole::handleToRadio(const uint8_t *buf, size_t len)
|
bool SerialConsole::handleToRadio(const uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
// Turn off debug serial printing once the API is activated, because other threads could print and corrupt packets
|
// only talk to the API once the configuration has been loaded and we're sure the serial port is not disabled.
|
||||||
if (!config.device.debug_log_enabled)
|
if (config.has_lora && config.device.serial_enabled) {
|
||||||
setDestination(&noopPrint);
|
// Turn off debug serial printing once the API is activated, because other threads could print and corrupt packets
|
||||||
canWrite = true;
|
if (!config.device.debug_log_enabled)
|
||||||
|
setDestination(&noopPrint);
|
||||||
|
canWrite = true;
|
||||||
|
|
||||||
return StreamAPI::handleToRadio(buf, len);
|
return StreamAPI::handleToRadio(buf, len);
|
||||||
}
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
|
* Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs
|
||||||
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
|
* (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs).
|
||||||
*/
|
*/
|
||||||
class SerialConsole : public StreamAPI, public RedirectablePrint
|
class SerialConsole : public StreamAPI, public RedirectablePrint, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SerialConsole();
|
SerialConsole();
|
||||||
@@ -24,6 +24,8 @@ class SerialConsole : public StreamAPI, public RedirectablePrint
|
|||||||
return RedirectablePrint::write(c);
|
return RedirectablePrint::write(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// Check the current underlying physical link to see if the client is currently connected
|
/// Check the current underlying physical link to see if the client is currently connected
|
||||||
|
|||||||
@@ -117,6 +117,20 @@ float AirTime::utilizationTXPercent()
|
|||||||
return (float(sum) / float(MS_IN_HOUR)) * 100;
|
return (float(sum) / float(MS_IN_HOUR)) * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the amount of minutes we have to be silent before we can send again
|
||||||
|
uint8_t AirTime::getSilentMinutes(float txPercent, float dutyCycle)
|
||||||
|
{
|
||||||
|
float newTxPercent = txPercent;
|
||||||
|
for (int8_t i = MINUTES_IN_HOUR-1; i >= 0; --i) {
|
||||||
|
newTxPercent -= ((float)this->utilizationTX[i] / (MS_IN_MINUTE * MINUTES_IN_HOUR / 100));
|
||||||
|
if (newTxPercent < dutyCycle)
|
||||||
|
return MINUTES_IN_HOUR-1-i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MINUTES_IN_HOUR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AirTime::AirTime() : concurrency::OSThread("AirTime"),airtimes({}) {
|
AirTime::AirTime() : concurrency::OSThread("AirTime"),airtimes({}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#define PERIODS_TO_LOG 8
|
#define PERIODS_TO_LOG 8
|
||||||
#define MINUTES_IN_HOUR 60
|
#define MINUTES_IN_HOUR 60
|
||||||
#define SECONDS_IN_MINUTE 60
|
#define SECONDS_IN_MINUTE 60
|
||||||
|
#define MS_IN_MINUTE (SECONDS_IN_MINUTE * 1000)
|
||||||
#define MS_IN_HOUR (MINUTES_IN_HOUR * SECONDS_IN_MINUTE * 1000)
|
#define MS_IN_HOUR (MINUTES_IN_HOUR * SECONDS_IN_MINUTE * 1000)
|
||||||
|
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ class AirTime : private concurrency::OSThread
|
|||||||
uint32_t getSecondsPerPeriod();
|
uint32_t getSecondsPerPeriod();
|
||||||
uint32_t getSecondsSinceBoot();
|
uint32_t getSecondsSinceBoot();
|
||||||
uint32_t *airtimeReport(reportTypes reportType);
|
uint32_t *airtimeReport(reportTypes reportType);
|
||||||
|
uint8_t getSilentMinutes(float txPercent, float dutyCycle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool firstTime = true;
|
bool firstTime = true;
|
||||||
|
|||||||
@@ -1,22 +1,14 @@
|
|||||||
#include "buzz.h"
|
#include "buzz.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "NodeDB.h"
|
||||||
|
|
||||||
#ifndef PIN_BUZZER
|
#if !defined(ARCH_ESP32) && !defined(ARCH_RP2040) && !defined(ARCH_PORTDUINO)
|
||||||
|
|
||||||
// Noop methods for boards w/o buzzer
|
|
||||||
void playBeep(){};
|
|
||||||
void playStartMelody(){};
|
|
||||||
void playShutdownMelody(){};
|
|
||||||
|
|
||||||
#else
|
|
||||||
#ifdef M5STACK
|
|
||||||
#include "Speaker.h"
|
|
||||||
TONE Tone;
|
|
||||||
#else
|
|
||||||
#include "Tone.h"
|
#include "Tone.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(ARCH_PORTDUINO)
|
||||||
extern "C" void delay(uint32_t dwMs);
|
extern "C" void delay(uint32_t dwMs);
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ToneDuration {
|
struct ToneDuration {
|
||||||
int frequency_khz;
|
int frequency_khz;
|
||||||
@@ -36,45 +28,42 @@ struct ToneDuration {
|
|||||||
#define NOTE_A3 220
|
#define NOTE_A3 220
|
||||||
#define NOTE_AS3 233
|
#define NOTE_AS3 233
|
||||||
#define NOTE_B3 247
|
#define NOTE_B3 247
|
||||||
|
#define NOTE_CS4 277
|
||||||
|
|
||||||
const int DURATION_1_8 = 125; // 1/8 note
|
const int DURATION_1_8 = 125; // 1/8 note
|
||||||
const int DURATION_1_4 = 250; // 1/4 note
|
const int DURATION_1_4 = 250; // 1/4 note
|
||||||
|
|
||||||
void playTones(const ToneDuration *tone_durations, int size) {
|
void playTones(const ToneDuration *tone_durations, int size) {
|
||||||
for (int i = 0; i < size; i++) {
|
#ifdef PIN_BUZZER
|
||||||
const auto &tone_duration = tone_durations[i];
|
if (!config.device.buzzer_gpio)
|
||||||
#ifdef M5STACK
|
config.device.buzzer_gpio = PIN_BUZZER;
|
||||||
Tone.tone(tone_duration.frequency_khz);
|
|
||||||
delay(tone_duration.duration_ms);
|
|
||||||
Tone.mute();
|
|
||||||
#else
|
|
||||||
tone(PIN_BUZZER, tone_duration.frequency_khz, tone_duration.duration_ms);
|
|
||||||
#endif
|
#endif
|
||||||
// to distinguish the notes, set a minimum time between them.
|
if (config.device.buzzer_gpio) {
|
||||||
delay(1.3 * tone_duration.duration_ms);
|
for (int i = 0; i < size; i++) {
|
||||||
|
const auto &tone_duration = tone_durations[i];
|
||||||
|
tone(config.device.buzzer_gpio, tone_duration.frequency_khz, tone_duration.duration_ms);
|
||||||
|
// to distinguish the notes, set a minimum time between them.
|
||||||
|
delay(1.3 * tone_duration.duration_ms);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef M5STACK
|
|
||||||
void playBeep() {
|
void playBeep() {
|
||||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4}};
|
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4}};
|
||||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
void playBeep() { tone(PIN_BUZZER, NOTE_B3, DURATION_1_4); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void playStartMelody() {
|
void playStartMelody() {
|
||||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4},
|
ToneDuration melody[] = {{NOTE_FS3, DURATION_1_8},
|
||||||
{NOTE_B3, DURATION_1_8},
|
{NOTE_AS3, DURATION_1_8},
|
||||||
{NOTE_B3, DURATION_1_8}};
|
{NOTE_CS4, DURATION_1_4}};
|
||||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
void playShutdownMelody() {
|
void playShutdownMelody() {
|
||||||
ToneDuration melody[] = {{NOTE_B3, DURATION_1_4},
|
ToneDuration melody[] = {{NOTE_CS4, DURATION_1_8},
|
||||||
{NOTE_G3, DURATION_1_8},
|
{NOTE_AS3, DURATION_1_8},
|
||||||
{NOTE_D3, DURATION_1_8}};
|
{NOTE_FS3, DURATION_1_4}};
|
||||||
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
playTones(melody, sizeof(melody) / sizeof(ToneDuration));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
@@ -94,19 +94,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
// Define this if you know you have that controller or your "SSD1306" misbehaves.
|
// Define this if you know you have that controller or your "SSD1306" misbehaves.
|
||||||
//#define USE_SH1106
|
//#define USE_SH1106
|
||||||
|
|
||||||
// Flip the screen upside down by default as it makes more sense on T-BEAM
|
|
||||||
// devices. Comment this out to not rotate screen 180 degrees.
|
|
||||||
#define SCREEN_FLIP_VERTICALLY
|
|
||||||
|
|
||||||
// Define if screen should be mirrored left to right
|
// Define if screen should be mirrored left to right
|
||||||
// #define SCREEN_MIRROR
|
// #define SCREEN_MIRROR
|
||||||
|
|
||||||
// The m5stack I2C Keyboard (also RAK14004)
|
// The m5stack I2C Keyboard (also RAK14004)
|
||||||
#define CARDKB_ADDR 0x5F
|
#define CARDKB_ADDR 0x5F
|
||||||
|
|
||||||
// The older M5 Faces I2C Keyboard
|
|
||||||
#define FACESKB_ADDR 0x88
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// SENSOR
|
// SENSOR
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -115,6 +108,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define MCP9808_ADDR 0x18
|
#define MCP9808_ADDR 0x18
|
||||||
#define INA_ADDR 0x40
|
#define INA_ADDR 0x40
|
||||||
#define INA_ADDR_ALTERNATE 0x41
|
#define INA_ADDR_ALTERNATE 0x41
|
||||||
|
#define QMC6310_ADDR 0x1C
|
||||||
|
#define QMI8658_ADDR 0x6B
|
||||||
|
#define QMC5883L_ADDR 0x1E
|
||||||
|
#define SHTC3_ADDR 0x70
|
||||||
|
#define LPS22HB_ADDR 0x5C
|
||||||
|
#define LPS22HB_ADDR_ALT 0x5D
|
||||||
|
#define SHT31_ADDR 0x44
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Security
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define ATECC608B_ADDR 0x35
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// GPS
|
// GPS
|
||||||
@@ -138,6 +144,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifndef HAS_WIFI
|
#ifndef HAS_WIFI
|
||||||
#define HAS_WIFI 0
|
#define HAS_WIFI 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAS_ETHERNET
|
||||||
|
#define HAS_ETHERNET 0
|
||||||
|
#endif
|
||||||
#ifndef HAS_SCREEN
|
#ifndef HAS_SCREEN
|
||||||
#define HAS_SCREEN 0
|
#define HAS_SCREEN 0
|
||||||
#endif
|
#endif
|
||||||
@@ -159,6 +168,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifndef HAS_RTC
|
#ifndef HAS_RTC
|
||||||
#define HAS_RTC 0
|
#define HAS_RTC 0
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAS_CPU_SHUTDOWN
|
||||||
|
#define HAS_CPU_SHUTDOWN 0
|
||||||
|
#endif
|
||||||
|
#ifndef HAS_BLUETOOTH
|
||||||
|
#define HAS_BLUETOOTH 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "RF95Configuration.h"
|
#include "RF95Configuration.h"
|
||||||
#include "DebugConfiguration.h"
|
#include "DebugConfiguration.h"
|
||||||
|
|||||||
@@ -3,11 +3,47 @@
|
|||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "mesh/generated/telemetry.pb.h"
|
#include "mesh/generated/telemetry.pb.h"
|
||||||
|
|
||||||
#ifdef HAS_AXP192
|
// AXP192 and AXP2101 have the same device address, we just need to identify it in Power.cpp
|
||||||
#include "axp20x.h"
|
#ifndef XPOWERS_AXP192_AXP2101_ADDRESS
|
||||||
|
#define XPOWERS_AXP192_AXP2101_ADDRESS 0x34
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_WIRE
|
#if HAS_WIRE
|
||||||
|
|
||||||
|
void printATECCInfo()
|
||||||
|
{
|
||||||
|
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
|
atecc.readConfigZone(false);
|
||||||
|
|
||||||
|
DEBUG_MSG("ATECC608B Serial Number: ");
|
||||||
|
for (int i = 0 ; i < 9 ; i++) {
|
||||||
|
DEBUG_MSG("%02x",atecc.serialNumber[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_MSG(", Rev Number: ");
|
||||||
|
for (int i = 0 ; i < 4 ; i++) {
|
||||||
|
DEBUG_MSG("%02x",atecc.revisionNumber[i]);
|
||||||
|
}
|
||||||
|
DEBUG_MSG("\n");
|
||||||
|
|
||||||
|
DEBUG_MSG("ATECC608B Config %s",atecc.configLockStatus ? "Locked" : "Unlocked");
|
||||||
|
DEBUG_MSG(", Data %s",atecc.dataOTPLockStatus ? "Locked" : "Unlocked");
|
||||||
|
DEBUG_MSG(", Slot 0 %s\n",atecc.slot0LockStatus ? "Locked" : "Unlocked");
|
||||||
|
|
||||||
|
if (atecc.configLockStatus && atecc.dataOTPLockStatus && atecc.slot0LockStatus) {
|
||||||
|
if (atecc.generatePublicKey() == false) {
|
||||||
|
DEBUG_MSG("ATECC608B Error generating public key\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("ATECC608B Public Key: ");
|
||||||
|
for (int i = 0 ; i < 64 ; i++) {
|
||||||
|
DEBUG_MSG("%02x",atecc.publicKey64Bytes[i]);
|
||||||
|
}
|
||||||
|
DEBUG_MSG("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
|
uint16_t getRegisterValue(uint8_t address, uint8_t reg, uint8_t length) {
|
||||||
uint16_t value = 0x00;
|
uint16_t value = 0x00;
|
||||||
Wire.beginTransmission(address);
|
Wire.beginTransmission(address);
|
||||||
@@ -54,7 +90,7 @@ uint8_t oled_probe(byte addr)
|
|||||||
return o_probe;
|
return o_probe;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanI2Cdevice(void)
|
void scanI2Cdevice()
|
||||||
{
|
{
|
||||||
byte err, addr;
|
byte err, addr;
|
||||||
uint16_t registerValue = 0x00;
|
uint16_t registerValue = 0x00;
|
||||||
@@ -70,14 +106,25 @@ void scanI2Cdevice(void)
|
|||||||
if (addr == SSD1306_ADDRESS) {
|
if (addr == SSD1306_ADDRESS) {
|
||||||
screen_found = addr;
|
screen_found = addr;
|
||||||
screen_model = oled_probe(addr);
|
screen_model = oled_probe(addr);
|
||||||
if (screen_model == 1){
|
if (screen_model == 1) {
|
||||||
DEBUG_MSG("ssd1306 display found\n");
|
DEBUG_MSG("ssd1306 display found\n");
|
||||||
} else if (screen_model == 2){
|
} else if (screen_model == 2) {
|
||||||
DEBUG_MSG("sh1106 display found\n");
|
DEBUG_MSG("sh1106 display found\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("unknown display found\n");
|
DEBUG_MSG("unknown display found\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
|
if (addr == ATECC608B_ADDR) {
|
||||||
|
keystore_found = addr;
|
||||||
|
if (atecc.begin(keystore_found) == true) {
|
||||||
|
DEBUG_MSG("ATECC608B initialized\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("ATECC608B initialization failed\n");
|
||||||
|
}
|
||||||
|
printATECCInfo();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef RV3028_RTC
|
#ifdef RV3028_RTC
|
||||||
if (addr == RV3028_RTC){
|
if (addr == RV3028_RTC){
|
||||||
rtc_found = addr;
|
rtc_found = addr;
|
||||||
@@ -106,48 +153,70 @@ void scanI2Cdevice(void)
|
|||||||
kb_model = 0x00;
|
kb_model = 0x00;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (addr == FACESKB_ADDR) {
|
|
||||||
faceskb_found = addr;
|
|
||||||
DEBUG_MSG("m5 Faces found\n");
|
|
||||||
}
|
|
||||||
if (addr == ST7567_ADDRESS) {
|
if (addr == ST7567_ADDRESS) {
|
||||||
screen_found = addr;
|
screen_found = addr;
|
||||||
DEBUG_MSG("st7567 display found\n");
|
DEBUG_MSG("st7567 display found\n");
|
||||||
}
|
}
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_PMU
|
||||||
if (addr == AXP192_SLAVE_ADDRESS) {
|
if (addr == XPOWERS_AXP192_AXP2101_ADDRESS) {
|
||||||
axp192_found = true;
|
pmu_found = true;
|
||||||
DEBUG_MSG("axp192 PMU found\n");
|
DEBUG_MSG("axp192/axp2101 PMU found\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (addr == BME_ADDR || addr == BME_ADDR_ALTERNATE) {
|
if (addr == BME_ADDR || addr == BME_ADDR_ALTERNATE) {
|
||||||
registerValue = getRegisterValue(addr, 0xD0, 1); // GET_ID
|
registerValue = getRegisterValue(addr, 0xD0, 1); // GET_ID
|
||||||
if (registerValue == 0x61) {
|
if (registerValue == 0x61) {
|
||||||
DEBUG_MSG("BME-680 sensor found at address 0x%x\n", (uint8_t)addr);
|
DEBUG_MSG("BME-680 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = addr;
|
nodeTelemetrySensorsMap[TelemetrySensorType_BME680] = addr;
|
||||||
} else if (registerValue == 0x60) {
|
} else if (registerValue == 0x60) {
|
||||||
DEBUG_MSG("BME-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
DEBUG_MSG("BME-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_BME280] = addr;
|
nodeTelemetrySensorsMap[TelemetrySensorType_BME280] = addr;
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("BMP-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
DEBUG_MSG("BMP-280 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_BMP280] = addr;
|
nodeTelemetrySensorsMap[TelemetrySensorType_BMP280] = addr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (addr == INA_ADDR || addr == INA_ADDR_ALTERNATE) {
|
||||||
if (addr == INA_ADDR || addr == INA_ADDR_ALTERNATE) {
|
registerValue = getRegisterValue(addr, 0xFE, 2);
|
||||||
registerValue = getRegisterValue(addr, 0xFE, 2);
|
DEBUG_MSG("Register MFG_UID: 0x%x\n", registerValue);
|
||||||
DEBUG_MSG("Register MFG_UID: 0x%x\n", registerValue);
|
if (registerValue == 0x5449) {
|
||||||
if (registerValue == 0x5449) {
|
DEBUG_MSG("INA260 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
DEBUG_MSG("INA260 sensor found at address 0x%x\n", (uint8_t)addr);
|
nodeTelemetrySensorsMap[TelemetrySensorType_INA260] = addr;
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_INA260] = addr;
|
} else { // Assume INA219 if INA260 ID is not found
|
||||||
} else { // Assume INA219 if INA260 ID is not found
|
DEBUG_MSG("INA219 sensor found at address 0x%x\n", (uint8_t)addr);
|
||||||
DEBUG_MSG("INA219 sensor found at address 0x%x\n", (uint8_t)addr);
|
nodeTelemetrySensorsMap[TelemetrySensorType_INA219] = addr;
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_INA219] = addr;
|
}
|
||||||
|
}
|
||||||
|
if (addr == MCP9808_ADDR) {
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
||||||
|
DEBUG_MSG("MCP9808 sensor found\n");
|
||||||
|
}
|
||||||
|
if (addr == SHT31_ADDR) {
|
||||||
|
DEBUG_MSG("SHT31 sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_SHT31] = addr;
|
||||||
|
}
|
||||||
|
if (addr == SHTC3_ADDR) {
|
||||||
|
DEBUG_MSG("SHTC3 sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_SHTC3] = addr;
|
||||||
|
}
|
||||||
|
if (addr == LPS22HB_ADDR || addr == LPS22HB_ADDR_ALT) {
|
||||||
|
DEBUG_MSG("LPS22HB sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_LPS22] = addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// High rate sensors, will be processed internally
|
||||||
|
if (addr == QMC6310_ADDR) {
|
||||||
|
DEBUG_MSG("QMC6310 Highrate 3-Axis magnetic sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_QMC6310] = addr;
|
||||||
|
}
|
||||||
|
if (addr == QMI8658_ADDR) {
|
||||||
|
DEBUG_MSG("QMI8658 Highrate 6-Axis inertial measurement sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_QMI8658] = addr;
|
||||||
|
}
|
||||||
|
if (addr == QMC5883L_ADDR) {
|
||||||
|
DEBUG_MSG("QMC5883L Highrate 3-Axis magnetic sensor found\n");
|
||||||
|
nodeTelemetrySensorsMap[TelemetrySensorType_QMC5883L] = addr;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (addr == MCP9808_ADDR) {
|
|
||||||
nodeTelemetrySensorsMap[TelemetrySensorType_MCP9808] = addr;
|
|
||||||
DEBUG_MSG("MCP9808 sensor found at address 0x%x\n", (uint8_t)addr);
|
|
||||||
}
|
|
||||||
} else if (err == 4) {
|
} else if (err == 4) {
|
||||||
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
DEBUG_MSG("Unknow error at address 0x%x\n", addr);
|
||||||
}
|
}
|
||||||
@@ -159,5 +228,5 @@ void scanI2Cdevice(void)
|
|||||||
DEBUG_MSG("%i I2C devices found\n",nDevices);
|
DEBUG_MSG("%i I2C devices found\n",nDevices);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void scanI2Cdevice(void) {}
|
void scanI2Cdevice() {}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,4 +8,4 @@
|
|||||||
#define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__)
|
#define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__)
|
||||||
|
|
||||||
/// Record an error that should be reported via analytics
|
/// Record an error that should be reported via analytics
|
||||||
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0, const char *filename = NULL);
|
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, const char *filename = NULL);
|
||||||
|
|||||||
439
src/gps/GPS.cpp
439
src/gps/GPS.cpp
@@ -59,98 +59,204 @@ bool GPS::getACK(uint8_t c, uint8_t i) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* @note New method, this method can wait for the specified class and message ID, and return the payload
|
||||||
|
* @param *buffer: The message buffer, if there is a response payload message, it will be returned through the buffer parameter
|
||||||
|
* @param size: size of buffer
|
||||||
|
* @param requestedClass: request class constant
|
||||||
|
* @param requestedID: request message ID constant
|
||||||
|
* @retval length of payload message
|
||||||
|
*/
|
||||||
|
int GPS::getAck(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID)
|
||||||
|
{
|
||||||
|
uint16_t ubxFrameCounter = 0;
|
||||||
|
uint32_t startTime = millis();
|
||||||
|
uint16_t needRead;
|
||||||
|
|
||||||
|
while (millis() - startTime < 800) {
|
||||||
|
while (_serial_gps->available()) {
|
||||||
|
int c = _serial_gps->read();
|
||||||
|
switch (ubxFrameCounter) {
|
||||||
|
case 0:
|
||||||
|
//ubxFrame 'μ'
|
||||||
|
if (c == 0xB5) {
|
||||||
|
ubxFrameCounter++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
//ubxFrame 'b'
|
||||||
|
if (c == 0x62) {
|
||||||
|
ubxFrameCounter++;
|
||||||
|
} else {
|
||||||
|
ubxFrameCounter = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//Class
|
||||||
|
if (c == requestedClass) {
|
||||||
|
ubxFrameCounter++;
|
||||||
|
} else {
|
||||||
|
ubxFrameCounter = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
//Message ID
|
||||||
|
if (c == requestedID) {
|
||||||
|
ubxFrameCounter++;
|
||||||
|
} else {
|
||||||
|
ubxFrameCounter = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
//Payload lenght lsb
|
||||||
|
needRead = c;
|
||||||
|
ubxFrameCounter++;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
//Payload lenght msb
|
||||||
|
needRead |= (c << 8);
|
||||||
|
ubxFrameCounter++;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
// Check for buffer overflow
|
||||||
|
if (needRead >= size) {
|
||||||
|
ubxFrameCounter = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (_serial_gps->readBytes(buffer, needRead) != needRead) {
|
||||||
|
ubxFrameCounter = 0;
|
||||||
|
} else {
|
||||||
|
// return payload lenght
|
||||||
|
return needRead;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool GPS::setupGPS()
|
bool GPS::setupGPS()
|
||||||
{
|
{
|
||||||
if (_serial_gps && !didSerialInit) {
|
if (_serial_gps && !didSerialInit) {
|
||||||
didSerialInit = true;
|
didSerialInit = true;
|
||||||
|
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
// In esp32 framework, setRxBufferSize needs to be initialized before Serial
|
||||||
|
_serial_gps->setRxBufferSize(2048); // the default is 256
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// if the overrides are not dialled in, set them from the board definitions, if they exist
|
||||||
|
|
||||||
|
#if defined(GPS_RX_PIN)
|
||||||
|
if (!config.position.rx_gpio)
|
||||||
|
config.position.rx_gpio = GPS_RX_PIN;
|
||||||
|
#endif
|
||||||
|
#if defined(GPS_TX_PIN)
|
||||||
|
if (!config.position.tx_gpio)
|
||||||
|
config.position.tx_gpio = GPS_TX_PIN;
|
||||||
|
#endif
|
||||||
|
|
||||||
// ESP32 has a special set of parameters vs other arduino ports
|
// ESP32 has a special set of parameters vs other arduino ports
|
||||||
#if defined(GPS_RX_PIN) && defined(ARCH_ESP32)
|
#if defined(ARCH_ESP32)
|
||||||
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
if(config.position.rx_gpio)
|
||||||
|
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, config.position.rx_gpio, config.position.tx_gpio);
|
||||||
#else
|
#else
|
||||||
_serial_gps->begin(GPS_BAUDRATE);
|
_serial_gps->begin(GPS_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
_serial_gps->setRxBufferSize(2048); // the default is 256
|
|
||||||
#endif
|
|
||||||
#ifdef TTGO_T_ECHO
|
|
||||||
// Switch to 9600 baud, then close and reopen port
|
|
||||||
_serial_gps->end();
|
|
||||||
delay(250);
|
|
||||||
_serial_gps->begin(4800);
|
|
||||||
delay(250);
|
|
||||||
_serial_gps->write("$PCAS01,1*1D\r\n");
|
|
||||||
delay(250);
|
|
||||||
_serial_gps->end();
|
|
||||||
delay(250);
|
|
||||||
_serial_gps->begin(9600);
|
|
||||||
delay(250);
|
|
||||||
// Initialize the L76K Chip, use GPS + GLONASS
|
|
||||||
_serial_gps->write("$PCAS04,5*1C\r\n");
|
|
||||||
delay(250);
|
|
||||||
// only ask for RMC and GGA
|
|
||||||
_serial_gps->write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n");
|
|
||||||
delay(250);
|
|
||||||
// Switch to Vehicle Mode, since SoftRF enables Aviation < 2g
|
|
||||||
_serial_gps->write("$PCAS11,3*1E\r\n");
|
|
||||||
delay(250);
|
|
||||||
#endif
|
|
||||||
#ifdef GPS_UBLOX
|
|
||||||
delay(250);
|
|
||||||
// Set the UART port to output NMEA only
|
|
||||||
byte _message_nmea[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00,
|
|
||||||
0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0xAF};
|
|
||||||
_serial_gps->write(_message_nmea, sizeof(_message_nmea));
|
|
||||||
if (!getACK(0x06, 0x00)) {
|
|
||||||
DEBUG_MSG("WARNING: Unable to enable NMEA Mode.\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable GGL
|
/*
|
||||||
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x05, 0x3A};
|
* T-Beam-S3-Core will be preset to use gps Probe here, and other boards will not be changed first
|
||||||
_serial_gps->write(_message_GGL, sizeof(_message_GGL));
|
*/
|
||||||
if (!getACK(0x06, 0x01)) {
|
gnssModel = probe();
|
||||||
DEBUG_MSG("WARNING: Unable to disable NMEA GGL.\n");
|
|
||||||
return true;
|
if(gnssModel == GNSS_MODEL_MTK){
|
||||||
|
/*
|
||||||
|
* t-beam-s3-core uses the same L76K GNSS module as t-echo.
|
||||||
|
* Unlike t-echo, L76K uses 9600 baud rate for communication by default.
|
||||||
|
* */
|
||||||
|
// _serial_gps->begin(9600); //The baud rate of 9600 has been initialized at the beginning of setupGPS, this line is the redundant part
|
||||||
|
// delay(250);
|
||||||
|
|
||||||
|
// Initialize the L76K Chip, use GPS + GLONASS
|
||||||
|
_serial_gps->write("$PCAS04,5*1C\r\n");
|
||||||
|
delay(250);
|
||||||
|
// only ask for RMC and GGA
|
||||||
|
_serial_gps->write("$PCAS03,1,0,0,0,1,0,0,0,0,0,,,0,0*02\r\n");
|
||||||
|
delay(250);
|
||||||
|
// Switch to Vehicle Mode, since SoftRF enables Aviation < 2g
|
||||||
|
_serial_gps->write("$PCAS11,3*1E\r\n");
|
||||||
|
delay(250);
|
||||||
|
|
||||||
|
}else if(gnssModel == GNSS_MODEL_UBLOX){
|
||||||
|
|
||||||
|
/*
|
||||||
|
tips: NMEA Only should not be set here, otherwise initializing Ublox gnss module again after
|
||||||
|
setting will not output command messages in UART1, resulting in unrecognized module information
|
||||||
|
|
||||||
|
// Set the UART port to output NMEA only
|
||||||
|
byte _message_nmea[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xC0, 0x08, 0x00, 0x00,
|
||||||
|
0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x91, 0xAF};
|
||||||
|
_serial_gps->write(_message_nmea, sizeof(_message_nmea));
|
||||||
|
if (!getACK(0x06, 0x00)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to enable NMEA Mode.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ublox-M10S can be compatible with UBLOX traditional protocol, so the following sentence settings are also valid
|
||||||
|
|
||||||
|
// disable GGL
|
||||||
|
byte _message_GGL[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x05, 0x3A};
|
||||||
|
_serial_gps->write(_message_GGL, sizeof(_message_GGL));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to disable NMEA GGL.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable GSA
|
||||||
|
byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x06, 0x41};
|
||||||
|
_serial_gps->write(_message_GSA, sizeof(_message_GSA));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to disable NMEA GSA.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable GSV
|
||||||
|
byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x07, 0x48};
|
||||||
|
_serial_gps->write(_message_GSV, sizeof(_message_GSV));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to disable NMEA GSV.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// disable VTG
|
||||||
|
byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x56};
|
||||||
|
_serial_gps->write(_message_VTG, sizeof(_message_VTG));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to disable NMEA VTG.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable RMC
|
||||||
|
byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x54};
|
||||||
|
_serial_gps->write(_message_RMC, sizeof(_message_RMC));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to enable NMEA RMC.\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable GGA
|
||||||
|
byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x38};
|
||||||
|
_serial_gps->write(_message_GGA, sizeof(_message_GGA));
|
||||||
|
if (!getACK(0x06, 0x01)) {
|
||||||
|
DEBUG_MSG("WARNING: Unable to enable NMEA GGA.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable GSA
|
|
||||||
byte _message_GSA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x06, 0x41};
|
|
||||||
_serial_gps->write(_message_GSA, sizeof(_message_GSA));
|
|
||||||
if (!getACK(0x06, 0x01)) {
|
|
||||||
DEBUG_MSG("WARNING: Unable to disable NMEA GSA.\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable GSV
|
|
||||||
byte _message_GSV[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x03, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x07, 0x48};
|
|
||||||
_serial_gps->write(_message_GSV, sizeof(_message_GSV));
|
|
||||||
if (!getACK(0x06, 0x01)) {
|
|
||||||
DEBUG_MSG("WARNING: Unable to disable NMEA GSV.\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// disable VTG
|
|
||||||
byte _message_VTG[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x05, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x09, 0x56};
|
|
||||||
_serial_gps->write(_message_VTG, sizeof(_message_VTG));
|
|
||||||
if (!getACK(0x06, 0x01)) {
|
|
||||||
DEBUG_MSG("WARNING: Unable to disable NMEA VTG.\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable RMC
|
|
||||||
byte _message_RMC[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x09, 0x54};
|
|
||||||
_serial_gps->write(_message_RMC, sizeof(_message_RMC));
|
|
||||||
if (!getACK(0x06, 0x01)) {
|
|
||||||
DEBUG_MSG("WARNING: Unable to enable NMEA RMC.\n");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable GGA
|
|
||||||
byte _message_GGA[] = {0xB5, 0x62, 0x06, 0x01, 0x08, 0x00, 0xF0, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x05, 0x38};
|
|
||||||
_serial_gps->write(_message_GGA, sizeof(_message_GGA));
|
|
||||||
if (!getACK(0x06, 0x01)) DEBUG_MSG("WARNING: Unable to enable NMEA GGA.\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -164,21 +270,30 @@ bool GPS::setup()
|
|||||||
pinMode(PIN_GPS_EN, OUTPUT);
|
pinMode(PIN_GPS_EN, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_PMU
|
||||||
|
if(config.position.gps_enabled){
|
||||||
|
setGPSPower(true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PIN_GPS_RESET
|
#ifdef PIN_GPS_RESET
|
||||||
digitalWrite(PIN_GPS_RESET, 1); // assert for 10ms
|
digitalWrite(PIN_GPS_RESET, 1); // assert for 10ms
|
||||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
pinMode(PIN_GPS_RESET, OUTPUT);
|
||||||
delay(10);
|
delay(10);
|
||||||
digitalWrite(PIN_GPS_RESET, 0);
|
digitalWrite(PIN_GPS_RESET, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
setAwake(true); // Wake GPS power before doing any init
|
setAwake(true); // Wake GPS power before doing any init
|
||||||
bool ok = setupGPS();
|
bool ok = setupGPS();
|
||||||
|
|
||||||
if (ok) {
|
if (ok) {
|
||||||
notifySleepObserver.observe(¬ifySleep);
|
notifySleepObserver.observe(¬ifySleep);
|
||||||
notifyDeepSleepObserver.observe(¬ifyDeepSleep);
|
notifyDeepSleepObserver.observe(¬ifyDeepSleep);
|
||||||
|
notifyGPSSleepObserver.observe(¬ifyGPSSleep);
|
||||||
|
}
|
||||||
|
if (config.position.gps_enabled==false) {
|
||||||
|
setAwake(false);
|
||||||
|
doGPSpowersave(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,6 +302,7 @@ GPS::~GPS()
|
|||||||
// we really should unregister our sleep observer
|
// we really should unregister our sleep observer
|
||||||
notifySleepObserver.unobserve(¬ifySleep);
|
notifySleepObserver.unobserve(¬ifySleep);
|
||||||
notifyDeepSleepObserver.unobserve(¬ifyDeepSleep);
|
notifyDeepSleepObserver.unobserve(¬ifyDeepSleep);
|
||||||
|
notifyGPSSleepObserver.observe(¬ifyGPSSleep);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPS::hasLock()
|
bool GPS::hasLock()
|
||||||
@@ -271,16 +387,7 @@ uint32_t GPS::getWakeTime() const
|
|||||||
|
|
||||||
if (t == UINT32_MAX)
|
if (t == UINT32_MAX)
|
||||||
return t; // already maxint
|
return t; // already maxint
|
||||||
|
return t * 1000;
|
||||||
if (t == 0)
|
|
||||||
t = (config.device.role == Config_DeviceConfig_Role_Router)
|
|
||||||
? 5 * 60
|
|
||||||
: 15 * 60; // Allow up to 15 mins for each attempt (probably will be much
|
|
||||||
// less if we can find sats) or less if a router
|
|
||||||
|
|
||||||
t *= 1000; // msecs
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get how long we should sleep between aqusition attempts in msecs
|
/** Get how long we should sleep between aqusition attempts in msecs
|
||||||
@@ -288,21 +395,15 @@ uint32_t GPS::getWakeTime() const
|
|||||||
uint32_t GPS::getSleepTime() const
|
uint32_t GPS::getSleepTime() const
|
||||||
{
|
{
|
||||||
uint32_t t = config.position.gps_update_interval;
|
uint32_t t = config.position.gps_update_interval;
|
||||||
bool gps_disabled = config.position.gps_disabled;
|
bool gps_enabled = config.position.gps_enabled;
|
||||||
|
|
||||||
if (gps_disabled)
|
if (!gps_enabled)
|
||||||
t = UINT32_MAX; // Sleep forever now
|
t = UINT32_MAX; // Sleep forever now
|
||||||
|
|
||||||
if (t == UINT32_MAX)
|
if (t == UINT32_MAX)
|
||||||
return t; // already maxint
|
return t; // already maxint
|
||||||
|
|
||||||
if (t == 0) // default - unset in preferences
|
return t * 1000;
|
||||||
t = (config.device.role == Config_DeviceConfig_Role_Router) ? 24 * 60 * 60
|
|
||||||
: 2 * 60; // 2 mins or once per day for routers
|
|
||||||
|
|
||||||
t *= 1000;
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPS::publishUpdate()
|
void GPS::publishUpdate()
|
||||||
@@ -311,10 +412,10 @@ void GPS::publishUpdate()
|
|||||||
shouldPublish = false;
|
shouldPublish = false;
|
||||||
|
|
||||||
// In debug logs, identify position by @timestamp:stage (stage 2 = publish)
|
// In debug logs, identify position by @timestamp:stage (stage 2 = publish)
|
||||||
DEBUG_MSG("publishing pos@%x:2, hasVal=%d, GPSlock=%d\n", p.pos_timestamp, hasValidLocation, hasLock());
|
DEBUG_MSG("publishing pos@%x:2, hasVal=%d, GPSlock=%d\n", p.timestamp, hasValidLocation, hasLock());
|
||||||
|
|
||||||
// Notify any status instances that are observing us
|
// Notify any status instances that are observing us
|
||||||
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), p);
|
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), isPowerSaving(), p);
|
||||||
newStatus.notifyObservers(&status);
|
newStatus.notifyObservers(&status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,14 +426,14 @@ int32_t GPS::runOnce()
|
|||||||
// if we have received valid NMEA claim we are connected
|
// if we have received valid NMEA claim we are connected
|
||||||
setConnected();
|
setConnected();
|
||||||
} else {
|
} else {
|
||||||
#ifdef GPS_UBLOX
|
if((config.position.gps_enabled == 1) && (gnssModel == GNSS_MODEL_UBLOX)){
|
||||||
// reset the GPS on next bootup
|
// reset the GPS on next bootup
|
||||||
if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
|
if(devicestate.did_gps_reset && (millis() > 60000) && !hasFlow()) {
|
||||||
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
|
DEBUG_MSG("GPS is not communicating, trying factory reset on next bootup.\n");
|
||||||
devicestate.did_gps_reset = false;
|
devicestate.did_gps_reset = false;
|
||||||
nodeDB.saveDeviceStateToDisk();
|
nodeDB.saveDeviceStateToDisk();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are overdue for an update, turn on the GPS and at least publish the current status
|
// If we are overdue for an update, turn on the GPS and at least publish the current status
|
||||||
@@ -427,11 +528,118 @@ int GPS::prepareDeepSleep(void *unused)
|
|||||||
DEBUG_MSG("GPS deep sleep!\n");
|
DEBUG_MSG("GPS deep sleep!\n");
|
||||||
|
|
||||||
// For deep sleep we also want abandon any lock attempts (because we want minimum power)
|
// For deep sleep we also want abandon any lock attempts (because we want minimum power)
|
||||||
|
getSleepTime();
|
||||||
setAwake(false);
|
setAwake(false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GnssModel_t GPS::probe()
|
||||||
|
{
|
||||||
|
// return immediately if the model is set by the variant.h file
|
||||||
|
#ifdef GPS_UBLOX
|
||||||
|
return GNSS_MODEL_UBLOX;
|
||||||
|
#elif defined(GPS_L76K)
|
||||||
|
return GNSS_MODEL_MTK;
|
||||||
|
#else
|
||||||
|
// we use autodetect, only T-BEAM S3 for now...
|
||||||
|
uint8_t buffer[256];
|
||||||
|
/*
|
||||||
|
* The GNSS module information variable is temporarily placed inside the function body,
|
||||||
|
* if it needs to be used elsewhere, it can be moved to the outside
|
||||||
|
* */
|
||||||
|
struct uBloxGnssModelInfo info ;
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(struct uBloxGnssModelInfo));
|
||||||
|
|
||||||
|
// Close all NMEA sentences , Only valid for MTK platform
|
||||||
|
_serial_gps->write("$PCAS03,0,0,0,0,0,0,0,0,0,0,,,0,0*02\r\n");
|
||||||
|
delay(20);
|
||||||
|
|
||||||
|
// Get version information
|
||||||
|
_serial_gps->write("$PCAS06,0*1B\r\n");
|
||||||
|
uint32_t startTimeout = millis() + 500;
|
||||||
|
while (millis() < startTimeout) {
|
||||||
|
if (_serial_gps->available()) {
|
||||||
|
String ver = _serial_gps->readStringUntil('\r');
|
||||||
|
// Get module info , If the correct header is returned,
|
||||||
|
// it can be determined that it is the MTK chip
|
||||||
|
int index = ver.indexOf("$");
|
||||||
|
if(index != -1){
|
||||||
|
ver = ver.substring(index);
|
||||||
|
if (ver.startsWith("$GPTXT,01,01,02")) {
|
||||||
|
DEBUG_MSG("L76K GNSS init succeeded, using L76K GNSS Module\n");
|
||||||
|
return GNSS_MODEL_MTK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t cfg_rate[] = {0xB5, 0x62, 0x06, 0x08, 0x00, 0x00, 0x0E, 0x30};
|
||||||
|
_serial_gps->write(cfg_rate, sizeof(cfg_rate));
|
||||||
|
// Check that the returned response class and message ID are correct
|
||||||
|
if (!getAck(buffer, 256, 0x06, 0x08)) {
|
||||||
|
DEBUG_MSG("Warning: Failed to find UBlox & MTK GNSS Module\n");
|
||||||
|
return GNSS_MODEL_UNKONW;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Ublox gnss module hardware and software info
|
||||||
|
uint8_t cfg_get_hw[] = {0xB5, 0x62, 0x0A, 0x04, 0x00, 0x00, 0x0E, 0x34};
|
||||||
|
_serial_gps->write(cfg_get_hw, sizeof(cfg_get_hw));
|
||||||
|
|
||||||
|
uint16_t len = getAck(buffer, 256, 0x0A, 0x04);
|
||||||
|
if (len) {
|
||||||
|
|
||||||
|
uint16_t position = 0;
|
||||||
|
for (int i = 0; i < 30; i++) {
|
||||||
|
info.swVersion[i] = buffer[position];
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
info.hwVersion[i] = buffer[position];
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (len >= position + 30) {
|
||||||
|
for (int i = 0; i < 30; i++) {
|
||||||
|
info.extension[info.extensionNo][i] = buffer[position];
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
info.extensionNo++;
|
||||||
|
if (info.extensionNo > 9)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_MSG("Module Info : \n");
|
||||||
|
DEBUG_MSG("Soft version: %s\n",info.swVersion);
|
||||||
|
DEBUG_MSG("Hard version: %s\n",info.hwVersion);
|
||||||
|
DEBUG_MSG("Extensions:%d\n",info.extensionNo);
|
||||||
|
for (int i = 0; i < info.extensionNo; i++) {
|
||||||
|
DEBUG_MSG(" %s\n",info.extension[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(buffer,0,sizeof(buffer));
|
||||||
|
|
||||||
|
//tips: extensionNo field is 0 on some 6M GNSS modules
|
||||||
|
for (int i = 0; i < info.extensionNo; ++i) {
|
||||||
|
if (!strncmp(info.extension[i], "OD=", 3)) {
|
||||||
|
strcpy((char *)buffer, &(info.extension[i][3]));
|
||||||
|
DEBUG_MSG("GetModel:%s\n",(char *)buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen((char*)buffer)) {
|
||||||
|
DEBUG_MSG("UBlox GNSS init succeeded, using UBlox %s GNSS Module\n" , buffer);
|
||||||
|
}else{
|
||||||
|
DEBUG_MSG("UBlox GNSS init succeeded, using UBlox GNSS Module\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return GNSS_MODEL_UBLOX;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if HAS_GPS
|
#if HAS_GPS
|
||||||
#include "NMEAGPS.h"
|
#include "NMEAGPS.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -442,7 +650,7 @@ GPS *createGps()
|
|||||||
#if !HAS_GPS
|
#if !HAS_GPS
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
if (!config.position.gps_disabled) {
|
if (config.position.gps_enabled) {
|
||||||
#ifdef GPS_ALTITUDE_HAE
|
#ifdef GPS_ALTITUDE_HAE
|
||||||
DEBUG_MSG("Using HAE altitude model\n");
|
DEBUG_MSG("Using HAE altitude model\n");
|
||||||
#else
|
#else
|
||||||
@@ -456,6 +664,11 @@ GPS *createGps()
|
|||||||
return new_gps;
|
return new_gps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
GPS *new_gps = new NMEAGPS();
|
||||||
|
new_gps->setup();
|
||||||
|
return new_gps;
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,20 @@
|
|||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct uBloxGnssModelInfo {
|
||||||
|
char swVersion[30];
|
||||||
|
char hwVersion[10];
|
||||||
|
uint8_t extensionNo;
|
||||||
|
char extension[10][30];
|
||||||
|
} ;
|
||||||
|
|
||||||
|
typedef enum{
|
||||||
|
GNSS_MODEL_MTK,
|
||||||
|
GNSS_MODEL_UBLOX,
|
||||||
|
GNSS_MODEL_UNKONW,
|
||||||
|
}GnssModel_t;
|
||||||
|
|
||||||
// Generate a string representation of DOP
|
// Generate a string representation of DOP
|
||||||
const char *getDOPString(uint32_t dop);
|
const char *getDOPString(uint32_t dop);
|
||||||
|
|
||||||
@@ -35,6 +49,7 @@ class GPS : private concurrency::OSThread
|
|||||||
|
|
||||||
CallbackObserver<GPS, void *> notifySleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareSleep);
|
CallbackObserver<GPS, void *> notifySleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareSleep);
|
||||||
CallbackObserver<GPS, void *> notifyDeepSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareDeepSleep);
|
CallbackObserver<GPS, void *> notifyDeepSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareDeepSleep);
|
||||||
|
CallbackObserver<GPS, void *> notifyGPSSleepObserver = CallbackObserver<GPS, void *>(this, &GPS::prepareDeepSleep);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** If !NULL we will use this serial port to construct our GPS */
|
/** If !NULL we will use this serial port to construct our GPS */
|
||||||
@@ -63,6 +78,8 @@ class GPS : private concurrency::OSThread
|
|||||||
/// Return true if we are connected to a GPS
|
/// Return true if we are connected to a GPS
|
||||||
bool isConnected() const { return hasGPS; }
|
bool isConnected() const { return hasGPS; }
|
||||||
|
|
||||||
|
bool isPowerSaving() const { return !config.position.gps_enabled;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restart our lock attempt - try to get and broadcast a GPS reading ASAP
|
* Restart our lock attempt - try to get and broadcast a GPS reading ASAP
|
||||||
* called after the CPU wakes from light-sleep state
|
* called after the CPU wakes from light-sleep state
|
||||||
@@ -146,6 +163,14 @@ class GPS : private concurrency::OSThread
|
|||||||
void publishUpdate();
|
void publishUpdate();
|
||||||
|
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
|
// Get GNSS model
|
||||||
|
GnssModel_t probe();
|
||||||
|
|
||||||
|
int getAck(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t requestedID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GnssModel_t gnssModel = GNSS_MODEL_UNKONW;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Creates an instance of the GPS class.
|
// Creates an instance of the GPS class.
|
||||||
|
|||||||
@@ -19,14 +19,21 @@ static int32_t toDegInt(RawDegrees d)
|
|||||||
|
|
||||||
bool NMEAGPS::factoryReset()
|
bool NMEAGPS::factoryReset()
|
||||||
{
|
{
|
||||||
#ifdef GPS_UBLOX
|
#ifdef PIN_GPS_REINIT
|
||||||
|
//The L76K GNSS on the T-Echo requires the RESET pin to be pulled LOW
|
||||||
|
digitalWrite(PIN_GPS_REINIT, 0);
|
||||||
|
pinMode(PIN_GPS_REINIT, OUTPUT);
|
||||||
|
delay(150); //The L76K datasheet calls for at least 100MS delay
|
||||||
|
digitalWrite(PIN_GPS_REINIT, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// send the UBLOX Factory Reset Command regardless of detect state, something is very wrong, just assume it's UBLOX.
|
||||||
// Factory Reset
|
// Factory Reset
|
||||||
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF,
|
byte _message_reset[] = {0xB5, 0x62, 0x06, 0x09, 0x0D, 0x00, 0xFF,
|
||||||
0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
|
0xFF, 0xFF, 0x00, 0x00, 0x17, 0x2B, 0x7E};
|
||||||
_serial_gps->write(_message_reset,sizeof(_message_reset));
|
_serial_gps->write(_message_reset,sizeof(_message_reset));
|
||||||
delay(1000);
|
delay(1000);
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +109,7 @@ bool NMEAGPS::lookForLocation()
|
|||||||
|
|
||||||
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
fixType = atoi(gsafixtype.value()); // will set to zero if no data
|
fixType = atoi(gsafixtype.value()); // will set to zero if no data
|
||||||
DEBUG_MSG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType);
|
// DEBUG_MSG("FIX QUAL=%d, TYPE=%d\n", fixQual, fixType);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check if GPS has an acceptable lock
|
// check if GPS has an acceptable lock
|
||||||
@@ -155,13 +162,13 @@ bool NMEAGPS::lookForLocation()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.location_source = Position_LocSource_LOCSRC_GPS_INTERNAL;
|
p.location_source = Position_LocSource_LOC_INTERNAL;
|
||||||
|
|
||||||
// Dilution of precision (an accuracy metric) is reported in 10^2 units, so we need to scale down when we use it
|
// Dilution of precision (an accuracy metric) is reported in 10^2 units, so we need to scale down when we use it
|
||||||
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
|
||||||
p.HDOP = reader.hdop.value();
|
p.HDOP = reader.hdop.value();
|
||||||
p.PDOP = TinyGPSPlus::parseDecimal(gsapdop.value());
|
p.PDOP = TinyGPSPlus::parseDecimal(gsapdop.value());
|
||||||
DEBUG_MSG("PDOP=%d, HDOP=%d\n", dop, reader.hdop.value());
|
// DEBUG_MSG("PDOP=%d, HDOP=%d\n", p.PDOP, p.HDOP);
|
||||||
#else
|
#else
|
||||||
// FIXME! naive PDOP emulation (assumes VDOP==HDOP)
|
// FIXME! naive PDOP emulation (assumes VDOP==HDOP)
|
||||||
// correct formula is PDOP = SQRT(HDOP^2 + VDOP^2)
|
// correct formula is PDOP = SQRT(HDOP^2 + VDOP^2)
|
||||||
@@ -176,8 +183,8 @@ bool NMEAGPS::lookForLocation()
|
|||||||
p.latitude_i = toDegInt(loc.lat);
|
p.latitude_i = toDegInt(loc.lat);
|
||||||
p.longitude_i = toDegInt(loc.lng);
|
p.longitude_i = toDegInt(loc.lng);
|
||||||
|
|
||||||
p.alt_geoid_sep = reader.geoidHeight.meters();
|
p.altitude_geoidal_separation = reader.geoidHeight.meters();
|
||||||
p.altitude_hae = reader.altitude.meters() + p.alt_geoid_sep;
|
p.altitude_hae = reader.altitude.meters() + p.altitude_geoidal_separation;
|
||||||
p.altitude = reader.altitude.meters();
|
p.altitude = reader.altitude.meters();
|
||||||
|
|
||||||
p.fix_quality = fixQual;
|
p.fix_quality = fixQual;
|
||||||
@@ -194,7 +201,7 @@ bool NMEAGPS::lookForLocation()
|
|||||||
t.tm_mon = reader.date.month() - 1;
|
t.tm_mon = reader.date.month() - 1;
|
||||||
t.tm_year = reader.date.year() - 1900;
|
t.tm_year = reader.date.year() - 1900;
|
||||||
t.tm_isdst = false;
|
t.tm_isdst = false;
|
||||||
p.pos_timestamp = mktime(&t);
|
p.timestamp = mktime(&t);
|
||||||
|
|
||||||
// Nice to have, if available
|
// Nice to have, if available
|
||||||
if (reader.satellites.isUpdated()) {
|
if (reader.satellites.isUpdated()) {
|
||||||
@@ -210,13 +217,10 @@ bool NMEAGPS::lookForLocation()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (reader.speed.isUpdated() && reader.speed.isValid()) {
|
||||||
// REDUNDANT?
|
p.ground_speed = reader.speed.kmph();
|
||||||
// expect gps pos lat=37.520825, lon=-122.309162, alt=158
|
}
|
||||||
DEBUG_MSG("new NMEA GPS pos lat=%f, lon=%f, alt=%d, dop=%g, heading=%f\n",
|
|
||||||
latitude * 1e-7, longitude * 1e-7, altitude, dop * 1e-2,
|
|
||||||
heading * 1e-5);
|
|
||||||
*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
90
src/gps/NMEAWPL.cpp
Normal file
90
src/gps/NMEAWPL.cpp
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#include "NMEAWPL.h"
|
||||||
|
#include "GeoCoord.h"
|
||||||
|
|
||||||
|
/* -------------------------------------------
|
||||||
|
* 1 2 3 4 5 6
|
||||||
|
* | | | | | |
|
||||||
|
* $--WPL,llll.ll,a,yyyyy.yy,a,c--c*hh<CR><LF>
|
||||||
|
*
|
||||||
|
* Field Number:
|
||||||
|
* 1 Latitude
|
||||||
|
* 2 N or S (North or South)
|
||||||
|
* 3 Longitude
|
||||||
|
* 4 E or W (East or West)
|
||||||
|
* 5 Waypoint name
|
||||||
|
* 6 Checksum
|
||||||
|
* -------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t printWPL(char *buf, const Position &pos, const char *name)
|
||||||
|
{
|
||||||
|
GeoCoord geoCoord(pos.latitude_i,pos.longitude_i,pos.altitude);
|
||||||
|
uint32_t len = sprintf(buf, "$GNWPL,%02d%07.4f,%c,%03d%07.4f,%c,%s",
|
||||||
|
geoCoord.getDMSLatDeg(),
|
||||||
|
(abs(geoCoord.getLatitude()) - geoCoord.getDMSLatDeg() * 1e+7) * 6e-6,
|
||||||
|
geoCoord.getDMSLatCP(),
|
||||||
|
geoCoord.getDMSLonDeg(),
|
||||||
|
(abs(geoCoord.getLongitude()) - geoCoord.getDMSLonDeg() * 1e+7) * 6e-6,
|
||||||
|
geoCoord.getDMSLonCP(),
|
||||||
|
name);
|
||||||
|
uint32_t chk = 0;
|
||||||
|
for (uint32_t i = 1; i < len; i++) {
|
||||||
|
chk ^= buf[i];
|
||||||
|
}
|
||||||
|
len += sprintf(buf + len, "*%02X\r\n", chk);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* -------------------------------------------
|
||||||
|
* 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||||
|
* | | | | | | | | | | | | | | |
|
||||||
|
* $--GGA,hhmmss.ss,ddmm.mm,a,ddmm.mm,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh<CR><LF>
|
||||||
|
*
|
||||||
|
* Field Number:
|
||||||
|
* 1 UTC of this position report, hh is hours, mm is minutes, ss.ss is seconds.
|
||||||
|
* 2 Latitude
|
||||||
|
* 3 N or S (North or South)
|
||||||
|
* 4 Longitude
|
||||||
|
* 5 E or W (East or West)
|
||||||
|
* 6 GPS Quality Indicator (non null)
|
||||||
|
* 7 Number of satellites in use, 00 - 12
|
||||||
|
* 8 Horizontal Dilution of precision (meters)
|
||||||
|
* 9 Antenna Altitude above/below mean-sea-level (geoid) (in meters)
|
||||||
|
* 10 Units of antenna altitude, meters
|
||||||
|
* 11 Geoidal separation, the difference between the WGS-84 earth ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid
|
||||||
|
* 12 Units of geoidal separation, meters
|
||||||
|
* 13 Age of differential GPS data, time in seconds since last SC104 type 1 or 9 update, null field when DGPS is not used
|
||||||
|
* 14 Differential reference station ID, 0000-1023
|
||||||
|
* 15 Checksum
|
||||||
|
* -------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
uint32_t printGGA(char *buf, const Position &pos)
|
||||||
|
{
|
||||||
|
GeoCoord geoCoord(pos.latitude_i,pos.longitude_i,pos.altitude);
|
||||||
|
uint32_t len = sprintf(buf, "$GNGGA,%06u.%03u,%02d%07.4f,%c,%03d%07.4f,%c,%u,%02u,%04u,%04d,%c,%04d,%c,%d,%04d",
|
||||||
|
pos.time / 1000,
|
||||||
|
pos.time % 1000,
|
||||||
|
geoCoord.getDMSLatDeg(),
|
||||||
|
(abs(geoCoord.getLatitude()) - geoCoord.getDMSLatDeg() * 1e+7) * 6e-6,
|
||||||
|
geoCoord.getDMSLatCP(),
|
||||||
|
geoCoord.getDMSLonDeg(),
|
||||||
|
(abs(geoCoord.getLongitude()) - geoCoord.getDMSLonDeg() * 1e+7) * 6e-6,
|
||||||
|
geoCoord.getDMSLonCP(),
|
||||||
|
pos.fix_type,
|
||||||
|
pos.sats_in_view,
|
||||||
|
pos.HDOP,
|
||||||
|
geoCoord.getAltitude(),
|
||||||
|
'M',
|
||||||
|
pos.altitude_geoidal_separation,
|
||||||
|
'M',
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
|
||||||
|
uint32_t chk = 0;
|
||||||
|
for (uint32_t i = 1; i < len; i++) {
|
||||||
|
chk ^= buf[i];
|
||||||
|
}
|
||||||
|
len += sprintf(buf + len, "*%02X\r\n", chk);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
7
src/gps/NMEAWPL.h
Normal file
7
src/gps/NMEAWPL.h
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
uint32_t printWPL(char *buf, const Position &pos, const char *name);
|
||||||
|
uint32_t printGGA(char *buf, const Position &pos);
|
||||||
@@ -44,11 +44,15 @@ void readFromRTC()
|
|||||||
if(rtc_found == PCF8563_RTC) {
|
if(rtc_found == PCF8563_RTC) {
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
PCF8563_Class rtc;
|
PCF8563_Class rtc;
|
||||||
|
#ifdef RTC_USE_WIRE1
|
||||||
|
rtc.begin(Wire1);
|
||||||
|
#else
|
||||||
rtc.begin();
|
rtc.begin();
|
||||||
|
#endif
|
||||||
auto tc = rtc.getDateTime();
|
auto tc = rtc.getDateTime();
|
||||||
tm t;
|
tm t;
|
||||||
t.tm_year = tc.year;
|
t.tm_year = tc.year - 1900;
|
||||||
t.tm_mon = tc.month;
|
t.tm_mon = tc.month - 1;
|
||||||
t.tm_mday = tc.day;
|
t.tm_mday = tc.day;
|
||||||
t.tm_hour = tc.hour;
|
t.tm_hour = tc.hour;
|
||||||
t.tm_min = tc.minute;
|
t.tm_min = tc.minute;
|
||||||
@@ -110,9 +114,13 @@ bool perhapsSetRTC(RTCQuality q, const struct timeval *tv)
|
|||||||
#elif defined(PCF8563_RTC)
|
#elif defined(PCF8563_RTC)
|
||||||
if(rtc_found == PCF8563_RTC) {
|
if(rtc_found == PCF8563_RTC) {
|
||||||
PCF8563_Class rtc;
|
PCF8563_Class rtc;
|
||||||
rtc.begin();
|
#ifdef RTC_USE_WIRE1
|
||||||
|
rtc.begin(Wire1);
|
||||||
|
#else
|
||||||
|
rtc.begin();
|
||||||
|
#endif
|
||||||
tm *t = localtime(&tv->tv_sec);
|
tm *t = localtime(&tv->tv_sec);
|
||||||
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_wday, t->tm_hour, t->tm_min, t->tm_sec);
|
rtc.setDateTime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
|
||||||
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
DEBUG_MSG("PCF8563_RTC setDateTime %02d-%02d-%02d %02d:%02d:%02d %ld\n", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, tv->tv_sec);
|
||||||
}
|
}
|
||||||
#elif defined(ARCH_ESP32)
|
#elif defined(ARCH_ESP32)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ enum RTCQuality {
|
|||||||
RTCQualityFromNet = 2,
|
RTCQualityFromNet = 2,
|
||||||
|
|
||||||
/// Our time is based on NTP
|
/// Our time is based on NTP
|
||||||
RTCQualityNTP= 3,
|
RTCQualityNTP = 3,
|
||||||
|
|
||||||
/// Our time is based on our own GPS
|
/// Our time is based on our own GPS
|
||||||
RTCQualityGPS = 4
|
RTCQualityGPS = 4
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#define TECHO_DISPLAY_MODEL GxEPD2_154_D67
|
#define TECHO_DISPLAY_MODEL GxEPD2_154_D67
|
||||||
#elif defined(RAK4630)
|
#elif defined(RAK4630)
|
||||||
|
|
||||||
//GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128
|
//GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update support
|
||||||
#define TECHO_DISPLAY_MODEL GxEPD2_213_B74
|
#define TECHO_DISPLAY_MODEL GxEPD2_213_BN
|
||||||
|
|
||||||
//4.2 inch 300x400 - GxEPD2_420_M01
|
//4.2 inch 300x400 - GxEPD2_420_M01
|
||||||
//#define TECHO_DISPLAY_MODEL GxEPD2_420_M01
|
//#define TECHO_DISPLAY_MODEL GxEPD2_420_M01
|
||||||
@@ -46,9 +46,9 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl)
|
|||||||
setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT);
|
setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT);
|
||||||
#elif defined(RAK4630)
|
#elif defined(RAK4630)
|
||||||
|
|
||||||
//GxEPD2_213_B74 - RAK14000 2.13 inch b/w 250x128
|
//GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122
|
||||||
setGeometry(GEOMETRY_RAWMODE, 250, 122);
|
setGeometry(GEOMETRY_RAWMODE, 250, 122);
|
||||||
|
|
||||||
//GxEPD2_420_M01
|
//GxEPD2_420_M01
|
||||||
//setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
//setGeometry(GEOMETRY_RAWMODE, 300, 400);
|
||||||
|
|
||||||
@@ -110,14 +110,17 @@ bool EInkDisplay::forceDisplay(uint32_t msecLimit)
|
|||||||
adafruitDisplay->display(false); // FIXME, use partial update mode
|
adafruitDisplay->display(false); // FIXME, use partial update mode
|
||||||
#elif defined(RAK4630)
|
#elif defined(RAK4630)
|
||||||
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
//RAK14000 2.13 inch b/w 250x122 actually now does support partial updates
|
||||||
adafruitDisplay->display(false); // FIXME, use partial update mode
|
|
||||||
|
//Full update mode (slow)
|
||||||
|
//adafruitDisplay->display(false); // FIXME, use partial update mode
|
||||||
|
|
||||||
//Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false);
|
//Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false);
|
||||||
// 1.54 inch 200x200 - GxEPD2_154_M09
|
// 1.54 inch 200x200 - GxEPD2_154_M09
|
||||||
|
// 2.13 inch 250x122 - GxEPD2_213_BN
|
||||||
// 2.9 inch 296x128 - GxEPD2_290_T5D
|
// 2.9 inch 296x128 - GxEPD2_290_T5D
|
||||||
// 4.2 inch 300x400 - GxEPD2_420_M01
|
// 4.2 inch 300x400 - GxEPD2_420_M01
|
||||||
//adafruitDisplay->nextPage();
|
adafruitDisplay->nextPage();
|
||||||
|
|
||||||
#elif defined(PCA10059) || defined(M5_COREINK)
|
#elif defined(PCA10059) || defined(M5_COREINK)
|
||||||
adafruitDisplay->nextPage();
|
adafruitDisplay->nextPage();
|
||||||
@@ -190,11 +193,11 @@ bool EInkDisplay::connect()
|
|||||||
|
|
||||||
adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||||
|
|
||||||
//RAK14000 2.13 inch b/w 250x122 does not support partial updates
|
//RAK14000 2.13 inch b/w 250x122 does actually now support partial updates
|
||||||
adafruitDisplay->setRotation(3);
|
adafruitDisplay->setRotation(3);
|
||||||
//For 1.54, 2.9 and 4.2
|
//Partial update support for 1.54, 2.13 RAK14000 b/w , 2.9 and 4.2
|
||||||
//adafruitDisplay->setRotation(1);
|
//adafruitDisplay->setRotation(1);
|
||||||
//adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight);
|
||||||
} else {
|
} else {
|
||||||
(void)adafruitDisplay;
|
(void)adafruitDisplay;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "mesh/Channels.h"
|
#include "mesh/Channels.h"
|
||||||
#include "mesh/generated/deviceonly.pb.h"
|
#include "mesh/generated/deviceonly.pb.h"
|
||||||
#include "modules/TextMessageModule.h"
|
#include "modules/TextMessageModule.h"
|
||||||
|
#include "modules/ExternalNotificationModule.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
#include "target_specific.h"
|
#include "target_specific.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@@ -42,6 +43,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "esp_task_wdt.h"
|
#include "esp_task_wdt.h"
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
|
#include "modules/esp32/StoreForwardModule.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OLED_RU
|
#ifdef OLED_RU
|
||||||
@@ -50,14 +52,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
using namespace meshtastic; /** @todo remove */
|
using namespace meshtastic; /** @todo remove */
|
||||||
|
|
||||||
extern bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct);
|
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
|
// This means the *visible* area (sh1106 can address 132, but shows 128 for example)
|
||||||
#define IDLE_FRAMERATE 1 // in fps
|
#define IDLE_FRAMERATE 1 // in fps
|
||||||
#define COMPASS_DIAM 44
|
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
#define NUM_EXTRA_FRAMES 3 // text message and debug frame
|
||||||
@@ -68,6 +67,8 @@ namespace graphics
|
|||||||
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
static FrameCallback normalFrames[MAX_NUM_NODES + NUM_EXTRA_FRAMES];
|
||||||
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
static uint32_t targetFramerate = IDLE_FRAMERATE;
|
||||||
static char btPIN[16] = "888888";
|
static char btPIN[16] = "888888";
|
||||||
|
|
||||||
|
uint32_t logo_timeout = 5000; // 4 seconds for EACH logo
|
||||||
|
|
||||||
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
// This image definition is here instead of images.h because it's modified dynamically by the drawBattery function
|
||||||
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
uint8_t imgBattery[16] = {0xFF, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xE7, 0x3C};
|
||||||
@@ -85,10 +86,6 @@ static char ourId[5];
|
|||||||
// GeoCoord object for the screen
|
// GeoCoord object for the screen
|
||||||
GeoCoord geoCoord;
|
GeoCoord geoCoord;
|
||||||
|
|
||||||
// OEM Config File
|
|
||||||
static const char *oemConfigFile = "/prefs/oem.proto";
|
|
||||||
OEMStore oemStore;
|
|
||||||
|
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
static bool heartbeat = false;
|
static bool heartbeat = false;
|
||||||
#endif
|
#endif
|
||||||
@@ -98,25 +95,26 @@ static uint16_t displayWidth, displayHeight;
|
|||||||
#define SCREEN_WIDTH displayWidth
|
#define SCREEN_WIDTH displayWidth
|
||||||
#define SCREEN_HEIGHT displayHeight
|
#define SCREEN_HEIGHT displayHeight
|
||||||
|
|
||||||
#if defined(USE_EINK) || defined(ILI9341_DRIVER)
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
// The screen is bigger so use bigger fonts
|
// The screen is bigger so use bigger fonts
|
||||||
#define FONT_SMALL ArialMT_Plain_16
|
#define FONT_SMALL ArialMT_Plain_16 // Height: 19
|
||||||
#define FONT_MEDIUM ArialMT_Plain_24
|
#define FONT_MEDIUM ArialMT_Plain_24 // Height: 28
|
||||||
#define FONT_LARGE ArialMT_Plain_24
|
#define FONT_LARGE ArialMT_Plain_24 // Height: 28
|
||||||
#else
|
#else
|
||||||
#ifdef OLED_RU
|
#ifdef OLED_RU
|
||||||
#define FONT_SMALL ArialMT_Plain_10_RU
|
#define FONT_SMALL ArialMT_Plain_10_RU
|
||||||
#else
|
#else
|
||||||
#define FONT_SMALL ArialMT_Plain_10
|
#define FONT_SMALL ArialMT_Plain_10 // Height: 13
|
||||||
#endif
|
#endif
|
||||||
#define FONT_MEDIUM ArialMT_Plain_16
|
#define FONT_MEDIUM ArialMT_Plain_16 // Height: 19
|
||||||
#define FONT_LARGE ArialMT_Plain_24
|
#define FONT_LARGE ArialMT_Plain_24 // Height: 28
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define fontHeight(font) ((font)[1] + 1) // height is position 1
|
#define fontHeight(font) ((font)[1] + 1) // height is position 1
|
||||||
|
|
||||||
#define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL)
|
#define FONT_HEIGHT_SMALL fontHeight(FONT_SMALL)
|
||||||
#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM)
|
#define FONT_HEIGHT_MEDIUM fontHeight(FONT_MEDIUM)
|
||||||
|
#define FONT_HEIGHT_LARGE fontHeight(FONT_LARGE)
|
||||||
|
|
||||||
#define getStringCenteredX(s) ((SCREEN_WIDTH - display->getStringWidth(s)) / 2)
|
#define getStringCenteredX(s) ((SCREEN_WIDTH - display->getStringWidth(s)) / 2)
|
||||||
|
|
||||||
@@ -287,27 +285,27 @@ static void drawModuleFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int
|
|||||||
|
|
||||||
static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawFrameBluetooth(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
|
int x_offset = display->width() / 2;
|
||||||
|
int y_offset = display->height() == 64 ? 0 : 32;
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->setFont(FONT_MEDIUM);
|
display->setFont(FONT_MEDIUM);
|
||||||
display->drawString(64 + x, y, "Bluetooth");
|
display->drawString(x_offset + x, y_offset + y, "Bluetooth");
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Enter this code");
|
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_MEDIUM -4 : y_offset + FONT_HEIGHT_MEDIUM + 5;
|
||||||
|
display->drawString(x_offset + x, y_offset + y, "Enter this code");
|
||||||
|
|
||||||
display->setFont(FONT_LARGE);
|
display->setFont(FONT_LARGE);
|
||||||
|
String displayPin(btPIN);
|
||||||
|
String pin = displayPin.substring(0, 3) + " " + displayPin.substring(3, 6);
|
||||||
|
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_SMALL - 5 : y_offset + FONT_HEIGHT_SMALL + 5;
|
||||||
|
display->drawString(x_offset + x, y_offset + y, pin);
|
||||||
|
|
||||||
auto displayPin = new String(btPIN);
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
display->drawString(12 + x, 26 + y, displayPin->substring(0, 3));
|
|
||||||
display->drawString(72 + x, 26 + y, displayPin->substring(3, 6));
|
|
||||||
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
char buf[30];
|
String deviceName = "Name: ";
|
||||||
const char *name = "Name: ";
|
deviceName.concat(getDeviceName());
|
||||||
strcpy(buf, name);
|
y_offset = display->height() == 64 ? y_offset + FONT_HEIGHT_LARGE - 6 : y_offset + FONT_HEIGHT_LARGE + 5;
|
||||||
strcat(buf, getDeviceName());
|
display->drawString(x_offset + x, y_offset + y, deviceName);
|
||||||
display->drawString(64 + x, 48 + y, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawFrameShutdown(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
static void drawFrameShutdown(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
@@ -333,11 +331,8 @@ static void drawFrameFirmware(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
display->drawString(64 + x, y, "Updating");
|
display->drawString(64 + x, y, "Updating");
|
||||||
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
if ((millis() / 1000) % 2) {
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . .");
|
display->drawStringMaxWidth(0 + x, 2 + y + FONT_HEIGHT_SMALL *2, x + display->getWidth(), "Please be patient and do not power off.");
|
||||||
} else {
|
|
||||||
display->drawString(64 + x, FONT_HEIGHT_SMALL + y + 2, "Please wait . . ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw the last text message we received
|
/// Draw the last text message we received
|
||||||
@@ -368,6 +363,9 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
|
|||||||
{
|
{
|
||||||
displayedNodeNum = 0; // Not currently showing a node pane
|
displayedNodeNum = 0; // Not currently showing a node pane
|
||||||
|
|
||||||
|
// the max length of this buffer is much longer than we can possibly print
|
||||||
|
static char tempBuf[237];
|
||||||
|
|
||||||
MeshPacket &mp = devicestate.rx_text_message;
|
MeshPacket &mp = devicestate.rx_text_message;
|
||||||
NodeInfo *node = nodeDB.getNode(getFrom(&mp));
|
NodeInfo *node = nodeDB.getNode(getFrom(&mp));
|
||||||
// DEBUG_MSG("drawing text message from 0x%x: %s\n", mp.from,
|
// DEBUG_MSG("drawing text message from 0x%x: %s\n", mp.from,
|
||||||
@@ -377,16 +375,14 @@ static void drawTextMessageFrame(OLEDDisplay *display, OLEDDisplayUiState *state
|
|||||||
// with the third parameter you can define the width after which words will
|
// with the third parameter you can define the width after which words will
|
||||||
// be wrapped. Currently only spaces and "-" are allowed for wrapping
|
// be wrapped. Currently only spaces and "-" are allowed for wrapping
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(FONT_MEDIUM);
|
|
||||||
String sender = (node && node->has_user) ? node->user.short_name : "???";
|
|
||||||
display->drawString(0 + x, 0 + y, sender);
|
|
||||||
display->setFont(FONT_SMALL);
|
display->setFont(FONT_SMALL);
|
||||||
|
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||||
// the max length of this buffer is much longer than we can possibly print
|
display->setColor(BLACK);
|
||||||
static char tempBuf[96];
|
display->drawStringf(0 + x, 0 + y, tempBuf, "From: %s", (node && node->has_user) ? node->user.short_name : "???");
|
||||||
snprintf(tempBuf, sizeof(tempBuf), " %s", mp.decoded.payload.bytes);
|
display->drawStringf(1 + x, 0 + y, tempBuf, "From: %s", (node && node->has_user) ? node->user.short_name : "???");
|
||||||
|
display->setColor(WHITE);
|
||||||
display->drawStringMaxWidth(4 + x, 10 + y, SCREEN_WIDTH - (6 + x), tempBuf);
|
snprintf(tempBuf, sizeof(tempBuf), "%s", mp.decoded.payload.bytes);
|
||||||
|
display->drawStringMaxWidth(0 + x, 0 + y + FONT_HEIGHT_SMALL, x + display->getWidth(), tempBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw a series of fields in a column, wrapping to multiple colums if needed
|
/// Draw a series of fields in a column, wrapping to multiple colums if needed
|
||||||
@@ -399,6 +395,10 @@ static void drawColumns(OLEDDisplay *display, int16_t x, int16_t y, const char *
|
|||||||
int xo = x, yo = y;
|
int xo = x, yo = y;
|
||||||
while (*f) {
|
while (*f) {
|
||||||
display->drawString(xo, yo, *f);
|
display->drawString(xo, yo, *f);
|
||||||
|
if (display->getColor() == BLACK)
|
||||||
|
display->drawString(xo + 1, yo, *f);
|
||||||
|
|
||||||
|
display->setColor(WHITE);
|
||||||
yo += FONT_HEIGHT_SMALL;
|
yo += FONT_HEIGHT_SMALL;
|
||||||
if (yo > SCREEN_HEIGHT - FONT_HEIGHT_SMALL) {
|
if (yo > SCREEN_HEIGHT - FONT_HEIGHT_SMALL) {
|
||||||
xo += SCREEN_WIDTH / 2;
|
xo += SCREEN_WIDTH / 2;
|
||||||
@@ -467,8 +467,13 @@ static void drawNodes(OLEDDisplay *display, int16_t x, int16_t y, NodeStatus *no
|
|||||||
{
|
{
|
||||||
char usersString[20];
|
char usersString[20];
|
||||||
sprintf(usersString, "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal());
|
sprintf(usersString, "%d/%d", nodeStatus->getNumOnline(), nodeStatus->getNumTotal());
|
||||||
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
|
display->drawFastImage(x, y + 3, 8, 8, imgUser);
|
||||||
|
#else
|
||||||
display->drawFastImage(x, y, 8, 8, imgUser);
|
display->drawFastImage(x, y, 8, 8, imgUser);
|
||||||
|
#endif
|
||||||
display->drawString(x + 10, y - 2, usersString);
|
display->drawString(x + 10, y - 2, usersString);
|
||||||
|
display->drawString(x + 11, y - 2, usersString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw GPS status summary
|
// Draw GPS status summary
|
||||||
@@ -477,15 +482,18 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus
|
|||||||
if (config.position.fixed_position) {
|
if (config.position.fixed_position) {
|
||||||
// GPS coordinates are currently fixed
|
// GPS coordinates are currently fixed
|
||||||
display->drawString(x - 1, y - 2, "Fixed GPS");
|
display->drawString(x - 1, y - 2, "Fixed GPS");
|
||||||
|
display->drawString(x, y - 2, "Fixed GPS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!gps->getIsConnected()) {
|
if (!gps->getIsConnected()) {
|
||||||
display->drawString(x, y - 2, "No GPS");
|
display->drawString(x, y - 2, "No GPS");
|
||||||
|
display->drawString(x + 1, y - 2, "No GPS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
display->drawFastImage(x, y, 6, 8, gps->getHasLock() ? imgPositionSolid : imgPositionEmpty);
|
display->drawFastImage(x, y, 6, 8, gps->getHasLock() ? imgPositionSolid : imgPositionEmpty);
|
||||||
if (!gps->getHasLock()) {
|
if (!gps->getHasLock()) {
|
||||||
display->drawString(x + 8, y - 2, "No sats");
|
display->drawString(x + 8, y - 2, "No sats");
|
||||||
|
display->drawString(x + 9, y - 2, "No sats");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
char satsString[3];
|
char satsString[3];
|
||||||
@@ -510,6 +518,23 @@ static void drawGPS(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Draw status when gps is disabled by PMU
|
||||||
|
static void drawGPSpowerstat(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
||||||
|
{
|
||||||
|
#ifdef HAS_PMU
|
||||||
|
String displayLine = "GPS disabled";
|
||||||
|
int16_t xPos = display->getStringWidth(displayLine);
|
||||||
|
|
||||||
|
if (!config.position.gps_enabled){
|
||||||
|
display->drawString(x + xPos, y, displayLine);
|
||||||
|
#ifdef GPS_POWER_TOGGLE
|
||||||
|
display->drawString(x + xPos, y - 2 + FONT_HEIGHT_SMALL, " by button");
|
||||||
|
#endif
|
||||||
|
//display->drawString(x + xPos, y + 2, displayLine);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GPSStatus *gps)
|
||||||
{
|
{
|
||||||
String displayLine = "";
|
String displayLine = "";
|
||||||
@@ -522,6 +547,8 @@ static void drawGPSAltitude(OLEDDisplay *display, int16_t x, int16_t y, const GP
|
|||||||
} else {
|
} else {
|
||||||
geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude()));
|
geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude()));
|
||||||
displayLine = "Altitude: " + String(geoCoord.getAltitude()) + "m";
|
displayLine = "Altitude: " + String(geoCoord.getAltitude()) + "m";
|
||||||
|
if (config.display.units == Config_DisplayConfig_DisplayUnits_IMPERIAL)
|
||||||
|
displayLine = "Altitude: " + String(geoCoord.getAltitude() * METERS_TO_FEET) + "ft";
|
||||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,21 +567,22 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
|
|||||||
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (gpsFormat != Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) {
|
geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude()));
|
||||||
|
|
||||||
|
if (gpsFormat != Config_DisplayConfig_GpsCoordinateFormat_DMS) {
|
||||||
char coordinateLine[22];
|
char coordinateLine[22];
|
||||||
geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude()));
|
if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_DEC) { // Decimal Degrees
|
||||||
if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec) { // Decimal Degrees
|
|
||||||
sprintf(coordinateLine, "%f %f", geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7);
|
sprintf(coordinateLine, "%f %f", geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7);
|
||||||
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatUTM) { // Universal Transverse Mercator
|
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_UTM) { // Universal Transverse Mercator
|
||||||
sprintf(coordinateLine, "%2i%1c %06u %07u", geoCoord.getUTMZone(), geoCoord.getUTMBand(),
|
sprintf(coordinateLine, "%2i%1c %06u %07u", geoCoord.getUTMZone(), geoCoord.getUTMBand(),
|
||||||
geoCoord.getUTMEasting(), geoCoord.getUTMNorthing());
|
geoCoord.getUTMEasting(), geoCoord.getUTMNorthing());
|
||||||
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatMGRS) { // Military Grid Reference System
|
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_MGRS) { // Military Grid Reference System
|
||||||
sprintf(coordinateLine, "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), geoCoord.getMGRSBand(),
|
sprintf(coordinateLine, "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), geoCoord.getMGRSBand(),
|
||||||
geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), geoCoord.getMGRSEasting(),
|
geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), geoCoord.getMGRSEasting(),
|
||||||
geoCoord.getMGRSNorthing());
|
geoCoord.getMGRSNorthing());
|
||||||
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOLC) { // Open Location Code
|
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OLC) { // Open Location Code
|
||||||
geoCoord.getOLCCode(coordinateLine);
|
geoCoord.getOLCCode(coordinateLine);
|
||||||
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR) { // Ordnance Survey Grid Reference
|
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OSGR) { // Ordnance Survey Grid Reference
|
||||||
if (geoCoord.getOSGRE100k() == 'I' || geoCoord.getOSGRN100k() == 'I') // OSGR is only valid around the UK region
|
if (geoCoord.getOSGRE100k() == 'I' || geoCoord.getOSGRN100k() == 'I') // OSGR is only valid around the UK region
|
||||||
sprintf(coordinateLine, "%s", "Out of Boundary");
|
sprintf(coordinateLine, "%s", "Out of Boundary");
|
||||||
else
|
else
|
||||||
@@ -666,6 +694,26 @@ static bool hasPosition(NodeInfo *n)
|
|||||||
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
return n->has_position && (n->position.latitude_i != 0 || n->position.longitude_i != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t getCompassDiam(OLEDDisplay *display)
|
||||||
|
{
|
||||||
|
uint16_t diam = 0;
|
||||||
|
// get the smaller of the 2 dimensions and subtract 20
|
||||||
|
if(display->getWidth() > (display->getHeight() - FONT_HEIGHT_SMALL)) {
|
||||||
|
diam = display->getHeight() - FONT_HEIGHT_SMALL;
|
||||||
|
// if 2/3 of the other size would be smaller, use that
|
||||||
|
if (diam > (display->getWidth() * 2 / 3)) {
|
||||||
|
diam = display->getWidth() * 2 / 3;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
diam = display->getWidth();
|
||||||
|
if (diam > ((display->getHeight() - FONT_HEIGHT_SMALL) * 2 / 3)) {
|
||||||
|
diam = (display->getHeight() - FONT_HEIGHT_SMALL) * 2 / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return diam - 20;
|
||||||
|
};
|
||||||
|
|
||||||
/// We will skip one node - the one for us, so we just blindly loop over all
|
/// We will skip one node - the one for us, so we just blindly loop over all
|
||||||
/// nodes
|
/// nodes
|
||||||
static size_t nodeIndex;
|
static size_t nodeIndex;
|
||||||
@@ -682,7 +730,7 @@ static void drawNodeHeading(OLEDDisplay *display, int16_t compassX, int16_t comp
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
arrowPoints[i]->rotate(headingRadian);
|
arrowPoints[i]->rotate(headingRadian);
|
||||||
arrowPoints[i]->scale(COMPASS_DIAM * 0.6);
|
arrowPoints[i]->scale(getCompassDiam(display) * 0.6);
|
||||||
arrowPoints[i]->translate(compassX, compassY);
|
arrowPoints[i]->translate(compassX, compassY);
|
||||||
}
|
}
|
||||||
drawLine(display, tip, tail);
|
drawLine(display, tip, tail);
|
||||||
@@ -704,7 +752,7 @@ static void drawCompassNorth(OLEDDisplay *display, int16_t compassX, int16_t com
|
|||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
// North on compass will be negative of heading
|
// North on compass will be negative of heading
|
||||||
rosePoints[i]->rotate(-myHeading);
|
rosePoints[i]->rotate(-myHeading);
|
||||||
rosePoints[i]->scale(COMPASS_DIAM);
|
rosePoints[i]->scale(getCompassDiam(display));
|
||||||
rosePoints[i]->translate(compassX, compassY);
|
rosePoints[i]->translate(compassX, compassY);
|
||||||
}
|
}
|
||||||
drawLine(display, N1, N3);
|
drawLine(display, N1, N3);
|
||||||
@@ -739,6 +787,8 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
// The coordinates define the left starting point of the text
|
// The coordinates define the left starting point of the text
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||||
|
|
||||||
const char *username = node->has_user ? node->user.long_name : "Unknown Name";
|
const char *username = node->has_user ? node->user.long_name : "Unknown Name";
|
||||||
|
|
||||||
static char signalStr[20];
|
static char signalStr[20];
|
||||||
@@ -769,7 +819,7 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
const char *fields[] = {username, distStr, signalStr, lastStr, NULL};
|
const char *fields[] = {username, distStr, signalStr, lastStr, NULL};
|
||||||
|
|
||||||
// coordinates for the center of the compass/circle
|
// coordinates for the center of the compass/circle
|
||||||
int16_t compassX = x + SCREEN_WIDTH - COMPASS_DIAM / 2 - 5, compassY = y + SCREEN_HEIGHT / 2;
|
int16_t compassX = x + SCREEN_WIDTH - getCompassDiam(display) / 2 - 5, compassY = y + FONT_HEIGHT_SMALL + (SCREEN_HEIGHT - FONT_HEIGHT_SMALL) / 2;
|
||||||
bool hasNodeHeading = false;
|
bool hasNodeHeading = false;
|
||||||
|
|
||||||
if (ourNode && hasPosition(ourNode)) {
|
if (ourNode && hasPosition(ourNode)) {
|
||||||
@@ -783,10 +833,18 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
Position &p = node->position;
|
Position &p = node->position;
|
||||||
float d =
|
float d =
|
||||||
GeoCoord::latLongToMeter(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
GeoCoord::latLongToMeter(DegD(p.latitude_i), DegD(p.longitude_i), DegD(op.latitude_i), DegD(op.longitude_i));
|
||||||
if (d < 2000)
|
|
||||||
snprintf(distStr, sizeof(distStr), "%.0f m", d);
|
if (config.display.units == Config_DisplayConfig_DisplayUnits_IMPERIAL) {
|
||||||
else
|
if (d < (2 * MILES_TO_FEET))
|
||||||
snprintf(distStr, sizeof(distStr), "%.1f km", d / 1000);
|
snprintf(distStr, sizeof(distStr), "%.0f ft", d * METERS_TO_FEET);
|
||||||
|
else
|
||||||
|
snprintf(distStr, sizeof(distStr), "%.1f mi", d * METERS_TO_FEET / MILES_TO_FEET);
|
||||||
|
} else {
|
||||||
|
if (d < 2000)
|
||||||
|
snprintf(distStr, sizeof(distStr), "%.0f m", d);
|
||||||
|
else
|
||||||
|
snprintf(distStr, sizeof(distStr), "%.1f km", d / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
float bearingToOther =
|
float bearingToOther =
|
||||||
GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
GeoCoord::bearing(DegD(op.latitude_i), DegD(op.longitude_i), DegD(p.latitude_i), DegD(p.longitude_i));
|
||||||
@@ -802,35 +860,13 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
|||||||
// Debug info for gps lock errors
|
// Debug info for gps lock errors
|
||||||
// DEBUG_MSG("ourNode %d, ourPos %d, theirPos %d\n", !!ourNode, ourNode && hasPosition(ourNode), hasPosition(node));
|
// DEBUG_MSG("ourNode %d, ourPos %d, theirPos %d\n", !!ourNode, ourNode && hasPosition(ourNode), hasPosition(node));
|
||||||
display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?");
|
display->drawString(compassX - FONT_HEIGHT_SMALL / 4, compassY - FONT_HEIGHT_SMALL / 2, "?");
|
||||||
display->drawCircle(compassX, compassY, COMPASS_DIAM / 2);
|
display->drawCircle(compassX, compassY, getCompassDiam(display) / 2);
|
||||||
|
|
||||||
|
display->setColor(BLACK);
|
||||||
// Must be after distStr is populated
|
// Must be after distStr is populated
|
||||||
drawColumns(display, x, y, fields);
|
drawColumns(display, x, y, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
void _screen_header()
|
|
||||||
{
|
|
||||||
if (!disp)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Message count
|
|
||||||
//snprintf(buffer, sizeof(buffer), "#%03d", ttn_get_count() % 1000);
|
|
||||||
//display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
//display->drawString(0, 2, buffer);
|
|
||||||
|
|
||||||
// Datetime
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
|
||||||
display->drawString(display->getWidth()/2, 2, gps.getTimeStr());
|
|
||||||
|
|
||||||
// Satellite count
|
|
||||||
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
|
||||||
char buffer[10];
|
|
||||||
display->drawString(display->getWidth() - SATELLITE_IMAGE_WIDTH - 4, 2, itoa(gps.satellites.value(), buffer, 10));
|
|
||||||
display->drawXbm(display->getWidth() - SATELLITE_IMAGE_WIDTH, 0, SATELLITE_IMAGE_WIDTH, SATELLITE_IMAGE_HEIGHT, SATELLITE_IMAGE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// #ifdef RAK4630
|
// #ifdef RAK4630
|
||||||
// Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl),
|
// Screen::Screen(uint8_t address, int sda, int scl) : OSThread("Screen"), cmdQueue(32), dispdev(address, sda, scl),
|
||||||
// dispdev_oled(address, sda, scl), ui(&dispdev)
|
// dispdev_oled(address, sda, scl), ui(&dispdev)
|
||||||
@@ -898,9 +934,6 @@ void Screen::setup()
|
|||||||
dispdev.setDetected(screen_model);
|
dispdev.setDetected(screen_model);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load OEM config from Proto file if existent
|
|
||||||
loadProto(oemConfigFile, OEMStore_size, sizeof(oemConfigFile), OEMStore_fields, &oemStore);
|
|
||||||
|
|
||||||
// Initialising the UI will init the display too.
|
// Initialising the UI will init the display too.
|
||||||
ui.init();
|
ui.init();
|
||||||
|
|
||||||
@@ -921,6 +954,9 @@ void Screen::setup()
|
|||||||
// Set the utf8 conversion function
|
// Set the utf8 conversion function
|
||||||
dispdev.setFontTableLookupFunction(customFontTableLookup);
|
dispdev.setFontTableLookupFunction(customFontTableLookup);
|
||||||
|
|
||||||
|
if (strlen(oemStore.oem_text) > 0)
|
||||||
|
logo_timeout *= 2;
|
||||||
|
|
||||||
// Add frames.
|
// Add frames.
|
||||||
static FrameCallback bootFrames[] = {drawBootScreen};
|
static FrameCallback bootFrames[] = {drawBootScreen};
|
||||||
static const int bootFrameCount = sizeof(bootFrames) / sizeof(bootFrames[0]);
|
static const int bootFrameCount = sizeof(bootFrames) / sizeof(bootFrames[0]);
|
||||||
@@ -936,8 +972,12 @@ void Screen::setup()
|
|||||||
|
|
||||||
#ifdef SCREEN_MIRROR
|
#ifdef SCREEN_MIRROR
|
||||||
dispdev.mirrorScreen();
|
dispdev.mirrorScreen();
|
||||||
#elif defined(SCREEN_FLIP_VERTICALLY)
|
#else
|
||||||
dispdev.flipScreenVertically();
|
// Standard behaviour is to FLIP the screen (needed on T-Beam). If this config item is set, unflip it, and thereby logically flip it.
|
||||||
|
// If you have a headache now, you're welcome.
|
||||||
|
if (!config.display.flip_screen) {
|
||||||
|
dispdev.flipScreenVertically();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get our hardware ID
|
// Get our hardware ID
|
||||||
@@ -985,32 +1025,34 @@ int32_t Screen::runOnce()
|
|||||||
return RUN_SAME;
|
return RUN_SAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show boot screen for first 5 seconds, then switch to normal operation.
|
// Show boot screen for first logo_timeout seconds, then switch to normal operation.
|
||||||
// serialSinceMsec adjusts for additional serial wait time during nRF52 bootup
|
// serialSinceMsec adjusts for additional serial wait time during nRF52 bootup
|
||||||
static bool showingBootScreen = true;
|
static bool showingBootScreen = true;
|
||||||
if (showingBootScreen && (millis() > (5000 + serialSinceMsec))) {
|
if (showingBootScreen && (millis() > (logo_timeout + serialSinceMsec))) {
|
||||||
DEBUG_MSG("Done with boot screen...\n");
|
DEBUG_MSG("Done with boot screen...\n");
|
||||||
stopBootScreen();
|
stopBootScreen();
|
||||||
showingBootScreen = false;
|
showingBootScreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have an OEM Boot screen, toggle after 2,5 seconds
|
// If we have an OEM Boot screen, toggle after logo_timeout seconds
|
||||||
if (strlen(oemStore.oem_text) > 0) {
|
if (strlen(oemStore.oem_text) > 0) {
|
||||||
static bool showingOEMBootScreen = true;
|
static bool showingOEMBootScreen = true;
|
||||||
if (showingOEMBootScreen && (millis() > (2500 + serialSinceMsec))) {
|
if (showingOEMBootScreen && (millis() > ((logo_timeout / 2) + serialSinceMsec))) {
|
||||||
DEBUG_MSG("Switch to OEM screen...\n");
|
DEBUG_MSG("Switch to OEM screen...\n");
|
||||||
// Change frames.
|
// Change frames.
|
||||||
static FrameCallback bootOEMFrames[] = {drawOEMBootScreen};
|
static FrameCallback bootOEMFrames[] = {drawOEMBootScreen};
|
||||||
static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]);
|
static const int bootOEMFrameCount = sizeof(bootOEMFrames) / sizeof(bootOEMFrames[0]);
|
||||||
ui.setFrames(bootOEMFrames, bootOEMFrameCount);
|
ui.setFrames(bootOEMFrames, bootOEMFrameCount);
|
||||||
ui.update();
|
ui.update();
|
||||||
|
#ifndef USE_EINK
|
||||||
ui.update();
|
ui.update();
|
||||||
|
#endif
|
||||||
showingOEMBootScreen = false;
|
showingOEMBootScreen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_WELCOME_UNSET
|
#ifndef DISABLE_WELCOME_UNSET
|
||||||
if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_Unset) {
|
if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_UNSET) {
|
||||||
setWelcomeFrames();
|
setWelcomeFrames();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1029,7 +1071,13 @@ int32_t Screen::runOnce()
|
|||||||
handleSetOn(false);
|
handleSetOn(false);
|
||||||
break;
|
break;
|
||||||
case Cmd::ON_PRESS:
|
case Cmd::ON_PRESS:
|
||||||
handleOnPress();
|
// If a nag notification is running, stop it
|
||||||
|
if (externalNotificationModule->nagCycleCutoff != UINT32_MAX) {
|
||||||
|
externalNotificationModule->stopNow();
|
||||||
|
} else {
|
||||||
|
// Don't advance the screen if we just wanted to switch off the nag notification
|
||||||
|
handleOnPress();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case Cmd::START_BLUETOOTH_PIN_SCREEN:
|
case Cmd::START_BLUETOOTH_PIN_SCREEN:
|
||||||
handleStartBluetoothPinScreen(cmd.bluetooth_pin);
|
handleStartBluetoothPinScreen(cmd.bluetooth_pin);
|
||||||
@@ -1071,7 +1119,6 @@ int32_t Screen::runOnce()
|
|||||||
// otherwise that breaks animations.
|
// otherwise that breaks animations.
|
||||||
if (targetFramerate != IDLE_FRAMERATE && ui.getUiState()->frameState == FIXED) {
|
if (targetFramerate != IDLE_FRAMERATE && ui.getUiState()->frameState == FIXED) {
|
||||||
// oldFrameState = ui.getUiState()->frameState;
|
// oldFrameState = ui.getUiState()->frameState;
|
||||||
DEBUG_MSG("Setting idle framerate\n");
|
|
||||||
targetFramerate = IDLE_FRAMERATE;
|
targetFramerate = IDLE_FRAMERATE;
|
||||||
|
|
||||||
ui.setTargetFPS(targetFramerate);
|
ui.setTargetFPS(targetFramerate);
|
||||||
@@ -1297,7 +1344,6 @@ void Screen::handleOnPress()
|
|||||||
// If we are in a transition, the press must have bounced, drop it.
|
// If we are in a transition, the press must have bounced, drop it.
|
||||||
if (ui.getUiState()->frameState == FIXED) {
|
if (ui.getUiState()->frameState == FIXED) {
|
||||||
ui.nextFrame();
|
ui.nextFrame();
|
||||||
DEBUG_MSG("Setting LastScreenTransition\n");
|
|
||||||
lastScreenTransition = millis();
|
lastScreenTransition = millis();
|
||||||
setFastFramerate();
|
setFastFramerate();
|
||||||
}
|
}
|
||||||
@@ -1309,8 +1355,6 @@ void Screen::handleOnPress()
|
|||||||
|
|
||||||
void Screen::setFastFramerate()
|
void Screen::setFastFramerate()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Setting fast framerate\n");
|
|
||||||
|
|
||||||
// We are about to start a transition so speed up fps
|
// We are about to start a transition so speed up fps
|
||||||
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
targetFramerate = SCREEN_TRANSITION_FRAMERATE;
|
||||||
|
|
||||||
@@ -1328,6 +1372,9 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
// The coordinates define the left starting point of the text
|
// The coordinates define the left starting point of the text
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
|
||||||
char channelStr[20];
|
char channelStr[20];
|
||||||
{
|
{
|
||||||
concurrency::LockGuard guard(&lock);
|
concurrency::LockGuard guard(&lock);
|
||||||
@@ -1337,18 +1384,54 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
|
|
||||||
// Display power status
|
// Display power status
|
||||||
if (powerStatus->getHasBattery())
|
if (powerStatus->getHasBattery())
|
||||||
drawBattery(display, x, y + 2, imgBattery, powerStatus);
|
drawBattery(display, x + 1, y + 3, imgBattery, powerStatus);
|
||||||
else if (powerStatus->knowsUSB())
|
else if (powerStatus->knowsUSB())
|
||||||
display->drawFastImage(x, y + 2, 16, 8, powerStatus->getHasUSB() ? imgUSB : imgPower);
|
display->drawFastImage(x + 1, y + 3, 16, 8, powerStatus->getHasUSB() ? imgUSB : imgPower);
|
||||||
// Display nodes status
|
// Display nodes status
|
||||||
drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 2, nodeStatus);
|
drawNodes(display, x + (SCREEN_WIDTH * 0.25), y + 3, nodeStatus);
|
||||||
// Display GPS status
|
// Display GPS status
|
||||||
drawGPS(display, x + (SCREEN_WIDTH * 0.63), y + 2, gpsStatus);
|
if (!config.position.gps_enabled){
|
||||||
|
int16_t yPos = y + 2;
|
||||||
|
#ifdef GPS_POWER_TOGGLE
|
||||||
|
yPos = (y + 10 + FONT_HEIGHT_SMALL);
|
||||||
|
#endif
|
||||||
|
drawGPSpowerstat(display, x, yPos, gpsStatus);
|
||||||
|
} else {
|
||||||
|
drawGPS(display, x + (SCREEN_WIDTH * 0.63), y + 2, gpsStatus);
|
||||||
|
drawGPS(display, x + (SCREEN_WIDTH * 0.63), y + 3, gpsStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
display->setColor(WHITE);
|
||||||
// Draw the channel name
|
// Draw the channel name
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr);
|
display->drawString(x, y + FONT_HEIGHT_SMALL, channelStr);
|
||||||
// Draw our hardware ID to assist with bluetooth pairing
|
// Draw our hardware ID to assist with bluetooth pairing. Either prefix with Info or S&F Logo
|
||||||
display->drawFastImage(x + SCREEN_WIDTH - (10) - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgInfo);
|
if (moduleConfig.store_forward.enabled) {
|
||||||
|
#ifdef ARCH_ESP32
|
||||||
|
if (millis() - storeForwardModule->lastHeartbeat > (storeForwardModule->heartbeatInterval * 1200)) { //no heartbeat, overlap a bit
|
||||||
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL1);
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, imgQuestionL2);
|
||||||
|
#else
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgQuestion);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 16, 8, imgSFL1);
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 18 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 16, 8, imgSFL2);
|
||||||
|
#else
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 13 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 11, 8, imgSF);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 3 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL1);
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 14 - display->getStringWidth(ourId), y + 11 + FONT_HEIGHT_SMALL, 12, 8, imgInfoL2);
|
||||||
|
#else
|
||||||
|
display->drawFastImage(x + SCREEN_WIDTH - 10 - display->getStringWidth(ourId), y + 2 + FONT_HEIGHT_SMALL, 8, 8, imgInfo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(ourId), y + FONT_HEIGHT_SMALL, ourId);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(ourId), y + FONT_HEIGHT_SMALL, ourId);
|
||||||
|
|
||||||
// Draw any log messages
|
// Draw any log messages
|
||||||
@@ -1366,8 +1449,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
|
|||||||
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
#if HAS_WIFI
|
#if HAS_WIFI
|
||||||
const char *wifiName = config.wifi.ssid;
|
const char *wifiName = config.network.wifi_ssid;
|
||||||
const char *wifiPsw = config.wifi.psk;
|
|
||||||
|
|
||||||
displayedNodeNum = 0; // Not currently showing a node pane
|
displayedNodeNum = 0; // Not currently showing a node pane
|
||||||
|
|
||||||
@@ -1376,19 +1458,24 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
// The coordinates define the left starting point of the text
|
// The coordinates define the left starting point of the text
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
if (isSoftAPForced()) {
|
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||||
display->drawString(x, y, String("WiFi: Software AP (Admin)"));
|
display->setColor(BLACK);
|
||||||
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
|
||||||
display->drawString(x, y, String("WiFi: Software AP"));
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
} else if (WiFi.status() != WL_CONNECTED) {
|
|
||||||
display->drawString(x, y, String("WiFi: Not Connected"));
|
display->drawString(x, y, String("WiFi: Not Connected"));
|
||||||
|
display->drawString(x + 1, y, String("WiFi: Not Connected"));
|
||||||
} else {
|
} else {
|
||||||
display->drawString(x, y, String("WiFi: Connected"));
|
display->drawString(x, y, String("WiFi: Connected"));
|
||||||
|
display->drawString(x + 1, y, String("WiFi: Connected"));
|
||||||
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("RSSI " + String(WiFi.RSSI())), y,
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("RSSI " + String(WiFi.RSSI())), y,
|
||||||
"RSSI " + String(WiFi.RSSI()));
|
"RSSI " + String(WiFi.RSSI()));
|
||||||
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("RSSI " + String(WiFi.RSSI())) - 1, y,
|
||||||
|
"RSSI " + String(WiFi.RSSI()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display->setColor(WHITE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
- WL_CONNECTED: assigned when connected to a WiFi network;
|
- WL_CONNECTED: assigned when connected to a WiFi network;
|
||||||
- WL_NO_SSID_AVAIL: assigned when no SSID are available;
|
- WL_NO_SSID_AVAIL: assigned when no SSID are available;
|
||||||
@@ -1401,25 +1488,14 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
- WL_NO_SHIELD: assigned when no WiFi shield is present;
|
- WL_NO_SHIELD: assigned when no WiFi shield is present;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) {
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.localIP().toString().c_str()));
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str()));
|
|
||||||
|
|
||||||
// Number of connections to the AP. Default max for the esp32 is 4
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth("(" + String(WiFi.softAPgetStationNum()) + "/4)"),
|
|
||||||
y + FONT_HEIGHT_SMALL * 1, "(" + String(WiFi.softAPgetStationNum()) + "/4)");
|
|
||||||
} else {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.localIP().toString().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (WiFi.status() == WL_NO_SSID_AVAIL) {
|
} else if (WiFi.status() == WL_NO_SSID_AVAIL) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "SSID Not Found");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "SSID Not Found");
|
||||||
} else if (WiFi.status() == WL_CONNECTION_LOST) {
|
} else if (WiFi.status() == WL_CONNECTION_LOST) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Lost");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Lost");
|
||||||
} else if (WiFi.status() == WL_CONNECT_FAILED) {
|
} else if (WiFi.status() == WL_CONNECT_FAILED) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Failed");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Connection Failed");
|
||||||
//} else if (WiFi.status() == WL_DISCONNECTED) {
|
|
||||||
// display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Disconnected");
|
|
||||||
} else if (WiFi.status() == WL_IDLE_STATUS) {
|
} else if (WiFi.status() == WL_IDLE_STATUS) {
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Idle ... Reconnecting");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "Idle ... Reconnecting");
|
||||||
} else {
|
} else {
|
||||||
@@ -1486,24 +1562,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSoftAPForced()) {
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
||||||
if ((millis() / 10000) % 2) {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: meshtasticAdmin");
|
|
||||||
} else {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: 12345678");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) {
|
|
||||||
if ((millis() / 10000) % 2) {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
|
||||||
} else {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "PWD: " + String(wifiPsw));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "http://meshtastic.local");
|
display->drawString(x, y + FONT_HEIGHT_SMALL * 3, "http://meshtastic.local");
|
||||||
|
|
||||||
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
||||||
@@ -1524,6 +1584,9 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
// The coordinates define the left starting point of the text
|
// The coordinates define the left starting point of the text
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
|
display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL);
|
||||||
|
display->setColor(BLACK);
|
||||||
|
|
||||||
char batStr[20];
|
char batStr[20];
|
||||||
if (powerStatus->getHasBattery()) {
|
if (powerStatus->getHasBattery()) {
|
||||||
int batV = powerStatus->getBatteryVoltageMv() / 1000;
|
int batV = powerStatus->getBatteryVoltageMv() / 1000;
|
||||||
@@ -1534,33 +1597,35 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
|
|
||||||
// Line 1
|
// Line 1
|
||||||
display->drawString(x, y, batStr);
|
display->drawString(x, y, batStr);
|
||||||
|
display->drawString(x + 1, y, batStr);
|
||||||
} else {
|
} else {
|
||||||
// Line 1
|
// Line 1
|
||||||
display->drawString(x, y, String("USB"));
|
display->drawString(x, y, String("USB"));
|
||||||
|
display->drawString(x + 1, y, String("USB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mode = "";
|
auto mode = "";
|
||||||
|
|
||||||
switch (config.lora.modem_preset) {
|
switch (config.lora.modem_preset) {
|
||||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
|
||||||
mode = "ShortS";
|
mode = "ShortS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_ShortFast:
|
case Config_LoRaConfig_ModemPreset_SHORT_FAST:
|
||||||
mode = "ShortF";
|
mode = "ShortF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MedSlow:
|
case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
|
||||||
mode = "MedS";
|
mode = "MedS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MedFast:
|
case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
|
||||||
mode = "MedF";
|
mode = "MedF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongSlow:
|
case Config_LoRaConfig_ModemPreset_LONG_SLOW:
|
||||||
mode = "LongS";
|
mode = "LongS";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongFast:
|
case Config_LoRaConfig_ModemPreset_LONG_FAST:
|
||||||
mode = "LongF";
|
mode = "LongF";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
|
||||||
mode = "VeryL";
|
mode = "VeryL";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1569,6 +1634,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode), y, mode);
|
||||||
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(mode) - 1, y, mode);
|
||||||
|
|
||||||
// Line 2
|
// Line 2
|
||||||
uint32_t currentMillis = millis();
|
uint32_t currentMillis = millis();
|
||||||
@@ -1581,6 +1647,8 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
// minutes %= 60;
|
// minutes %= 60;
|
||||||
// hours %= 24;
|
// hours %= 24;
|
||||||
|
|
||||||
|
display->setColor(WHITE);
|
||||||
|
|
||||||
// Show uptime as days, hours, minutes OR seconds
|
// Show uptime as days, hours, minutes OR seconds
|
||||||
String uptime;
|
String uptime;
|
||||||
if (days >= 2)
|
if (days >= 2)
|
||||||
@@ -1616,15 +1684,17 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
char chUtil[13];
|
char chUtil[13];
|
||||||
sprintf(chUtil, "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
sprintf(chUtil, "ChUtil %2.0f%%", airTime->channelUtilizationPercent());
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
||||||
|
if (config.position.gps_enabled) {
|
||||||
// Line 3
|
// Line 3
|
||||||
if (config.display.gps_format !=
|
if (config.display.gps_format !=
|
||||||
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude
|
Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude
|
||||||
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||||
|
|
||||||
// Line 4
|
// Line 4
|
||||||
drawGPScoordinates(display, x, y + FONT_HEIGHT_SMALL * 3, gpsStatus);
|
drawGPScoordinates(display, x, y + FONT_HEIGHT_SMALL * 3, gpsStatus);
|
||||||
|
} else {
|
||||||
|
drawGPSpowerstat(display, x - (SCREEN_WIDTH / 4), y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||||
|
}
|
||||||
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
/* Display a heartbeat pixel that blinks every time the frame is redrawn */
|
||||||
#ifdef SHOW_REDRAWS
|
#ifdef SHOW_REDRAWS
|
||||||
if (heartbeat)
|
if (heartbeat)
|
||||||
@@ -1635,6 +1705,9 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
|||||||
// adjust Brightness cycle trough 1 to 254 as long as attachDuringLongPress is true
|
// adjust Brightness cycle trough 1 to 254 as long as attachDuringLongPress is true
|
||||||
void Screen::adjustBrightness()
|
void Screen::adjustBrightness()
|
||||||
{
|
{
|
||||||
|
if (!useDisplay)
|
||||||
|
return;
|
||||||
|
|
||||||
if (brightness == 254) {
|
if (brightness == 254) {
|
||||||
brightness = 0;
|
brightness = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace graphics
|
|||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Screen(char){}
|
explicit Screen(char){}
|
||||||
void onPress() {}
|
void onPress() {}
|
||||||
void setup() {}
|
void setup() {}
|
||||||
void setOn(bool) {}
|
void setOn(bool) {}
|
||||||
@@ -21,6 +21,7 @@ class Screen
|
|||||||
void startBluetoothPinScreen(uint32_t pin) {}
|
void startBluetoothPinScreen(uint32_t pin) {}
|
||||||
void stopBluetoothPinScreen() {}
|
void stopBluetoothPinScreen() {}
|
||||||
void startRebootScreen() {}
|
void startRebootScreen() {}
|
||||||
|
void startFirmwareUpdateScreen() {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +58,16 @@ class Screen
|
|||||||
#define BRIGHTNESS_DEFAULT 150
|
#define BRIGHTNESS_DEFAULT 150
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Meters to feet conversion
|
||||||
|
#ifndef METERS_TO_FEET
|
||||||
|
#define METERS_TO_FEET 3.28
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Feet to miles conversion
|
||||||
|
#ifndef MILES_TO_FEET
|
||||||
|
#define MILES_TO_FEET 5280
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace graphics
|
namespace graphics
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -121,8 +132,7 @@ class Screen : public concurrency::OSThread
|
|||||||
void setOn(bool on)
|
void setOn(bool on)
|
||||||
{
|
{
|
||||||
if (!on)
|
if (!on)
|
||||||
handleSetOn(
|
handleSetOn(false); // We handle off commands immediately, because they might be called because the CPU is shutting down
|
||||||
false); // We handle off commands immediately, because they might be called because the CPU is shutting down
|
|
||||||
else
|
else
|
||||||
enqueueCmd(ScreenCmd{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF});
|
enqueueCmd(ScreenCmd{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF});
|
||||||
}
|
}
|
||||||
@@ -213,27 +223,29 @@ class Screen : public concurrency::OSThread
|
|||||||
LASTCHAR = ch;
|
LASTCHAR = ch;
|
||||||
|
|
||||||
switch (last) { // conversion depending on first UTF8-character
|
switch (last) { // conversion depending on first UTF8-character
|
||||||
case 0xC2: {
|
case 0xC2: {
|
||||||
SKIPREST = false;
|
SKIPREST = false;
|
||||||
return (uint8_t)ch;
|
return (uint8_t)ch;
|
||||||
}
|
}
|
||||||
case 0xC3: {
|
case 0xC3: {
|
||||||
SKIPREST = false;
|
SKIPREST = false;
|
||||||
return (uint8_t)(ch | 0xC0);
|
return (uint8_t)(ch | 0xC0);
|
||||||
}
|
}
|
||||||
// map UTF-8 cyrillic chars to it Windows-1251 (CP-1251) ASCII codes
|
// map UTF-8 cyrillic chars to it Windows-1251 (CP-1251) ASCII codes
|
||||||
// note: in this case we must use compatible font - provided ArialMT_Plain_10/16/24 by 'ThingPulse/esp8266-oled-ssd1306' library
|
// note: in this case we must use compatible font - provided ArialMT_Plain_10/16/24 by 'ThingPulse/esp8266-oled-ssd1306' library
|
||||||
// have empty chars for non-latin ASCII symbols
|
// have empty chars for non-latin ASCII symbols
|
||||||
case 0xD0: {
|
case 0xD0: {
|
||||||
SKIPREST = false;
|
SKIPREST = false;
|
||||||
if (ch == 129) return (uint8_t)(168); // Ё
|
if (ch == 129) return (uint8_t)(168); // Ё
|
||||||
if (ch > 143 && ch < 192) return (uint8_t)(ch + 48);
|
if (ch > 143 && ch < 192) return (uint8_t)(ch + 48);
|
||||||
}
|
break;
|
||||||
case 0xD1: {
|
}
|
||||||
SKIPREST = false;
|
case 0xD1: {
|
||||||
if (ch == 145) return (uint8_t)(184); // ё
|
SKIPREST = false;
|
||||||
if (ch > 127 && ch < 144) return (uint8_t)(ch + 112);
|
if (ch == 145) return (uint8_t)(184); // ё
|
||||||
}
|
if (ch > 127 && ch < 144) return (uint8_t)(ch + 112);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want to strip out prefix chars for two-byte char formats
|
// We want to strip out prefix chars for two-byte char formats
|
||||||
|
|||||||
@@ -22,13 +22,23 @@ void TFTDisplay::display(void)
|
|||||||
{
|
{
|
||||||
concurrency::LockGuard g(spiLock);
|
concurrency::LockGuard g(spiLock);
|
||||||
|
|
||||||
// FIXME - only draw bits have changed (use backbuf similar to the other displays)
|
uint16_t x,y;
|
||||||
// tft.drawBitmap(0, 0, buffer, 128, 64, TFT_YELLOW, TFT_BLACK);
|
|
||||||
for (uint16_t y = 0; y < displayHeight; y++) {
|
for (y = 0; y < displayHeight; y++) {
|
||||||
for (uint16_t x = 0; x < displayWidth; x++) {
|
for (x = 0; x < displayWidth; x++) {
|
||||||
// get src pixel in the page based ordering the OLED lib uses FIXME, super inefficent
|
// get src pixel in the page based ordering the OLED lib uses FIXME, super inefficent
|
||||||
auto isset = buffer[x + (y / 8) * displayWidth] & (1 << (y & 7));
|
auto isset = buffer[x + (y / 8) * displayWidth] & (1 << (y & 7));
|
||||||
tft.drawPixel(x, y, isset ? TFT_WHITE : TFT_BLACK);
|
auto dblbuf_isset = buffer_back[x + (y / 8) * displayWidth] & (1 << (y & 7));
|
||||||
|
if (isset != dblbuf_isset) {
|
||||||
|
tft.drawPixel(x, y, isset ? TFT_WHITE : TFT_BLACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Copy the Buffer to the Back Buffer
|
||||||
|
for (y = 0; y < (displayHeight / 8); y++) {
|
||||||
|
for (x = 0; x < displayWidth; x++) {
|
||||||
|
uint16_t pos = x + y * displayWidth;
|
||||||
|
buffer_back[pos] = buffer[pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,36 +12,18 @@ const uint8_t imgPower[] PROGMEM = { 0x40, 0x40, 0x40, 0x58, 0x48, 0x08,
|
|||||||
const uint8_t imgUser[] PROGMEM = { 0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3C };
|
const uint8_t imgUser[] PROGMEM = { 0x3C, 0x42, 0x99, 0xA5, 0xA5, 0x99, 0x42, 0x3C };
|
||||||
const uint8_t imgPositionEmpty[] PROGMEM = { 0x20, 0x30, 0x28, 0x24, 0x42, 0xFF };
|
const uint8_t imgPositionEmpty[] PROGMEM = { 0x20, 0x30, 0x28, 0x24, 0x42, 0xFF };
|
||||||
const uint8_t imgPositionSolid[] PROGMEM = { 0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF };
|
const uint8_t imgPositionSolid[] PROGMEM = { 0x20, 0x30, 0x38, 0x3C, 0x7E, 0xFF };
|
||||||
const uint8_t imgInfo[] PROGMEM = { 0xFF, 0x81, 0x81, 0xB5, 0xB5, 0x81, 0x81, 0xFF };
|
|
||||||
|
|
||||||
#include "img/icon.xbm"
|
#if defined(USE_EINK) || defined(ILI9341_DRIVER) || defined(ST7735_CS)
|
||||||
|
const uint8_t imgQuestionL1[] PROGMEM = { 0xff, 0x01, 0x01, 0x32, 0x7b, 0x49, 0x49, 0x6f, 0x26, 0x01, 0x01, 0xff };
|
||||||
// We now programmatically draw our compass
|
const uint8_t imgQuestionL2[] PROGMEM = { 0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f };
|
||||||
#if 0
|
const uint8_t imgInfoL1[] PROGMEM = { 0xff, 0x01, 0x01, 0x01, 0x1e, 0x7f, 0x1e, 0x01, 0x01, 0x01, 0x01, 0xff };
|
||||||
const
|
const uint8_t imgInfoL2[] PROGMEM = { 0x0f, 0x08, 0x08, 0x08, 0x06, 0x0f, 0x0f, 0x06, 0x08, 0x08, 0x08, 0x0f };
|
||||||
#include "img/compass.xbm"
|
const uint8_t imgSFL1[] PROGMEM = { 0xb6, 0x8f, 0x19, 0x11, 0x31, 0xe3, 0xc2, 0x01, 0x01, 0xf9, 0xf9, 0x89, 0x89, 0x89, 0x09, 0xeb};
|
||||||
|
const uint8_t imgSFL2[] PROGMEM = { 0x0e, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x00, 0x0f, 0x0f, 0x00, 0x08, 0x08, 0x08, 0x0f};
|
||||||
|
#else
|
||||||
|
const uint8_t imgInfo[] PROGMEM = { 0xff, 0x81, 0x00, 0xfb, 0xfb, 0x00, 0x81, 0xff };
|
||||||
|
const uint8_t imgQuestion[] PROGMEM = { 0xbf, 0x41, 0xc0, 0x8b, 0xdb, 0x70, 0xa1, 0xdf };
|
||||||
|
const uint8_t imgSF[] PROGMEM = { 0xd2, 0xb7, 0xad, 0xbb, 0x92, 0x01, 0xfd, 0xfd, 0x15, 0x85, 0xf5};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#include "img/icon.xbm"
|
||||||
const uint8_t activeSymbol[] PROGMEM = {
|
|
||||||
B00000000,
|
|
||||||
B00000000,
|
|
||||||
B00011000,
|
|
||||||
B00100100,
|
|
||||||
B01000010,
|
|
||||||
B01000010,
|
|
||||||
B00100100,
|
|
||||||
B00011000
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t inactiveSymbol[] PROGMEM = {
|
|
||||||
B00000000,
|
|
||||||
B00000000,
|
|
||||||
B00000000,
|
|
||||||
B00000000,
|
|
||||||
B00011000,
|
|
||||||
B00011000,
|
|
||||||
B00000000,
|
|
||||||
B00000000
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
#define compass_width 48
|
|
||||||
#define compass_height 48
|
|
||||||
static char compass_bits[] = {
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x01, 0x00,
|
|
||||||
0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x0F, 0x00,
|
|
||||||
0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0xFC, 0x07, 0xE0, 0x3F, 0x00,
|
|
||||||
0x00, 0xFE, 0x01, 0x80, 0x7F, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x7F, 0x00,
|
|
||||||
0x00, 0x7F, 0x00, 0x00, 0xFE, 0x00, 0x80, 0x3F, 0x00, 0x00, 0xFC, 0x01,
|
|
||||||
0x80, 0x1F, 0x00, 0x00, 0xF8, 0x01, 0x80, 0x0F, 0x00, 0x00, 0xF0, 0x01,
|
|
||||||
0xC0, 0x0F, 0x00, 0x00, 0xF0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03,
|
|
||||||
0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03,
|
|
||||||
0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F,
|
|
||||||
0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F, 0xFC, 0x07, 0x00, 0x00, 0xE0, 0x3F,
|
|
||||||
0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03,
|
|
||||||
0xC0, 0x07, 0x00, 0x00, 0xE0, 0x03, 0xC0, 0x0F, 0x00, 0x00, 0xF0, 0x03,
|
|
||||||
0x80, 0x0F, 0x00, 0x00, 0xF0, 0x01, 0x80, 0x1F, 0x00, 0x00, 0xF8, 0x01,
|
|
||||||
0x80, 0x3F, 0x00, 0x00, 0xFC, 0x01, 0x00, 0x7F, 0x00, 0x00, 0xFE, 0x00,
|
|
||||||
0x00, 0xFE, 0x00, 0x00, 0x7F, 0x00, 0x00, 0xFE, 0x01, 0x80, 0x7F, 0x00,
|
|
||||||
0x00, 0xFC, 0x07, 0xE0, 0x3F, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00,
|
|
||||||
0x00, 0xF0, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x03, 0x00,
|
|
||||||
0x00, 0x80, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0xFC, 0x3F, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0xC0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
};
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#define pin_width 13
|
|
||||||
#define pin_height 13
|
|
||||||
static char pin_bits[] = {
|
|
||||||
0x00, 0x00, 0xF0, 0x01, 0xF8, 0x03, 0xFC, 0x07, 0xBC, 0x07, 0xBC, 0x07,
|
|
||||||
0xFC, 0x07, 0xF8, 0x03, 0xF8, 0x03, 0xF0, 0x01, 0xE0, 0x00, 0xE0, 0x00,
|
|
||||||
0x00, 0x00, };
|
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
|
|
||||||
|
#define ANYKEY 0xFF
|
||||||
|
#define MATRIXKEY 0xFE
|
||||||
|
|
||||||
typedef struct _InputEvent {
|
typedef struct _InputEvent {
|
||||||
const char* source;
|
const char* source;
|
||||||
char inputEvent;
|
char inputEvent;
|
||||||
|
char kbchar;
|
||||||
} InputEvent;
|
} InputEvent;
|
||||||
class InputBroker :
|
class InputBroker :
|
||||||
public Observable<const InputEvent *>
|
public Observable<const InputEvent *>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void RotaryEncoderInterruptBase::init(
|
|||||||
int32_t RotaryEncoderInterruptBase::runOnce()
|
int32_t RotaryEncoderInterruptBase::runOnce()
|
||||||
{
|
{
|
||||||
InputEvent e;
|
InputEvent e;
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
e.source = this->_originName;
|
e.source = this->_originName;
|
||||||
|
|
||||||
if (this->action == ROTARY_ACTION_PRESSED) {
|
if (this->action == ROTARY_ACTION_PRESSED) {
|
||||||
@@ -48,7 +48,7 @@ int32_t RotaryEncoderInterruptBase::runOnce()
|
|||||||
e.inputEvent = this->_eventCcw;
|
e.inputEvent = this->_eventCcw;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE) {
|
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
|
||||||
this->notifyObservers(&e);
|
this->notifyObservers(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ class RotaryEncoderInterruptBase : public Observable<const InputEvent *>, privat
|
|||||||
private:
|
private:
|
||||||
uint8_t _pinA = 0;
|
uint8_t _pinA = 0;
|
||||||
uint8_t _pinB = 0;
|
uint8_t _pinB = 0;
|
||||||
char _eventCw = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventCw = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
char _eventCcw = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventCcw = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
const char *_originName;
|
const char *_originName;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class UpDownInterruptBase : public Observable<const InputEvent *>
|
|||||||
private:
|
private:
|
||||||
uint8_t _pinDown = 0;
|
uint8_t _pinDown = 0;
|
||||||
uint8_t _pinUp = 0;
|
uint8_t _pinUp = 0;
|
||||||
char _eventDown = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventDown = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
char _eventUp = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventUp = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
const char *_originName;
|
const char *_originName;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ void UpDownInterruptImpl1::init()
|
|||||||
uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b;
|
uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b;
|
||||||
uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
|
uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
|
||||||
|
|
||||||
char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN);
|
char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_DOWN);
|
||||||
char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP);
|
char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_UP);
|
||||||
char eventPressed = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT);
|
char eventPressed = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_SELECT);
|
||||||
|
|
||||||
UpDownInterruptBase::init(pinDown, pinUp, pinPress, eventDown, eventUp, eventPressed, UpDownInterruptImpl1::handleIntDown,
|
UpDownInterruptBase::init(pinDown, pinUp, pinPress, eventDown, eventUp, eventPressed, UpDownInterruptImpl1::handleIntDown,
|
||||||
UpDownInterruptImpl1::handleIntUp, UpDownInterruptImpl1::handleIntPressed);
|
UpDownInterruptImpl1::handleIntUp, UpDownInterruptImpl1::handleIntPressed);
|
||||||
|
|||||||
@@ -16,6 +16,5 @@ void CardKbI2cImpl::init()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_MSG("registerSource\n");
|
|
||||||
inputBroker->registerSource(this);
|
inputBroker->registerSource(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
#include "facesKbI2cImpl.h"
|
|
||||||
#include "InputBroker.h"
|
|
||||||
|
|
||||||
FacesKbI2cImpl *facesKbI2cImpl;
|
|
||||||
|
|
||||||
FacesKbI2cImpl::FacesKbI2cImpl() :
|
|
||||||
KbI2cBase("facesKB")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FacesKbI2cImpl::init()
|
|
||||||
{
|
|
||||||
if (faceskb_found != FACESKB_ADDR)
|
|
||||||
{
|
|
||||||
// Input device is not detected.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputBroker->registerSource(this);
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "kbI2cBase.h"
|
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The idea behind this class to have static methods for the event handlers.
|
|
||||||
* Check attachInterrupt() at RotaryEncoderInteruptBase.cpp
|
|
||||||
* Technically you can have as many rotary encoders hardver attached
|
|
||||||
* to your device as you wish, but you always need to have separate event
|
|
||||||
* handlers, thus you need to have a RotaryEncoderInterrupt implementation.
|
|
||||||
*/
|
|
||||||
class FacesKbI2cImpl :
|
|
||||||
public KbI2cBase
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FacesKbI2cImpl();
|
|
||||||
void init();
|
|
||||||
};
|
|
||||||
|
|
||||||
extern FacesKbI2cImpl *facesKbI2cImpl;
|
|
||||||
@@ -2,48 +2,114 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
extern uint8_t cardkb_found;
|
||||||
|
extern uint8_t kb_model;
|
||||||
|
|
||||||
KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
|
||||||
{
|
{
|
||||||
this->_originName = name;
|
this->_originName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t read_from_14004(uint8_t reg, uint8_t *data, uint8_t length)
|
||||||
|
{
|
||||||
|
uint8_t readflag = 0;
|
||||||
|
Wire.beginTransmission(CARDKB_ADDR);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
delay(20);
|
||||||
|
Wire.requestFrom(CARDKB_ADDR, (int)length);
|
||||||
|
int i = 0;
|
||||||
|
while ( Wire.available() ) // slave may send less than requested
|
||||||
|
{
|
||||||
|
data[i++] = Wire.read(); // receive a byte as a proper uint8_t
|
||||||
|
readflag = 1;
|
||||||
|
}
|
||||||
|
return readflag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_to_14004(uint8_t reg, uint8_t data)
|
||||||
|
{
|
||||||
|
Wire.beginTransmission(CARDKB_ADDR);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.write(data);
|
||||||
|
Wire.endTransmission(); // stop transmitting
|
||||||
|
}
|
||||||
|
|
||||||
int32_t KbI2cBase::runOnce()
|
int32_t KbI2cBase::runOnce()
|
||||||
{
|
{
|
||||||
InputEvent e;
|
if (cardkb_found != CARDKB_ADDR){
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE;
|
// Input device is not detected.
|
||||||
e.source = this->_originName;
|
return INT32_MAX;
|
||||||
|
|
||||||
Wire.requestFrom(CARDKB_ADDR, 1);
|
|
||||||
|
|
||||||
while (Wire.available()) {
|
|
||||||
char c = Wire.read();
|
|
||||||
switch (c) {
|
|
||||||
case 0x1b: // ESC
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_CANCEL;
|
|
||||||
break;
|
|
||||||
case 0x08: // Back
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_BACK;
|
|
||||||
break;
|
|
||||||
case 0xb5: // Up
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP;
|
|
||||||
break;
|
|
||||||
case 0xb6: // Down
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN;
|
|
||||||
break;
|
|
||||||
case 0xb4: // Left
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_LEFT;
|
|
||||||
break;
|
|
||||||
case 0xb7: // Right
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_RIGHT;
|
|
||||||
break;
|
|
||||||
case 0x0d: // Enter
|
|
||||||
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE) {
|
if (kb_model == 0x02) {
|
||||||
this->notifyObservers(&e);
|
// RAK14004
|
||||||
|
uint8_t rDataBuf[8] = {0};
|
||||||
|
uint8_t PrintDataBuf = 0;
|
||||||
|
if (read_from_14004(0x01, rDataBuf, 0x04) == 1) {
|
||||||
|
for (uint8_t aCount = 0; aCount < 0x04; aCount++) {
|
||||||
|
for (uint8_t bCount = 0; bCount < 0x04; bCount++ ) {
|
||||||
|
if (((rDataBuf[aCount] >> bCount) & 0x01) == 0x01) {
|
||||||
|
PrintDataBuf = aCount * 0x04 + bCount + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PrintDataBuf != 0) {
|
||||||
|
DEBUG_MSG("RAK14004 key 0x%x pressed\n", PrintDataBuf);
|
||||||
|
InputEvent e;
|
||||||
|
e.inputEvent = MATRIXKEY;
|
||||||
|
e.source = this->_originName;
|
||||||
|
e.kbchar = PrintDataBuf;
|
||||||
|
this->notifyObservers(&e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// m5 cardkb
|
||||||
|
Wire.requestFrom(CARDKB_ADDR, 1);
|
||||||
|
|
||||||
|
while (Wire.available()) {
|
||||||
|
char c = Wire.read();
|
||||||
|
InputEvent e;
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
|
e.source = this->_originName;
|
||||||
|
switch (c) {
|
||||||
|
case 0x1b: // ESC
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
|
||||||
|
break;
|
||||||
|
case 0x08: // Back
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
|
||||||
|
e.kbchar = c;
|
||||||
|
break;
|
||||||
|
case 0xb5: // Up
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_UP;
|
||||||
|
break;
|
||||||
|
case 0xb6: // Down
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
|
||||||
|
break;
|
||||||
|
case 0xb4: // Left
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
|
||||||
|
e.kbchar = c;
|
||||||
|
break;
|
||||||
|
case 0xb7: // Right
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
|
||||||
|
e.kbchar = c;
|
||||||
|
break;
|
||||||
|
case 0x0d: // Enter
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
|
||||||
|
break;
|
||||||
|
case 0x00: //nopress
|
||||||
|
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
|
||||||
|
break;
|
||||||
|
default: // all other keys
|
||||||
|
e.inputEvent = ANYKEY;
|
||||||
|
e.kbchar = c;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
|
||||||
|
this->notifyObservers(&e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 500;
|
return 500;
|
||||||
}
|
}
|
||||||
|
|||||||
133
src/main.cpp
133
src/main.cpp
@@ -8,8 +8,6 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
// #include "rom/rtc.h"
|
|
||||||
//#include "DSRRouter.h"
|
|
||||||
#include "ReliableRouter.h"
|
#include "ReliableRouter.h"
|
||||||
// #include "debug.h"
|
// #include "debug.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
@@ -30,6 +28,7 @@
|
|||||||
// #include <driver/rtc_io.h>
|
// #include <driver/rtc_io.h>
|
||||||
|
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
|
#include "mesh/eth/ethClient.h"
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
@@ -41,10 +40,19 @@
|
|||||||
#include "mqtt/MQTT.h"
|
#include "mqtt/MQTT.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAS_ETHERNET
|
||||||
|
#include "mesh/eth/ethServerAPI.h"
|
||||||
|
#include "mqtt/MQTT.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LLCC68Interface.h"
|
#include "LLCC68Interface.h"
|
||||||
#include "RF95Interface.h"
|
#include "RF95Interface.h"
|
||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
#include "SX1268Interface.h"
|
#include "SX1268Interface.h"
|
||||||
|
#include "SX1280Interface.h"
|
||||||
|
#if !HAS_RADIO && defined(ARCH_PORTDUINO)
|
||||||
|
#include "platform/portduino/SimRadio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_BUTTON
|
#if HAS_BUTTON
|
||||||
#include "ButtonThread.h"
|
#include "ButtonThread.h"
|
||||||
@@ -74,20 +82,23 @@ uint8_t cardkb_found;
|
|||||||
// 0x02 for RAK14004 and 0x00 for cardkb
|
// 0x02 for RAK14004 and 0x00 for cardkb
|
||||||
uint8_t kb_model;
|
uint8_t kb_model;
|
||||||
|
|
||||||
// The I2C address of the Faces Keyboard (if found)
|
|
||||||
uint8_t faceskb_found;
|
|
||||||
|
|
||||||
// The I2C address of the RTC Module (if found)
|
// The I2C address of the RTC Module (if found)
|
||||||
uint8_t rtc_found;
|
uint8_t rtc_found;
|
||||||
|
|
||||||
|
// Keystore Chips
|
||||||
|
uint8_t keystore_found;
|
||||||
|
#ifndef ARCH_PORTDUINO
|
||||||
|
ATECCX08A atecc;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool eink_found = true;
|
bool eink_found = true;
|
||||||
|
|
||||||
uint32_t serialSinceMsec;
|
uint32_t serialSinceMsec;
|
||||||
|
|
||||||
bool axp192_found;
|
bool pmu_found;
|
||||||
|
|
||||||
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
|
// Array map of sensor types (as array index) and i2c address as value we'll find in the i2c scan
|
||||||
uint8_t nodeTelemetrySensorsMap[7] = { 0, 0, 0, 0, 0, 0, 0 };
|
uint8_t nodeTelemetrySensorsMap[_TelemetrySensorType_MAX + 1] = { 0 }; // one is enough, missing elements will be initialized to 0 anyway.
|
||||||
|
|
||||||
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
Router *router = NULL; // Users of router don't care what sort of subclass implements that API
|
||||||
|
|
||||||
@@ -127,8 +138,9 @@ bool ButtonThread::shutdown_on_long_stop = false;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Periodic *ledPeriodic;
|
static Periodic *ledPeriodic;
|
||||||
static OSThread *powerFSMthread, *buttonThread;
|
static OSThread *powerFSMthread;
|
||||||
#if HAS_BUTTON
|
#if HAS_BUTTON
|
||||||
|
static OSThread *buttonThread;
|
||||||
uint32_t ButtonThread::longPressTime = 0;
|
uint32_t ButtonThread::longPressTime = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -157,9 +169,7 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_PORT
|
#ifdef DEBUG_PORT
|
||||||
if (!config.device.serial_disabled) {
|
|
||||||
consoleInit(); // Set serial baud rate and init our mesh console
|
consoleInit(); // Set serial baud rate and init our mesh console
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
serialSinceMsec = millis();
|
serialSinceMsec = millis();
|
||||||
@@ -184,8 +194,6 @@ void setup()
|
|||||||
digitalWrite(RESET_OLED, 1);
|
digitalWrite(RESET_OLED, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool forceSoftAP = 0;
|
|
||||||
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
||||||
@@ -198,12 +206,6 @@ void setup()
|
|||||||
delay(10);
|
delay(10);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BUTTON_PIN is pulled high by a 12k resistor.
|
|
||||||
if (!digitalRead(BUTTON_PIN)) {
|
|
||||||
forceSoftAP = 1;
|
|
||||||
DEBUG_MSG("Setting forceSoftAP = 1\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -213,9 +215,12 @@ void setup()
|
|||||||
|
|
||||||
fsInit();
|
fsInit();
|
||||||
|
|
||||||
// router = new DSRRouter();
|
|
||||||
router = new ReliableRouter();
|
router = new ReliableRouter();
|
||||||
|
|
||||||
|
#ifdef I2C_SDA1
|
||||||
|
Wire1.begin(I2C_SDA1, I2C_SCL1);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef I2C_SDA
|
#ifdef I2C_SDA
|
||||||
Wire.begin(I2C_SDA, I2C_SCL);
|
Wire.begin(I2C_SDA, I2C_SCL);
|
||||||
#elif HAS_WIRE
|
#elif HAS_WIRE
|
||||||
@@ -231,7 +236,37 @@ void setup()
|
|||||||
delay(1);
|
delay(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef RAK4630
|
||||||
|
// We need to enable 3.3V periphery in order to scan it
|
||||||
|
pinMode(PIN_3V3_EN, OUTPUT);
|
||||||
|
digitalWrite(PIN_3V3_EN, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Currently only the tbeam has a PMU
|
||||||
|
// PMU initialization needs to be placed before scanI2Cdevice
|
||||||
|
power = new Power();
|
||||||
|
power->setStatusHandler(powerStatus);
|
||||||
|
powerStatus->observe(&power->newStatus);
|
||||||
|
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef LILYGO_TBEAM_S3_CORE
|
||||||
|
// In T-Beam-S3-core, the I2C device cannot be scanned before power initialization, otherwise the device will be stuck
|
||||||
|
// PCF8563 RTC in tbeam-s3 uses Wire1 to share I2C bus
|
||||||
|
Wire1.beginTransmission(PCF8563_RTC);
|
||||||
|
if (Wire1.endTransmission() == 0){
|
||||||
|
rtc_found = PCF8563_RTC;
|
||||||
|
DEBUG_MSG("PCF8563 RTC found\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// We need to scan here to decide if we have a screen for nodeDB.init()
|
||||||
scanI2Cdevice();
|
scanI2Cdevice();
|
||||||
|
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
setupSDCard();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RAK4630
|
#ifdef RAK4630
|
||||||
// scanEInkDevice();
|
// scanEInkDevice();
|
||||||
#endif
|
#endif
|
||||||
@@ -260,16 +295,15 @@ void setup()
|
|||||||
#ifdef ARCH_NRF52
|
#ifdef ARCH_NRF52
|
||||||
nrf52Setup();
|
nrf52Setup();
|
||||||
#endif
|
#endif
|
||||||
playStartMelody();
|
|
||||||
// We do this as early as possible because this loads preferences from flash
|
// We do this as early as possible because this loads preferences from flash
|
||||||
// but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
|
// but we need to do this after main cpu iniot (esp32setup), because we need the random seed set
|
||||||
nodeDB.init();
|
nodeDB.init();
|
||||||
|
|
||||||
// Currently only the tbeam has a PMU
|
playStartMelody();
|
||||||
power = new Power();
|
|
||||||
power->setStatusHandler(powerStatus);
|
// fixed screen override?
|
||||||
powerStatus->observe(&power->newStatus);
|
if (config.display.oled != Config_DisplayConfig_OledType_OLED_AUTO)
|
||||||
power->setup(); // Must be after status handler is installed, so that handler gets notified of the initial configuration
|
screen_model = config.display.oled;
|
||||||
|
|
||||||
// Init our SPI controller (must be before screen and lora)
|
// Init our SPI controller (must be before screen and lora)
|
||||||
initSPI();
|
initSPI();
|
||||||
@@ -301,9 +335,9 @@ void setup()
|
|||||||
setupModules();
|
setupModules();
|
||||||
|
|
||||||
// Do this after service.init (because that clears error_code)
|
// Do this after service.init (because that clears error_code)
|
||||||
#ifdef HAS_AXP192
|
#ifdef HAS_PMU
|
||||||
if (!axp192_found)
|
if (!pmu_found)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
|
RECORD_CRITICALERROR(CriticalErrorCode_NO_AXP192); // Record a hardware fault for missing hardware
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Don't call screen setup until after nodedb is setup (because we need
|
// Don't call screen setup until after nodedb is setup (because we need
|
||||||
@@ -324,7 +358,7 @@ void setup()
|
|||||||
DEBUG_MSG("GPS FactoryReset requested\n");
|
DEBUG_MSG("GPS FactoryReset requested\n");
|
||||||
if (gps->factoryReset()) { // If we don't succeed try again next time
|
if (gps->factoryReset()) { // If we don't succeed try again next time
|
||||||
devicestate.did_gps_reset = true;
|
devicestate.did_gps_reset = true;
|
||||||
nodeDB.saveToDisk();
|
nodeDB.saveToDisk(SEGMENT_DEVICESTATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +383,19 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(USE_SX1280)
|
||||||
|
if (!rIf) {
|
||||||
|
rIf = new SX1280Interface(SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY, SPI);
|
||||||
|
if (!rIf->init()) {
|
||||||
|
DEBUG_MSG("Warning: Failed to find SX1280 radio\n");
|
||||||
|
delete rIf;
|
||||||
|
rIf = NULL;
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("SX1280 Radio init succeeded, using SX1280 radio\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(USE_SX1262)
|
#if defined(USE_SX1262)
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
rIf = new SX1262Interface(SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY, SPI);
|
rIf = new SX1262Interface(SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY, SPI);
|
||||||
@@ -388,7 +435,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !HAS_RADIO
|
#ifdef ARCH_PORTDUINO
|
||||||
if (!rIf) {
|
if (!rIf) {
|
||||||
rIf = new SimRadio;
|
rIf = new SimRadio;
|
||||||
if (!rIf->init()) {
|
if (!rIf->init()) {
|
||||||
@@ -401,12 +448,30 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_WIFI
|
// check if the radio chip matches the selected region
|
||||||
|
|
||||||
|
if((config.lora.region == Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLora())){
|
||||||
|
DEBUG_MSG("Warning: Radio chip does not support 2.4GHz LoRa. Reverting to unset.\n");
|
||||||
|
config.lora.region = Config_LoRaConfig_RegionCode_UNSET;
|
||||||
|
nodeDB.saveToDisk(SEGMENT_CONFIG);
|
||||||
|
if(!rIf->reconfigure()) {
|
||||||
|
DEBUG_MSG("Reconfigure failed, rebooting\n");
|
||||||
|
screen->startRebootScreen();
|
||||||
|
rebootAtMsec = millis() + 5000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if HAS_WIFI || HAS_ETHERNET
|
||||||
mqttInit();
|
mqttInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef ARCH_PORTDUINO
|
||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
initWifi(forceSoftAP);
|
initWifi();
|
||||||
|
|
||||||
|
// Initialize Ethernet
|
||||||
|
initEthernet();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// Start web server thread.
|
// Start web server thread.
|
||||||
@@ -414,14 +479,14 @@ void setup()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ARCH_PORTDUINO
|
#ifdef ARCH_PORTDUINO
|
||||||
initApiServer();
|
initApiServer(TCPPort);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start airtime logger thread.
|
// Start airtime logger thread.
|
||||||
airTime = new AirTime();
|
airTime = new AirTime();
|
||||||
|
|
||||||
if (!rIf)
|
if (!rIf)
|
||||||
RECORD_CRITICALERROR(CriticalErrorCode_NoRadio);
|
RECORD_CRITICALERROR(CriticalErrorCode_NO_RADIO);
|
||||||
else {
|
else {
|
||||||
router->addInterface(rIf);
|
router->addInterface(rIf);
|
||||||
|
|
||||||
|
|||||||
15
src/main.h
15
src/main.h
@@ -6,20 +6,29 @@
|
|||||||
#include "PowerStatus.h"
|
#include "PowerStatus.h"
|
||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
#include "mesh/generated/telemetry.pb.h"
|
#include "mesh/generated/telemetry.pb.h"
|
||||||
|
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
|
#include <SparkFun_ATECCX08a_Arduino_Library.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
extern uint8_t screen_found;
|
extern uint8_t screen_found;
|
||||||
extern uint8_t screen_model;
|
extern uint8_t screen_model;
|
||||||
extern uint8_t cardkb_found;
|
extern uint8_t cardkb_found;
|
||||||
extern uint8_t kb_model;
|
extern uint8_t kb_model;
|
||||||
extern uint8_t faceskb_found;
|
|
||||||
extern uint8_t rtc_found;
|
extern uint8_t rtc_found;
|
||||||
|
extern uint8_t keystore_found;
|
||||||
|
|
||||||
extern bool eink_found;
|
extern bool eink_found;
|
||||||
extern bool axp192_found;
|
extern bool pmu_found;
|
||||||
extern bool isCharging;
|
extern bool isCharging;
|
||||||
extern bool isUSBPowered;
|
extern bool isUSBPowered;
|
||||||
|
|
||||||
extern uint8_t nodeTelemetrySensorsMap[7];
|
#if !defined(ARCH_PORTDUINO) && !defined(ARCH_STM32WL)
|
||||||
|
extern ATECCX08A atecc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern uint8_t nodeTelemetrySensorsMap[_TelemetrySensorType_MAX + 1];
|
||||||
|
|
||||||
|
extern int TCPPort; // set by Portduino
|
||||||
|
|
||||||
// Global Screen singleton.
|
// Global Screen singleton.
|
||||||
extern graphics::Screen *screen;
|
extern graphics::Screen *screen;
|
||||||
|
|||||||
@@ -62,13 +62,6 @@ Channel &Channels::fixupChannel(ChannelIndex chIndex)
|
|||||||
// Convert the old string "Default" to our new short representation
|
// Convert the old string "Default" to our new short representation
|
||||||
if (strcmp(channelSettings.name, "Default") == 0)
|
if (strcmp(channelSettings.name, "Default") == 0)
|
||||||
*channelSettings.name = '\0';
|
*channelSettings.name = '\0';
|
||||||
|
|
||||||
/* Convert any old usage of the defaultpsk into our new short representation.
|
|
||||||
if (channelSettings.psk.size == sizeof(defaultpsk) &&
|
|
||||||
memcmp(channelSettings.psk.bytes, defaultpsk, sizeof(defaultpsk)) == 0) {
|
|
||||||
*channelSettings.psk.bytes = 1;
|
|
||||||
channelSettings.psk.size = 1;
|
|
||||||
} */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hashes[chIndex] = generateHash(chIndex);
|
hashes[chIndex] = generateHash(chIndex);
|
||||||
@@ -85,8 +78,8 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
|||||||
ChannelSettings &channelSettings = ch.settings;
|
ChannelSettings &channelSettings = ch.settings;
|
||||||
Config_LoRaConfig &loraConfig = config.lora;
|
Config_LoRaConfig &loraConfig = config.lora;
|
||||||
|
|
||||||
loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; // Default to Long Range & Fast
|
loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
|
||||||
|
loraConfig.use_preset = true;
|
||||||
loraConfig.tx_power = 0; // default
|
loraConfig.tx_power = 0; // default
|
||||||
uint8_t defaultpskIndex = 1;
|
uint8_t defaultpskIndex = 1;
|
||||||
channelSettings.psk.bytes[0] = defaultpskIndex;
|
channelSettings.psk.bytes[0] = defaultpskIndex;
|
||||||
@@ -124,7 +117,22 @@ CryptoKey Channels::getKey(ChannelIndex chIndex)
|
|||||||
DEBUG_MSG("Expanding short PSK #%d\n", pskIndex);
|
DEBUG_MSG("Expanding short PSK #%d\n", pskIndex);
|
||||||
if (pskIndex == 0)
|
if (pskIndex == 0)
|
||||||
k.length = 0; // Turn off encryption
|
k.length = 0; // Turn off encryption
|
||||||
else {
|
else if (oemStore.oem_aes_key.size > 1) {
|
||||||
|
// Use the OEM key
|
||||||
|
DEBUG_MSG("Using OEM Key with %d bytes\n", oemStore.oem_aes_key.size);
|
||||||
|
memcpy(k.bytes, oemStore.oem_aes_key.bytes , oemStore.oem_aes_key.size);
|
||||||
|
k.length = oemStore.oem_aes_key.size;
|
||||||
|
// Bump up the last byte of PSK as needed
|
||||||
|
uint8_t *last = k.bytes + oemStore.oem_aes_key.size - 1;
|
||||||
|
*last = *last + pskIndex - 1; // index of 1 means no change vs defaultPSK
|
||||||
|
if (k.length < 16) {
|
||||||
|
DEBUG_MSG("Warning: OEM provided a too short AES128 key - padding\n");
|
||||||
|
k.length = 16;
|
||||||
|
} else if (k.length < 32 && k.length != 16) {
|
||||||
|
DEBUG_MSG("Warning: OEM provided a too short AES256 key - padding\n");
|
||||||
|
k.length = 32;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
memcpy(k.bytes, defaultpsk, sizeof(defaultpsk));
|
memcpy(k.bytes, defaultpsk, sizeof(defaultpsk));
|
||||||
k.length = sizeof(defaultpsk);
|
k.length = sizeof(defaultpsk);
|
||||||
// Bump up the last byte of PSK as needed
|
// Bump up the last byte of PSK as needed
|
||||||
@@ -188,6 +196,17 @@ Channel &Channels::getByIndex(ChannelIndex chIndex)
|
|||||||
return *ch;
|
return *ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Channel &Channels::getByName(const char* chName)
|
||||||
|
{
|
||||||
|
for (ChannelIndex i = 0; i < getNumChannels(); i++) {
|
||||||
|
if (strcasecmp(channelFile.channels[i].settings.name, chName) == 0) {
|
||||||
|
return channelFile.channels[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getByIndex(getPrimaryIndex());
|
||||||
|
}
|
||||||
|
|
||||||
void Channels::setChannel(const Channel &c)
|
void Channels::setChannel(const Channel &c)
|
||||||
{
|
{
|
||||||
Channel &old = getByIndex(c.index);
|
Channel &old = getByIndex(c.index);
|
||||||
@@ -210,35 +229,37 @@ const char *Channels::getName(size_t chIndex)
|
|||||||
// Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case
|
// Per mesh.proto spec, if bandwidth is specified we must ignore modemPreset enum, we assume that in that case
|
||||||
// the app fucked up and forgot to set channelSettings.name
|
// the app fucked up and forgot to set channelSettings.name
|
||||||
|
|
||||||
if (config.lora.bandwidth != 0)
|
if (config.lora.use_preset) {
|
||||||
channelName = "Custom";
|
|
||||||
else
|
|
||||||
switch (config.lora.modem_preset) {
|
switch (config.lora.modem_preset) {
|
||||||
case Config_LoRaConfig_ModemPreset_ShortSlow:
|
case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
|
||||||
channelName = "ShortS";
|
channelName = "ShortSlow";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_ShortFast:
|
case Config_LoRaConfig_ModemPreset_SHORT_FAST:
|
||||||
channelName = "ShortF";
|
channelName = "ShortFast";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MedSlow:
|
case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
|
||||||
channelName = "MedS";
|
channelName = "MediumSlow";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_MedFast:
|
case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
|
||||||
channelName = "MedF";
|
channelName = "MediumFast";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongSlow:
|
case Config_LoRaConfig_ModemPreset_LONG_SLOW:
|
||||||
channelName = "LongS";
|
channelName = "LongSlow";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_LongFast:
|
case Config_LoRaConfig_ModemPreset_LONG_FAST:
|
||||||
channelName = "LongF";
|
channelName = "LongFast";
|
||||||
break;
|
break;
|
||||||
case Config_LoRaConfig_ModemPreset_VLongSlow:
|
case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
|
||||||
channelName = "VeryL";
|
channelName = "VLongSlow";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
channelName = "Invalid";
|
channelName = "Invalid";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
channelName = "Custom";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return channelName;
|
return channelName;
|
||||||
@@ -257,7 +278,7 @@ their nodes
|
|||||||
*
|
*
|
||||||
* This function will also need to be implemented in GUI apps that talk to the radio.
|
* This function will also need to be implemented in GUI apps that talk to the radio.
|
||||||
*
|
*
|
||||||
* https://github.com/meshtastic/Meshtastic-device/issues/269
|
* https://github.com/meshtastic/firmware/issues/269
|
||||||
*/
|
*/
|
||||||
const char *Channels::getPrimaryName()
|
const char *Channels::getPrimaryName()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ class Channels
|
|||||||
/** Return the Channel for a specified index */
|
/** Return the Channel for a specified index */
|
||||||
Channel &getByIndex(ChannelIndex chIndex);
|
Channel &getByIndex(ChannelIndex chIndex);
|
||||||
|
|
||||||
|
/** Return the Channel for a specified name, return primary if not found. */
|
||||||
|
Channel &getByName(const char* chName);
|
||||||
|
|
||||||
/** Using the index inside the channel, update the specified channel's settings and role. If this channel is being promoted
|
/** Using the index inside the channel, update the specified channel's settings and role. If this channel is being promoted
|
||||||
* to be primary, force all other channels to be secondary.
|
* to be primary, force all other channels to be secondary.
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +77,7 @@ class Channels
|
|||||||
*
|
*
|
||||||
* This function will also need to be implemented in GUI apps that talk to the radio.
|
* This function will also need to be implemented in GUI apps that talk to the radio.
|
||||||
*
|
*
|
||||||
* https://github.com/meshtastic/Meshtastic-device/issues/269
|
* https://github.com/meshtastic/firmware/issues/269
|
||||||
*/
|
*/
|
||||||
const char *getPrimaryName();
|
const char *getPrimaryName();
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ ErrorCode FloodingRouter::send(MeshPacket *p)
|
|||||||
return Router::send(p);
|
return Router::send(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FloodingRouter::shouldFilterReceived(MeshPacket *p)
|
bool FloodingRouter::shouldFilterReceived(const MeshPacket *p)
|
||||||
{
|
{
|
||||||
if (wasSeenRecently(p)) { // Note: this will also add a recent packet record
|
if (wasSeenRecently(p)) { // Note: this will also add a recent packet record
|
||||||
printPacket("Ignoring incoming msg, because we've already seen it", p);
|
printPacket("Ignoring incoming msg, because we've already seen it", p);
|
||||||
@@ -29,18 +29,24 @@ bool FloodingRouter::shouldFilterReceived(MeshPacket *p)
|
|||||||
|
|
||||||
void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||||
{
|
{
|
||||||
PacketId ackId = ((c && c->error_reason == Routing_Error_NONE) || !c) ? p->decoded.request_id : 0;
|
bool isAck = ((c && c->error_reason == Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK
|
||||||
if (ackId && p->to != getNodeNum()) {
|
if (isAck && p->to != getNodeNum()) {
|
||||||
// do not flood direct message that is ACKed
|
// do not flood direct message that is ACKed
|
||||||
DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
DEBUG_MSG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
||||||
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
|
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
|
||||||
} else if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
|
}
|
||||||
|
if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
|
||||||
if (p->id != 0) {
|
if (p->id != 0) {
|
||||||
if (config.device.role != Config_DeviceConfig_Role_ClientMute) {
|
if (config.device.role != Config_DeviceConfig_Role_CLIENT_MUTE) {
|
||||||
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
|
||||||
|
|
||||||
tosend->hop_limit--; // bump down the hop count
|
tosend->hop_limit--; // bump down the hop count
|
||||||
|
|
||||||
|
// If it is a traceRoute request, update the route that it went via me
|
||||||
|
if (p->which_payload_variant == MeshPacket_decoded_tag && traceRouteModule->wantPacket(p)) {
|
||||||
|
traceRouteModule->updateRoute(tosend);
|
||||||
|
}
|
||||||
|
|
||||||
printPacket("Rebroadcasting received floodmsg to neighbors", p);
|
printPacket("Rebroadcasting received floodmsg to neighbors", p);
|
||||||
// Note: we are careful to resend using the original senders node id
|
// Note: we are careful to resend using the original senders node id
|
||||||
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
// We are careful not to call our hooked version of send() - because we don't want to check this again
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "PacketHistory.h"
|
#include "PacketHistory.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
#include "modules/TraceRouteModule.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a mixin that extends Router with the ability to do Naive Flooding (in the standard mesh protocol sense)
|
* This is a mixin that extends Router with the ability to do Naive Flooding (in the standard mesh protocol sense)
|
||||||
@@ -50,7 +51,7 @@ class FloodingRouter : public Router, protected PacketHistory
|
|||||||
* Called immedately on receiption, before any further processing.
|
* Called immedately on receiption, before any further processing.
|
||||||
* @return true to abandon the packet
|
* @return true to abandon the packet
|
||||||
*/
|
*/
|
||||||
virtual bool shouldFilterReceived(MeshPacket *p) override;
|
virtual bool shouldFilterReceived(const MeshPacket *p) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Look for broadcasts we need to rebroadcast
|
* Look for broadcasts we need to rebroadcast
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#include "SX126xInterface.h"
|
#include "SX126xInterface.h"
|
||||||
#include "SX126xInterface.cpp"
|
#include "SX126xInterface.cpp"
|
||||||
|
#include "SX128xInterface.h"
|
||||||
|
#include "SX128xInterface.cpp"
|
||||||
|
|
||||||
// We need this declaration for proper linking in derived classes
|
// We need this declaration for proper linking in derived classes
|
||||||
template class SX126xInterface<SX1262>;
|
template class SX126xInterface<SX1262>;
|
||||||
template class SX126xInterface<SX1268>;
|
template class SX126xInterface<SX1268>;
|
||||||
template class SX126xInterface<LLCC68>;
|
template class SX126xInterface<LLCC68>;
|
||||||
|
template class SX128xInterface<SX1280>;
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ MeshPacket *MeshModule::allocAckNak(Routing_Error err, NodeNum to, PacketId idFr
|
|||||||
// auto p = allocDataProtobuf(c);
|
// auto p = allocDataProtobuf(c);
|
||||||
MeshPacket *p = router->allocForSending();
|
MeshPacket *p = router->allocForSending();
|
||||||
p->decoded.portnum = PortNum_ROUTING_APP;
|
p->decoded.portnum = PortNum_ROUTING_APP;
|
||||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), Routing_fields, &c);
|
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &Routing_msg, &c);
|
||||||
|
|
||||||
p->priority = MeshPacket_Priority_ACK;
|
p->priority = MeshPacket_Priority_ACK;
|
||||||
|
|
||||||
p->hop_limit = 0; // Assume just immediate neighbors for now
|
p->hop_limit = config.lora.hop_limit; // Flood ACK back to original sender
|
||||||
p->to = to;
|
p->to = to;
|
||||||
p->decoded.request_id = idFrom;
|
p->decoded.request_id = idFrom;
|
||||||
p->channel = chIndex;
|
p->channel = chIndex;
|
||||||
@@ -72,7 +72,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
bool moduleFound = false;
|
bool moduleFound = false;
|
||||||
|
|
||||||
// We now allow **encrypted** packets to pass through the modules
|
// We now allow **encrypted** packets to pass through the modules
|
||||||
bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag;
|
bool isDecoded = mp.which_payload_variant == MeshPacket_decoded_tag;
|
||||||
|
|
||||||
currentReply = NULL; // No reply yet
|
currentReply = NULL; // No reply yet
|
||||||
|
|
||||||
@@ -109,10 +109,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
|||||||
/// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to
|
/// Also: if a packet comes in on the local PC interface, we don't check for bound channels, because it is TRUSTED and it needs to
|
||||||
/// to be able to fetch the initial admin packets without yet knowing any channels.
|
/// to be able to fetch the initial admin packets without yet knowing any channels.
|
||||||
|
|
||||||
bool rxChannelOk = !pi.boundChannel || (mp.from == 0) ||
|
bool rxChannelOk = !pi.boundChannel || (mp.from == 0) || (strcasecmp(ch->settings.name, pi.boundChannel) == 0);
|
||||||
!ch ||
|
|
||||||
strlen(ch->settings.name) > 0 ||
|
|
||||||
strcmp(ch->settings.name, pi.boundChannel);
|
|
||||||
|
|
||||||
if (!rxChannelOk) {
|
if (!rxChannelOk) {
|
||||||
// no one should have already replied!
|
// no one should have already replied!
|
||||||
@@ -211,7 +208,7 @@ void MeshModule::sendResponse(const MeshPacket &req)
|
|||||||
*/
|
*/
|
||||||
void setReplyTo(MeshPacket *p, const MeshPacket &to)
|
void setReplyTo(MeshPacket *p, const MeshPacket &to)
|
||||||
{
|
{
|
||||||
assert(p->which_payloadVariant == MeshPacket_decoded_tag); // Should already be set by now
|
assert(p->which_payload_variant == MeshPacket_decoded_tag); // Should already be set by now
|
||||||
p->to = getFrom(&to); // Make sure that if we are sending to the local node, we use our local node addr, not 0
|
p->to = getFrom(&to); // Make sure that if we are sending to the local node, we use our local node addr, not 0
|
||||||
p->channel = to.channel; // Use the same channel that the request came in on
|
p->channel = to.channel; // Use the same channel that the request came in on
|
||||||
|
|
||||||
@@ -266,7 +263,7 @@ AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const MeshP
|
|||||||
// In case we have a response it always has priority.
|
// In case we have a response it always has priority.
|
||||||
DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n",
|
DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n",
|
||||||
pi.name,
|
pi.name,
|
||||||
response->which_variant);
|
response->which_payload_variant);
|
||||||
handled = h;
|
handled = h;
|
||||||
}
|
}
|
||||||
else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) &&
|
else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) &&
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct RegionInfo {
|
|||||||
uint8_t powerLimit; // Or zero for not set
|
uint8_t powerLimit; // Or zero for not set
|
||||||
bool audioPermitted;
|
bool audioPermitted;
|
||||||
bool freqSwitching;
|
bool freqSwitching;
|
||||||
|
bool wideLora;
|
||||||
const char *name; // EU433 etc
|
const char *name; // EU433 etc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ void MeshService::loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The radioConfig object just changed, call this to force the hw to change to the new settings
|
/// The radioConfig object just changed, call this to force the hw to change to the new settings
|
||||||
bool MeshService::reloadConfig()
|
bool MeshService::reloadConfig(int saveWhat)
|
||||||
{
|
{
|
||||||
// If we can successfully set this radio to these settings, save them to disk
|
// If we can successfully set this radio to these settings, save them to disk
|
||||||
|
|
||||||
@@ -98,22 +98,23 @@ bool MeshService::reloadConfig()
|
|||||||
bool didReset = nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings
|
bool didReset = nodeDB.resetRadioConfig(); // Don't let the phone send us fatally bad settings
|
||||||
|
|
||||||
configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc
|
configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc
|
||||||
nodeDB.saveToDisk();
|
nodeDB.saveToDisk(saveWhat);
|
||||||
|
|
||||||
return didReset;
|
return didReset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
|
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
|
||||||
void MeshService::reloadOwner()
|
void MeshService::reloadOwner(bool shouldSave)
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("reloadOwner()\n");
|
// DEBUG_MSG("reloadOwner()\n");
|
||||||
// update our local data directly
|
// update our local data directly
|
||||||
nodeDB.updateUser(nodeDB.getNodeNum(), owner);
|
nodeDB.updateUser(nodeDB.getNodeNum(), owner);
|
||||||
assert(nodeInfoModule);
|
assert(nodeInfoModule);
|
||||||
// update everyone else
|
// update everyone else and save to disk
|
||||||
if (nodeInfoModule)
|
if (nodeInfoModule && shouldSave) {
|
||||||
nodeInfoModule->sendOurNodeInfo();
|
nodeInfoModule->sendOurNodeInfo();
|
||||||
nodeDB.saveToDisk();
|
nodeDB.saveToDisk(SEGMENT_DEVICESTATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,6 +124,29 @@ void MeshService::reloadOwner()
|
|||||||
*/
|
*/
|
||||||
void MeshService::handleToRadio(MeshPacket &p)
|
void MeshService::handleToRadio(MeshPacket &p)
|
||||||
{
|
{
|
||||||
|
#ifdef ARCH_PORTDUINO
|
||||||
|
// Simulates device is receiving a packet via the LoRa chip
|
||||||
|
if (p.decoded.portnum == PortNum_SIMULATOR_APP) {
|
||||||
|
// Simulator packet (=Compressed packet) is encapsulated in a MeshPacket, so need to unwrap first
|
||||||
|
Compressed scratch;
|
||||||
|
Compressed *decoded = NULL;
|
||||||
|
if (p.which_payload_variant == MeshPacket_decoded_tag) {
|
||||||
|
memset(&scratch, 0, sizeof(scratch));
|
||||||
|
p.decoded.payload.size = pb_decode_from_bytes(p.decoded.payload.bytes, p.decoded.payload.size, &Compressed_msg, &scratch);
|
||||||
|
if (p.decoded.payload.size) {
|
||||||
|
decoded = &scratch;
|
||||||
|
// Extract the original payload and replace
|
||||||
|
memcpy(&p.decoded.payload, &decoded->data, sizeof(decoded->data));
|
||||||
|
// Switch the port from PortNum_SIMULATOR_APP back to the original PortNum
|
||||||
|
p.decoded.portnum = decoded->portnum;
|
||||||
|
} else
|
||||||
|
DEBUG_MSG("Error decoding protobuf for simulator message!\n");
|
||||||
|
}
|
||||||
|
// Let SimRadio receive as if it did via its LoRa chip
|
||||||
|
SimRadio::instance->startReceive(&p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (p.from != 0) { // We don't let phones assign nodenums to their sent messages
|
if (p.from != 0) { // We don't let phones assign nodenums to their sent messages
|
||||||
DEBUG_MSG("Warning: phone tried to pick a nodenum, we don't allow that.\n");
|
DEBUG_MSG("Warning: phone tried to pick a nodenum, we don't allow that.\n");
|
||||||
p.from = 0;
|
p.from = 0;
|
||||||
@@ -252,7 +276,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
|||||||
pos.time = getValidTime(RTCQualityGPS);
|
pos.time = getValidTime(RTCQualityGPS);
|
||||||
|
|
||||||
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
|
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
|
||||||
DEBUG_MSG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.pos_timestamp, pos.time, pos.latitude_i,
|
DEBUG_MSG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.timestamp, pos.time, pos.latitude_i,
|
||||||
pos.longitude_i, pos.altitude);
|
pos.longitude_i, pos.altitude);
|
||||||
|
|
||||||
// Update our current position in the local DB
|
// Update our current position in the local DB
|
||||||
@@ -260,3 +284,8 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MeshService::isToPhoneQueueEmpty()
|
||||||
|
{
|
||||||
|
return toPhoneQueue.isEmpty();
|
||||||
|
}
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
#include "MeshTypes.h"
|
#include "MeshTypes.h"
|
||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
#include "PointerQueue.h"
|
#include "PointerQueue.h"
|
||||||
|
#ifdef ARCH_PORTDUINO
|
||||||
|
#include "../platform/portduino/SimRadio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Top level app for this service. keeps the mesh, the radio config and the queue of received packets.
|
* Top level app for this service. keeps the mesh, the radio config and the queue of received packets.
|
||||||
@@ -63,10 +66,10 @@ class MeshService
|
|||||||
/** The radioConfig object just changed, call this to force the hw to change to the new settings
|
/** The radioConfig object just changed, call this to force the hw to change to the new settings
|
||||||
* @return true if client devices should be sent a new set of radio configs
|
* @return true if client devices should be sent a new set of radio configs
|
||||||
*/
|
*/
|
||||||
bool reloadConfig();
|
bool reloadConfig(int saveWhat=SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS);
|
||||||
|
|
||||||
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
|
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
|
||||||
void reloadOwner();
|
void reloadOwner(bool shouldSave = true);
|
||||||
|
|
||||||
/// Called when the user wakes up our GUI, normally sends our latest location to the mesh (if we have it), otherwise at least
|
/// Called when the user wakes up our GUI, normally sends our latest location to the mesh (if we have it), otherwise at least
|
||||||
/// sends our owner
|
/// sends our owner
|
||||||
@@ -86,6 +89,8 @@ class MeshService
|
|||||||
/// Send a packet to the phone
|
/// Send a packet to the phone
|
||||||
void sendToPhone(MeshPacket *p);
|
void sendToPhone(MeshPacket *p);
|
||||||
|
|
||||||
|
bool isToPhoneQueueEmpty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
/// Called when our gps position has changed - updates nodedb and sends Location message out into the mesh
|
||||||
/// returns 0 to allow futher processing
|
/// returns 0 to allow futher processing
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
|
#include <ErriezCRC32.h>
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include "mesh/http/WiFiAPClient.h"
|
#include "mesh/http/WiFiAPClient.h"
|
||||||
@@ -37,6 +38,7 @@ MyNodeInfo &myNodeInfo = devicestate.my_node;
|
|||||||
LocalConfig config;
|
LocalConfig config;
|
||||||
LocalModuleConfig moduleConfig;
|
LocalModuleConfig moduleConfig;
|
||||||
ChannelFile channelFile;
|
ChannelFile channelFile;
|
||||||
|
OEMStore oemStore;
|
||||||
|
|
||||||
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
/** The current change # for radio settings. Starts at 0 on boot and any time the radio settings
|
||||||
* might have changed is incremented. Allows others to detect they might now be on a new channel.
|
* might have changed is incremented. Allows others to detect they might now be on a new channel.
|
||||||
@@ -73,14 +75,13 @@ NodeNum getFrom(const MeshPacket *p)
|
|||||||
return (p->from == 0) ? nodeDB.getNodeNum() : p->from;
|
return (p->from == 0) ? nodeDB.getNodeNum() : p->from;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeDB::resetRadioConfig()
|
bool NodeDB::resetRadioConfig(bool factory_reset)
|
||||||
{
|
{
|
||||||
bool didFactoryReset = false;
|
bool didFactoryReset = false;
|
||||||
|
|
||||||
radioGeneration++;
|
radioGeneration++;
|
||||||
|
|
||||||
// radioConfig.has_preferences = true;
|
if (factory_reset) {
|
||||||
if (config.device.factory_reset) {
|
|
||||||
didFactoryReset = factoryReset();
|
didFactoryReset = factoryReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +114,6 @@ bool NodeDB::resetRadioConfig()
|
|||||||
initRegion();
|
initRegion();
|
||||||
|
|
||||||
if (didFactoryReset) {
|
if (didFactoryReset) {
|
||||||
config.device.factory_reset = false;
|
|
||||||
DEBUG_MSG("Rebooting due to factory reset");
|
DEBUG_MSG("Rebooting due to factory reset");
|
||||||
screen->startRebootScreen();
|
screen->startRebootScreen();
|
||||||
rebootAtMsec = millis() + (5 * 1000);
|
rebootAtMsec = millis() + (5 * 1000);
|
||||||
@@ -130,7 +130,9 @@ bool NodeDB::factoryReset()
|
|||||||
// second, install default state (this will deal with the duplicate mac address issue)
|
// second, install default state (this will deal with the duplicate mac address issue)
|
||||||
installDefaultDeviceState();
|
installDefaultDeviceState();
|
||||||
installDefaultConfig();
|
installDefaultConfig();
|
||||||
// third, write to disk
|
installDefaultModuleConfig();
|
||||||
|
installDefaultChannels();
|
||||||
|
// third, write everything to disk
|
||||||
saveToDisk();
|
saveToDisk();
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
||||||
@@ -157,13 +159,18 @@ void NodeDB::installDefaultConfig()
|
|||||||
config.has_lora = true;
|
config.has_lora = true;
|
||||||
config.has_position = true;
|
config.has_position = true;
|
||||||
config.has_power = true;
|
config.has_power = true;
|
||||||
config.has_wifi = true;
|
config.has_network = true;
|
||||||
config.has_bluetooth = true;
|
config.has_bluetooth = true;
|
||||||
|
config.lora.tx_enabled = true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
|
||||||
config.lora.region = Config_LoRaConfig_RegionCode_Unset;
|
config.lora.override_duty_cycle = false;
|
||||||
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast;
|
config.lora.region = Config_LoRaConfig_RegionCode_UNSET;
|
||||||
|
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST;
|
||||||
|
config.lora.hop_limit = HOP_RELIABLE;
|
||||||
|
config.position.gps_enabled = true;
|
||||||
|
config.position.position_broadcast_smart_enabled = true;
|
||||||
|
config.device.serial_enabled = true;
|
||||||
resetRadioConfig();
|
resetRadioConfig();
|
||||||
strncpy(config.device.ntp_server, "0.pool.ntp.org", 32);
|
strncpy(config.network.ntp_server, "0.pool.ntp.org", 32);
|
||||||
// FIXME: Default to bluetooth capability of platform as default
|
// FIXME: Default to bluetooth capability of platform as default
|
||||||
config.bluetooth.enabled = true;
|
config.bluetooth.enabled = true;
|
||||||
config.bluetooth.fixed_pin = defaultBLEPin;
|
config.bluetooth.fixed_pin = defaultBLEPin;
|
||||||
@@ -172,15 +179,33 @@ void NodeDB::installDefaultConfig()
|
|||||||
#else
|
#else
|
||||||
bool hasScreen = screen_found;
|
bool hasScreen = screen_found;
|
||||||
#endif
|
#endif
|
||||||
config.bluetooth.mode = hasScreen ? Config_BluetoothConfig_PairingMode_RandomPin : Config_BluetoothConfig_PairingMode_FixedPin;
|
config.bluetooth.mode = hasScreen ? Config_BluetoothConfig_PairingMode_RANDOM_PIN : Config_BluetoothConfig_PairingMode_FIXED_PIN;
|
||||||
// for backward compat, default position flags are ALT+MSL
|
// for backward compat, default position flags are ALT+MSL
|
||||||
config.position.position_flags = (Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL);
|
config.position.position_flags = (Config_PositionConfig_PositionFlags_ALTITUDE | Config_PositionConfig_PositionFlags_ALTITUDE_MSL);
|
||||||
|
|
||||||
|
initConfigIntervals();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeDB::initConfigIntervals()
|
||||||
|
{
|
||||||
|
config.position.gps_update_interval = default_gps_update_interval;
|
||||||
|
config.position.gps_attempt_time = default_gps_attempt_time;
|
||||||
|
config.position.position_broadcast_secs = default_broadcast_interval_secs;
|
||||||
|
|
||||||
|
config.power.ls_secs = default_ls_secs;
|
||||||
|
config.power.mesh_sds_timeout_secs = default_mesh_sds_timeout_secs;
|
||||||
|
config.power.min_wake_secs = default_min_wake_secs;
|
||||||
|
config.power.sds_secs = default_sds_secs;
|
||||||
|
config.power.wait_bluetooth_secs = default_wait_bluetooth_secs;
|
||||||
|
|
||||||
|
config.display.screen_on_secs = default_screen_on_secs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultModuleConfig()
|
void NodeDB::installDefaultModuleConfig()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Installing default ModuleConfig\n");
|
DEBUG_MSG("Installing default ModuleConfig\n");
|
||||||
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
memset(&moduleConfig, 0, sizeof(ModuleConfig));
|
||||||
|
|
||||||
moduleConfig.version = DEVICESTATE_CUR_VER;
|
moduleConfig.version = DEVICESTATE_CUR_VER;
|
||||||
moduleConfig.has_mqtt = true;
|
moduleConfig.has_mqtt = true;
|
||||||
moduleConfig.has_range_test = true;
|
moduleConfig.has_range_test = true;
|
||||||
@@ -189,6 +214,18 @@ void NodeDB::installDefaultModuleConfig()
|
|||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_telemetry = true;
|
||||||
moduleConfig.has_external_notification = true;
|
moduleConfig.has_external_notification = true;
|
||||||
moduleConfig.has_canned_message = true;
|
moduleConfig.has_canned_message = true;
|
||||||
|
|
||||||
|
strncpy(moduleConfig.mqtt.address, default_mqtt_address, sizeof(moduleConfig.mqtt.address));
|
||||||
|
strncpy(moduleConfig.mqtt.username, default_mqtt_username, sizeof(moduleConfig.mqtt.username));
|
||||||
|
strncpy(moduleConfig.mqtt.password, default_mqtt_password, sizeof(moduleConfig.mqtt.password));
|
||||||
|
|
||||||
|
initModuleConfigIntervals();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NodeDB::initModuleConfigIntervals()
|
||||||
|
{
|
||||||
|
moduleConfig.telemetry.device_update_interval = default_broadcast_interval_secs;
|
||||||
|
moduleConfig.telemetry.environment_update_interval = default_broadcast_interval_secs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultChannels()
|
void NodeDB::installDefaultChannels()
|
||||||
@@ -198,13 +235,20 @@ void NodeDB::installDefaultChannels()
|
|||||||
channelFile.version = DEVICESTATE_CUR_VER;
|
channelFile.version = DEVICESTATE_CUR_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NodeDB::resetNodes()
|
||||||
|
{
|
||||||
|
devicestate.node_db_count = 0;
|
||||||
|
memset(devicestate.node_db, 0, sizeof(devicestate.node_db));
|
||||||
|
saveDeviceStateToDisk();
|
||||||
|
}
|
||||||
|
|
||||||
void NodeDB::installDefaultDeviceState()
|
void NodeDB::installDefaultDeviceState()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Installing default DeviceState\n");
|
DEBUG_MSG("Installing default DeviceState\n");
|
||||||
memset(&devicestate, 0, sizeof(DeviceState));
|
memset(&devicestate, 0, sizeof(DeviceState));
|
||||||
|
|
||||||
*numNodes = 0; // Forget node DB
|
*numNodes = 0;
|
||||||
|
|
||||||
// init our devicestate with valid flags so protobuf writing/reading will work
|
// init our devicestate with valid flags so protobuf writing/reading will work
|
||||||
devicestate.has_my_node = true;
|
devicestate.has_my_node = true;
|
||||||
devicestate.has_owner = true;
|
devicestate.has_owner = true;
|
||||||
@@ -232,12 +276,17 @@ void NodeDB::installDefaultDeviceState()
|
|||||||
void NodeDB::init()
|
void NodeDB::init()
|
||||||
{
|
{
|
||||||
DEBUG_MSG("Initializing NodeDB\n");
|
DEBUG_MSG("Initializing NodeDB\n");
|
||||||
// saveToDisk();
|
|
||||||
loadFromDisk();
|
loadFromDisk();
|
||||||
|
|
||||||
|
uint32_t devicestateCRC = crc32Buffer(&devicestate, sizeof(devicestate));
|
||||||
|
uint32_t configCRC = crc32Buffer(&config, sizeof(config));
|
||||||
|
uint32_t channelFileCRC = crc32Buffer(&channelFile, sizeof(channelFile));
|
||||||
|
|
||||||
|
int saveWhat = 0;
|
||||||
|
|
||||||
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
|
||||||
|
|
||||||
myNodeInfo.error_code = CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash)
|
myNodeInfo.error_code = CriticalErrorCode_NONE; // For the error code, only show values from this boot (discard value from flash)
|
||||||
myNodeInfo.error_address = 0;
|
myNodeInfo.error_address = 0;
|
||||||
|
|
||||||
// likewise - we always want the app requirements to come from the running appload
|
// likewise - we always want the app requirements to come from the running appload
|
||||||
@@ -272,7 +321,15 @@ void NodeDB::init()
|
|||||||
|
|
||||||
resetRadioConfig(); // If bogus settings got saved, then fix them
|
resetRadioConfig(); // If bogus settings got saved, then fix them
|
||||||
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
DEBUG_MSG("region=%d, NODENUM=0x%x, dbsize=%d\n", config.lora.region, myNodeInfo.my_node_num, *numNodes);
|
||||||
saveToDisk();
|
|
||||||
|
if (devicestateCRC != crc32Buffer(&devicestate, sizeof(devicestate)))
|
||||||
|
saveWhat |= SEGMENT_DEVICESTATE;
|
||||||
|
if (configCRC != crc32Buffer(&config, sizeof(config)))
|
||||||
|
saveWhat |= SEGMENT_CONFIG;
|
||||||
|
if (channelFileCRC != crc32Buffer(&channelFile, sizeof(channelFile)))
|
||||||
|
saveWhat |= SEGMENT_CHANNELS;
|
||||||
|
|
||||||
|
saveToDisk(saveWhat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We reserve a few nodenums for future use
|
// We reserve a few nodenums for future use
|
||||||
@@ -306,6 +363,8 @@ static const char *prefFileName = "/prefs/db.proto";
|
|||||||
static const char *configFileName = "/prefs/config.proto";
|
static const char *configFileName = "/prefs/config.proto";
|
||||||
static const char *moduleConfigFileName = "/prefs/module.proto";
|
static const char *moduleConfigFileName = "/prefs/module.proto";
|
||||||
static const char *channelFileName = "/prefs/channels.proto";
|
static const char *channelFileName = "/prefs/channels.proto";
|
||||||
|
static const char *oemConfigFile = "/oem/oem.proto";
|
||||||
|
|
||||||
|
|
||||||
/** Load a protobuf from a file, return true for success */
|
/** Load a protobuf from a file, return true for success */
|
||||||
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, void *dest_struct)
|
||||||
@@ -342,30 +401,18 @@ bool loadProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
void NodeDB::loadFromDisk()
|
void NodeDB::loadFromDisk()
|
||||||
{
|
{
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
if (!loadProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate)) {
|
if (!loadProto(prefFileName, DeviceState_size, sizeof(DeviceState), &DeviceState_msg, &devicestate)) {
|
||||||
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
||||||
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
DEBUG_MSG("Warn: devicestate %d is old, discarding\n", devicestate.version);
|
||||||
installDefaultDeviceState();
|
factoryReset();
|
||||||
#ifdef ARCH_ESP32
|
|
||||||
// This will erase what's in NVS including ssl keys, persistant variables and ble pairing
|
|
||||||
nvs_flash_erase();
|
|
||||||
#endif
|
|
||||||
#ifdef ARCH_NRF52
|
|
||||||
Bluefruit.begin();
|
|
||||||
DEBUG_MSG("Clearing bluetooth bonds!\n");
|
|
||||||
bond_print_list(BLE_GAP_ROLE_PERIPH);
|
|
||||||
bond_print_list(BLE_GAP_ROLE_CENTRAL);
|
|
||||||
Bluefruit.Periph.clearBonds();
|
|
||||||
Bluefruit.Central.clearBonds();
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);
|
DEBUG_MSG("Loaded saved devicestate version %d\n", devicestate.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config)) {
|
if (!loadProto(configFileName, LocalConfig_size, sizeof(LocalConfig), &LocalConfig_msg, &config)) {
|
||||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (config.version < DEVICESTATE_MIN_VER) {
|
if (config.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -376,7 +423,7 @@ void NodeDB::loadFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig)) {
|
if (!loadProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), &LocalModuleConfig_msg, &moduleConfig)) {
|
||||||
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -387,7 +434,7 @@ void NodeDB::loadFromDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile)) {
|
if (!loadProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), &ChannelFile_msg, &channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
||||||
@@ -397,10 +444,13 @@ void NodeDB::loadFromDisk()
|
|||||||
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
DEBUG_MSG("Loaded saved channelFile version %d\n", channelFile.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (loadProto(oemConfigFile, OEMStore_size, sizeof(OEMStore), &OEMStore_msg, &oemStore))
|
||||||
|
DEBUG_MSG("Loaded OEMStore\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Save a protobuf from a file, return true for success */
|
/** Save a protobuf from a file, return true for success */
|
||||||
bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
bool saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct)
|
||||||
{
|
{
|
||||||
bool okay = false;
|
bool okay = false;
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
@@ -417,7 +467,6 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
} else {
|
} else {
|
||||||
okay = true;
|
okay = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
f.close();
|
f.close();
|
||||||
|
|
||||||
// brief window of risk here ;-)
|
// brief window of risk here ;-)
|
||||||
@@ -427,6 +476,15 @@ bool saveProto(const char *filename, size_t protoSize, size_t objSize, const pb_
|
|||||||
DEBUG_MSG("Error: can't rename new pref file\n");
|
DEBUG_MSG("Error: can't rename new pref file\n");
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("Can't write prefs\n");
|
DEBUG_MSG("Can't write prefs\n");
|
||||||
|
#ifdef ARCH_NRF52
|
||||||
|
static uint8_t failedCounter = 0;
|
||||||
|
failedCounter++;
|
||||||
|
if(failedCounter >= 2){
|
||||||
|
FSCom.format();
|
||||||
|
//After formatting, the device needs to be restarted
|
||||||
|
nodeDB.resetRadioConfig(true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
DEBUG_MSG("ERROR: Filesystem not implemented\n");
|
DEBUG_MSG("ERROR: Filesystem not implemented\n");
|
||||||
@@ -440,7 +498,7 @@ void NodeDB::saveChannelsToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(channelFileName, ChannelFile_size, sizeof(ChannelFile), ChannelFile_fields, &channelFile);
|
saveProto(channelFileName, ChannelFile_size, &ChannelFile_msg, &channelFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,38 +508,45 @@ void NodeDB::saveDeviceStateToDisk()
|
|||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
saveProto(prefFileName, DeviceState_size, &DeviceState_msg, &devicestate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeDB::saveToDisk()
|
void NodeDB::saveToDisk(int saveWhat)
|
||||||
{
|
{
|
||||||
if (!devicestate.no_save) {
|
if (!devicestate.no_save) {
|
||||||
#ifdef FSCom
|
#ifdef FSCom
|
||||||
FSCom.mkdir("/prefs");
|
FSCom.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
saveProto(prefFileName, DeviceState_size, sizeof(devicestate), DeviceState_fields, &devicestate);
|
if (saveWhat & SEGMENT_DEVICESTATE) {
|
||||||
|
saveDeviceStateToDisk();
|
||||||
|
}
|
||||||
|
|
||||||
// save all config segments
|
if (saveWhat & SEGMENT_CONFIG) {
|
||||||
config.has_device = true;
|
config.has_device = true;
|
||||||
config.has_display = true;
|
config.has_display = true;
|
||||||
config.has_lora = true;
|
config.has_lora = true;
|
||||||
config.has_position = true;
|
config.has_position = true;
|
||||||
config.has_power = true;
|
config.has_power = true;
|
||||||
config.has_wifi = true;
|
config.has_network = true;
|
||||||
config.has_bluetooth = true;
|
config.has_bluetooth = true;
|
||||||
saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
|
saveProto(configFileName, LocalConfig_size, &LocalConfig_msg, &config);
|
||||||
|
}
|
||||||
|
|
||||||
moduleConfig.has_canned_message = true;
|
if (saveWhat & SEGMENT_MODULECONFIG) {
|
||||||
moduleConfig.has_external_notification = true;
|
moduleConfig.has_canned_message = true;
|
||||||
moduleConfig.has_mqtt = true;
|
moduleConfig.has_external_notification = true;
|
||||||
moduleConfig.has_range_test = true;
|
moduleConfig.has_mqtt = true;
|
||||||
moduleConfig.has_serial = true;
|
moduleConfig.has_range_test = true;
|
||||||
moduleConfig.has_store_forward = true;
|
moduleConfig.has_serial = true;
|
||||||
moduleConfig.has_telemetry = true;
|
moduleConfig.has_store_forward = true;
|
||||||
saveProto(moduleConfigFileName, LocalModuleConfig_size, sizeof(LocalModuleConfig), LocalModuleConfig_fields, &moduleConfig);
|
moduleConfig.has_telemetry = true;
|
||||||
|
saveProto(moduleConfigFileName, LocalModuleConfig_size, &LocalModuleConfig_msg, &moduleConfig);
|
||||||
|
}
|
||||||
|
|
||||||
saveChannelsToDisk();
|
if (saveWhat & SEGMENT_CHANNELS) {
|
||||||
|
saveChannelsToDisk();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
DEBUG_MSG("***** DEVELOPMENT MODE - DO NOT RELEASE - not saving to flash *****\n");
|
||||||
}
|
}
|
||||||
@@ -534,11 +599,11 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
|
|||||||
|
|
||||||
if (src == RX_SRC_LOCAL) {
|
if (src == RX_SRC_LOCAL) {
|
||||||
// Local packet, fully authoritative
|
// Local packet, fully authoritative
|
||||||
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.pos_timestamp, p.time, p.latitude_i,
|
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i,
|
||||||
p.longitude_i, p.altitude);
|
p.longitude_i, p.altitude);
|
||||||
info->position = p;
|
info->position = p;
|
||||||
|
|
||||||
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.pos_timestamp && !p.location_source) {
|
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) {
|
||||||
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
|
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
|
||||||
// (stop-gap fix for issue #900)
|
// (stop-gap fix for issue #900)
|
||||||
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
|
||||||
@@ -623,7 +688,7 @@ void NodeDB::updateUser(uint32_t nodeId, const User &p)
|
|||||||
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
|
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
|
||||||
void NodeDB::updateFrom(const MeshPacket &mp)
|
void NodeDB::updateFrom(const MeshPacket &mp)
|
||||||
{
|
{
|
||||||
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.from) {
|
if (mp.which_payload_variant == MeshPacket_decoded_tag && mp.from) {
|
||||||
DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
|
DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
|
||||||
|
|
||||||
NodeInfo *info = getOrCreateNode(getFrom(&mp));
|
NodeInfo *info = getOrCreateNode(getFrom(&mp));
|
||||||
@@ -657,11 +722,23 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
|||||||
|
|
||||||
if (!info) {
|
if (!info) {
|
||||||
if (*numNodes >= MAX_NUM_NODES) {
|
if (*numNodes >= MAX_NUM_NODES) {
|
||||||
screen->print("error: node_db full!\n");
|
screen->print("warning: node_db full! erasing oldest entry\n");
|
||||||
DEBUG_MSG("ERROR! could not create new node, node_db is full! (%d nodes)", *numNodes);
|
// look for oldest node and erase it
|
||||||
return NULL;
|
uint32_t oldest = UINT32_MAX;
|
||||||
|
int oldestIndex = -1;
|
||||||
|
for (int i = 0; i < *numNodes; i++) {
|
||||||
|
if (nodes[i].last_heard < oldest) {
|
||||||
|
oldest = nodes[i].last_heard;
|
||||||
|
oldestIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Shove the remaining nodes down the chain
|
||||||
|
for (int i = oldestIndex; i < *numNodes - 1; i++) {
|
||||||
|
nodes[i] = nodes[i + 1];
|
||||||
|
}
|
||||||
|
(*numNodes)--;
|
||||||
}
|
}
|
||||||
// add the node
|
// add the node at the end
|
||||||
info = &nodes[(*numNodes)++];
|
info = &nodes[(*numNodes)++];
|
||||||
|
|
||||||
// everything is missing except the nodenum
|
// everything is missing except the nodenum
|
||||||
@@ -679,9 +756,9 @@ void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *f
|
|||||||
String lcd = String("Critical error ") + code + "!\n";
|
String lcd = String("Critical error ") + code + "!\n";
|
||||||
screen->print(lcd.c_str());
|
screen->print(lcd.c_str());
|
||||||
if (filename)
|
if (filename)
|
||||||
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lx\n", code, filename, address);
|
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lu\n", code, filename, address);
|
||||||
else
|
else
|
||||||
DEBUG_MSG("NOTE! Recording critical error %d, address=%lx\n", code, address);
|
DEBUG_MSG("NOTE! Recording critical error %d, address=0x%lx\n", code, address);
|
||||||
|
|
||||||
// Record error to DB
|
// Record error to DB
|
||||||
myNodeInfo.error_code = code;
|
myNodeInfo.error_code = code;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user