Skip to content

Commit 90e2612

Browse files
committed
Merge branch 'dev' into remove_set_setting_by_key
2 parents 37dc715 + 1520f4d commit 90e2612

File tree

96 files changed

+3051
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3051
-433
lines changed

boards/ESP32-S3-WROOM-1-N4.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "esp32s3_out.ld"
5+
},
6+
"core": "esp32",
7+
"extra_flags": [
8+
"-D ARDUINO_USB_CDC_ON_BOOT=0",
9+
"-D ARDUINO_USB_MSC_ON_BOOT=0",
10+
"-D ARDUINO_USB_DFU_ON_BOOT=0",
11+
"-D ARDUINO_USB_MODE=0",
12+
"-D ARDUINO_RUNNING_CORE=1",
13+
"-D ARDUINO_EVENT_RUNNING_CORE=1"
14+
],
15+
"f_cpu": "240000000L",
16+
"f_flash": "80000000L",
17+
"flash_mode": "qio",
18+
"hwids": [["0x303A", "0x1001"]],
19+
"mcu": "esp32s3",
20+
"variant": "ESP32-S3-WROOM-1-N4"
21+
},
22+
"connectivity": ["wifi", "bluetooth"],
23+
"debug": {
24+
"default_tool": "esp-builtin",
25+
"onboard_tools": ["esp-builtin"],
26+
"openocd_target": "esp32s3.cfg"
27+
},
28+
"frameworks": ["arduino", "espidf"],
29+
"name": "ESP32-S3-WROOM-1-N4 (4 MB Flash, No PSRAM)",
30+
"upload": {
31+
"flash_size": "4MB",
32+
"maximum_ram_size": 524288,
33+
"maximum_size": 4194304,
34+
"require_upload_port": true,
35+
"speed": 921600
36+
},
37+
"url": "https://www.espressif.com/sites/default/files/documentation/esp32-s3-wroom-1_wroom-1u_datasheet_en.pdf",
38+
"vendor": "Espressif"
39+
}

boards/rak4631.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v6.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
[
12+
"0x239A",
13+
"0x8029"
14+
],
15+
[
16+
"0x239A",
17+
"0x0029"
18+
],
19+
[
20+
"0x239A",
21+
"0x002A"
22+
],
23+
[
24+
"0x239A",
25+
"0x802A"
26+
]
27+
],
28+
"usb_product": "WisCore RAK4631 Board",
29+
"mcu": "nrf52840",
30+
"variant": "WisCore_RAK4631_Board",
31+
"bsp": {
32+
"name": "adafruit"
33+
},
34+
"softdevice": {
35+
"sd_flags": "-DS140",
36+
"sd_name": "s140",
37+
"sd_version": "6.1.1",
38+
"sd_fwid": "0x00B6"
39+
},
40+
"bootloader": {
41+
"settings_addr": "0xFF000"
42+
}
43+
},
44+
"connectivity": [
45+
"bluetooth"
46+
],
47+
"debug": {
48+
"jlink_device": "nRF52840_xxAA",
49+
"svd_path": "nrf52840.svd"
50+
},
51+
"frameworks": [
52+
"arduino"
53+
],
54+
"name": "WisCore RAK4631 Board",
55+
"upload": {
56+
"maximum_ram_size": 248832,
57+
"maximum_size": 815104,
58+
"speed": 115200,
59+
"protocol": "nrfutil",
60+
"protocols": [
61+
"jlink",
62+
"nrfjprog",
63+
"nrfutil",
64+
"stlink"
65+
],
66+
"use_1200bps_touch": true,
67+
"require_upload_port": true,
68+
"wait_for_upload_port": true
69+
},
70+
"url": "https://www.rakwireless.com",
71+
"vendor": "RAKwireless"
72+
}

build.sh

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
#!/usr/bin/env bash
22

3-
# usage
4-
# sh build.sh build-firmware RAK_4631_Repeater
5-
# sh build.sh build-firmwares
6-
# sh build.sh build-matching-firmwares RAK_4631
7-
# sh build.sh build-companion-firmwares
8-
# sh build.sh build-repeater-firmwares
9-
# sh build.sh build-room-server-firmwares
3+
global_usage() {
4+
cat - <<EOF
5+
Usage:
6+
sh build.sh <command> [target]
7+
8+
Commands:
9+
help|usage|-h|--help: Shows this message.
10+
build-firmware <target>: Build the firmware for the given build target.
11+
build-firmwares: Build all firmwares for all targets.
12+
build-matching-firmwares <build-match-spec>: Build all firmwares for build targets containing the string given for <build-match-spec>.
13+
build-companion-firmwares: Build all companion firmwares for all build targets.
14+
build-repeater-firmwares: Build all repeater firmwares for all build targets.
15+
build-room-server-firmwares: Build all chat room server firmwares for all build targets.
16+
17+
Examples:
18+
Build firmware for the "RAK_4631_repeater" device target
19+
$ sh build.sh build-firmware RAK_4631_repeater
20+
21+
Build all firmwares for device targets containing the string "RAK_4631"
22+
$ sh build.sh build-matching-firmwares <build-match-spec>
23+
24+
Build all companion firmwares
25+
$ sh build.sh build-companion-firmwares
26+
27+
Build all repeater firmwares
28+
$ sh build.sh build-repeater-firmwares
29+
30+
Build all chat room server firmwares
31+
$ sh build.sh build-room-server-firmwares
32+
EOF
33+
}
34+
35+
# Catch cries for help before doing anything else.
36+
case $1 in
37+
help|usage|-h|--help)
38+
global_usage
39+
exit 1
40+
;;
41+
esac
42+
1043

