Skip to content

Commit 5b975d9

Browse files
author
Scott Powell
committed
Merge branch 'dev' into ext-trace
2 parents cdbeacd + ffbc24b commit 5b975d9

Some content is hidden

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

47 files changed

+1036
-68
lines changed

examples/companion_radio/DataStore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ void DataStore::loadPrefsInt(const char *filename, NodePrefs& _prefs, double& no
221221
file.read((uint8_t *)&_prefs.multi_acks, sizeof(_prefs.multi_acks)); // 77
222222
file.read(pad, 2); // 78
223223
file.read((uint8_t *)&_prefs.ble_pin, sizeof(_prefs.ble_pin)); // 80
224+
file.read((uint8_t *)&_prefs.buzzer_quiet, sizeof(_prefs.buzzer_quiet)); // 84
224225

225226
file.close();
226227
}
@@ -252,6 +253,7 @@ void DataStore::savePrefs(const NodePrefs& _prefs, double node_lat, double node_
252253
file.write((uint8_t *)&_prefs.multi_acks, sizeof(_prefs.multi_acks)); // 77
253254
file.write(pad, 2); // 78
254255
file.write((uint8_t *)&_prefs.ble_pin, sizeof(_prefs.ble_pin)); // 80
256+
file.write((uint8_t *)&_prefs.buzzer_quiet, sizeof(_prefs.buzzer_quiet)); // 84
255257

256258
file.close();
257259
}

examples/companion_radio/MyMesh.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
152152
pending_login = pending_status = pending_telemetry = pending_discovery = pending_req = 0;
153153
}
154154

155+
public:
156+
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
157+
155158
private:
156159
void writeOKFrame();
157160
void writeErrFrame(uint8_t err_code);
@@ -171,11 +174,9 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
171174
void checkSerialInterface();
172175

173176
// helpers, short-cuts
174-
void savePrefs() { _store->savePrefs(_prefs, sensors.node_lat, sensors.node_lon); }
175177
void saveChannels() { _store->saveChannels(this); }
176178
void saveContacts() { _store->saveContacts(this); }
177179

178-
private:
179180
DataStore* _store;
180181
NodePrefs _prefs;
181182
uint32_t pending_login;

examples/companion_radio/NodePrefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ struct NodePrefs { // persisted to file
2424
float rx_delay_base;
2525
uint32_t ble_pin;
2626
uint8_t advert_loc_policy;
27+
uint8_t buzzer_quiet;
2728
};

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
532532

533533
#ifdef PIN_BUZZER
534534
buzzer.begin();
535+
buzzer.quiet(_node_prefs->buzzer_quiet);
535536
#endif
536537

537538
#ifdef PIN_VIBRATION
@@ -618,7 +619,7 @@ void UITask::userLedHandler() {
618619
led_state = 0;
619620
next_led_change = cur_time + LED_CYCLE_MILLIS - last_led_increment;
620621
}
621-
digitalWrite(PIN_STATUS_LED, led_state);
622+
digitalWrite(PIN_STATUS_LED, led_state == LED_STATE_ON);
622623
}
623624
#endif
624625
}
@@ -650,6 +651,7 @@ void UITask::shutdown(bool restart){
650651
_board->reboot();
651652
} else {
652653
_display->turnOff();
654+
radio_driver.powerOff();
653655
_board->powerOff();
654656
}
655657
}
@@ -871,6 +873,8 @@ void UITask::toggleBuzzer() {
871873
buzzer.quiet(true);
872874
showAlert("Buzzer: OFF", 800);
873875
}
876+
_node_prefs->buzzer_quiet = buzzer.isQuiet();
877+
the_mesh.savePrefs();
874878
_next_refresh = 0; // trigger refresh
875879
#endif
876880
}

examples/companion_radio/ui-orig/UITask.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
5656

5757
#ifdef PIN_BUZZER
5858
buzzer.begin();
59+
buzzer.quiet(_node_prefs->buzzer_quiet);
5960
#endif
6061

6162
// Initialize digital button if available
@@ -269,7 +270,7 @@ void UITask::userLedHandler() {
269270
state = 0;
270271
next_change = cur_time + LED_CYCLE_MILLIS - last_increment;
271272
}
272-
digitalWrite(PIN_STATUS_LED, state);
273+
digitalWrite(PIN_STATUS_LED, state == LED_STATE_ON);
273274
}
274275
#endif
275276
}
@@ -292,10 +293,12 @@ void UITask::shutdown(bool restart){
292293

293294
#endif // PIN_BUZZER
294295

295-
if (restart)
296+
if (restart) {
296297
_board->reboot();
297-
else
298+
} else {
299+
radio_driver.powerOff();
298300
_board->powerOff();
301+
}
299302
}
300303

