Skip to content

Commit d360931

Browse files
authored
Merge branch 'meshcore-dev:dev' into dev
2 parents bfdd5fb + be78049 commit d360931

33 files changed

Lines changed: 2118 additions & 23 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ cmake-*
1616
compile_commands.json
1717
.venv/
1818
venv/
19+
platformio.local.ini

docs/cli_commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ This document provides an overview of CLI commands that can be sent to MeshCore
557557
- `set agc.reset.interval <value>`
558558

559559
**Parameters:**
560-
- `value`: Interval in seconds rounded down to a multiple of 4 (17 becomes 16)
560+
- `value`: Interval in seconds rounded down to a multiple of 4 (17 becomes 16). 0 to disable.
561561

562562
**Default:** `0.0`
563563

docs/nrf52_power_management.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@ Shutdown reason codes (stored in GPREGRET2):
3333

3434
## Supported Boards
3535

36+
3637
| Board | Implemented | LPCOMP wake | VBUS wake |
3738
|-------|-------------|-------------|-----------|
3839
| Seeed Studio XIAO nRF52840 (`xiao_nrf52`) | Yes | Yes | Yes |
3940
| RAK4631 (`rak4631`) | Yes | Yes | Yes |
4041
| Heltec T114 (`heltec_t114`) | Yes | Yes | Yes |
42+
| GAT562 Mesh Watch13 | Yes | Yes | Yes |
4143
| Promicro nRF52840 | No | No | No |
4244
| RAK WisMesh Tag | No | No | No |
4345
| Heltec Mesh Solar | No | No | No |

docs/number_allocations.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Number Allocations
2+
3+
This document lists unique numbers/identifiers used in various MeshCore protcol payloads.
4+
5+
# Group Data Types
6+
7+
The `PAYLOAD_TYPE_GRP_DATA` payloads have a 16-bit data-type field, which identifies which application the packet is for.
8+
9+
To make sure multiple applications can function without interfering with each other, the table below is for reserving various ranges of data-type values. Just modify this table, adding a row, then submit a PR to have it authorised/merged.
10+
11+
NOTE: the range FF00 - FFFF is for use while you're developing, doing POC, and for these you don't need to request to use/allocate.
12+
13+
Once you have a working app/project, you need to be able to demonstrate it exists/works, and THEN request type IDs. So, just use the testing/dev range while developing, then request IDs before you transition to publishing your project.
14+
15+
| Data-Type range | App name | Contact |
16+
|-----------------|-----------------------------|------------------------------------------------------|
17+
| 0000 - 00FF | -reserved for internal use- | |
18+
| FF00 - FFFF | -reserved for testing/dev- | |
19+
20+
(add rows, inside the range 0100 - FEFF for custom apps)

docs/payloads.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ txt_type
226226
| reply path | (variable) | reply path |
227227

228228

229-
# Group text message / datagram
229+
# Group text message
230230

231231
| Field | Size (bytes) | Description |
232232
|--------------|-----------------|--------------------------------------------|
@@ -236,6 +236,22 @@ txt_type
236236

