Skip to content

Commit e50fe31

Browse files
authored
Merge pull request #1528 from recrof/revert-1437-dev
Revert "Remove _serial->isConnected() logic from buzzer notifications"
2 parents acca73f + c345f1d commit e50fe31

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

examples/companion_radio/MyMesh.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,11 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
330330
memcpy(&out_frame[1], contact.id.pub_key, PUB_KEY_SIZE);
331331
_serial->writeFrame(out_frame, 1 + PUB_KEY_SIZE);
332332
}
333-
}
333+
} else {
334334
#ifdef DISPLAY_CLASS
335-
if (_ui && !_prefs.buzzer_quiet) _ui->notify(UIEventType::newContactMessage); //buzz if enabled
335+
if (_ui) _ui->notify(UIEventType::newContactMessage);
336336
#endif
337+
}
337338

338339
// add inbound-path to mem cache
339340
if (path && path_len <= sizeof(AdvertPath::path)) { // check path is valid
@@ -440,7 +441,9 @@ void MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
440441
bool should_display = txt_type == TXT_TYPE_PLAIN || txt_type == TXT_TYPE_SIGNED_PLAIN;
441442
if (should_display && _ui) {
442443
_ui->newMsg(path_len, from.name, text, offline_queue_len);
443-
if (!_prefs.buzzer_quiet) _ui->notify(UIEventType::contactMessage); //buzz if enabled
444+
if (!_serial->isConnected()) {
445+
_ui->notify(UIEventType::contactMessage);
446+
}
444447
}
445448
#endif
446449
}
@@ -525,19 +528,19 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
525528
uint8_t frame[1];
526529
frame[0] = PUSH_CODE_MSG_WAITING; // send push 'tickle'
527530
_serial->writeFrame(frame, 1);
531+
} else {
532+
#ifdef DISPLAY_CLASS
533+
if (_ui) _ui->notify(UIEventType::channelMessage);
534+
#endif
528535
}
529-
530536
#ifdef DISPLAY_CLASS
531537
// Get the channel name from the channel index
532538
const char *channel_name = "Unknown";
533539
ChannelDetails channel_details;
534540
if (getChannel(channel_idx, channel_details)) {
535541
channel_name = channel_details.name;
536542
}
537-
if (_ui) {
538-
_ui->newMsg(path_len, channel_name, text, offline_queue_len);
539-
if (!_prefs.buzzer_quiet) _ui->notify(UIEventType::channelMessage); //buzz if enabled
540-
}
543+
if (_ui) _ui->newMsg(path_len, channel_name, text, offline_queue_len);
541544
#endif
542545
}
543546

@@ -796,7 +799,6 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
796799
_prefs.bw = LORA_BW;
797800
_prefs.cr = LORA_CR;
798801
_prefs.tx_power_dbm = LORA_TX_POWER;
799-
_prefs.buzzer_quiet = 0;
800802
_prefs.gps_enabled = 0; // GPS disabled by default
801803
_prefs.gps_interval = 0; // No automatic GPS updates by default
802804
//_prefs.rx_delay_base = 10.0f; enable once new algo fixed
@@ -836,7 +838,6 @@ void MyMesh::begin(bool has_display) {
836838
_prefs.sf = constrain(_prefs.sf, 5, 12);
837839
_prefs.cr = constrain(_prefs.cr, 5, 8);
838840
_prefs.tx_power_dbm = constrain(_prefs.tx_power_dbm, 1, MAX_LORA_TX_POWER);
839-
_prefs.buzzer_quiet = constrain(_prefs.buzzer_quiet, 0, 1); // Ensure boolean 0 or 1
840841
_prefs.gps_enabled = constrain(_prefs.gps_enabled, 0, 1); // Ensure boolean 0 or 1
841842
_prefs.gps_interval = constrain(_prefs.gps_interval, 0, 86400); // Max 24 hours
842843

0 commit comments

Comments
 (0)