Skip to content

Commit d84feac

Browse files
author
Scott Powell
committed
Merge branch 'dev' into double-acks
2 parents 1f23632 + fc541bd commit d84feac

26 files changed

+699
-17
lines changed

boards/seeed-wio-tracker-l1.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v7.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_SEEED_WIO_TRACKER_L1 -DNRF52840_XXAA -DSEEED_WIO_TRACKER_L1 ",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
[ "0x2886", "0x1667" ],
12+
[ "0x2886", "0x1668" ]
13+
],
14+
"mcu": "nrf52840",
15+
"variant": "Seeed_Wio_Tracker_L1",
16+
"softdevice": {
17+
"sd_flags": "-DS140",
18+
"sd_name": "s140",
19+
"sd_version": "7.3.0",
20+
"sd_fwid": "0x0123"
21+
},
22+
"bsp": {
23+
"name": "adafruit"
24+
},
25+
"bootloader": {
26+
"settings_addr": "0xFF000"
27+
},
28+
"usb_product": "Seeed Wio Tracker L1"
29+
},
30+
"connectivity": [
31+
"bluetooth"
32+
],
33+
"debug": {
34+
"jlink_device": "nRF52840_xxAA",
35+
"openocd_target": "nrf52.cfg",
36+
"svd_path": "nrf52840.svd"
37+
},
38+
"frameworks": [
39+
"arduino"
40+
],
41+
"name": "Seeed Wio Tracker L1",
42+
"upload": {
43+
"maximum_ram_size": 248832,
44+
"maximum_size": 815104,
45+
"protocol": "nrfutil",
46+
"speed": 115200,
47+
"protocols": [
48+
"jlink",
49+
"nrfjprog",
50+
"nrfutil",
51+
"cmsis-dap",
52+
"sam-ba",
53+
"blackmagic"
54+
],
55+
"use_1200bps_touch": true,
56+
"require_upload_port": true,
57+
"wait_for_upload_port": true
58+
},
59+
"url": "https://wiki.seeedstudio.com/wio_tracker_l1_node/",
60+
"vendor": "Seeed Studio"
61+
}

examples/companion_radio/MyMesh.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define CMD_GET_CUSTOM_VARS 40
4646
#define CMD_SET_CUSTOM_VAR 41
4747
#define CMD_GET_ADVERT_PATH 42
48+
#define CMD_GET_TUNING_PARAMS 43
4849

4950
#define RESP_CODE_OK 0
5051
#define RESP_CODE_ERR 1
@@ -69,6 +70,7 @@
6970
#define RESP_CODE_SIGNATURE 20
7071
#define RESP_CODE_CUSTOM_VARS 21
7172
#define RESP_CODE_ADVERT_PATH 22
73+
#define RESP_CODE_TUNING_PARAMS 23
7274

7375
#define SEND_TIMEOUT_BASE_MILLIS 500
7476
#define FLOOD_SEND_TIMEOUT_FACTOR 16.0f
@@ -1016,6 +1018,13 @@ void MyMesh::handleCmdFrame(size_t len) {
10161018
_prefs.airtime_factor = ((float)af) / 1000.0f;
10171019
savePrefs();
10181020
writeOKFrame();
1021+
} else if (cmd_frame[0] == CMD_GET_TUNING_PARAMS) {
1022+
uint32_t rx = _prefs.rx_delay_base * 1000, af = _prefs.airtime_factor * 1000;
1023+
int i = 0;
1024+
out_frame[i++] = RESP_CODE_TUNING_PARAMS;
1025+
memcpy(&out_frame[i], &rx, 4); i += 4;
1026+
memcpy(&out_frame[i], &af, 4); i += 4;
1027+
_serial->writeFrame(out_frame, i);
10191028
} else if (cmd_frame[0] == CMD_SET_OTHER_PARAMS) {
10201029
_prefs.manual_add_contacts = cmd_frame[1];
10211030
if (len >= 3) {

examples/simple_sensor/SensorMesh.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,14 @@ void SensorMesh::applyContactPermissions(const uint8_t* pubkey, uint16_t perms)
332332
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); // trigger saveContacts()
333333
}
334334

