Compare commits

...

203 commits
master ... main

Author SHA1 Message Date
31bebeee13 added @thunder 2025-06-30 22:22:35 +09:00
fe4b1f120b added 'buzz'
a tone generator.
2024-10-30 20:57:24 +09:00
0e0157db06 updated 'p'
more straightforward que generation.
2024-10-30 20:57:01 +09:00
410b42c303 added 'looping task'
- with looping_task enabled => audio will always keep playing. (non 
stop.)
2024-10-30 20:50:38 +09:00
dcf62905a2 trying different tabs 2 -> 4 2024-04-24 04:08:36 +09:00
ca9f217eaf taak - you can change pin# 2024-04-18 16:38:29 +09:00
96876c230c audioooo - small fix. 2024-04-18 16:37:07 +09:00
f7b0c0aa27 update 'p' (q without self-audio) 2023-09-19 23:32:42 +09:00
56b05e6a3d mubupu 2022-12-19 14:51:21 +09:00
02e443984b ... 2022-12-01 14:34:14 +09:00
f5a5615e24 walking towards the flow @ SEMA - init 2022-11-26 23:45:45 +09:00
e6e8855c9f .. last changes 2022-11-26 22:47:42 +09:00
05a780a72e [조]금 [쓸]쓸한 독백과 [언]제나 [다]정한 [노]래들 - init 2022-11-23 16:16:03 +09:00
92f504caa5 atm2022 init 2022-10-21 03:07:04 +09:00
61ebc041da add .python-version to .gitignore 2022-10-20 18:33:09 +09:00
d8d4e30cd3 저 너머로의 발걸음 - 추가 공연.. (기본 볼륨 상향 조정) 2022-06-17 21:57:55 +09:00
62ed878b69 .. little more update 2022-06-14 19:33:45 +09:00
4c16300556 some machine couldn't bear with [comport -1] -> changed [comport 99] 2022-06-14 19:32:53 +09:00
735658d964 .. update. 2022-06-14 18:08:12 +09:00
0977c5cc2e 점, 곁에서 말하는 점들 @ 코리아나미술관, 2022.06.13 - first release 2022-06-13 17:14:02 +09:00
dcd149b878 update roller2
+ onoff==2 mode: timed torque driving. (use X1 extra. para.)
2022-06-11 18:56:48 +09:00
f2fbd68bf5 update gonggong servo raw timing signal added 2022-06-11 18:53:14 +09:00
4fca7fc789 무엇의 숲 @ 탈영역 우정국 / 2021.11.05 2022-06-07 13:39:43 +09:00
9063eeeb80 `hing 01 @ 다이애나밴드 studio - pd patch 2022-06-07 13:36:42 +09:00
9025b1cdec 돌깨는 잠, 숨짓는 숲 pd patch @ 2021 신촌극장 2022-06-07 13:31:52 +09:00
1d693b99bb pwm range prob. resolved. @ roller - especially for 'rounder' 2022-06-07 02:38:31 +09:00
98da7d670c stop comport opening port 0 -> -1 2022-06-06 19:01:51 +09:00
b6579f8196 q update 2022-05-29 00:12:50 +09:00
2b7e778bf2 q update 2022-05-27 23:52:25 +09:00
f68c861c79 q update 2022-05-27 14:01:36 +09:00
bf06a72aa1 default volume preset 2022-05-26 14:35:49 +09:00
53ad1c9504 add individual volume control for teensy 2022-05-21 05:51:32 +09:00
d1512da5dc disable recursive listing for faster boot-up 2022-05-21 05:37:33 +09:00
04524cabb3 added individual volume control
+ n.onoff == 2, special msg.
+ n.velocity == 0 => leave vol as is.
2022-05-21 05:19:13 +09:00
08c2188fce relax onoff field (0|1) => unlimited. 2022-05-21 05:17:40 +09:00
886066374a q update 2022-05-21 04:49:09 +09:00
ad8bc3adc4 audioooo update 2022-05-19 15:03:23 +09:00
ea6b588be9 osc/ for esp8266 & makepython-esp32
+ enable OSC bundle tag processing (a bug fix. endianness problem)
2022-05-07 15:31:03 +09:00
345ec0925e tidy up 2022-05-07 15:26:38 +09:00
fa1acde77b rename osc8266/ -> osc/
+ (planned) add support for esp32
2022-05-04 15:50:38 +09:00
f61aee2c5f obsolete osc/ -> @osc/
- for osc(pd) we don't need teensy+esp8266 anymore.
+ (planned) rename osc8266 to be osc and add support for esp32 too.
2022-05-04 15:46:38 +09:00
fa4cb573d1 revised '@bell'
- now support 'live' angles w/ x1, x2
2022-05-04 00:43:00 +09:00
4d5bc1a114 update 'taak'
+ replicate note
+ addressbook
2022-04-27 21:01:32 +09:00
288ddd88d5 updates for simpler communication
+ peer book listing (debug)
+ no addressbook/peer list -> all go broadcast!
+ wifi_channel == 1 for later 
(https://github.com/espressif/arduino-esp32/issues/878#issuecomment-578885352)
2022-04-26 10:40:54 +09:00
7db9b9a374 revised esp32<->esp32 broadcast comm. 2022-04-26 01:47:29 +09:00
85ed754955 re-enable archived addressbook. for TESTING 2022-04-26 01:17:47 +09:00
590cfbedfc added gong1 2021-10-13 13:48:01 +09:00
6081661e73 . 2021-10-13 12:54:15 +09:00
30e90fdfe2 add p (qlist sender)
- q sender but doesn't play itself.
- hold a complex q list
2021-10-10 09:30:57 +09:00
73f17f0ebe .. 2021-10-08 15:21:10 +09:00
5ccae80ea8 don't send msg. 20000 0 0 0
- this brakes all modules' stabilities
- send 20000 30 0 0
- we need to be sure that the 'pitch' to be exist. here 000.wav doesn't 
exist. but 030.wav surely exists.
2021-10-08 14:33:07 +09:00
Dooho Yi
7d7f469d0f 0set 2021-10-08 14:25:33 +09:00
1daa4a5868 a patch for @sampler stability + speaker idle noise malfunction issue
+ just don't give it message w/ note == 0. that breaks audio loop. and 
don't reach actual player.stop()
2021-10-08 08:32:53 +09:00
149b21e64a code arrange 2021-10-08 08:24:27 +09:00
a831a59dd4 idel noise bug fix - testing 2021-10-07 06:38:42 +09:00
b7315afc9b 0set v1.2
add final scene volume increase
2021-10-05 03:37:04 +09:00
f1fec7992d 0set v1.1 update 2021-10-04 23:52:24 +09:00
6ed99551ea roundly bug fix 2021-10-04 18:45:02 +09:00
21a3209625 0set v1 2021-10-02 11:43:38 +09:00
66582b4c28 @postman network func. upd.
support burst repeat -> use of 'recent list'
2021-10-02 11:43:27 +09:00
88933fd25d 0set puredata final v0 2021-10-01 20:19:58 +09:00
a92a0ac7c5 more sophiscated idle_noise (1 sec / every 1 min) 2021-10-01 17:48:22 +09:00
4eb8ef9deb @sampler upd 2021-09-30 22:00:10 +09:00
1e2dea3bab disabled print info 2021-09-30 18:27:25 +09:00
a5770d0a36 0set pd upd 2021-09-30 17:32:54 +09:00
1c4ea89fd0 @sampler idle_noise activate 2021-09-30 17:32:34 +09:00
76f0edabd9 @sampler upd 2021-09-30 16:48:11 +09:00
9bdbdc3926 0set pd patch upd 2021-09-30 16:25:56 +09:00
080ba731b4 @sample upd 2021-09-30 14:52:21 +09:00
5121ce427a 0set testing. 2021-09-27 14:05:58 +09:00
e5b0fc9b83 @postman groupid chg. 2021-09-27 13:04:09 +09:00
3e16eabaf3 better ui init message for audioooo 2021-09-22 19:20:23 +09:00
31d16adf3e ui upd audioooo 2021-09-22 19:02:52 +09:00
be3679162b added volume control for audioooo 2021-09-22 18:58:19 +09:00
f0fec17db8 . 2021-09-07 21:44:45 +09:00
2e8fdd05b7 osc8266
pd osc interface without teensy!
2021-09-07 21:39:47 +09:00
632be4da1f 're-triggering filter-out' re-enabled. 2021-08-25 21:29:09 +09:00
b219e19eb4 update 109(beakgu) 5percent exhibition 2021-08-24 18:24:21 +09:00
d4a217df11 .. 2021-07-07 16:50:30 +09:00
c32ab07980 added xylophone * 5 for fragments1444 (wip) 2021-06-22 21:20:58 +09:00
d353a2f0f2 postman now collects also 'Hello' msg. (WIP) 2021-06-22 20:06:54 +09:00
a259d5116a roller2 pin 7/8 => 2/3
- don't use pin 8, that's used for boot mode selection!
2021-06-21 23:30:33 +09:00
89bd38be01 roller w/ 2 motors (wip) 2021-06-21 18:20:06 +09:00
6c8be8c1be . 2021-06-17 12:38:30 +09:00
7843e1a0c6 . bugfix 2021-06-17 12:24:32 +09:00
ff99cf2a16 teensy players => amp down to 20% 2021-06-17 12:21:43 +09:00
6188746811 q player wav -> mp3 2021-06-15 12:01:38 +09:00
3ef00c2221 upd q 2021-06-14 19:06:56 +09:00
808787c134 added addressbook alt 2021-06-14 19:03:34 +09:00
8785309bd4 address book upd
+ removed 'sampler #f' from the address book.
+ added 'sender (q)' back again.

=> sender must monitor the network. so open their ears back.
2021-06-14 17:45:33 +09:00
bca30fa34e @sampler re-trigger filter for same '
note'
2021-06-14 17:30:20 +09:00
87fcb123bf upd 2021-06-14 17:23:14 +09:00
f66d5315f7 teensy/esp8266 update
+ replicate msg. added.
2021-06-13 14:56:06 +09:00
40f7c3503e q tested. 2021-06-13 14:55:10 +09:00
3f63314172 update @sampler/@postman 2021-06-13 02:30:27 +09:00
5816f4d62a added 'q'
- the sequencer.
2021-06-13 00:32:37 +09:00
d709fe9850 audioooo file format chg. wav -> mp3
- w/ wav files. bad sound at end
- w/ mp3 files. no such prob.
2021-06-13 00:32:15 +09:00
96d3fbcecc audioooo update. sd err msg on lcd. 2021-06-12 22:33:08 +09:00
2536e090ad audioooo update. added. replication support. + address book explicited. 2021-06-12 22:22:18 +09:00
ecbcbbeb50 audioooo done. w/ a debug monitoring screen. 2021-06-12 18:56:35 +09:00
334ab57f4a esp32 based sampler 'audioooo' added. (wip) 2021-05-29 14:27:43 +09:00
9bca5aaa35 roundly 'moving' added. 2021-05-06 23:18:38 +09:00
11e21ba386 testing 2021-05-05 12:22:51 +09:00
ba8623b286 testing... 2021-05-04 13:24:46 +09:00
9cecb4baa0 testing.. 2021-05-04 13:21:38 +09:00
8df3217731 watcher added @ roller 2021-04-08 21:23:40 +09:00
cc3a3b583d upd 2021-04-08 11:41:16 +09:00
4f9bb32b3d upd 2021-04-08 11:36:21 +09:00
7ac2936ad2 upd 2021-04-08 11:15:52 +09:00
09f042ba04 upd 2021-04-07 11:03:04 +09:00
318bb24a8c upd 2021-04-07 10:53:52 +09:00
ad246c9ec7 upd 2021-04-07 10:35:13 +09:00
0d041c8c17 upd 2021-04-07 10:21:28 +09:00
c03bb408be upd / E_SEQ -> STRESS change <= disable. 2021-04-07 02:27:13 +09:00
1201a8fbc5 upd..(wip) 2021-04-07 00:12:49 +09:00
9d5b7cc4c2 upd 2021-04-05 13:09:57 +09:00
76cfcc7ef5 upd 2021-04-05 10:48:38 +09:00
59d45add35 check if connected, before sending. 2021-03-31 13:15:55 +09:00
0ce9c1f31a upd. 2021-03-31 00:06:54 +09:00
1070afa6b7 roomA ver2 prepared. (not released yet) 2021-03-25 23:38:51 +09:00
c4b74bf6d1 upd 2021-03-20 22:44:59 +09:00
378c271461 upd 2021-03-20 22:40:32 +09:00
dd6d763efe upd 2021-03-20 22:06:55 +09:00
af2d048f15 upd 2021-03-20 22:04:14 +09:00
c5c61056c4 main patch rename 2021-03-20 21:33:47 +09:00
e3a67c6336 upd 2021-03-20 21:10:02 +09:00
c590631b8a upd 2021-03-20 12:02:17 +09:00
f4e2410c1c upd 2021-03-20 09:54:51 +09:00
dad0a7ef53 correction of the name of exhibition place
"SEMA warehouses" -> "SEMA storage"
2021-03-19 23:30:02 +09:00
9ad0bde82c upd 2021-03-19 11:07:11 +09:00
e3aef157fa final ver.1 2021-03-19 10:56:51 +09:00
e1e11a2eb5 wonj update. room2 done. 2021-03-18 02:22:16 +09:00
459419529d wonj update. (wip) 2021-03-17 14:20:55 +09:00
a687b74dcc wonj 2021-03-14 11:53:32 +09:00
d47301e7a2 revert riff.pd 2021-03-14 11:51:14 +09:00
7db692918a .. 2021-03-14 11:34:51 +09:00
09d9e3b507 retro modified (outlet added) 2021-03-10 04:38:32 +09:00
521ce47f92 rational pattern array mix added. 2021-03-10 04:36:49 +09:00
0300a426a9 constellations added
+ line draw planet1-2
2021-03-10 01:33:06 +09:00
f6b9cc84b5 disable_ap for taak. (spk. noise)
but, why not all disable ap? this will save power consumption in 
general.
2021-03-09 18:46:11 +09:00
c70cfee2b4 taak3 added 2021-03-09 18:45:15 +09:00
e21e715f09 concept 'bin' start. 2021-03-09 18:43:47 +09:00
45d9558fa5 planet simulation for sequencing 2021-03-09 18:00:48 +09:00
a5d923efda . 2021-02-25 15:14:57 +09:00
338cfe72a5 * 2021-02-25 13:36:03 +09:00
075c4ac0bb ** 2021-02-24 23:18:55 +09:00
03d1a63a1e * 2021-02-24 23:14:04 +09:00
86e85fe352 . 2021-02-24 23:13:35 +09:00
8106e776e9 riff update 2021-02-24 23:10:50 +09:00
d19ad30d8c roller added (bi-directional cricket) 2021-02-24 22:20:57 +09:00
349d0e5680 pd dhy ver. 2021-02-23 23:25:44 +09:00
5efb074cbe id update
+ some more cri
2021-02-23 22:57:16 +09:00
e60a345c6f won update 2021-02-23 22:16:05 +09:00
c5611c1eae riff update 2021-02-23 21:57:24 +09:00
c715c2e500 id update. 2021-02-23 20:34:29 +09:00
17ece89564 pwm freq. 1khz (default) --> 40khz (max.) 2021-02-23 20:24:06 +09:00
a4cb108b03 . 2021-02-23 15:51:01 +09:00
a544a59547 id update 2021-02-23 15:17:58 +09:00
a089f6a157 pd update 2021-02-23 01:41:39 +09:00
5cdcc80fa5 pd update 2021-02-22 23:11:31 +09:00
37304490ab cricket update 2021-02-22 22:47:54 +09:00
fad7a9ddff pd updated 2021-02-22 22:12:35 +09:00
899948a71a id & gid applied/arranged for all. 2021-02-22 19:41:46 +09:00
37e5ad8562 (done) broadcast testing.
+ sometimes... messages dropped. but.. it is acceptable.
+ let's move on!
2021-02-22 17:20:57 +09:00
9df611f361 (wip) broadcast testing... 2021-02-22 03:21:55 +09:00
4a507b2372 everyone ==> broadcast ! 2021-02-21 23:44:41 +09:00
355a033738 broadcast tx -> rx esp8266 tested. IT WORKS. 2021-02-21 22:59:19 +09:00
86432d1cc4 @sampler revised. preserve I2C i/f + esp now enabled 2021-02-21 13:01:16 +09:00
774865b639 AddressLibrary added 2021-02-21 12:58:32 +09:00
591888b611 remove example proj. bye2 2021-02-18 21:59:41 +09:00
42a96a435a archived some + modify readme a bit. 2021-02-18 21:58:26 +09:00
62b70d407b addr 2021-02-18 21:46:02 +09:00
1cd58477a4 gonggong updated 2021-02-18 21:31:53 +09:00
3beb447cde rename gastank -> gonggong 2021-02-18 20:50:15 +09:00
1602bc0003 addr 2021-02-18 20:45:36 +09:00
3672180b3e addr 2021-02-18 20:31:57 +09:00
24e81f304b addr 2021-02-18 20:21:29 +09:00
49a366f381 address update 2021-02-18 18:46:01 +09:00
9c76b29277 crickets 2021-02-18 17:57:30 +09:00
3ab0e825eb /note now all floats. 2021-02-17 19:21:28 +09:00
c1a471b6bb roundly migrated. 2021-02-17 17:55:10 +09:00
3bf8314f2e osc bug fix 2021-02-17 17:54:41 +09:00
7fc7eb2719 .. 2021-02-17 14:09:57 +09:00
ad480b753b peer addressbook added 2021-02-17 14:06:06 +09:00
d1f537f002 tx pseudo-broadcast using peer-list 2021-02-17 03:53:01 +09:00
42606a34da slower blinks 2021-02-17 03:22:25 +09:00
b33f9e4e6b taak update (espnow) 2021-02-17 03:08:01 +09:00
0c1441cb86 osc -> esp_now verified
- 20ms tx successful! very fast.
2021-02-17 02:16:39 +09:00
1a50d9b5cf taak update. 2021-02-16 13:43:04 +09:00
8fa1ee7f54 . 2021-02-16 13:42:51 +09:00
12d0a2dd5f speed test esp_now --> very good. 2021-02-16 12:48:58 +09:00
50bac35c13 postman<->teensy comm. updated (I2C --> Serial) 2021-02-15 21:09:20 +09:00
615a6eeab9 roundly resting task added. 2021-02-14 19:24:49 +09:00
47a05f3ac5 roundly update
+ fact 1: we cannot use D1-D4 set. (D2 for LED, D4 for TXD1)
+ fact 2: using D5-D8 set again. (N.B. but to get proper stepping 
sequence w/ accelstepper lib. u need to CROSS D6 and D7 wiring, 
otherwise very poor torque & uni-directional not sane movements.)
2021-02-06 00:53:14 +09:00
cd05b27dbb roundly added 2021-02-05 20:08:43 +09:00
65c4570eef crickets (d1_mini_pro) 2021-01-31 16:37:32 +09:00
ca8605fd1f added taak. 2021-01-22 22:04:08 +09:00
e7b2da3246 added gastank side -> set angle action. (102) 2021-01-20 23:53:45 +09:00
dad6aa2ea4 added support for WeMos board. 2021-01-20 23:20:37 +09:00
928008ad10 (--> tested) 2021-01-11 21:19:49 +09:00
ba2010203e added eXtra parameter send (not tested yet.) 2021-01-11 03:51:10 +09:00
6389953b8c last MMCA update (performance @ Museum for All, Museum for Dogs) 2021-01-11 01:27:26 +09:00
42b0294090 branchnamechg 2021-01-10 20:02:18 +09:00
1807 changed files with 258258 additions and 2384 deletions

1
.gitignore vendored
View file

@ -42,3 +42,4 @@
.pio/* .pio/*
members/*/.pio/ members/*/.pio/
members/*/.pio/* members/*/.pio/*
.python-version

172
0-set-group.list Normal file
View file

@ -0,0 +1,172 @@
==== ADDRESSBOOK ====
1- my id: 20001, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:0A:07, channel: 5
2- my id: 20002, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: EC:FA:BC:63:19:84, channel: 5
3- my id: 20003, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 98:F4:AB:B3:B4:19, channel: 5
4- my id: 20004, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 98:F4:AB:B3:B4:DD, channel: 5
5- my id: 20005, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: BC:DD:C2:14:74:D2, channel: 5
6- my id: 20006, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: BC:DD:C2:14:75:6F, channel: 5
7- my id: 20007, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:45:F5, channel: 5
8- my id: 20008, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 84:CC:A8:A3:A7:B5, channel: 5
9- my id: 20009, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:11:E6, channel: 5
a- my id: 20010, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: BC:DD:C2:14:63:8E, channel: 5
b- my id: 20011, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 98:F4:AB:B3:BA:44, channel: 5
c- my id: 20012, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 5C:CF:7F:B8:B6:80, channel: 5
d- my id: 20013, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:18:AE, channel: 5
e- my id: 20014, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 98:F4:AB:B3:B5:C2, channel: 5
f- my id: 20015, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:37:AE, channel: 5
g- my id: 20016, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: BC:DD:C2:B2:AF:D4, channel: 5
h- my id: 20017, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 68:C6:3A:D5:3E:F3, channel: 5
i- my id: 20018, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: B4:E6:2D:37:09:92, channel: 5
j- my id: 20019, gid: 20000, call me ==> "@POSTMAN|@SAMPLER"- mac address: 5C:CF:7F:B7:55:98, channel: 5
repeaters
10- my id: 21010, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: A8:48:FA:CD:29:76, channel: 5
11- my id: 21011, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 30:83:98:B1:D2:66, channel: 5
12- my id: 21012, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 30:83:98:B2:77:E6, channel: 5
13- my id: 21013, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 30:83:98:B2:6C:7B, channel: 5
14- my id: 21014, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 60:01:94:38:20:5B, channel: 5
15- my id: 21015, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: A8:48:FA:CD:47:84, channel: 5
16- my id: 21016, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: A8:48:FA:CD:43:A7, channel: 5
17- my id: 21017, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: B4:E6:2D:37:3B:90, channel: 5
18- my id: 21018, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: A8:48:FA:CD:1C:53, channel: 5
19- my id: 21019, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 80:7D:3A:58:87:2D, channel: 5
20- my id: 21020, gid: 20000, call me ==> "@POSTMAN|REPEATER"- mac address: 30:83:98:B1:18:B4, channel: 5
==== GROUPS ====
[slopeway] => 5 11 8 12 a + c 2 13 4 i j e f 19 7 6
5 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:74:D2
11 : "@POSTMAN|REPEATER" => 30:83:98:B1:D2:66
8 : "@POSTMAN|@SAMPLER" => 84:CC:A8:A3:A7:B5
12 : "@POSTMAN|REPEATER" => 30:83:98:B2:77:E6
a : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:63:8E
+
c : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B8:B6:80
2 : "@POSTMAN|@SAMPLER" => EC:FA:BC:63:19:84
13 : "@POSTMAN|REPEATER" => 30:83:98:B2:6C:7B
4 : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B4:DD
i : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:09:92
j : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B7:55:98
e : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B5:C2
f : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:37:AE
19 : "@POSTMAN|REPEATER" => 80:7D:3A:58:87:2D
7 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:45:F5
6 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:75:6F
+
broadcast
----------------
[1st floor] => c 2 10 b 14 3 + slopeway(5 11 8 12 a)
c : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B8:B6:80
2 : "@POSTMAN|@SAMPLER" => EC:FA:BC:63:19:84
10 : "@POSTMAN|REPEATER" => A8:48:FA:CD:29:76
b : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:BA:44
14 : "@POSTMAN|REPEATER" => 60:01:94:38:20:5B
3 : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B4:19
+
5 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:74:D2
11 : "@POSTMAN|REPEATER" => 30:83:98:B1:D2:66
8 : "@POSTMAN|@SAMPLER" => 84:CC:A8:A3:A7:B5
12 : "@POSTMAN|REPEATER" => 30:83:98:B2:77:E6
a : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:63:8E
+
broadcast
----------------
[2nd floor] => 4 j i 13 e f h + slopeway(5 11 8 12 a) + bridge(15 16 1 17)
4 : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B4:DD
j : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B7:55:98
i : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:09:92
13 : "@POSTMAN|REPEATER" => 30:83:98:B2:6C:7B
e : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B5:C2
f : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:37:AE
h : "@POSTMAN|@SAMPLER" => 68:C6:3A:D5:3E:F3
+
5 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:74:D2
11 : "@POSTMAN|REPEATER" => 30:83:98:B1:D2:66
8 : "@POSTMAN|@SAMPLER" => 84:CC:A8:A3:A7:B5
12 : "@POSTMAN|REPEATER" => 30:83:98:B2:77:E6
a : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:63:8E
+
15 : "@POSTMAN|REPEATER" => A8:48:FA:CD:47:84
16 : "@POSTMAN|REPEATER" => A8:48:FA:CD:43:A7
1 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:0A:07
17 : "@POSTMAN|REPEATER" => B4:E6:2D:37:3B:90
+
broadcast
----------------
[bridge] => 15 16 1 17 + h 13 18 9
15 : "@POSTMAN|REPEATER" => A8:48:FA:CD:47:84
16 : "@POSTMAN|REPEATER" => A8:48:FA:CD:43:A7
1 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:0A:07
17 : "@POSTMAN|REPEATER" => B4:E6:2D:37:3B:90
+
h : "@POSTMAN|@SAMPLER" => 68:C6:3A:D5:3E:F3
13 : "@POSTMAN|REPEATER" => 30:83:98:B2:6C:7B
18 : "@POSTMAN|REPEATER" => A8:48:FA:CD:1C:53
9 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:11:E6
+
broadcast
----------------
[2nd floor annex] => 18 g 9 + bridge(15 16 1 17)
18 : "@POSTMAN|REPEATER" => A8:48:FA:CD:1C:53
g : "@POSTMAN|@SAMPLER" => BC:DD:C2:B2:AF:D4
9 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:11:E6
+
15 : "@POSTMAN|REPEATER" => A8:48:FA:CD:47:84
16 : "@POSTMAN|REPEATER" => A8:48:FA:CD:43:A7
1 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:0A:07
17 : "@POSTMAN|REPEATER" => B4:E6:2D:37:3B:90
+
broadcast
----------------
[3rd floor] => 7 19 20 6 d + slopeway(5 11 8 12 a)
7 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:45:F5
19 : "@POSTMAN|REPEATER" => 80:7D:3A:58:87:2D
20 : "@POSTMAN|REPEATER" => 30:83:98:B1:18:B4
6 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:75:6F
d : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:18:AE
+
5 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:74:D2
11 : "@POSTMAN|REPEATER" => 30:83:98:B1:D2:66
8 : "@POSTMAN|@SAMPLER" => 84:CC:A8:A3:A7:B5
12 : "@POSTMAN|REPEATER" => 30:83:98:B2:77:E6
a : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:63:8E
----------------
1 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:0A:07 [bridge]
2 : "@POSTMAN|@SAMPLER" => EC:FA:BC:63:19:84 [1st floor]
3 : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B4:19 [1st floor]
4 : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B4:DD [2nd floor]
5 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:74:D2 [slopeway]
6 : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:75:6F [3rd floor]
7 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:45:F5 [3rd floor]
8 : "@POSTMAN|@SAMPLER" => 84:CC:A8:A3:A7:B5 [slopeway]
9 : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:11:E6 [2nd floor annex]
a : "@POSTMAN|@SAMPLER" => BC:DD:C2:14:63:8E [slopeway]
b : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:BA:44 [1st floor]
c : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B8:B6:80 [1st floor]
d : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:18:AE [3rd floor]
e : "@POSTMAN|@SAMPLER" => 98:F4:AB:B3:B5:C2 [2nd floor]
f : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:37:AE [2nd floor]
g : "@POSTMAN|@SAMPLER" => BC:DD:C2:B2:AF:D4 [2nd floor annex]
h : "@POSTMAN|@SAMPLER" => 68:C6:3A:D5:3E:F3 [2nd floor]
i : "@POSTMAN|@SAMPLER" => B4:E6:2D:37:09:92 [2nd floor]
j : "@POSTMAN|@SAMPLER" => 5C:CF:7F:B7:55:98 [2nd floor]
10 : "@POSTMAN|REPEATER" => A8:48:FA:CD:29:76 [1st floor]
11 : "@POSTMAN|REPEATER" => 30:83:98:B1:D2:66 [slopeway]
12 : "@POSTMAN|REPEATER" => 30:83:98:B2:77:E6 [slopeway]
13 : "@POSTMAN|REPEATER" => 30:83:98:B2:6C:7B [2nd floor]
14 : "@POSTMAN|REPEATER" => 60:01:94:38:20:5B [1st floor]
15 : "@POSTMAN|REPEATER" => A8:48:FA:CD:47:84 [bridge]
16 : "@POSTMAN|REPEATER" => A8:48:FA:CD:43:A7 [bridge]
17 : "@POSTMAN|REPEATER" => B4:E6:2D:37:3B:90 [bridge]
18 : "@POSTMAN|REPEATER" => A8:48:FA:CD:1C:53 [2nd floor annex]
19 : "@POSTMAN|REPEATER" => 80:7D:3A:58:87:2D [3rd floor]
20 : "@POSTMAN|REPEATER" => 30:83:98:B1:18:B4 [3rd floor]

45
@bell/platformio.ini Normal file
View file

@ -0,0 +1,45 @@
; < NOTE >
; to enable verbose output add option -->
; $ platformio run --verbose
; to make this permanent for the proj. -->
; $ platformio settings set force_verbose Yes
; then confirm the change -->
; $ platformio settings get
; // pio v 4.0 'Build options'
; - build_type
; - build_flags
; - src_build_flags
; - build_unflags
; - src_filter
; - targets
[platformio]
default_envs = nodemcuv2
[env]
framework = arduino
upload_port =
/dev/ttyUSB0
/dev/tty.SLAB_USBtoUART
lib_deps =
721 ; TaskScheduler
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
lib_deps =
${env.lib_deps}
upload_speed = 921600 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
lib_deps =
${env.lib_deps}
upload_speed = 460800 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600

524
@bell/src/main.cpp Normal file
View file

@ -0,0 +1,524 @@
//
// wirelessly connected cloud (based on ESP-NOW, a kind of LPWAN?)
//
//
// `hing @ dianaband studio, Seoul
//
//
// 2021 02 15
//
// this module will be an esp-now node in a group.
// like, a bird in a group of birds.
//
// esp-now @ esp8266 w/ broadcast address (FF:FF:FF:FF:FF:FF)
// always broadcasting. everyone is 'talkative'.
//
// then, let it save a value in EEPROM (object with memory=mind?)
//============<identities>============
//
#define MY_GROUP_ID (11000)
#define MY_ID (MY_GROUP_ID + 1)
#define MY_SIGN ("BELL")
#define ADDRESSBOOK_TITLE ("broadcast only")
//
//============</identities>============
//==========<list-of-configurations>===========
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
//
// 'SERIAL_SWAP'
// --> UART pin swapped.
// you want this, when you want a bi-directional comm. to external client boards (e.g. teensy).
//
// 'DISABLE_AP'
// --> (questioning)...
//
// 'REPLICATE_NOTE_REQ' (+ N_SEC_BLOCKING_NOTE_REQ)
// --> for supporting wider area with simple esp_now protocol,
// all receipents will replicate NOTE msg. when they are newly appeared.
// + then, network would be flooded by infinite duplicating msg.,
// unless they stop reacting to 'known' req. for some seconds. (e.g. 3 seconds)
// 'HAVE_CLIENT_I2C'
// --> i have a client w/ I2C i/f. enable the I2C client task.
//
// 'ADDRESSBOOK_TITLE'
// --> peer list limited max. 20.
// so, we might use different address books for each node to cover a network of more than 20 nodes.
//
//==========</list-of-configurations>==========
//
// (EMPTY)
#define DISABLE_AP
// #define REPLICATE_NOTE_REQ
//============<bell>============
#define BELL_HIT_KEY 105
//============</bell>===========
//============<parameters>============
//
#define LED_PERIOD (11111)
#define LED_ONTIME (1)
#define LED_GAPTIME (222)
//
#define WIFI_CHANNEL 1
//
// 'MONITORING_SERIAL'
//
// --> sometimes, the 'Serial' is in use (for example, 'osc' node)
// then, use 'Serial1' - D4/GPIO2/TDX1 @ nodemcu (this is TX only.)
//
// --> otherwise, MONITORING_SERIAL == Serial.
//
#if defined(SERIAL_SWAP)
#define MONITORING_SERIAL (Serial1)
#else
#define MONITORING_SERIAL (Serial)
#endif
//
//============</parameters>===========
//============<board-specifics>============
#if defined(ARDUINO_FEATHER_ESP32) // featheresp32
#define LED_PIN 13
#else
#define LED_PIN 2
#endif
//============</board-specifics>===========
//arduino
#include <Arduino.h>
//post & addresses
#include "../../post.h"
//vector
#include <vector>
std::vector<Note> recentNotes;
//espnow
#include <ESP8266WiFi.h>
#include <espnow.h>
AddressLibrary lib;
//task
#include <TaskScheduler.h>
Scheduler runner;
//
#if defined(REPLICATE_NOTE_REQ)
Note note_now = {
-1, // int32_t id;
-1, // float pitch;
-1, // float velocity;
-1, // float onoff;
-1, // float x1;
-1, // float x2;
-1, // float x3;
-1, // float x4;
-1 // float ps;
};
#define RECENT_NOTES_TIMEOUT (3000)
static unsigned long last_note_time = 0;
void recent_clear() {
//
if (millis() - last_note_time > RECENT_NOTES_TIMEOUT) {
recentNotes.clear();
Serial.println("recent list cleared");
last_note_time = millis();
}
//
}
Task recent_clear_task(100, TASK_FOREVER, &recent_clear, &runner, true);
#endif
//-*-*-*-*-*-*-*-*-*-*-*-*-
// servo
#include <Servo.h>
#define SERVO_PIN D6
Servo myservo;
int hitting_angle = 90;
int release_angle = 60;
int stabilize_angle = 53;
//
extern Task hit_task;
//
extern Task pcontrol_task;
bool pcontrol_new = false;
int pcontrol_start = 0;
int pcontrol_target = 0;
int control_count = 0;
//
extern Task servo_release_task;
// my tasks
// hit!
void hit() {
static int count = 0;
if (hit_task.isFirstIteration()) {
count = 0;
Serial.println("hit! start.");
}
if (count % 3 == 0) {
//
myservo.attach(SERVO_PIN);
myservo.write(release_angle);
// servo_release_task.restartDelayed(200);
//
} else if (count % 3 == 1) {
//
myservo.attach(SERVO_PIN);
myservo.write(hitting_angle);
// servo_release_task.restartDelayed(200);
//
Serial.print("bell, bell, bell! : ");
Serial.print(hitting_angle);
Serial.println(" deg.");
//
} else {
//
myservo.attach(SERVO_PIN);
myservo.write(release_angle);
servo_release_task.restartDelayed(200);
//
Serial.print("release to .. : ");
Serial.print(release_angle);
Serial.println(" deg.");
// start stablizing..
pcontrol_new = true;
pcontrol_start = release_angle;
pcontrol_target = stabilize_angle;
pcontrol_task.restartDelayed(80);
//
control_count = 0;
}
//
count++;
}
Task hit_task(100, 3, &hit);
// pcontrol
void pcontrol() {
static int angle;
if (pcontrol_new == true) {
pcontrol_new = false;
angle = pcontrol_start;
}
int error = pcontrol_target - angle;
int sign = (error >= 0 ? 1 : -1);
//
Serial.print("step-by-step to.. : ");
Serial.println(sign);
//
if (error != 0) {
angle = angle + sign; // most gentle move : 1 step each time.
//
Serial.print("stablizing in action ==> next angle : ");
Serial.print(angle);
Serial.println(" deg.");
//
myservo.attach(SERVO_PIN);
myservo.write(angle);
servo_release_task.restartDelayed(50);
pcontrol_task.restartDelayed(400);
}
else {
// stand-by processes
if (control_count % 2 == 0) {
pcontrol_new = true;
pcontrol_start = stabilize_angle;
pcontrol_target = release_angle;
pcontrol_task.restartDelayed(300);
} else if (control_count % 2 == 1) {
pcontrol_new = true;
pcontrol_start = release_angle;
pcontrol_target = stabilize_angle;
pcontrol_task.restartDelayed(300);
}
//
control_count++;
}
}
Task pcontrol_task(0, TASK_ONCE, &pcontrol); // hit -> 100ms -> step back -> 50ms -> slowly move to rest pos.
// pcontrol release
void servo_release() {
myservo.detach();
}
Task servo_release_task(0, TASK_ONCE, &servo_release);
//*-*-*-*-*-*-*-*-*-*-*-*-*
//
extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
byte mac[6];
WiFi.macAddress(mac);
uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
//
Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
// and you can append some floats
static int count = 0;
count++;
hello.h1 = (count % 1000);
// hello.h2 = 0;
// hello.h3 = 0;
// hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
frm[0] = '{';
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
// MONITORING_SERIAL.write(frm, frm_size);
// MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
void blink() {
//
static int count = 0;
count++;
//
switch (count % 4) {
case 0:
digitalWrite(LED_PIN, LOW); // first ON
blink_task.delay(LED_ONTIME);
break;
case 1:
digitalWrite(LED_PIN, HIGH); // first OFF
blink_task.delay(LED_GAPTIME);
break;
case 2:
digitalWrite(LED_PIN, LOW); // second ON
blink_task.delay(LED_ONTIME);
break;
case 3:
digitalWrite(LED_PIN, HIGH); // second OFF
blink_task.delay(LED_PERIOD - 2* LED_ONTIME - LED_GAPTIME);
break;
}
}
Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start-up.
// on 'Note'
void onNoteHandler(Note & n) {
//is it for me?
if (n.id == MY_GROUP_ID || n.id == MY_ID) {
//
if (n.pitch == BELL_HIT_KEY) {
if (n.onoff == 1) {
hitting_angle = n.velocity;
release_angle = n.x1;
stabilize_angle = n.x2;
hit_task.restartDelayed(10);
}
}
}
}
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
//
//MONITORING_SERIAL.write(incomingData, len);
//
#if defined(HAVE_CLIENT)
Serial.write(incomingData, len); // we pass it over to the client.
#endif
// open => identify => use.
if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
Hello hello("");
memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
//
MONITORING_SERIAL.println(hello.to_string());
//
}
// open => identify => use.
if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) &note, incomingData + 1, sizeof(Note));
onNoteHandler(note);
//is it for me?
if (note.id == MY_GROUP_ID || note.id == MY_ID) {
hello_delay = note.ps;
if (hello_delay > 0 && hello_task.isEnabled() == false) {
hello_task.restart();
}
}
MONITORING_SERIAL.println(note.to_string());
#if defined(REPLICATE_NOTE_REQ)
last_note_time = millis(); //clear timer reset : the recent list holding (re)started
// check if this note is in the list?
bool check = false;
for (uint32_t idx = 0; idx < recentNotes.size(); idx++) {
if (recentNotes[idx].pitch == note.pitch && recentNotes[idx].id == note.id) {
check = true;
}
}
// if not, add this into the list and repeat!
if (check == false) {
//
recentNotes.push_back(note);
//
uint8_t frm_size = sizeof(Note) + 2;
uint8_t frm[frm_size];
frm[0] = '[';
memcpy(frm + 1, (uint8_t *) &note, sizeof(Note));
frm[frm_size - 1] = ']';
//
esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.print("repeat! ==> ");
MONITORING_SERIAL.println(note.to_string());
//
}
//EMERGENCY PATCH.HACK:
// original code is not intended for a BURST of notes.
// so, only 1 msg. will be repeated in 3 sec. all others will be simply ignored.
// to make a burst of msgs repeatible:
// --> make a list of recent 'pitches'
// if there is any new msg. check if this is in the list, if not, add it & repeat, if yes, skip it.
// after 3sec no new msg., the list will be flushed. every new msg. will reset timeout + save the list for extra. 3 sec.
#endif
}
}
// on 'sent'
void onDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
char buff[256] = "";
sprintf(buff, "Delivery failed! -> %02X:%02X:%02X:%02X:%02X:%02X", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
if (sendStatus != 0) MONITORING_SERIAL.println(buff);
}
//
void setup() {
//led
pinMode(LED_PIN, OUTPUT);
//serial
Serial.begin(115200);
delay(100);
//info
Serial.println();
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
Serial.println("- ======== 'DISABLE_AP' ========");
#endif
#if defined(HAVE_CLIENT_I2C)
Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
#if defined(REPLICATE_NOTE_REQ)
Serial.println("- ======== 'REPLICATE_NOTE_REQ' ========");
#endif
Serial.println("-");
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
#if defined(DISABLE_AP)
system_phy_set_max_tpw(0);
node_type = WIFI_STA;
#endif
WiFi.mode(node_type);
//esp-now
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
// Serial.println("- ! (esp_now_add_peer) ==> add a 'broadcast peer' (FF:FF:FF:FF:FF:FF).");
// uint8_t broadcastmac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// esp_now_add_peer(broadcastmac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
AddressBook * book = lib.getBookByTitle(ADDRESSBOOK_TITLE);
if (book == NULL) {
Serial.println("- ! wrong book !! : \"" + String(ADDRESSBOOK_TITLE) + "\""); while(1);
}
for (int idx = 0; idx < book->list.size(); idx++) {
Serial.println("- ! (esp_now_add_peer) ==> add a '" + book->list[idx].name + "'.");
#if defined(ESP32)
esp_now_peer_info_t peerInfo = {};
memcpy(peerInfo.peer_addr, book->list[idx].mac, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
esp_now_add_peer(&peerInfo);
#else
esp_now_add_peer(book->list[idx].mac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
#endif
}
// (DEBUG) fetch full peer list
{ PeerLister a; a.print(); }
//
Serial.println("-");
Serial.println("\".-.-.-. :)\"");
Serial.println();
#if defined(SERIAL_SWAP)
Serial.println("- ======== 'SERIAL_SWAP' ========");
// a proper say goodbye.
Serial.println("\"bye, i will do 'swap' in 1 second. find me on alternative pins!\"");
Serial.println("\" hint: osc wiring ==> esp8266(serial.swap) <-> teensy(serial3)\"");
Serial.println("-");
Serial.println("\".-.-.-. :)\"");
delay(1000); // flush out unsent serial messages.
// moving...
Serial.swap(); // use RXD2/TXD2 pins, afterwards.
delay(100); // wait re-initialization of the 'Serial'
#endif
//tasks
runner.addTask(hit_task);
runner.addTask(pcontrol_task);
runner.addTask(servo_release_task);
}
void loop() {
//
runner.execute();
//
}

226
@osc/main_taskscheduler.cpp Normal file
View file

@ -0,0 +1,226 @@
//
// wirelessly connected cloud (Wireless Mesh Networking)
//
//
// Conversations about the ROOT @ SEMA storage, Seoul
//
//
// 2021 02 15
//
// (part-2) teensy35 : 'client:osc' (osc over slip --> mesh post)
//
//arduino
#include <Arduino.h>
//osc (already included in "framework-arduinoteensy")
#include <OSCBundle.h>
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial(Serial);
//post definition
#include "../../post.h"
//postman's uart
#define POSTMAN_SERIAL (Serial3)
//
void midinote(OSCMessage& msg, int offset) {
// matches will happen in the order. that the bundle is packed.
static int pitch = 0;
static int velocity = 0;
static int onoff = 0;
static int x1 = 0;
static int x2 = 0;
static int x3 = 0;
static int x4 = 0;
static int ps = 0;
// (1) --> /onoff
if (msg.fullMatch("/onoff", offset)) {
//
pitch = 0;
velocity = 0;
onoff = 0;
//
onoff = msg.getInt(0);
if (onoff != 0) onoff = 1;
}
// (2) --> /velocity
if (msg.fullMatch("/velocity", offset)) {
velocity = msg.getInt(0);
if (velocity < 0) velocity = 0;
// if (velocity > 127) velocity = 127;
if (velocity > 999) velocity = 999;
}
// (3) --> /pitch
if (msg.fullMatch("/pitch", offset)) {
pitch = msg.getInt(0);
if (pitch < 0) pitch = 0;
// if (pitch > 127) pitch = 127;
if (pitch > 999) pitch = 999;
}
// (4) --> /x
if (msg.fullMatch("/x", offset)) {
x1 = msg.getInt(0);
x2 = msg.getInt(1);
x3 = msg.getInt(2);
x4 = msg.getInt(3);
ps = msg.getInt(4);
char letter[POST_BUFF_LEN] = "";
snprintf(letter, POST_BUFF_LEN, "[%03d%03d%01dX%05d%05d%05d%05d%02d]",
pitch,
velocity,
onoff,
x1,
x2,
x3,
x4,
ps);
POSTMAN_SERIAL.print(letter);
}
}
//task
#include <TaskScheduler.h>
Scheduler runner;
void osc_listen () {
//
static OSCBundle bundleIN;
int size = 0;
while (!SLIPSerial.endofPacket()) {
if ((size = SLIPSerial.available()) > 0) {
while(size--) {
bundleIN.fill(SLIPSerial.read());
}
}
}
//
if(!bundleIN.hasError()) {
bundleIN.route("/note", midinote);
//
bundleIN.empty();
}
}
Task osc_listen_task(0, TASK_FOREVER, osc_listen, &runner, true); // aInterval == 0 >>> immediately re-schedule ?
//
// OSCBundle bundleIN;
// int size;
//
// while(!SLIPSerial.endofPacket())
// if( (size =SLIPSerial.available()) > 0)
// {
// while(size--)
// bundleIN.fill(SLIPSerial.read());
// }
//
// if(!bundleIN.hasError())
// bundleIN.dispatch("/led", LEDcontrol);
//
void postman_talk () {
//
static bool insync = false;
if (insync == false) {
int size;
if ((size = POSTMAN_SERIAL.available()) > 0) {
char last = '.';
while(size--) {
// get the last byte
last = POSTMAN_SERIAL.read();
}
// expectable last of the messages
if (last == ']' || last == '}') {
insync = true;
}
}
} else if (insync == true) {
if (POSTMAN_SERIAL.available() > POST_LENGTH) {
char cstr[POST_BUFF_LEN] = "................................";
// fetch all the bytes
POSTMAN_SERIAL.readBytes(cstr, POST_LENGTH);
// protocol checks
char first = cstr[0];
char last = cstr[POST_LENGTH-1];
if (first != '[' && first != '{') {
insync = false;
return; //error!!
}
if (last != ']' && last != '}') {
insync = false;
return; //error!!
}
//// OK -> parse && compose & send OSC message!
String msg = String(cstr);
// hello frame ( '{' + 30 bytes + '}' )
// : {123456789012345678901234567890}
// hello frame
// : {123456789012345678901234567890}
// : {IIIA111111222222333333444444__}
// : III - ID_KEY
// .substring(1, 4);
// : 1 - data of 6 letters
// .substring(9, 14);
// : 2 - data of 6 letters
// .substring(14, 19);
// : 3 - data of 6 letters
// .substring(19, 24);
// : 4 - data of 6 letters
// .substring(24, 29);
// received a hello.
String str_id = msg.substring(1, 4);
int id = str_id.toInt();
//
OSCMessage hello("/hello");
hello.add(id);
//
String str_aa = msg.substring(4, 5);
//
if (str_aa == "A") {
//
String str_h1 = msg.substring(5, 11);
String str_h2 = msg.substring(11, 17);
String str_h3 = msg.substring(17, 23);
String str_h4 = msg.substring(23, 29);
//
hello.add(str_h1.toInt());
hello.add(str_h2.toInt());
hello.add(str_h3.toInt());
hello.add(str_h4.toInt());
}
//
SLIPSerial.beginPacket();
hello.send(SLIPSerial);
SLIPSerial.endPacket();
hello.empty();
}
}
}
Task postman_talk_task(0, TASK_FOREVER, postman_talk, &runner, true); // aInterval == 0 >>> immediately re-schedule ?
//
void setup() {
//osc
SLIPSerial.begin(57600);
//
POSTMAN_SERIAL.begin(115200);
}
//
void loop() {
runner.execute();
}

30
@osc/platformio.ini Normal file
View file

@ -0,0 +1,30 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
env_default = teensy36
[common]
lib_deps =
721@3.0.2 ; TaskScheduler
; osc -> (already included in "framework-arduinoteensy")
[env:teensy35]
platform = teensy@3.6.0
board = teensy35
framework = arduino
lib_deps = ${common.lib_deps}
[env:teensy36]
platform = teensy@3.6.0
board = teensy36
framework = arduino
lib_deps = ${common.lib_deps}

159
@osc/src/main.cpp Normal file
View file

@ -0,0 +1,159 @@
//
// wirelessly connected cloud (based on ESP-NOW, a kind of LPWAN?)
//
//
// Conversations about the ROOT @ SEMA storage, Seoul
//
//
// 2021 02 15
//
// (part-2) teensy35 : 'client:osc' (osc over slip <--> esp-now 'post')
//
//arduino
#include <Arduino.h>
//osc (already included in "framework-arduinoteensy")
#include <OSCBundle.h>
#include <SLIPEncodedUSBSerial.h>
SLIPEncodedUSBSerial SLIPSerial(Serial);
//post definition
#include "../../post.h"
//postman's uart
#define POSTMAN_SERIAL (Serial3)
//
void setup() {
//osc
SLIPSerial.begin(57600);
//
POSTMAN_SERIAL.begin(115200);
}
//
void route_note(OSCMessage& msg, int offset) {
// matches will happen in the order. that the bundle is packed.
static Note note;
// (1) --> /onoff
if (msg.fullMatch("/onoff", offset)) {
//
note.clear();
//
note.onoff = msg.getFloat(0);
if (note.onoff != 0) note.onoff = 1;
}
// (2) --> /velocity
if (msg.fullMatch("/velocity", offset)) {
note.velocity = msg.getFloat(0);
}
// (3) --> /pitch
if (msg.fullMatch("/pitch", offset)) {
note.pitch = msg.getFloat(0);
}
// (4) --> /id
if (msg.fullMatch("/id", offset)) {
note.id = msg.getInt(0);
}
// (5) --> /x
if (msg.fullMatch("/x", offset)) {
note.x1 = msg.getFloat(0);
note.x2 = msg.getFloat(1);
note.x3 = msg.getFloat(2);
note.x4 = msg.getFloat(3);
note.ps = msg.getFloat(4);
//
POSTMAN_SERIAL.write('['); // start byte of 'Note'
POSTMAN_SERIAL.write((uint8_t *) &note, sizeof(Note));
POSTMAN_SERIAL.write(']'); // end byte of 'Note'
//
}
}
//
void loop() {
//osc
OSCBundle bundleIN;
int size;
if (SLIPSerial.available()) {
while(!SLIPSerial.endofPacket()) {
if( (size = SLIPSerial.available()) > 0) {
while(size--) {
bundleIN.fill(SLIPSerial.read());
}
}
}
if(!bundleIN.hasError()) {
// on '/note'
bundleIN.route("/note", route_note);
}
}
//postman (serial comm.)
static bool insync = false;
if (insync == false) {
while (POSTMAN_SERIAL.available() > 0) {
// search the last byte
char last = POSTMAN_SERIAL.read();
// expectable last of the messages
if (last == ']' || last == '}') {
insync = true;
}
}
} else {
//
if (POSTMAN_SERIAL.available() > 0) {
//
char type = POSTMAN_SERIAL.peek();
//
if (type == '{') {
//expecting a Hello message.
if (POSTMAN_SERIAL.available() > sizeof(Hello) + 2) {
POSTMAN_SERIAL.read();
//
Hello hello("");
POSTMAN_SERIAL.readBytes((uint8_t *) &hello, sizeof(Hello));
char last = POSTMAN_SERIAL.read();
if (last == '}') {
//good.
//
OSCMessage osc("/hello");
osc.add(hello.id);
osc.add(hello.h1);
osc.add(hello.h2);
osc.add(hello.h3);
osc.add(hello.h4);
//
SLIPSerial.beginPacket();
osc.send(SLIPSerial);
SLIPSerial.endPacket();
osc.empty();
//
} else {
insync = false; //error!
}
}
} else if (type == '[') {
//expecting a Note message.
if (POSTMAN_SERIAL.available() > sizeof(Note) + 2) {
POSTMAN_SERIAL.read();
//
Note note;
POSTMAN_SERIAL.readBytes((uint8_t *) &note, sizeof(Note));
char last = POSTMAN_SERIAL.read();
if (last == ']') {
//good.
} else {
insync = false; //error!
}
}
//
}
}
}
}

52
@postman/platformio.ini Normal file
View file

@ -0,0 +1,52 @@
; < NOTE >
; to enable verbose output add option -->
; $ platformio run --verbose
; to make this permanent for the proj. -->
; $ platformio settings set force_verbose Yes
; then confirm the change -->
; $ platformio settings get
; // pio v 4.0 'Build options'
; - build_type
; - build_flags
; - src_build_flags
; - build_unflags
; - src_filter
; - targets
[platformio]
default_envs = d1_mini_pro
[env]
framework = arduino
upload_port = /dev/ttyUSB0
lib_deps =
; SPI
; Wire
721 ; TaskScheduler
[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
lib_deps =
${env.lib_deps}
upload_speed = 921600 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
lib_deps =
${env.lib_deps}
upload_speed = 460800 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600
[env:huzzah]
platform = espressif8266
board = huzzah
lib_deps =
${env.lib_deps}
upload_speed = 921600 ; 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600

433
@postman/src/main.cpp Normal file
View file

@ -0,0 +1,433 @@
//
// wirelessly connected cloud (based on ESP-NOW, a kind of LPWAN?)
//
//
// Conversation about the ROOT @ SEMA storage, Seoul
//
//
// 2021 02 15
//
// (part-1) esp8266 : 'postman' (the esp-now network nodes)
//
// this module will be an esp-now node in a group.
// like, a bird in a group of birds.
//
// esp-now @ esp8266 w/ broadcast address (FF:FF:FF:FF:FF:FF)
// always broadcasting. everyone is 'talkative'.
//
// then, let it save a value in EEPROM (object with memory=mind?)
//============<identities>============
//
#define MY_GROUP_ID (898989)
#define MY_ID (MY_GROUP_ID + 0)
#define MY_SIGN ("@POSTMAN|@SAMPLER")
#define ADDRESSBOOK_TITLE ("broadcast only")
//
//============</identities>============
//==========<list-of-configurations>===========
//
// 'HAVE_CLIENT'
// --> i have a client. enable the client task.
//
// 'SERIAL_SWAP'
// --> UART pin swapped.
// you want this, when you want a bi-directional comm. to external client boards (e.g. teensy).
//
// 'DISABLE_AP'
// --> (questioning)...
//
// 'REPLICATE_NOTE_REQ' (+ N_SEC_BLOCKING_NOTE_REQ)
// --> for supporting wider area with simple esp_now protocol,
// all receipents will replicate NOTE msg. when they are newly appeared.
// + then, network would be flooded by infinite duplicating msg.,
// unless they stop reacting to 'known' req. for some seconds. (e.g. 3 seconds)
// 'HAVE_CLIENT_I2C'
// --> i have a client w/ I2C i/f. enable the I2C client task.
//
// 'ADDRESSBOOK_TITLE'
// --> peer list limited max. 20.
// so, we might use different address books for each node to cover a network of more than 20 nodes.
//
//==========</list-of-configurations>==========
//
#define HAVE_CLIENT_I2C
#define DISABLE_AP
// #define SERIAL_SWAP
// #define REPLICATE_NOTE_REQ
//============<parameters>============
//
#define LED_PERIOD (11111)
#define LED_ONTIME (1)
#define LED_GAPTIME (222)
//
#define WIFI_CHANNEL 1
//
// 'MONITORING_SERIAL'
//
// --> sometimes, the 'Serial' is in use (for example, 'osc' node)
// then, use 'Serial1' - D4/GPIO2/TDX1 @ nodemcu (this is TX only.)
//
// --> otherwise, MONITORING_SERIAL == Serial.
//
#if defined(SERIAL_SWAP)
#define MONITORING_SERIAL (Serial1)
#else
#define MONITORING_SERIAL (Serial)
#endif
//
//============</parameters>===========
//============<board-specifics>============
#if defined(ARDUINO_FEATHER_ESP32) // featheresp32
#define LED_PIN 13
#else
#define LED_PIN 2
#endif
//============</board-specifics>===========
//arduino
#include <Arduino.h>
//i2c
#include <Wire.h>
//post & addresses
#include "../../post.h"
//vector
#include <vector>
std::vector<Note> recentNotes;
//espnow
#include <ESP8266WiFi.h>
#include <espnow.h>
AddressLibrary lib;
//task
#include <TaskScheduler.h>
Scheduler runner;
//
#if defined(REPLICATE_NOTE_REQ)
Note note_now = {
-1, // int32_t id;
-1, // float pitch;
-1, // float velocity;
-1, // float onoff;
-1, // float x1;
-1, // float x2;
-1, // float x3;
-1, // float x4;
-1 // float ps;
};
#define RECENT_NOTES_TIMEOUT (3000)
static unsigned long last_note_time = 0;
void recent_clear() {
//
if (millis() - last_note_time > RECENT_NOTES_TIMEOUT) {
recentNotes.clear();
Serial.println("recent list cleared");
last_note_time = millis();
}
//
}
Task recent_clear_task(100, TASK_FOREVER, &recent_clear, &runner, true);
#endif
//*-*-*-*-*-*-*-*-*-*-*-*-*
//
extern Task hello_task;
static int hello_delay = 0;
void hello() {
//
byte mac[6];
WiFi.macAddress(mac);
uint32_t mac32 = (((((mac[2] << 8) + mac[3]) << 8) + mac[4]) << 8) + mac[5];
//
Hello hello(String(MY_SIGN), MY_ID, mac32); // the most basic 'hello'
// and you can append some floats
static int count = 0;
count++;
hello.h1 = (count % 1000);
// hello.h2 = 0;
// hello.h3 = 0;
// hello.h4 = 0;
//
uint8_t frm_size = sizeof(Hello) + 2;
uint8_t frm[frm_size];
frm[0] = '{';
memcpy(frm + 1, (uint8_t *) &hello, sizeof(Hello));
frm[frm_size - 1] = '}';
//
esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
// MONITORING_SERIAL.write(frm, frm_size);
// MONITORING_SERIAL.println(" ==(esp_now_send/0)==> ");
//
if (hello_delay > 0) {
if (hello_delay < 100) hello_delay = 100;
hello_task.restartDelayed(hello_delay);
}
}
Task hello_task(0, TASK_ONCE, &hello, &runner, false);
//task #0 : blink led
extern Task blink_task;
void blink() {
//
static int count = 0;
count++;
//
switch (count % 4) {
case 0:
digitalWrite(LED_PIN, LOW); // first ON
blink_task.delay(LED_ONTIME);
break;
case 1:
digitalWrite(LED_PIN, HIGH); // first OFF
blink_task.delay(LED_GAPTIME);
break;
case 2:
digitalWrite(LED_PIN, LOW); // second ON
blink_task.delay(LED_ONTIME);
break;
case 3:
digitalWrite(LED_PIN, HIGH); // second OFF
blink_task.delay(LED_PERIOD - 2* LED_ONTIME - LED_GAPTIME);
break;
}
}
Task blink_task(0, TASK_FOREVER, &blink, &runner, true); // -> ENABLED, at start-up.
// on 'receive'
void onDataReceive(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
//
//MONITORING_SERIAL.write(incomingData, len);
//
#if defined(HAVE_CLIENT)
Serial.write(incomingData, len); // we pass it over to the client.
#endif
// open => identify => use.
if (incomingData[0] == '{' && incomingData[len - 1] == '}' && len == (sizeof(Hello) + 2)) {
Hello hello("");
memcpy((uint8_t *) &hello, incomingData + 1, sizeof(Hello));
//
MONITORING_SERIAL.println(hello.to_string());
//
}
// open => identify => use.
if (incomingData[0] == '[' && incomingData[len - 1] == ']' && len == (sizeof(Note) + 2)) {
Note note;
memcpy((uint8_t *) &note, incomingData + 1, sizeof(Note));
//is this for me & my client?
if (note.id == MY_GROUP_ID || note.id == MY_ID) {
#if defined(HAVE_CLIENT_I2C)
// (struct --> obsolete I2C format.)
// --> we want to open & re-construct the msg.
// letter frame ( '[' + 30 bytes + ']' )
// : [123456789012345678901234567890]
// 'MIDI' letter frame
// : [123456789012345678901234567890]
// : [KKKVVVG.......................]
// : KKK - Key
// .substring(1, 4);
// : VVV - Velocity (volume/amp.)
// .substring(4, 7);
// : G - Gate (note on/off)
// .substring(7, 8);
char letter_outro[POST_BUFF_LEN] = "................................";
if (note.pitch < 0) note.pitch = 0;
if (note.pitch >= 1000) note.pitch = 999;
if (note.velocity < 0) note.velocity = 0;
if (note.velocity >= 1000) note.velocity = 999;
if (note.onoff < 0) note.onoff = 0;
if (note.onoff >= 10) note.onoff = 9;
sprintf(letter_outro, "[%03d%03d%01d.......................]",
(int32_t)note.pitch,
(int32_t)note.velocity,
(int32_t)note.onoff);
String msg = String(letter_outro);
// truncate any extra. letters.
msg = msg.substring(0, POST_LENGTH); // (0) ~ (POST_LENGTH-1)
// send out
Wire.beginTransmission(I2C_ADDR);
Wire.write(msg.c_str(), POST_LENGTH);
Wire.endTransmission();
#endif
//
hello_delay = note.ps;
if (hello_delay > 0 && hello_task.isEnabled() == false) {
hello_task.restart();
}
}
//
MONITORING_SERIAL.println(note.to_string());
#if defined(REPLICATE_NOTE_REQ)
last_note_time = millis(); //clear timer reset : the recent list holding (re)started
// check if this note is in the list?
bool check = false;
for (uint32_t idx = 0; idx < recentNotes.size(); idx++) {
if (recentNotes[idx].pitch == note.pitch && recentNotes[idx].id == note.id) {
check = true;
}
}
// if not, add this into the list and repeat!
if (check == false) {
//
recentNotes.push_back(note);
//
uint8_t frm_size = sizeof(Note) + 2;
uint8_t frm[frm_size];
frm[0] = '[';
memcpy(frm + 1, (uint8_t *) &note, sizeof(Note));
frm[frm_size - 1] = ']';
//
esp_now_send(NULL, frm, frm_size); // to all peers in the list.
//
MONITORING_SERIAL.print("repeat! ==> ");
MONITORING_SERIAL.println(note.to_string());
//
}
//EMERGENCY PATCH.HACK:
// original code is not intended for a BURST of notes.
// so, only 1 msg. will be repeated in 3 sec. all others will be simply ignored.
// to make a burst of msgs repeatible:
// --> make a list of recent 'pitches'
// if there is any new msg. check if this is in the list, if not, add it & repeat, if yes, skip it.
// after 3sec no new msg., the list will be flushed. every new msg. will reset timeout + save the list for extra. 3 sec.
#endif
}
}
// on 'sent'
void onDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
char buff[256] = "";
sprintf(buff, "Delivery failed! -> %02X:%02X:%02X:%02X:%02X:%02X", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
if (sendStatus != 0) MONITORING_SERIAL.println(buff);
}
//
void setup() {
//led
pinMode(LED_PIN, OUTPUT);
//serial
Serial.begin(115200);
delay(100);
//info
Serial.println();
Serial.println();
Serial.println("\"hi, i m your postman.\"");
Serial.println("-");
Serial.println("- my id: " + String(MY_ID) + ", gid: " + String(MY_GROUP_ID) + ", call me ==> \"" + String(MY_SIGN) + "\"");
Serial.println("- mac address: " + WiFi.macAddress() + ", channel: " + String(WIFI_CHANNEL));
#if defined(HAVE_CLIENT)
Serial.println("- ======== 'HAVE_CLIENT' ========");
#endif
#if defined(SERIAL_SWAP)
Serial.println("- ======== 'SERIAL_SWAP' ========");
#endif
#if defined(DISABLE_AP)
Serial.println("- ======== 'DISABLE_AP' ========");
#endif
#if defined(HAVE_CLIENT_I2C)
Serial.println("- ======== 'HAVE_CLIENT_I2C' ========");
#endif
#if defined(REPLICATE_NOTE_REQ)
Serial.println("- ======== 'REPLICATE_NOTE_REQ' ========");
#endif
Serial.println("-");
//wifi
WiFiMode_t node_type = WIFI_AP_STA;
#if defined(DISABLE_AP)
system_phy_set_max_tpw(0);
node_type = WIFI_STA;
#endif
WiFi.mode(node_type);
//esp-now
if (esp_now_init() != 0) {
Serial.println("Error initializing ESP-NOW");
return;
}
#if defined(ESP8266)
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
#endif
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);
//
AddressBook * book = lib.getBookByTitle(ADDRESSBOOK_TITLE);
if (book == NULL) {
Serial.println("- ! wrong book !! : \"" + String(ADDRESSBOOK_TITLE) + "\""); while(1);
}
for (int idx = 0; idx < book->list.size(); idx++) {
Serial.println("- ! (esp_now_add_peer) ==> add a '" + book->list[idx].name + "'.");
#if defined(ESP32)
esp_now_peer_info_t peerInfo = {};
memcpy(peerInfo.peer_addr, book->list[idx].mac, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
esp_now_add_peer(&peerInfo);
#else
esp_now_add_peer(book->list[idx].mac, ESP_NOW_ROLE_COMBO, 1, NULL, 0);
#endif
}
// (DEBUG) fetch full peer list
{ PeerLister a; a.print(); }
//
Serial.println("-");
Serial.println("\".-.-.-. :)\"");
Serial.println();
#if defined(SERIAL_SWAP)
Serial.println("- ======== 'SERIAL_SWAP' ========");
// a proper say goodbye.
Serial.println("\"bye, i will do 'swap' in 1 second. find me on alternative pins!\"");
Serial.println("\" hint: osc wiring ==> esp8266(serial.swap) <-> teensy(serial3)\"");
Serial.println("-");
Serial.println("\".-.-.-. :)\"");
delay(1000); // flush out unsent serial messages.
// moving...
Serial.swap(); // use RXD2/TXD2 pins, afterwards.
delay(100); // wait re-initialization of the 'Serial'
#endif
//
#if defined(HAVE_CLIENT_I2C)
//i2c master
Wire.begin();
#endif
}
void loop() {
//
runner.execute();
//
}

Some files were not shown because too many files have changed in this diff Show more