Merge upstream/dev (10 commits) [upstream-sync]
This commit is contained in:
commit
9d02e2870d
21 files changed
+123
-33
No files matched your search
@@ -521,6 +521,11 @@ int BaseChatMesh::sendCommandData(const ContactInfo& recipient, uint32_t timest
|
||||
}
|
||||
|
||||
bool BaseChatMesh::sendGroupMessage(uint32_t timestamp, mesh::GroupChannel& channel, const char* sender_name, const char* text, int text_len) {
|
||||
if (text_len < 0) { // memcpy() below would read this as a size_t, so clamping cannot catch it
|
||||
MESH_DEBUG_PRINTLN("sendGroupMessage: invalid negative text_len=%d", text_len);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t temp[5+MAX_TEXT_LEN+32];
|
||||
memcpy(temp, ×tamp, 4); // mostly an extra blob to help make packet_hash unique
|
||||
temp[4] = 0; // TXT_TYPE_PLAIN
|
||||
|
||||
@@ -2,6 +2,22 @@
|
||||
#include "TxtDataHelpers.h"
|
||||
#include "Utils.h"
|
||||
#include "target.h"
|
||||
#include <ctype.h>
|
||||
|
||||
namespace {
|
||||
|
||||
// strtof() and atof() also read "nan" and "inf". A NaN cannot be refused by a
|
||||
// range check: no ordered comparison is true for it, and under -ffast-math,
|
||||
// which nRF52 builds use, the compiler may assume it never occurs and fold any
|
||||
// test on the parsed value away. So the text is checked before it is parsed:
|
||||
// after optional white space and sign, a number starts with a digit or a '.'.
|
||||
bool looksLikeANumber(const char* s) {
|
||||
while (isspace((unsigned char)*s)) s++;
|
||||
if (*s == '+' || *s == '-') s++;
|
||||
return isdigit((unsigned char)*s) || *s == '.';
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool CommonRadioPrefs::getByKey(const char* key, char* value, size_t max_len) {
|
||||
if (strcmp(key, "fem_rxgain") == 0) {
|
||||
@@ -69,7 +85,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
|
||||
if (memcmp(command, "set af ", 7) == 0) {
|
||||
char* end;
|
||||
float af = strtof(&command[7], &end);
|
||||
if (end == &command[7] || af < 0 || af > 9) {
|
||||
if (end == &command[7] || !looksLikeANumber(&command[7]) || af < 0 || af > 9) {
|
||||
strcpy(reply, "ERROR: af must be 0-9");
|
||||
} else {
|
||||
setAirtimeFactor(af);
|
||||
@@ -87,7 +103,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
|
||||
}
|
||||
if (memcmp(command, "set dutycycle ", 14) == 0) {
|
||||
float dc = atof(&command[14]);
|
||||
if (dc < 1 || dc > 100) {
|
||||
if (!looksLikeANumber(&command[14]) || dc < 1 || dc > 100) {
|
||||
strcpy(reply, "ERROR: dutycycle must be 1-100");
|
||||
} else {
|
||||
setAirtimeFactor((100.0f / dc) - 1.0f);
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
virtual void forceFullRefresh() {} // next refresh will be full for eink
|
||||
virtual void turnOn() = 0;
|
||||
virtual void turnOff() = 0;
|
||||
virtual void blankScreen() {} // to cleanly erase screen before turning off
|
||||
virtual void powerOff() {}
|
||||
virtual void clear() = 0;
|
||||
virtual void startFrame(ColorVal bkg = UIColor::window_bkg) = 0;
|
||||
virtual void setTextSize(int sz) = 0;
|
||||
|
||||
@@ -75,20 +75,27 @@ void GxEPDDisplay::turnOn() {
|
||||
}
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff() {
|
||||
void GxEPDDisplay::powerOff() {
|
||||
display.hibernate();
|
||||
}
|
||||
|
||||
void GxEPDDisplay::turnOff() { // Only stops refresh
|
||||
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
digitalWrite(DISP_BACKLIGHT, LOW);
|
||||
#elif defined(EXP_PIN_BACKLIGHT) && !defined(BACKLIGHT_BTN)
|
||||
expander.digitalWrite(EXP_PIN_BACKLIGHT, LOW);
|
||||
#endif
|
||||
_isOn = false;
|
||||
last_display_crc_value=0;
|
||||
}
|
||||
|
||||
void GxEPDDisplay::blankScreen() {
|
||||
// do full refresh before powering off to clear screen
|
||||
// no full refresh needed at wakeup
|
||||
display.clearScreen(0xFF); // Clears microcontroller side RAM
|
||||
display.writeScreenBuffer(0xFF); // Forces 0xFF (White) into the display controller's history registers
|
||||
resetPartialRefreshCounter();
|
||||
last_display_crc_value=0;
|
||||
display.hibernate();
|
||||
}
|
||||
|
||||
void GxEPDDisplay::clear() {
|
||||
|
||||
@@ -60,6 +60,8 @@ public:
|
||||
void resetPartialRefreshCounter() { _cycles_before_full_refresh = max_partial_refresh; };
|
||||
void turnOn() override;
|
||||
void turnOff() override;
|
||||
void blankScreen() override;
|
||||
void powerOff() override;
|
||||
void clear() override;
|
||||
void startFrame(ColorVal bkg = UIColor::window_bkg) override;
|
||||
void setTextSize(int sz) override;
|
||||
|
||||
Reference in new issue
Block a user