301304
void UITask::loop() {
@@ -394,6 +397,8 @@ void UITask::handleButtonTriplePress() {
394397
buzzer.quiet(true);
395398
sprintf(_alert, "Buzzer: OFF");
396399
}
400+
_node_prefs->buzzer_quiet = buzzer.isQuiet();
401+
the_mesh.savePrefs();
397402
_need_refresh = true;
398403
#endif
399404
}

examples/simple_repeater/MyMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ void MyMesh::onPeerDataRecv(mesh::Packet *packet, uint8_t type, int sender_idx,
545545
} else if (type == PAYLOAD_TYPE_TXT_MSG && len > 5 && client->isAdmin()) { // a CLI command
546546
uint32_t sender_timestamp;
547547
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
548-
uint flags = (data[4] >> 2); // message attempt number, and other flags
548+
uint8_t flags = (data[4] >> 2); // message attempt number, and other flags
549549

550550
if (!(flags == TXT_TYPE_PLAIN || flags == TXT_TYPE_CLI_DATA)) {
551551
MESH_DEBUG_PRINTLN("onPeerDataRecv: unsupported text type received: flags=%02x", (uint32_t)flags);

examples/simple_room_server/MyMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void MyMesh::onPeerDataRecv(mesh::Packet *packet, uint8_t type, int sender_idx,
398398
if (type == PAYLOAD_TYPE_TXT_MSG && len > 5) { // a CLI command or new Post
399399
uint32_t sender_timestamp;
400400
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
401-
uint flags = (data[4] >> 2); // message attempt number, and other flags
401+
uint8_t flags = (data[4] >> 2); // message attempt number, and other flags
402402

403403
if (!(flags == TXT_TYPE_PLAIN || flags == TXT_TYPE_CLI_DATA)) {
404404
MESH_DEBUG_PRINTLN("onPeerDataRecv: unsupported command flags received: flags=%02x", (uint32_t)flags);

examples/simple_sensor/SensorMesh.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
554554
} else if (type == PAYLOAD_TYPE_TXT_MSG && len > 5 && from->isAdmin()) { // a CLI command
555555
uint32_t sender_timestamp;
556556
memcpy(&sender_timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
557-
uint flags = (data[4] >> 2); // message attempt number, and other flags
557+
uint8_t flags = (data[4] >> 2); // message attempt number, and other flags
558558

559559
if (sender_timestamp > from->last_timestamp) { // prevent replay attacks
560560
if (flags == TXT_TYPE_PLAIN) {
@@ -612,7 +612,7 @@ void SensorMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender_i
612612
}
613613
}
614614

615-
bool SensorMesh::handleIncomingMsg(ClientInfo& from, uint32_t timestamp, uint8_t* data, uint flags, size_t len) {
615+
bool SensorMesh::handleIncomingMsg(ClientInfo& from, uint32_t timestamp, uint8_t* data, uint8_t flags, size_t len) {
616616
MESH_DEBUG_PRINT("handleIncomingMsg: unhandled msg from ");
617617
#ifdef MESH_DEBUG
618618
mesh::Utils::printHex(Serial, from.id.pub_key, PUB_KEY_SIZE);

examples/simple_sensor/SensorMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class SensorMesh : public mesh::Mesh, public CommonCLICallbacks {
127127
bool onPeerPathRecv(mesh::Packet* packet, int sender_idx, const uint8_t* secret, uint8_t* path, uint8_t path_len, uint8_t extra_type, uint8_t* extra, uint8_t extra_len) override;
128128
void onControlDataRecv(mesh::Packet* packet) override;
129129
void onAckRecv(mesh::Packet* packet, uint32_t ack_crc) override;
130-
virtual bool handleIncomingMsg(ClientInfo& from, uint32_t timestamp, uint8_t* data, uint flags, size_t len);
130+
virtual bool handleIncomingMsg(ClientInfo& from, uint32_t timestamp, uint8_t* data, uint8_t flags, size_t len);
131131
void sendAckTo(const ClientInfo& dest, uint32_t ack_hash);
132132
private:
133133
FILESYSTEM* _fs;

src/helpers/BaseChatMesh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void BaseChatMesh::onPeerDataRecv(mesh::Packet* packet, uint8_t type, int sender
166166
if (type == PAYLOAD_TYPE_TXT_MSG && len > 5) {
167167
uint32_t timestamp;
168168
memcpy(&timestamp, data, 4); // timestamp (by sender's RTC clock - which could be wrong)
169-
uint flags = data[4] >> 2; // message attempt number, and other flags
169+
uint8_t flags = data[4] >> 2; // message attempt number, and other flags
170170

171171
// len can be > original length, but 'text' will be padded with zeroes
172172
data[len] = 0; // need to make a C string again, with null terminator

0 commit comments

Comments
 (0)