1144
# get a list of pio env names that start with "env:"
1245
get_pio_envs() {

docs/packet_structure.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ bit 0 means the lowest bit (1s place)
4444
| `0x08` | `PAYLOAD_TYPE_PATH` | Returned path. |
4545
| `0x09` | `PAYLOAD_TYPE_TRACE` | trace a path, collecting SNI for each hop. |
4646
| `0x0A` | `PAYLOAD_TYPE_MULTIPART` | packet is part of a sequence of packets. |
47+
| `0x0B` | `PAYLOAD_TYPE_CONTROL` | control packet data (unencrypted) |
48+
| `0x0C` | . | reserved |
49+
| `0x0D` | . | reserved |
50+
| `0x0E` | . | reserved |
4751
| `0x0F` | `PAYLOAD_TYPE_RAW_CUSTOM` | Custom packet (raw bytes, custom encryption). |
4852

4953
## Payload Version Values

docs/payloads.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Inside of each [meshcore packet](./packet_structure.md) is a payload, identified
1111
* Group text message (unverified).
1212
* Group datagram (unverified).
1313
* Multi-part packet
14+
* Control data packet
1415
* Custom packet (raw bytes, custom encryption).
1516

1617
This document defines the structure of each of these payload types.
@@ -57,7 +58,7 @@ Appdata Flags
5758

5859
# Acknowledgement
5960

60-
An acknowledgement that a message was received. Note that for returned path messages, an acknowledgement will be sent in the "extra" payload (see [Returned Path](#returned-path)) and not as a discrete ackowledgement. CLI commands do not require an acknowledgement, neither discrete nor extra.
61+
An acknowledgement that a message was received. Note that for returned path messages, an acknowledgement can be sent in the "extra" payload (see [Returned Path](#returned-path)) instead of as a separate ackowledgement packet. CLI commands do not cause acknowledgement responses, neither discrete nor extra.
6162

6263
| Field | Size (bytes) | Description |
6364
|----------|--------------|------------------------------------------------------------|
@@ -140,13 +141,13 @@ Request data about sensors on the node, including battery level.
140141

141142
## Plain text message
142143

143-
| Field | Size (bytes) | Description |
144-
|-----------------|-----------------|--------------------------------------------------------------|
145-
| timestamp | 4 | send time (unix timestamp) |
146-
| flags + attempt | 1 | upper six bits are flags (see below), lower two bits are attempt number (0..3) |
147-
| message | rest of payload | the message content, see next table |
144+
| Field | Size (bytes) | Description |
145+
|--------------------|-----------------|--------------------------------------------------------------|
146+
| timestamp | 4 | send time (unix timestamp) |
147+
| txt_type + attempt | 1 | upper six bits are txt_type (see below), lower two bits are attempt number (0..3) |
148+
| message | rest of payload | the message content, see next table |
148149

149-
Flags
150+
txt_type
150151

151152
| Value | Description | Message content |
152153
|--------|---------------------------|------------------------------------------------------------|
@@ -163,13 +164,20 @@ Flags
163164
| cipher MAC | 2 | MAC for encrypted data in next field |
164165
| ciphertext | rest of payload | encrypted message, see below for details |
165166

166-
Plaintext message
167+
## Room server login
167168

168169
| Field | Size (bytes) | Description |
169170
|----------------|-----------------|-------------------------------------------------------------------------------|
170-
| timestamp | 4 | send time (unix timestamp) |
171-
| sync timestamp | 4 | NOTE: room server only! - sender's "sync messages SINCE x" timestamp |
172-
| password | rest of message | password for repeater/room |
171+
| timestamp | 4 | sender time (unix timestamp) |
172+
| sync timestamp | 4 | sender's "sync messages SINCE x" timestamp |
173+
| password | rest of message | password for room |
174+
175+
## Repeater/Sensor login
176+
177+
| Field | Size (bytes) | Description |
178+
|----------------|-----------------|-------------------------------------------------------------------------------|
179+
| timestamp | 4 | sender time (unix timestamp) |
180+
| password | rest of message | password for repeater/sensor |
173181

174182
# Group text message / datagram
175183

@@ -182,7 +190,31 @@ Plaintext message
182190
The plaintext contained in the ciphertext matches the format described in [plain text message](#plain-text-message). Specifically, it consists of a four byte timestamp, a flags byte, and the message. The flags byte will generally be `0x00` because it is a "plain text message". The message will be of the form `<sender name>: <message body>` (eg., `user123: I'm on my way`).
183191

184192

185-
TODO: describe what datagram looks like
193+
# Control data
194+
195+
| Field | Size (bytes) | Description |
196+
|--------------|-----------------|--------------------------------------------|
197+
| flags | 1 | upper 4 bits is sub_type |
198+
| data | rest of payload | typically unencrypted data |
199+
200+
## DISCOVER_REQ (sub_type)
201+
202+
| Field | Size (bytes) | Description |
203+
|--------------|-----------------|----------------------------------------------|
204+
| flags | 1 | 0x8 (upper 4 bits), prefix_only (lowest bit) |
205+
| type_filter | 1 | bit for each ADV_TYPE_* |
206+
| tag | 4 | randomly generate by sender |
207+
| since | 4 | (optional) epoch timestamp (0 by default) |
208+
209+
## DISCOVER_RESP (sub_type)
210+
211+
| Field | Size (bytes) | Description |
212+
|--------------|-----------------|--------------------------------------------|
213+
| flags | 1 | 0x9 (upper 4 bits), node_type (lower 4) |
214+
| snr | 1 | signed, SNR*4 |
215+
| tag | 4 | reflected back from DISCOVER_REQ |
216+
| pubkey | 8 or 32 | node's ID (or prefix) |
217+
186218

187219
# Custom packet
188220

examples/companion_radio/DataStore.cpp

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ void DataStore::loadPrefs(NodePrefs& prefs, double& node_lat, double& node_lon)
197197
}
198198

199199
void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& node_lat, double& node_lon) {
200-
#if defined(RP2040_PLATFORM)
201-
File file = _fs->open(filename, "r");
202-
#else
203-
File file = _fs->open(filename);
204-
#endif
200+
File file = openRead(_fs, filename);
205201
if (file) {
206202
uint8_t pad[8];
207203

@@ -262,16 +258,7 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
262258
}
263259

264260
void DataStore::loadContacts(DataStoreHost* host) {
265-
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
266-
if (_getContactsChannelsFS()->exists("/contacts3")) {
267-
File file = _getContactsChannelsFS()->open("/contacts3");
268-
#elif defined(RP2040_PLATFORM)
269-
if (_fs->exists("/contacts3")) {
270-
File file = _fs->open("/contacts3", "r");
271-
#else
272-
if (_fs->exists("/contacts3")) {
273-
File file = _fs->open("/contacts3", "r", false);
274-
#endif
261+
File file = openRead(_getContactsChannelsFS(), "/contacts3");
275262
if (file) {
276263
bool full = false;
277264
while (!full) {
@@ -299,7 +286,6 @@ void DataStore::loadContacts(DataStoreHost* host) {
299286
}
300287
file.close();
301288
}
302-
}
303289
}
304290

305291
void DataStore::saveContacts(DataStoreHost* host) {
@@ -332,16 +318,7 @@ void DataStore::saveContacts(DataStoreHost* host) {
332318
}
333319

334320
void DataStore::loadChannels(DataStoreHost* host) {
335-
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
336-
if (_getContactsChannelsFS()->exists("/channels2")) {
337-
File file = _getContactsChannelsFS()->open("/channels2");
338-
#elif defined(RP2040_PLATFORM)
339-
if (_fs->exists("/channels2")) {
340-
File file = _fs->open("/channels2", "r");
341-
#else
342-
if (_fs->exists("/channels2")) {
343-
File file = _fs->open("/channels2", "r", false);
344-
#endif
321+
File file = openRead(_getContactsChannelsFS(), "/channels2");
345322
if (file) {
346323
bool full = false;
347324
uint8_t channel_idx = 0;
@@ -363,7 +340,6 @@ void DataStore::loadChannels(DataStoreHost* host) {
363340
}
364341
file.close();
365342
}
366-
}
367343
}
368344

369345
void DataStore::saveChannels(DataStoreHost* host) {
@@ -520,7 +496,7 @@ void DataStore::migrateToSecondaryFS() {
520496
}
521497

522498
uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_buf[]) {
523-
File file = _getContactsChannelsFS()->open("/adv_blobs");
499+
File file = openRead(_getContactsChannelsFS(), "/adv_blobs");
524500
uint8_t len = 0; // 0 = not found
525501
if (file) {
526502
BlobRec tmp;
@@ -583,11 +559,7 @@ uint8_t DataStore::getBlobByKey(const uint8_t key[], int key_len, uint8_t dest_b
583559
sprintf(path, "/bl/%s", fname);
584560

585561
if (_fs->exists(path)) {
586-
#if defined(RP2040_PLATFORM)
587-
File f = _fs->open(path, "r");
588-
#else
589-
File f = _fs->open(path);
590-
#endif
562+
File f = openRead(_fs, path);
591563
if (f) {
592564
int len = f.read(dest_buf, 255); // currently MAX 255 byte blob len supported!!
593565
f.close();

0 commit comments

Comments
 (0)