335-
void SensorMesh::sendAlert(const char* text) {
335+
void SensorMesh::sendAlert(AlertPriority pri, const char* text) {
336336
int text_len = strlen(text);
337+
uint16_t pri_mask = (pri == HIGH_PRI_ALERT) ? PERM_RECV_ALERTS_HI : PERM_RECV_ALERTS_LO;
337338

338339
// send text message to all contacts with RECV_ALERT permission
339340
for (int i = 0; i < num_contacts; i++) {
340341
auto c = &contacts[i];
341-
if ((c->permissions & PERM_RECV_ALERTS) == 0) continue; // contact does NOT want alerts
342+
if ((c->permissions & pri_mask) == 0) continue; // contact does NOT want alert
342343

343344
uint8_t data[MAX_PACKET_PAYLOAD];
344345
uint32_t now = getRTCClock()->getCurrentTimeUnique(); // need different timestamp per packet
@@ -360,12 +361,12 @@ void SensorMesh::sendAlert(const char* text) {
360361
}
361362
}
362363

363-
void SensorMesh::alertIf(bool condition, Trigger& t, const char* text) {
364+
void SensorMesh::alertIf(bool condition, Trigger& t, AlertPriority pri, const char* text) {
364365
if (condition) {
365366
if (!t.triggered) {
366367
t.triggered = true;
367368
t.time = getRTCClock()->getCurrentTime();
368-
sendAlert(text);
369+
sendAlert(pri, text);
369370
}
370371
} else {
371372
if (t.triggered) {
@@ -422,7 +423,7 @@ uint8_t SensorMesh::handleLoginReq(const mesh::Identity& sender, const uint8_t*
422423
MESH_DEBUG_PRINTLN("Login success!");
423424
client->last_timestamp = sender_timestamp;
424425
client->last_activity = getRTCClock()->getCurrentTime();
425-
client->permissions = PERM_IS_ADMIN | PERM_RECV_ALERTS;
426+
client->permissions = PERM_IS_ADMIN | PERM_RECV_ALERTS_HI | PERM_RECV_ALERTS_LO; // initially opt-in to receive alerts (can opt out)
426427
memcpy(client->shared_secret, secret, PUB_KEY_SIZE);
427428

428429
dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY);

examples/simple_sensor/SensorMesh.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
#define PERM_IS_ADMIN 0x8000
2727
#define PERM_GET_TELEMETRY 0x0001
2828
#define PERM_GET_MIN_MAX_AVG 0x0002
29-
#define PERM_RECV_ALERTS 0x0100
29+
#define PERM_RECV_ALERTS_LO 0x0100 // low priority alerts
30+
#define PERM_RECV_ALERTS_HI 0x0200 // high priority alerts
3031

3132
struct ContactInfo {
3233
mesh::Identity id;
@@ -104,8 +105,8 @@ class SensorMesh : public mesh::Mesh, public CommonCLICallbacks {
104105

105106
Trigger() { triggered = false; time = 0; }
106107
};
107-
108-
void alertIf(bool condition, Trigger& t, const char* text);
108+
enum AlertPriority { LOW_PRI_ALERT, HIGH_PRI_ALERT };
109+
void alertIf(bool condition, Trigger& t, AlertPriority pri, const char* text);
109110

110111
virtual void onSensorDataRead() = 0; // for app to implement
111112
virtual int querySeriesData(uint32_t start_secs_ago, uint32_t end_secs_ago, MinMaxAvg dest[], int max_num) = 0; // for app to implement
@@ -145,6 +146,6 @@ class SensorMesh : public mesh::Mesh, public CommonCLICallbacks {
145146
ContactInfo* putContact(const mesh::Identity& id);
146147
void applyContactPermissions(const uint8_t* pubkey, uint16_t perms);
147148

148-
void sendAlert(const char* text);
149+
void sendAlert(AlertPriority pri, const char* text);
149150

150151
};

examples/simple_sensor/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MyMesh : public SensorMesh {
2222
float batt_voltage = getVoltage(TELEM_CHANNEL_SELF);
2323

2424
battery_data.recordData(getRTCClock(), batt_voltage); // record battery
25-
alertIf(batt_voltage < 3.4f, low_batt, "Battery low!");
25+
alertIf(batt_voltage < 3.4f, low_batt, HIGH_PRI_ALERT, "Battery low!");
2626
}
2727

2828
int querySeriesData(uint32_t start_secs_ago, uint32_t end_secs_ago, MinMaxAvg dest[], int max_num) override {

src/helpers/ui/buzzer.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ void genericBuzzer::shutdown() {
4646

4747
void genericBuzzer::quiet(bool buzzer_state) {
4848
_is_quiet = buzzer_state;
49+
#ifdef PIN_BUZZER_EN
50+
if (_is_quiet) {
51+
digitalWrite(PIN_BUZZER_EN, LOW);
52+
} else {
53+
digitalWrite(PIN_BUZZER_EN, HIGH);
54+
}
55+
#endif
4956
}
5057

5158
bool genericBuzzer::isQuiet() {
File renamed without changes.
File renamed without changes.

variants/minewsemi_me25ls01/platformio.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ build_flags = ${nrf52840_me25ls01.build_flags}
3434
-D ENV_INCLUDE_INA219=1
3535
build_src_filter = ${nrf52840_me25ls01.build_src_filter}
3636
+<helpers/*.cpp>
37-
+<helpers/nrf52/MinewsemiME25LS01Board.cpp>
3837
+<../variants/minewsemi_me25ls01>
3938
+<helpers/sensors>
4039
debug_tool = jlink

variants/minewsemi_me25ls01/target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define RADIOLIB_STATIC_ONLY 1
44
#include <RadioLib.h>
55
#include <helpers/RadioLibWrappers.h>
6-
#include <helpers/nrf52/MinewsemiME25LS01Board.h>
6+
#include <MinewsemiME25LS01Board.h>
77
#include <helpers/CustomLR1110Wrapper.h>
88
#include <helpers/ArduinoHelpers.h>
99
#include <helpers/SensorManager.h>

0 commit comments

Comments
 (0)