237237
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`).
238238

239+
# Group datagram
240+
241+
| Field | Size (bytes) | Description |
242+
|--------------|-----------------|--------------------------------------------|
243+
| channel hash | 1 | first byte of SHA256 of channel's shared key |
244+
| cipher MAC | 2 | MAC for encrypted data in next field |
245+
| ciphertext | rest of payload | encrypted data, see below for details |
246+
247+
The data contained in the ciphertext uses the format below:
248+
249+
| Field | Size (bytes) | Description |
250+
|--------------|-----------------|--------------------------------------------|
251+
| data type | 2 | Identifier for type of data. (See number_allocations.md) |
252+
| data len | 1 | byte length of data |
253+
| data | rest of payload | (depends on data type) |
254+
239255

240256
# Control data
241257

examples/simple_repeater/MyMesh.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
119119
#endif
120120

121121
void putNeighbour(const mesh::Identity& id, uint32_t timestamp, float snr);
122-
void sendNodeDiscoverReq();
123122
uint8_t handleLoginReq(const mesh::Identity& sender, const uint8_t* secret, uint32_t sender_timestamp, const uint8_t* data, bool is_flood);
124123
uint8_t handleAnonRegionsReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
125124
uint8_t handleAnonOwnerReq(const mesh::Identity& sender, uint32_t sender_timestamp, const uint8_t* data);
@@ -177,7 +176,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
177176
MyMesh(mesh::MainBoard& board, mesh::Radio& radio, mesh::MillisecondClock& ms, mesh::RNG& rng, mesh::RTCClock& rtc, mesh::MeshTables& tables);
178177

179178
void begin(FILESYSTEM* fs);
180-
179+
void sendNodeDiscoverReq();
181180
const char* getFirmwareVer() override { return FIRMWARE_VERSION; }
182181
const char* getBuildDate() override { return FIRMWARE_BUILD_DATE; }
183182
const char* getRole() override { return FIRMWARE_ROLE; }

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dependencies": {
55
"SPI": "*",
66
"Wire": "*",
7-
"jgromes/RadioLib": "^7.3.0",
7+
"jgromes/RadioLib": "^7.6.0",
88
"rweather/Crypto": "^0.4.0",
99
"adafruit/RTClib": "^2.1.3",
1010
"melopero/Melopero RV3028": "^1.1.0",

platformio.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
[platformio]
1212
extra_configs =
1313
variants/*/platformio.ini
14+
platformio.local.ini
1415

1516
[arduino_base]
1617
framework = arduino
1718
monitor_speed = 115200
1819
lib_deps =
1920
SPI
2021
Wire
21-
jgromes/RadioLib @ ^7.3.0
22+
jgromes/RadioLib @ ^7.6.0
2223
rweather/Crypto @ ^0.4.0
2324
adafruit/RTClib @ ^2.1.3
2425
melopero/Melopero RV3028 @ ^1.1.0

src/helpers/AutoDiscoverRTCClock.cpp

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "AutoDiscoverRTCClock.h"
22
#include "RTClib.h"
33
#include <Melopero_RV3028.h>
4+
#include "RTC_RX8130CE.h"
45

56
static RTC_DS3231 rtc_3231;
67
static bool ds3231_success = false;
@@ -11,9 +12,13 @@ static bool rv3028_success = false;
1112
static RTC_PCF8563 rtc_8563;
1213
static bool rtc_8563_success = false;
1314

15+
static RTC_RX8130CE rtc_8130;
16+
static bool rtc_8130_success = false;
17+
1418
#define DS3231_ADDRESS 0x68
1519
#define RV3028_ADDRESS 0x52
1620
#define PCF8563_ADDRESS 0x51
21+
#define RX8130CE_ADDRESS 0x32
1722

1823
bool AutoDiscoverRTCClock::i2c_probe(TwoWire& wire, uint8_t addr) {
1924
wire.beginTransmission(addr);
@@ -25,22 +30,32 @@ void AutoDiscoverRTCClock::begin(TwoWire& wire) {
2530
if (i2c_probe(wire, DS3231_ADDRESS)) {
2631
ds3231_success = rtc_3231.begin(&wire);
2732
}
33+
2834
if (i2c_probe(wire, RV3028_ADDRESS)) {
2935
rtc_rv3028.initI2C(wire);
30-
rtc_rv3028.writeToRegister(0x35, 0x00);
31-
rtc_rv3028.writeToRegister(0x37, 0xB4); // Direct Switching Mode (DSM): when VDD < VBACKUP, switchover occurs from VDD to VBACKUP
32-
rtc_rv3028.set24HourMode(); // Set the device to use the 24hour format (default) instead of the 12 hour format
36+
rtc_rv3028.writeToRegister(0x35, 0x00);
37+
rtc_rv3028.writeToRegister(0x37, 0xB4); // Direct Switching Mode (DSM): when VDD < VBACKUP, switchover occurs from VDD to VBACKUP
38+
rtc_rv3028.set24HourMode(); // Set the device to use the 24hour format (default) instead of the 12 hour format
3339
rv3028_success = true;
3440
}
35-
if(i2c_probe(wire,PCF8563_ADDRESS)){
41+
42+
if (i2c_probe(wire, PCF8563_ADDRESS)) {
3643
rtc_8563_success = rtc_8563.begin(&wire);
3744
}
45+
46+
if (i2c_probe(wire, RX8130CE_ADDRESS)) {
47+
MESH_DEBUG_PRINTLN("RX8130CE: Found");
48+
rtc_8130.begin(&wire);
49+
rtc_8130_success = true;
50+
MESH_DEBUG_PRINTLN("RX8130CE: Initialized");
51+
}
3852
}
3953

4054
uint32_t AutoDiscoverRTCClock::getCurrentTime() {
4155
if (ds3231_success) {
4256
return rtc_3231.now().unixtime();
4357
}
58+
4459
if (rv3028_success) {
4560
return DateTime(
4661
rtc_rv3028.getYear(),
@@ -51,9 +66,16 @@ uint32_t AutoDiscoverRTCClock::getCurrentTime() {
5166
rtc_rv3028.getSecond()
5267
).unixtime();
5368
}
54-
if(rtc_8563_success){
69+
70+
if (rtc_8563_success) {
5571
return rtc_8563.now().unixtime();
5672
}
73+
74+
if (rtc_8130_success) {
75+
MESH_DEBUG_PRINTLN("RX8130CE: Reading time");
76+
return rtc_8130.now().unixtime();
77+
}
78+
5779
return _fallback->getCurrentTime();
5880
}
5981

@@ -66,6 +88,9 @@ void AutoDiscoverRTCClock::setCurrentTime(uint32_t time) {
6688
rtc_rv3028.setTime(dt.year(), dt.month(), weekday, dt.day(), dt.hour(), dt.minute(), dt.second());
6789
} else if (rtc_8563_success) {
6890
rtc_8563.adjust(DateTime(time));
91+
} else if (rtc_8130_success) {
92+
MESH_DEBUG_PRINTLN("RX8130CE: Setting time");
93+
rtc_8130.adjust(DateTime(time));
6994
} else {
7095
_fallback->setCurrentTime(time);
7196
}

0 commit comments

Comments
 (0)