Skip to content

Commit 4541380

Browse files
committed
Support MeshAdventurer
Added support for MeshAdventurer, including radio, display, button, GPS, voltage reading
1 parent 165fb33 commit 4541380

File tree

5 files changed

+557
-0
lines changed

5 files changed

+557
-0
lines changed

src/helpers/MeshadventurerBoard.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#pragma once
2+
3+
#include <Arduino.h>
4+
5+
// LoRa radio module pins for Meshadventurer
6+
#define P_LORA_DIO_1 33
7+
#define P_LORA_NSS 18
8+
#define P_LORA_RESET 23
9+
#define P_LORA_BUSY 32
10+
#define P_LORA_SCLK 5
11+
#define P_LORA_MISO 19
12+
#define P_LORA_MOSI 27
13+
14+
#define PIN_VBAT_READ 35
15+
16+
#include "ESP32Board.h"
17+
18+
#include <driver/rtc_io.h>
19+
20+
class MeshadventurerBoard : public ESP32Board {
21+
22+
public:
23+
void begin() {
24+
ESP32Board::begin();
25+
26+
esp_reset_reason_t reason = esp_reset_reason();
27+
if (reason == ESP_RST_DEEPSLEEP) {
28+
long wakeup_source = esp_sleep_get_ext1_wakeup_status();
29+
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
30+
startup_reason = BD_STARTUP_RX_PACKET;
31+
}
32+
33+
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
34+
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
35+
}
36+
}
37+
38+
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
39+
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
40+
41+
// Make sure the DIO1 and NSS GPIOs are held on required levels during deep sleep
42+
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
43+
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
44+
45+
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
46+
47+
if (pin_wake_btn < 0) {
48+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
49+
} else {
50+
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
51+
}
52+
53+
if (secs > 0) {
54+
esp_sleep_enable_timer_wakeup(secs * 1000000);
55+
}
56+
57+
// Finally set ESP32 into sleep
58+
esp_deep_sleep_start(); // CPU halts here and never returns!
59+
}
60+
61+
void powerOff() override {
62+
// TODO: re-enable this when there is a definite wake-up source pin:
63+
// enterDeepSleep(0);
64+
}
65+
66+
uint16_t getBattMilliVolts() override {
67+
analogReadResolution(12);
68+
69+
uint32_t raw = 0;
70+
for (int i = 0; i < 4; i++) {
71+
raw += analogReadMilliVolts(PIN_VBAT_READ);
72+
}
73+
raw = raw / 4;
74+
75+
return (2 * raw);
76+
}
77+
78+
const char* getManufacturerName() const override {
79+
return "Meshadventurer";
80+
}
81+
};
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
[Meshadventurer]
2+
extends = esp32_base
3+
board = esp32doit-devkit-v1
4+
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
5+
build_flags =
6+
${esp32_base.build_flags}
7+
-I variants/meshadventurer
8+
-D MESHADVENTURER
9+
-D P_LORA_TX_LED=2
10+
-D PIN_VBAT_READ=35
11+
-D PIN_USER_BTN_ANA=39
12+
-D P_LORA_DIO_1=33
13+
-D P_LORA_NSS=18
14+
-D P_LORA_RESET=23
15+
-D P_LORA_BUSY=32
16+
-D P_LORA_SCLK=5
17+
-D P_LORA_MOSI=27
18+
-D P_LORA_MISO=19
19+
-D SX126X_TXEN=13
20+
-D SX126X_RXEN=14
21+
-D PIN_BOARD_SDA=21
22+
-D PIN_BOARD_SCL=22
23+
-D SX126X_DIO2_AS_RF_SWITCH=false
24+
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
25+
-D SX126X_RX_BOOSTED_GAIN=1
26+
-D PIN_GPS_RX=12
27+
-D PIN_GPS_TX=15
28+
-D DISPLAY_CLASS=SSD1306Display
29+
build_src_filter = ${esp32_base.build_src_filter}
30+
+<../variants/meshadventurer>
31+
lib_deps =
32+
${esp32_base.lib_deps}
33+
stevemarple/MicroNMEA @ ^2.0.6
34+
adafruit/Adafruit SSD1306 @ ^2.5.13
35+
36+
[env:Meshadventurer_sx1262_repeater]
37+
extends = Meshadventurer
38+
build_src_filter = ${Meshadventurer.build_src_filter}
39+
+<../examples/simple_repeater/main.cpp>
40+
+<helpers/ui/SSD1306Display.cpp>
41+
build_flags =
42+
${Meshadventurer.build_flags}
43+
-D RADIO_CLASS=CustomSX1262
44+
-D WRAPPER_CLASS=CustomSX1262Wrapper
45+
-D LORA_TX_POWER=22
46+
-D ADVERT_NAME='"Meshadventurer Repeater"'
47+
-D ADVERT_LAT=0.0
48+
-D ADVERT_LON=0.0
49+
-D ADMIN_PASSWORD='"password"'
50+
-D MAX_NEIGHBOURS=8
51+
; -D MESH_PACKET_LOGGING=1
52+
; -D MESH_DEBUG=1
53+
lib_deps =
54+
${Meshadventurer.lib_deps}
55+
${esp32_ota.lib_deps}
56+
57+
[env:Meshadventurer_sx1268_repeater]
58+
extends = Meshadventurer
59+
build_src_filter = ${Meshadventurer.build_src_filter}
60+
+<../examples/simple_repeater/main.cpp>
61+
+<helpers/ui/SSD1306Display.cpp>
62+
build_flags =
63+
${Meshadventurer.build_flags}
64+
-D RADIO_CLASS=CustomSX1268
65+
-D WRAPPER_CLASS=CustomSX1268Wrapper
66+
-D LORA_TX_POWER=22
67+
-D ADVERT_NAME='"Meshadventurer Repeater"'
68+
-D ADVERT_LAT=0.0
69+
-D ADVERT_LON=0.0
70+
-D ADMIN_PASSWORD='"password"'
71+
-D MAX_NEIGHBOURS=8
72+
; -D MESH_PACKET_LOGGING=1
73+
; -D MESH_DEBUG=1
74+
lib_deps =
75+
${Meshadventurer.lib_deps}
76+
${esp32_ota.lib_deps}
77+
78+
[env:Meshadventurer_sx1262_companion_radio_usb]
79+
extends = Meshadventurer
80+
build_src_filter = ${Meshadventurer.build_src_filter}
81+
+<../examples/companion_radio>
82+
+<helpers/ui/SSD1306Display.cpp>
83+
build_flags =
84+
${Meshadventurer.build_flags}
85+
-D RADIO_CLASS=CustomSX1262
86+
-D WRAPPER_CLASS=CustomSX1262Wrapper
87+
-D LORA_TX_POWER=22
88+
-D MAX_CONTACTS=100
89+
-D MAX_GROUP_CHANNELS=8
90+
; -D MESH_PACKET_LOGGING=1
91+
; -D MESH_DEBUG=1
92+
lib_deps =
93+
${Meshadventurer.lib_deps}
94+
densaugeo/base64 @ ~1.4.0
95+
96+
[env:Meshadventurer_sx1262_companion_radio_ble]
97+
extends = Meshadventurer
98+
build_src_filter = ${Meshadventurer.build_src_filter}
99+
+<../examples/companion_radio>
100+
+<helpers/esp32/*.cpp>
101+
+<helpers/ui/SSD1306Display.cpp>
102+
build_flags =
103+
${Meshadventurer.build_flags}
104+
-D RADIO_CLASS=CustomSX1262
105+
-D WRAPPER_CLASS=CustomSX1262Wrapper
106+
-D LORA_TX_POWER=22
107+
-D MAX_CONTACTS=100
108+
-D MAX_GROUP_CHANNELS=8
109+
-D BLE_PIN_CODE=123456
110+
-D BLE_DEBUG_LOGGING=1
111+
-D OFFLINE_QUEUE_SIZE=256
112+
-D MESH_PACKET_LOGGING=1
113+
-D MESH_DEBUG=1
114+
lib_deps =
115+
${Meshadventurer.lib_deps}
116+
densaugeo/base64 @ ~1.4.0
117+
118+
[env:Meshadventurer_sx1262_terminal_chat]
119+
extends = Meshadventurer
120+
build_flags =
121+
${Meshadventurer.build_flags}
122+
-D RADIO_CLASS=CustomSX1262
123+
-D WRAPPER_CLASS=CustomSX1262Wrapper
124+
-D LORA_TX_POWER=22
125+
-D MAX_CONTACTS=100
126+
-D MAX_GROUP_CHANNELS=1
127+
; -D MESH_PACKET_LOGGING=1
128+
; -D MESH_DEBUG=1
129+
build_src_filter = ${Meshadventurer.build_src_filter}
130+
+<../examples/simple_secure_chat/main.cpp>
131+
+<helpers/ui/SSD1306Display.cpp>
132+
lib_deps =
133+
${Meshadventurer.lib_deps}
134+
densaugeo/base64 @ ~1.4.0
135+
136+
[env:Meshadventurer_sx1262_room_server]
137+
extends = Meshadventurer
138+
build_flags =
139+
${Meshadventurer.build_flags}
140+
-D RADIO_CLASS=CustomSX1262
141+
-D WRAPPER_CLASS=CustomSX1262Wrapper
142+
-D LORA_TX_POWER=22
143+
-D ADVERT_NAME='"Meshadventurer Room"'
144+
-D ADVERT_LAT=0.0
145+
-D ADVERT_LON=0.0
146+
-D ADMIN_PASSWORD='"password"'
147+
-D ROOM_PASSWORD='"hello"'
148+
; -D MESH_PACKET_LOGGING=1
149+
; -D MESH_DEBUG=1
150+
build_src_filter = ${Meshadventurer.build_src_filter}
151+
+<../examples/simple_room_server>
152+
+<helpers/ui/SSD1306Display.cpp>
153+
lib_deps =
154+
${Meshadventurer.lib_deps}
155+
${esp32_ota.lib_deps}
156+
157+
[env:Meshadventurer_sx1268_companion_radio_usb]
158+
extends = Meshadventurer
159+
build_src_filter = ${Meshadventurer.build_src_filter}
160+
+<../examples/companion_radio>
161+
+<helpers/ui/SSD1306Display.cpp>
162+
build_flags =
163+
${Meshadventurer.build_flags}
164+
-D RADIO_CLASS=CustomSX1268
165+
-D WRAPPER_CLASS=CustomSX1268Wrapper
166+
-D LORA_TX_POWER=22
167+
-D MAX_CONTACTS=100
168+
-D MAX_GROUP_CHANNELS=8
169+
; -D MESH_PACKET_LOGGING=1
170+
; -D MESH_DEBUG=1
171+
lib_deps =
172+
${Meshadventurer.lib_deps}
173+
densaugeo/base64 @ ~1.4.0
174+
175+
[env:Meshadventurer_sx1268_companion_radio_ble]
176+
extends = Meshadventurer
177+
build_src_filter = ${Meshadventurer.build_src_filter}
178+
+<../examples/companion_radio>
179+
+<helpers/esp32/*.cpp>
180+
+<helpers/ui/SSD1306Display.cpp>
181+
build_flags =
182+
${Meshadventurer.build_flags}
183+
-D RADIO_CLASS=CustomSX1268
184+
-D WRAPPER_CLASS=CustomSX1268Wrapper
185+
-D LORA_TX_POWER=22
186+
-D MAX_CONTACTS=100
187+
-D MAX_GROUP_CHANNELS=8
188+
-D BLE_PIN_CODE=123456
189+
-D BLE_DEBUG_LOGGING=1
190+
-D OFFLINE_QUEUE_SIZE=256
191+
-D MESH_PACKET_LOGGING=1
192+
-D MESH_DEBUG=1
193+
lib_deps =
194+
${Meshadventurer.lib_deps}
195+
densaugeo/base64 @ ~1.4.0
196+
197+
[env:Meshadventurer_sx1268_terminal_chat]
198+
extends = Meshadventurer
199+
build_flags =
200+
${Meshadventurer.build_flags}
201+
-D RADIO_CLASS=CustomSX1268
202+
-D WRAPPER_CLASS=CustomSX1268Wrapper
203+
-D LORA_TX_POWER=22
204+
-D MAX_CONTACTS=100
205+
-D MAX_GROUP_CHANNELS=1
206+
; -D MESH_PACKET_LOGGING=1
207+
; -D MESH_DEBUG=1
208+
build_src_filter = ${Meshadventurer.build_src_filter}
209+
+<../examples/simple_secure_chat/main.cpp>
210+
+<helpers/ui/SSD1306Display.cpp>
211+
lib_deps =
212+
${Meshadventurer.lib_deps}
213+
densaugeo/base64 @ ~1.4.0
214+
215+
[env:Meshadventurer_sx1268_room_server]
216+
extends = Meshadventurer
217+
build_flags =
218+
${Meshadventurer.build_flags}
219+
-D RADIO_CLASS=CustomSX1268
220+
-D WRAPPER_CLASS=CustomSX1268Wrapper
221+
-D LORA_TX_POWER=22
222+
-D ADVERT_NAME='"Meshadventurer Room"'
223+
-D ADVERT_LAT=0.0
224+
-D ADVERT_LON=0.0
225+
-D ADMIN_PASSWORD='"password"'
226+
-D ROOM_PASSWORD='"hello"'
227+
; -D MESH_PACKET_LOGGING=1
228+
; -D MESH_DEBUG=1
229+
build_src_filter = ${Meshadventurer.build_src_filter}
230+
+<../examples/simple_room_server>
231+
+<helpers/ui/SSD1306Display.cpp>
232+
lib_deps =
233+
${Meshadventurer.lib_deps}
234+
${esp32_ota.lib_deps}

0 commit comments

Comments
 (0)