Adapt to new protobufs - TODO: factory_reset rewire

This commit is contained in:
Thomas Göttgens
2022-09-09 12:51:41 +02:00
parent 0c46ad91ef
commit f7b12f0695
38 changed files with 268 additions and 325 deletions

View File

@@ -122,7 +122,7 @@ class GPSStatus : public Status
// Only update the status if values have actually changed // Only update the status if values have actually changed
bool isDirty = matches(newStatus); bool isDirty = matches(newStatus);
if (isDirty && p.pos_timestamp && (newStatus->p.pos_timestamp == p.pos_timestamp)) { if (isDirty && p.timestamp && (newStatus->p.timestamp == p.timestamp)) {
// We can NEVER be in two locations at the same time! (also PR #886) // We can NEVER be in two locations at the same time! (also PR #886)
DEBUG_MSG("BUG!! positional timestamp unchanged from prev solution\n"); DEBUG_MSG("BUG!! positional timestamp unchanged from prev solution\n");
} }
@@ -136,7 +136,7 @@ class GPSStatus : public Status
if (isDirty) { if (isDirty) {
if (hasLock) { if (hasLock) {
// In debug logs, identify position by @timestamp:stage (stage 3 = notify) // In debug logs, identify position by @timestamp:stage (stage 3 = notify)
DEBUG_MSG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, sats=%d\n", p.pos_timestamp, DEBUG_MSG("New GPS pos@%x:3 lat=%f, lon=%f, alt=%d, pdop=%.2f, track=%.2f, sats=%d\n", p.timestamp,
p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5, p.latitude_i * 1e-7, p.longitude_i * 1e-7, p.altitude, p.PDOP * 1e-2, p.ground_track * 1e-5,
p.sats_in_view); p.sats_in_view);
} else } else

View File

@@ -384,59 +384,8 @@ bool Power::axp192Init()
DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE"); DEBUG_MSG("DCDC3: %s\n", axp.isDCDC3Enable() ? "ENABLE" : "DISABLE");
DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE"); DEBUG_MSG("Exten: %s\n", axp.isExtenEnable() ? "ENABLE" : "DISABLE");
switch (config.power.charge_current) { // this was the previous 'Unset' default.
case Config_PowerConfig_ChargeCurrent_MAUnset: axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
break;
case Config_PowerConfig_ChargeCurrent_MA100:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_100MA);
break;
case Config_PowerConfig_ChargeCurrent_MA190:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_190MA);
break;
case Config_PowerConfig_ChargeCurrent_MA280:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_280MA);
break;
case Config_PowerConfig_ChargeCurrent_MA360:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_360MA);
break;
case Config_PowerConfig_ChargeCurrent_MA450:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_450MA);
break;
case Config_PowerConfig_ChargeCurrent_MA550:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_550MA);
break;
case Config_PowerConfig_ChargeCurrent_MA630:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_630MA);
break;
case Config_PowerConfig_ChargeCurrent_MA700:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_700MA);
break;
case Config_PowerConfig_ChargeCurrent_MA780:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_780MA);
break;
case Config_PowerConfig_ChargeCurrent_MA880:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_880MA);
break;
case Config_PowerConfig_ChargeCurrent_MA960:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_960MA);
break;
case Config_PowerConfig_ChargeCurrent_MA1000:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1000MA);
break;
case Config_PowerConfig_ChargeCurrent_MA1080:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1080MA);
break;
case Config_PowerConfig_ChargeCurrent_MA1160:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1160MA);
break;
case Config_PowerConfig_ChargeCurrent_MA1240:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1240MA);
break;
case Config_PowerConfig_ChargeCurrent_MA1320:
axp.setChargeControlCur(AXP1XX_CHARGE_CUR_1320MA);
break;
}
#if 0 #if 0

View File

@@ -16,7 +16,7 @@ static bool isPowered()
return true; return true;
#endif #endif
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0); bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER ? 1 : 0);
// If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON // If we are not a router and we already have AC power go to POWER state after init, otherwise go to ON
// We assume routers might be powered all the time, but from a low current (solar) source // We assume routers might be powered all the time, but from a low current (solar) source
@@ -237,7 +237,7 @@ Fsm powerFSM(&stateBOOT);
void PowerFSM_setup() void PowerFSM_setup()
{ {
bool isRouter = (config.device.role == Config_DeviceConfig_Role_Router ? 1 : 0); bool isRouter = (config.device.role == Config_DeviceConfig_Role_ROUTER ? 1 : 0);
bool hasPower = isPowered(); bool hasPower = isPowered();
DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower); DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower);

View File

@@ -8,4 +8,4 @@
#define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__) #define RECORD_CRITICALERROR(code) recordCriticalError(code, __LINE__, __FILE__)
/// Record an error that should be reported via analytics /// Record an error that should be reported via analytics
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0, const char *filename = NULL); void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_UNSPECIFIED, uint32_t address = 0, const char *filename = NULL);

View File

@@ -273,7 +273,7 @@ uint32_t GPS::getWakeTime() const
return t; // already maxint return t; // already maxint
if (t == 0) if (t == 0)
t = (config.device.role == Config_DeviceConfig_Role_Router) t = (config.device.role == Config_DeviceConfig_Role_ROUTER)
? 5 * 60 ? 5 * 60
: 15 * 60; // Allow up to 15 mins for each attempt (probably will be much : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much
// less if we can find sats) or less if a router // less if we can find sats) or less if a router
@@ -297,7 +297,7 @@ uint32_t GPS::getSleepTime() const
return t; // already maxint return t; // already maxint
if (t == 0) // default - unset in preferences if (t == 0) // default - unset in preferences
t = (config.device.role == Config_DeviceConfig_Role_Router) ? 24 * 60 * 60 t = (config.device.role == Config_DeviceConfig_Role_ROUTER) ? 24 * 60 * 60
: 2 * 60; // 2 mins or once per day for routers : 2 * 60; // 2 mins or once per day for routers
t *= 1000; t *= 1000;
@@ -311,7 +311,7 @@ void GPS::publishUpdate()
shouldPublish = false; shouldPublish = false;
// In debug logs, identify position by @timestamp:stage (stage 2 = publish) // In debug logs, identify position by @timestamp:stage (stage 2 = publish)
DEBUG_MSG("publishing pos@%x:2, hasVal=%d, GPSlock=%d\n", p.pos_timestamp, hasValidLocation, hasLock()); DEBUG_MSG("publishing pos@%x:2, hasVal=%d, GPSlock=%d\n", p.timestamp, hasValidLocation, hasLock());
// Notify any status instances that are observing us // Notify any status instances that are observing us
const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), p); const meshtastic::GPSStatus status = meshtastic::GPSStatus(hasValidLocation, isConnected(), p);

View File

@@ -155,7 +155,7 @@ bool NMEAGPS::lookForLocation()
return false; return false;
} }
p.location_source = Position_LocSource_LOCSRC_GPS_INTERNAL; p.location_source = Position_LocSource_LOC_INTERNAL;
// Dilution of precision (an accuracy metric) is reported in 10^2 units, so we need to scale down when we use it // Dilution of precision (an accuracy metric) is reported in 10^2 units, so we need to scale down when we use it
#ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS #ifndef TINYGPS_OPTION_NO_CUSTOM_FIELDS
@@ -176,8 +176,7 @@ bool NMEAGPS::lookForLocation()
p.latitude_i = toDegInt(loc.lat); p.latitude_i = toDegInt(loc.lat);
p.longitude_i = toDegInt(loc.lng); p.longitude_i = toDegInt(loc.lng);
p.alt_geoid_sep = reader.geoidHeight.meters(); p.altitude_hae = reader.altitude.meters() + reader.geoidHeight.meters();
p.altitude_hae = reader.altitude.meters() + p.alt_geoid_sep;
p.altitude = reader.altitude.meters(); p.altitude = reader.altitude.meters();
p.fix_quality = fixQual; p.fix_quality = fixQual;
@@ -194,7 +193,7 @@ bool NMEAGPS::lookForLocation()
t.tm_mon = reader.date.month() - 1; t.tm_mon = reader.date.month() - 1;
t.tm_year = reader.date.year() - 1900; t.tm_year = reader.date.year() - 1900;
t.tm_isdst = false; t.tm_isdst = false;
p.pos_timestamp = mktime(&t); p.timestamp = mktime(&t);
// Nice to have, if available // Nice to have, if available
if (reader.satellites.isUpdated()) { if (reader.satellites.isUpdated()) {

View File

@@ -540,21 +540,21 @@ static void drawGPScoordinates(OLEDDisplay *display, int16_t x, int16_t y, const
display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine); display->drawString(x + (SCREEN_WIDTH - (display->getStringWidth(displayLine))) / 2, y, displayLine);
} else { } else {
if (gpsFormat != Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) { if (gpsFormat != Config_DisplayConfig_GpsCoordinateFormat_DMS) {
char coordinateLine[22]; char coordinateLine[22];
geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude())); geoCoord.updateCoords(int32_t(gps->getLatitude()), int32_t(gps->getLongitude()), int32_t(gps->getAltitude()));
if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDec) { // Decimal Degrees if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_DEC) { // Decimal Degrees
sprintf(coordinateLine, "%f %f", geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7); sprintf(coordinateLine, "%f %f", geoCoord.getLatitude() * 1e-7, geoCoord.getLongitude() * 1e-7);
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatUTM) { // Universal Transverse Mercator } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_UTM) { // Universal Transverse Mercator
sprintf(coordinateLine, "%2i%1c %06u %07u", geoCoord.getUTMZone(), geoCoord.getUTMBand(), sprintf(coordinateLine, "%2i%1c %06u %07u", geoCoord.getUTMZone(), geoCoord.getUTMBand(),
geoCoord.getUTMEasting(), geoCoord.getUTMNorthing()); geoCoord.getUTMEasting(), geoCoord.getUTMNorthing());
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatMGRS) { // Military Grid Reference System } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_MGRS) { // Military Grid Reference System
sprintf(coordinateLine, "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), geoCoord.getMGRSBand(), sprintf(coordinateLine, "%2i%1c %1c%1c %05u %05u", geoCoord.getMGRSZone(), geoCoord.getMGRSBand(),
geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), geoCoord.getMGRSEasting(), geoCoord.getMGRSEast100k(), geoCoord.getMGRSNorth100k(), geoCoord.getMGRSEasting(),
geoCoord.getMGRSNorthing()); geoCoord.getMGRSNorthing());
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOLC) { // Open Location Code } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OLC) { // Open Location Code
geoCoord.getOLCCode(coordinateLine); geoCoord.getOLCCode(coordinateLine);
} else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_GpsFormatOSGR) { // Ordnance Survey Grid Reference } else if (gpsFormat == Config_DisplayConfig_GpsCoordinateFormat_OSGR) { // Ordnance Survey Grid Reference
if (geoCoord.getOSGRE100k() == 'I' || geoCoord.getOSGRN100k() == 'I') // OSGR is only valid around the UK region if (geoCoord.getOSGRE100k() == 'I' || geoCoord.getOSGRN100k() == 'I') // OSGR is only valid around the UK region
sprintf(coordinateLine, "%s", "Out of Boundary"); sprintf(coordinateLine, "%s", "Out of Boundary");
else else
@@ -1010,7 +1010,7 @@ int32_t Screen::runOnce()
} }
#ifndef DISABLE_WELCOME_UNSET #ifndef DISABLE_WELCOME_UNSET
if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_Unset) { if (showingNormalScreen && config.lora.region == Config_LoRaConfig_RegionCode_UNSET) {
setWelcomeFrames(); setWelcomeFrames();
} }
#endif #endif
@@ -1366,8 +1366,8 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
#if HAS_WIFI #if HAS_WIFI
const char *wifiName = config.wifi.ssid; const char *wifiName = config.network.wifi_ssid;
const char *wifiPsw = config.wifi.psk; const char *wifiPsw = config.network.wifi_psk;
displayedNodeNum = 0; // Not currently showing a node pane displayedNodeNum = 0; // Not currently showing a node pane
@@ -1378,7 +1378,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
if (isSoftAPForced()) { if (isSoftAPForced()) {
display->drawString(x, y, String("WiFi: Software AP (Admin)")); display->drawString(x, y, String("WiFi: Software AP (Admin)"));
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) { } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) {
display->drawString(x, y, String("WiFi: Software AP")); display->drawString(x, y, String("WiFi: Software AP"));
} else if (WiFi.status() != WL_CONNECTED) { } else if (WiFi.status() != WL_CONNECTED) {
display->drawString(x, y, String("WiFi: Not Connected")); display->drawString(x, y, String("WiFi: Not Connected"));
@@ -1401,8 +1401,8 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
- WL_NO_SHIELD: assigned when no WiFi shield is present; - WL_NO_SHIELD: assigned when no WiFi shield is present;
*/ */
if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) { if (WiFi.status() == WL_CONNECTED || isSoftAPForced() || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) {
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) { if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str())); display->drawString(x, y + FONT_HEIGHT_SMALL * 1, "IP: " + String(WiFi.softAPIP().toString().c_str()));
// Number of connections to the AP. Default max for the esp32 is 4 // Number of connections to the AP. Default max for the esp32 is 4
@@ -1494,7 +1494,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
} }
} else { } else {
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) { if (config.network.wifi_mode== Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) {
if ((millis() / 10000) % 2) { if ((millis() / 10000) % 2) {
display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName)); display->drawString(x, y + FONT_HEIGHT_SMALL * 2, "SSID: " + String(wifiName));
} else { } else {
@@ -1542,25 +1542,25 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
auto mode = ""; auto mode = "";
switch (config.lora.modem_preset) { switch (config.lora.modem_preset) {
case Config_LoRaConfig_ModemPreset_ShortSlow: case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
mode = "ShortS"; mode = "ShortS";
break; break;
case Config_LoRaConfig_ModemPreset_ShortFast: case Config_LoRaConfig_ModemPreset_SHORT_FAST:
mode = "ShortF"; mode = "ShortF";
break; break;
case Config_LoRaConfig_ModemPreset_MedSlow: case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
mode = "MedS"; mode = "MedS";
break; break;
case Config_LoRaConfig_ModemPreset_MedFast: case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
mode = "MedF"; mode = "MedF";
break; break;
case Config_LoRaConfig_ModemPreset_LongSlow: case Config_LoRaConfig_ModemPreset_LONG_SLOW:
mode = "LongS"; mode = "LongS";
break; break;
case Config_LoRaConfig_ModemPreset_LongFast: case Config_LoRaConfig_ModemPreset_LONG_FAST:
mode = "LongF"; mode = "LongF";
break; break;
case Config_LoRaConfig_ModemPreset_VLongSlow: case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
mode = "VeryL"; mode = "VeryL";
break; break;
default: default:
@@ -1619,7 +1619,7 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
// Line 3 // Line 3
if (config.display.gps_format != if (config.display.gps_format !=
Config_DisplayConfig_GpsCoordinateFormat_GpsFormatDMS) // if DMS then don't draw altitude Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus); drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
// Line 4 // Line 4

View File

@@ -34,7 +34,7 @@ void RotaryEncoderInterruptBase::init(
int32_t RotaryEncoderInterruptBase::runOnce() int32_t RotaryEncoderInterruptBase::runOnce()
{ {
InputEvent e; InputEvent e;
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.source = this->_originName; e.source = this->_originName;
if (this->action == ROTARY_ACTION_PRESSED) { if (this->action == ROTARY_ACTION_PRESSED) {
@@ -48,7 +48,7 @@ int32_t RotaryEncoderInterruptBase::runOnce()
e.inputEvent = this->_eventCcw; e.inputEvent = this->_eventCcw;
} }
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE) { if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
this->notifyObservers(&e); this->notifyObservers(&e);
} }

View File

@@ -33,8 +33,8 @@ class RotaryEncoderInterruptBase : public Observable<const InputEvent *>, privat
private: private:
uint8_t _pinA = 0; uint8_t _pinA = 0;
uint8_t _pinB = 0; uint8_t _pinB = 0;
char _eventCw = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventCw = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
char _eventCcw = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventCcw = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
const char *_originName; const char *_originName;
}; };

View File

@@ -16,8 +16,8 @@ class UpDownInterruptBase : public Observable<const InputEvent *>
private: private:
uint8_t _pinDown = 0; uint8_t _pinDown = 0;
uint8_t _pinUp = 0; uint8_t _pinUp = 0;
char _eventDown = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventDown = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
char _eventUp = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventUp = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; char _eventPressed = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
const char *_originName; const char *_originName;
}; };

View File

@@ -17,9 +17,9 @@ void UpDownInterruptImpl1::init()
uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b; uint8_t pinDown = moduleConfig.canned_message.inputbroker_pin_b;
uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press; uint8_t pinPress = moduleConfig.canned_message.inputbroker_pin_press;
char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN); char eventDown = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_DOWN);
char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP); char eventUp = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_UP);
char eventPressed = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT); char eventPressed = static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_SELECT);
UpDownInterruptBase::init(pinDown, pinUp, pinPress, eventDown, eventUp, eventPressed, UpDownInterruptImpl1::handleIntDown, UpDownInterruptBase::init(pinDown, pinUp, pinPress, eventDown, eventUp, eventPressed, UpDownInterruptImpl1::handleIntDown,
UpDownInterruptImpl1::handleIntUp, UpDownInterruptImpl1::handleIntPressed); UpDownInterruptImpl1::handleIntUp, UpDownInterruptImpl1::handleIntPressed);

View File

@@ -10,7 +10,7 @@ KbI2cBase::KbI2cBase(const char *name) : concurrency::OSThread(name)
int32_t KbI2cBase::runOnce() int32_t KbI2cBase::runOnce()
{ {
InputEvent e; InputEvent e;
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_NONE;
e.source = this->_originName; e.source = this->_originName;
Wire.requestFrom(CARDKB_ADDR, 1); Wire.requestFrom(CARDKB_ADDR, 1);
@@ -19,30 +19,30 @@ int32_t KbI2cBase::runOnce()
char c = Wire.read(); char c = Wire.read();
switch (c) { switch (c) {
case 0x1b: // ESC case 0x1b: // ESC
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_CANCEL; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_CANCEL;
break; break;
case 0x08: // Back case 0x08: // Back
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_BACK; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_BACK;
break; break;
case 0xb5: // Up case 0xb5: // Up
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_UP;
break; break;
case 0xb6: // Down case 0xb6: // Down
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_DOWN;
break; break;
case 0xb4: // Left case 0xb4: // Left
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_LEFT; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_LEFT;
break; break;
case 0xb7: // Right case 0xb7: // Right
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_RIGHT; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_RIGHT;
break; break;
case 0x0d: // Enter case 0x0d: // Enter
e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT; e.inputEvent = ModuleConfig_CannedMessageConfig_InputEventChar_SELECT;
break; break;
} }
} }
if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_KEY_NONE) { if (e.inputEvent != ModuleConfig_CannedMessageConfig_InputEventChar_NONE) {
this->notifyObservers(&e); this->notifyObservers(&e);
} }
return 500; return 500;

View File

@@ -303,7 +303,7 @@ void setup()
// Do this after service.init (because that clears error_code) // Do this after service.init (because that clears error_code)
#ifdef HAS_AXP192 #ifdef HAS_AXP192
if (!axp192_found) if (!axp192_found)
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware RECORD_CRITICALERROR(CriticalErrorCode_NO_AXP192); // Record a hardware fault for missing hardware
#endif #endif
// Don't call screen setup until after nodedb is setup (because we need // Don't call screen setup until after nodedb is setup (because we need
@@ -421,7 +421,7 @@ void setup()
airTime = new AirTime(); airTime = new AirTime();
if (!rIf) if (!rIf)
RECORD_CRITICALERROR(CriticalErrorCode_NoRadio); RECORD_CRITICALERROR(CriticalErrorCode_NO_RADIO);
else { else {
router->addInterface(rIf); router->addInterface(rIf);

View File

@@ -85,7 +85,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
ChannelSettings &channelSettings = ch.settings; ChannelSettings &channelSettings = ch.settings;
Config_LoRaConfig &loraConfig = config.lora; Config_LoRaConfig &loraConfig = config.lora;
loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; // Default to Long Range & Fast loraConfig.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
loraConfig.tx_power = 0; // default loraConfig.tx_power = 0; // default
uint8_t defaultpskIndex = 1; uint8_t defaultpskIndex = 1;
@@ -214,25 +214,25 @@ const char *Channels::getName(size_t chIndex)
channelName = "Custom"; channelName = "Custom";
else else
switch (config.lora.modem_preset) { switch (config.lora.modem_preset) {
case Config_LoRaConfig_ModemPreset_ShortSlow: case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
channelName = "ShortS"; channelName = "ShortS";
break; break;
case Config_LoRaConfig_ModemPreset_ShortFast: case Config_LoRaConfig_ModemPreset_SHORT_FAST:
channelName = "ShortF"; channelName = "ShortF";
break; break;
case Config_LoRaConfig_ModemPreset_MedSlow: case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
channelName = "MedS"; channelName = "MedS";
break; break;
case Config_LoRaConfig_ModemPreset_MedFast: case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
channelName = "MedF"; channelName = "MedF";
break; break;
case Config_LoRaConfig_ModemPreset_LongSlow: case Config_LoRaConfig_ModemPreset_LONG_SLOW:
channelName = "LongS"; channelName = "LongS";
break; break;
case Config_LoRaConfig_ModemPreset_LongFast: case Config_LoRaConfig_ModemPreset_LONG_FAST:
channelName = "LongF"; channelName = "LongF";
break; break;
case Config_LoRaConfig_ModemPreset_VLongSlow: case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
channelName = "VeryL"; channelName = "VeryL";
break; break;
default: default:

View File

@@ -36,7 +36,7 @@ void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM Router::cancelSending(p->to, p->decoded.request_id); // cancel rebroadcast for this DM
} else if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { } else if ((p->to != getNodeNum()) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
if (p->id != 0) { if (p->id != 0) {
if (config.device.role != Config_DeviceConfig_Role_ClientMute) { if (config.device.role != Config_DeviceConfig_Role_CLIENT_MUTE) {
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
tosend->hop_limit--; // bump down the hop count tosend->hop_limit--; // bump down the hop count

View File

@@ -72,7 +72,7 @@ void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
bool moduleFound = false; bool moduleFound = false;
// We now allow **encrypted** packets to pass through the modules // We now allow **encrypted** packets to pass through the modules
bool isDecoded = mp.which_payloadVariant == MeshPacket_decoded_tag; bool isDecoded = mp.which_payload_variant == MeshPacket_decoded_tag;
currentReply = NULL; // No reply yet currentReply = NULL; // No reply yet
@@ -211,7 +211,7 @@ void MeshModule::sendResponse(const MeshPacket &req)
*/ */
void setReplyTo(MeshPacket *p, const MeshPacket &to) void setReplyTo(MeshPacket *p, const MeshPacket &to)
{ {
assert(p->which_payloadVariant == MeshPacket_decoded_tag); // Should already be set by now assert(p->which_payload_variant == MeshPacket_decoded_tag); // Should already be set by now
p->to = getFrom(&to); // Make sure that if we are sending to the local node, we use our local node addr, not 0 p->to = getFrom(&to); // Make sure that if we are sending to the local node, we use our local node addr, not 0
p->channel = to.channel; // Use the same channel that the request came in on p->channel = to.channel; // Use the same channel that the request came in on
@@ -266,7 +266,7 @@ AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const MeshP
// In case we have a response it always has priority. // In case we have a response it always has priority.
DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n", DEBUG_MSG("Reply prepared by module '%s' of variant: %d\n",
pi.name, pi.name,
response->which_variant); response->which_payload_variant);
handled = h; handled = h;
} }
else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) && else if ((handled != AdminMessageHandleResult::HANDLED_WITH_RESPONSE) &&

View File

@@ -252,7 +252,7 @@ int MeshService::onGPSChanged(const meshtastic::GPSStatus *newStatus)
pos.time = getValidTime(RTCQualityGPS); pos.time = getValidTime(RTCQualityGPS);
// In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB) // In debug logs, identify position by @timestamp:stage (stage 4 = nodeDB)
DEBUG_MSG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.pos_timestamp, pos.time, pos.latitude_i, DEBUG_MSG("onGPSChanged() pos@%x, time=%u, lat=%d, lon=%d, alt=%d\n", pos.timestamp, pos.time, pos.latitude_i,
pos.longitude_i, pos.altitude); pos.longitude_i, pos.altitude);
// Update our current position in the local DB // Update our current position in the local DB

View File

@@ -73,14 +73,13 @@ NodeNum getFrom(const MeshPacket *p)
return (p->from == 0) ? nodeDB.getNodeNum() : p->from; return (p->from == 0) ? nodeDB.getNodeNum() : p->from;
} }
bool NodeDB::resetRadioConfig() bool NodeDB::resetRadioConfig(bool factory_reset)
{ {
bool didFactoryReset = false; bool didFactoryReset = false;
radioGeneration++; radioGeneration++;
// radioConfig.has_preferences = true; if (factory_reset) {
if (config.device.factory_reset) {
didFactoryReset = factoryReset(); didFactoryReset = factoryReset();
} }
@@ -113,7 +112,6 @@ bool NodeDB::resetRadioConfig()
initRegion(); initRegion();
if (didFactoryReset) { if (didFactoryReset) {
config.device.factory_reset = false;
DEBUG_MSG("Rebooting due to factory reset"); DEBUG_MSG("Rebooting due to factory reset");
screen->startRebootScreen(); screen->startRebootScreen();
rebootAtMsec = millis() + (5 * 1000); rebootAtMsec = millis() + (5 * 1000);
@@ -157,13 +155,13 @@ void NodeDB::installDefaultConfig()
config.has_lora = true; config.has_lora = true;
config.has_position = true; config.has_position = true;
config.has_power = true; config.has_power = true;
config.has_wifi = true; config.has_network = true;
config.has_bluetooth = true; config.has_bluetooth = true;
config.lora.region = Config_LoRaConfig_RegionCode_Unset; config.lora.region = Config_LoRaConfig_RegionCode_UNSET;
config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LongFast; config.lora.modem_preset = Config_LoRaConfig_ModemPreset_LONG_FAST;
resetRadioConfig(); resetRadioConfig();
strncpy(config.device.ntp_server, "0.pool.ntp.org", 32); strncpy(config.network.ntp_server, "0.pool.ntp.org", 32);
// FIXME: Default to bluetooth capability of platform as default // FIXME: Default to bluetooth capability of platform as default
config.bluetooth.enabled = true; config.bluetooth.enabled = true;
config.bluetooth.fixed_pin = defaultBLEPin; config.bluetooth.fixed_pin = defaultBLEPin;
@@ -172,9 +170,9 @@ void NodeDB::installDefaultConfig()
#else #else
bool hasScreen = screen_found; bool hasScreen = screen_found;
#endif #endif
config.bluetooth.mode = hasScreen ? Config_BluetoothConfig_PairingMode_RandomPin : Config_BluetoothConfig_PairingMode_FixedPin; config.bluetooth.mode = hasScreen ? Config_BluetoothConfig_PairingMode_RANDOM_PIN : Config_BluetoothConfig_PairingMode_FIXED_PIN;
// for backward compat, default position flags are ALT+MSL // for backward compat, default position flags are ALT+MSL
config.position.position_flags = (Config_PositionConfig_PositionFlags_POS_ALTITUDE | Config_PositionConfig_PositionFlags_POS_ALT_MSL); config.position.position_flags = (Config_PositionConfig_PositionFlags_ALTITUDE | Config_PositionConfig_PositionFlags_ALTITUDE_MSL);
} }
void NodeDB::installDefaultModuleConfig() void NodeDB::installDefaultModuleConfig()
@@ -237,7 +235,7 @@ void NodeDB::init()
myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand myNodeInfo.max_channels = MAX_NUM_CHANNELS; // tell others the max # of channels we can understand
myNodeInfo.error_code = CriticalErrorCode_None; // For the error code, only show values from this boot (discard value from flash) myNodeInfo.error_code = CriticalErrorCode_NONE; // For the error code, only show values from this boot (discard value from flash)
myNodeInfo.error_address = 0; myNodeInfo.error_address = 0;
// likewise - we always want the app requirements to come from the running appload // likewise - we always want the app requirements to come from the running appload
@@ -468,7 +466,7 @@ void NodeDB::saveToDisk()
config.has_lora = true; config.has_lora = true;
config.has_position = true; config.has_position = true;
config.has_power = true; config.has_power = true;
config.has_wifi = true; config.has_network = true;
config.has_bluetooth = true; config.has_bluetooth = true;
saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config); saveProto(configFileName, LocalConfig_size, sizeof(LocalConfig), LocalConfig_fields, &config);
@@ -534,11 +532,11 @@ void NodeDB::updatePosition(uint32_t nodeId, const Position &p, RxSource src)
if (src == RX_SRC_LOCAL) { if (src == RX_SRC_LOCAL) {
// Local packet, fully authoritative // Local packet, fully authoritative
DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.pos_timestamp, p.time, p.latitude_i, DEBUG_MSG("updatePosition LOCAL pos@%x, time=%u, latI=%d, lonI=%d, alt=%d\n", p.timestamp, p.time, p.latitude_i,
p.longitude_i, p.altitude); p.longitude_i, p.altitude);
info->position = p; info->position = p;
} else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.pos_timestamp && !p.location_source) { } else if ((p.time > 0) && !p.latitude_i && !p.longitude_i && !p.timestamp && !p.location_source) {
// FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO // FIXME SPECIAL TIME SETTING PACKET FROM EUD TO RADIO
// (stop-gap fix for issue #900) // (stop-gap fix for issue #900)
DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time); DEBUG_MSG("updatePosition SPECIAL time setting time=%u\n", p.time);
@@ -623,7 +621,7 @@ void NodeDB::updateUser(uint32_t nodeId, const User &p)
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
void NodeDB::updateFrom(const MeshPacket &mp) void NodeDB::updateFrom(const MeshPacket &mp)
{ {
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.from) { if (mp.which_payload_variant == MeshPacket_decoded_tag && mp.from) {
DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time); DEBUG_MSG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time);
NodeInfo *info = getOrCreateNode(getFrom(&mp)); NodeInfo *info = getOrCreateNode(getFrom(&mp));

View File

@@ -60,7 +60,7 @@ class NodeDB
* *
* @return true if the config was completely reset, in that case, we should send it back to the client * @return true if the config was completely reset, in that case, we should send it back to the client
*/ */
bool resetRadioConfig(); bool resetRadioConfig(bool factory_reset = false);
/// given a subpacket sniffed from the network, update our DB state /// given a subpacket sniffed from the network, update our DB state
/// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw
@@ -171,7 +171,7 @@ extern NodeDB nodeDB;
// Our delay functions check for this for times that should never expire // Our delay functions check for this for times that should never expire
#define NODE_DELAY_FOREVER 0xffffffff #define NODE_DELAY_FOREVER 0xffffffff
#define IF_ROUTER(routerVal, normalVal) ((config.device.role == Config_DeviceConfig_Role_Router) ? (routerVal) : (normalVal)) #define IF_ROUTER(routerVal, normalVal) ((config.device.role == Config_DeviceConfig_Role_ROUTER) ? (routerVal) : (normalVal))
#define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60) #define default_broadcast_interval_secs IF_ROUTER(12 * 60 * 60, 15 * 60)
#define default_wait_bluetooth_secs IF_ROUTER(1, 60) #define default_wait_bluetooth_secs IF_ROUTER(1, 60)

View File

@@ -78,7 +78,7 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
memset(&toRadioScratch, 0, sizeof(toRadioScratch)); memset(&toRadioScratch, 0, sizeof(toRadioScratch));
if (pb_decode_from_bytes(buf, bufLength, ToRadio_fields, &toRadioScratch)) { if (pb_decode_from_bytes(buf, bufLength, ToRadio_fields, &toRadioScratch)) {
switch (toRadioScratch.which_payloadVariant) { switch (toRadioScratch.which_payload_variant) {
case ToRadio_packet_tag: case ToRadio_packet_tag:
return handleToRadioPacket(toRadioScratch.packet); return handleToRadioPacket(toRadioScratch.packet);
case ToRadio_want_config_id_tag: case ToRadio_want_config_id_tag:
@@ -134,7 +134,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
// If the user has specified they don't want our node to share its location, make sure to tell the phone // If the user has specified they don't want our node to share its location, make sure to tell the phone
// app not to send locations on our behalf. // app not to send locations on our behalf.
myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info
fromRadioScratch.which_payloadVariant = FromRadio_my_info_tag; fromRadioScratch.which_payload_variant = FromRadio_my_info_tag;
fromRadioScratch.my_info = myNodeInfo; fromRadioScratch.my_info = myNodeInfo;
state = STATE_SEND_NODEINFO; state = STATE_SEND_NODEINFO;
@@ -149,7 +149,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
if (info) { if (info) {
DEBUG_MSG("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id, DEBUG_MSG("Sending nodeinfo: num=0x%x, lastseen=%u, id=%s, name=%s\n", info->num, info->last_heard, info->user.id,
info->user.long_name); info->user.long_name);
fromRadioScratch.which_payloadVariant = FromRadio_node_info_tag; fromRadioScratch.which_payload_variant = FromRadio_node_info_tag;
fromRadioScratch.node_info = *info; fromRadioScratch.node_info = *info;
// Stay in current state until done sending nodeinfos // Stay in current state until done sending nodeinfos
} else { } else {
@@ -163,36 +163,36 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_CONFIG: case STATE_SEND_CONFIG:
DEBUG_MSG("getFromRadio=STATE_SEND_CONFIG\n"); DEBUG_MSG("getFromRadio=STATE_SEND_CONFIG\n");
fromRadioScratch.which_payloadVariant = FromRadio_config_tag; fromRadioScratch.which_payload_variant = FromRadio_config_tag;
switch (config_state) { switch (config_state) {
case Config_device_tag: case Config_device_tag:
fromRadioScratch.config.which_payloadVariant = Config_device_tag; fromRadioScratch.config.which_payload_variant = Config_device_tag;
fromRadioScratch.config.payloadVariant.device = config.device; fromRadioScratch.config.payload_variant.device = config.device;
break; break;
case Config_position_tag: case Config_position_tag:
fromRadioScratch.config.which_payloadVariant = Config_position_tag; fromRadioScratch.config.which_payload_variant = Config_position_tag;
fromRadioScratch.config.payloadVariant.position = config.position; fromRadioScratch.config.payload_variant.position = config.position;
break; break;
case Config_power_tag: case Config_power_tag:
fromRadioScratch.config.which_payloadVariant = Config_power_tag; fromRadioScratch.config.which_payload_variant = Config_power_tag;
fromRadioScratch.config.payloadVariant.power = config.power; fromRadioScratch.config.payload_variant.power = config.power;
fromRadioScratch.config.payloadVariant.power.ls_secs = default_ls_secs; fromRadioScratch.config.payload_variant.power.ls_secs = default_ls_secs;
break; break;
case Config_wifi_tag: case Config_network_tag:
fromRadioScratch.config.which_payloadVariant = Config_wifi_tag; fromRadioScratch.config.which_payload_variant = Config_network_tag;
fromRadioScratch.config.payloadVariant.wifi = config.wifi; fromRadioScratch.config.payload_variant.network = config.network;
break; break;
case Config_display_tag: case Config_display_tag:
fromRadioScratch.config.which_payloadVariant = Config_display_tag; fromRadioScratch.config.which_payload_variant = Config_display_tag;
fromRadioScratch.config.payloadVariant.display = config.display; fromRadioScratch.config.payload_variant.display = config.display;
break; break;
case Config_lora_tag: case Config_lora_tag:
fromRadioScratch.config.which_payloadVariant = Config_lora_tag; fromRadioScratch.config.which_payload_variant = Config_lora_tag;
fromRadioScratch.config.payloadVariant.lora = config.lora; fromRadioScratch.config.payload_variant.lora = config.lora;
break; break;
case Config_bluetooth_tag: case Config_bluetooth_tag:
fromRadioScratch.config.which_payloadVariant = Config_bluetooth_tag; fromRadioScratch.config.which_payload_variant = Config_bluetooth_tag;
fromRadioScratch.config.payloadVariant.bluetooth = config.bluetooth; fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
break; break;
} }
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. // NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
@@ -209,31 +209,31 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_MODULECONFIG: case STATE_SEND_MODULECONFIG:
DEBUG_MSG("getFromRadio=STATE_SEND_MODULECONFIG\n"); DEBUG_MSG("getFromRadio=STATE_SEND_MODULECONFIG\n");
fromRadioScratch.which_payloadVariant = FromRadio_moduleConfig_tag; fromRadioScratch.which_payload_variant = FromRadio_moduleConfig_tag;
switch (config_state) { switch (config_state) {
case ModuleConfig_mqtt_tag: case ModuleConfig_mqtt_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_mqtt_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_mqtt_tag;
fromRadioScratch.moduleConfig.payloadVariant.mqtt = moduleConfig.mqtt; fromRadioScratch.moduleConfig.payload_variant.mqtt = moduleConfig.mqtt;
break; break;
case ModuleConfig_serial_tag: case ModuleConfig_serial_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_serial_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_serial_tag;
fromRadioScratch.moduleConfig.payloadVariant.serial = moduleConfig.serial; fromRadioScratch.moduleConfig.payload_variant.serial = moduleConfig.serial;
break; break;
case ModuleConfig_external_notification_tag: case ModuleConfig_external_notification_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_external_notification_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_external_notification_tag;
fromRadioScratch.moduleConfig.payloadVariant.external_notification = moduleConfig.external_notification; fromRadioScratch.moduleConfig.payload_variant.external_notification = moduleConfig.external_notification;
break; break;
case ModuleConfig_range_test_tag: case ModuleConfig_range_test_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_range_test_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_range_test_tag;
fromRadioScratch.moduleConfig.payloadVariant.range_test = moduleConfig.range_test; fromRadioScratch.moduleConfig.payload_variant.range_test = moduleConfig.range_test;
break; break;
case ModuleConfig_telemetry_tag: case ModuleConfig_telemetry_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_telemetry_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_telemetry_tag;
fromRadioScratch.moduleConfig.payloadVariant.telemetry = moduleConfig.telemetry; fromRadioScratch.moduleConfig.payload_variant.telemetry = moduleConfig.telemetry;
break; break;
case ModuleConfig_canned_message_tag: case ModuleConfig_canned_message_tag:
fromRadioScratch.moduleConfig.which_payloadVariant = ModuleConfig_canned_message_tag; fromRadioScratch.moduleConfig.which_payload_variant = ModuleConfig_canned_message_tag;
fromRadioScratch.moduleConfig.payloadVariant.canned_message = moduleConfig.canned_message; fromRadioScratch.moduleConfig.payload_variant.canned_message = moduleConfig.canned_message;
break; break;
} }
@@ -247,7 +247,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
case STATE_SEND_COMPLETE_ID: case STATE_SEND_COMPLETE_ID:
DEBUG_MSG("getFromRadio=STATE_SEND_COMPLETE_ID\n"); DEBUG_MSG("getFromRadio=STATE_SEND_COMPLETE_ID\n");
fromRadioScratch.which_payloadVariant = FromRadio_config_complete_id_tag; fromRadioScratch.which_payload_variant = FromRadio_config_complete_id_tag;
fromRadioScratch.config_complete_id = config_nonce; fromRadioScratch.config_complete_id = config_nonce;
config_nonce = 0; config_nonce = 0;
state = STATE_SEND_PACKETS; state = STATE_SEND_PACKETS;
@@ -260,7 +260,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
printPacket("phone downloaded packet", packetForPhone); printPacket("phone downloaded packet", packetForPhone);
// Encapsulate as a FromRadio packet // Encapsulate as a FromRadio packet
fromRadioScratch.which_payloadVariant = FromRadio_packet_tag; fromRadioScratch.which_payload_variant = FromRadio_packet_tag;
fromRadioScratch.packet = *packetForPhone; fromRadioScratch.packet = *packetForPhone;
} }
releasePhonePacket(); releasePhonePacket();
@@ -271,7 +271,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
} }
// Do we have a message from the mesh? // Do we have a message from the mesh?
if (fromRadioScratch.which_payloadVariant != 0) { if (fromRadioScratch.which_payload_variant != 0) {
// Encapsulate as a FromRadio packet // Encapsulate as a FromRadio packet
size_t numbytes = pb_encode_to_bytes(buf, FromRadio_size, FromRadio_fields, &fromRadioScratch); size_t numbytes = pb_encode_to_bytes(buf, FromRadio_size, FromRadio_fields, &fromRadioScratch);
// DEBUG_MSG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payloadVariant, numbytes); // DEBUG_MSG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payloadVariant, numbytes);

View File

@@ -75,7 +75,7 @@ template <class T> class ProtobufModule : protected SinglePortModule
T scratch; T scratch;
T *decoded = NULL; T *decoded = NULL;
if (mp.which_payloadVariant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) { if (mp.which_payload_variant == MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) { if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) {
decoded = &scratch; decoded = &scratch;

View File

@@ -104,15 +104,15 @@ bool RF95Interface::reconfigure()
// configure publicly accessible settings // configure publicly accessible settings
int err = lora->setSpreadingFactor(sf); int err = lora->setSpreadingFactor(sf);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora->setBandwidth(bw); err = lora->setBandwidth(bw);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora->setCodingRate(cr); err = lora->setCodingRate(cr);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora->setSyncWord(syncWord); err = lora->setSyncWord(syncWord);
assert(err == RADIOLIB_ERR_NONE); assert(err == RADIOLIB_ERR_NONE);
@@ -125,13 +125,13 @@ bool RF95Interface::reconfigure()
err = lora->setFrequency(getFreq()); err = lora->setFrequency(getFreq());
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
if (power > MAX_POWER) // This chip has lower power limits than some if (power > MAX_POWER) // This chip has lower power limits than some
power = MAX_POWER; power = MAX_POWER;
err = lora->setOutputPower(power); err = lora->setOutputPower(power);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
startReceive(); // restart receiving startReceive(); // restart receiving

View File

@@ -27,7 +27,7 @@ const RegionInfo regions[] = {
/* /*
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
*/ */
RDEF(EU433, 433.0f, 434.0f, 10, 0, 12, true, false), RDEF(EU_433, 433.0f, 434.0f, 10, 0, 12, true, false),
/* /*
https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/ https://www.thethingsnetwork.org/docs/lorawan/duty-cycle/
@@ -43,7 +43,7 @@ const RegionInfo regions[] = {
(Please refer to section 4.21 in the following document) (Please refer to section 4.21 in the following document)
https://ec.europa.eu/growth/tools-databases/tris/index.cfm/ro/search/?trisaction=search.detail&year=2021&num=528&dLang=EN https://ec.europa.eu/growth/tools-databases/tris/index.cfm/ro/search/?trisaction=search.detail&year=2021&num=528&dLang=EN
*/ */
RDEF(EU868, 869.4f, 869.65f, 10, 0, 27, false, false), RDEF(EU_868, 869.4f, 869.65f, 10, 0, 27, false, false),
/* /*
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
@@ -88,7 +88,7 @@ const RegionInfo regions[] = {
https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752 https://rrf.rsm.govt.nz/smart-web/smart/page/-smart/domain/licence/LicenceSummary.wdk?id=219752
https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf https://iotalliance.org.nz/wp-content/uploads/sites/4/2019/05/IoT-Spectrum-in-NZ-Briefing-Paper.pdf
*/ */
RDEF(NZ865, 864.0f, 868.0f, 100, 0, 0, true, false), RDEF(NZ_865, 864.0f, 868.0f, 100, 0, 0, true, false),
/* /*
https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf https://lora-alliance.org/wp-content/uploads/2020/11/lorawan_regional_parameters_v1.0.3reva_0.pdf
@@ -98,7 +98,7 @@ const RegionInfo regions[] = {
/* /*
This needs to be last. Same as US. This needs to be last. Same as US.
*/ */
RDEF(Unset, 902.0f, 928.0f, 100, 0, 30, true, false) RDEF(UNSET, 902.0f, 928.0f, 100, 0, 30, true, false)
}; };
@@ -107,7 +107,7 @@ const RegionInfo *myRegion;
void initRegion() void initRegion()
{ {
const RegionInfo *r = regions; const RegionInfo *r = regions;
for (; r->code != Config_LoRaConfig_RegionCode_Unset && r->code != config.lora.region; r++) for (; r->code != Config_LoRaConfig_RegionCode_UNSET && r->code != config.lora.region; r++)
; ;
myRegion = r; myRegion = r;
DEBUG_MSG("Wanted region %d, using %s\n", config.lora.region, r->name); DEBUG_MSG("Wanted region %d, using %s\n", config.lora.region, r->name);
@@ -157,7 +157,7 @@ uint32_t RadioInterface::getPacketTime(uint32_t pl)
uint32_t RadioInterface::getPacketTime(MeshPacket *p) uint32_t RadioInterface::getPacketTime(MeshPacket *p)
{ {
assert(p->which_payloadVariant == MeshPacket_encrypted_tag); // It should have already been encoded by now assert(p->which_payload_variant == MeshPacket_encrypted_tag); // It should have already been encoded by now
uint32_t pl = p->encrypted.size + sizeof(PacketHeader); uint32_t pl = p->encrypted.size + sizeof(PacketHeader);
return getPacketTime(pl); return getPacketTime(pl);
@@ -204,8 +204,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
uint32_t delay = 0; uint32_t delay = 0;
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax); uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
// DEBUG_MSG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize); // DEBUG_MSG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
if (config.device.role == Config_DeviceConfig_Role_Router || if (config.device.role == Config_DeviceConfig_Role_ROUTER ||
config.device.role == Config_DeviceConfig_Role_RouterClient) { config.device.role == Config_DeviceConfig_Role_ROUTER_CLIENT) {
delay = random(0, 2*CWsize) * slotTimeMsec; delay = random(0, 2*CWsize) * slotTimeMsec;
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay); DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
} else { } else {
@@ -220,7 +220,7 @@ void printPacket(const char *prefix, const MeshPacket *p)
{ {
DEBUG_MSG("%s (id=0x%08x Fr0x%02x To0x%02x, WantAck%d, HopLim%d Ch0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff, DEBUG_MSG("%s (id=0x%08x Fr0x%02x To0x%02x, WantAck%d, HopLim%d Ch0x%x", prefix, p->id, p->from & 0xff, p->to & 0xff,
p->want_ack, p->hop_limit, p->channel); p->want_ack, p->hop_limit, p->channel);
if (p->which_payloadVariant == MeshPacket_decoded_tag) { if (p->which_payload_variant == MeshPacket_decoded_tag) {
auto &s = p->decoded; auto &s = p->decoded;
DEBUG_MSG(" Portnum=%d", s.portnum); DEBUG_MSG(" Portnum=%d", s.portnum);
@@ -357,37 +357,37 @@ void RadioInterface::applyModemConfig()
auto channelSettings = channels.getPrimary(); auto channelSettings = channels.getPrimary();
if (loraConfig.spread_factor == 0) { if (loraConfig.spread_factor == 0) {
switch (loraConfig.modem_preset) { switch (loraConfig.modem_preset) {
case Config_LoRaConfig_ModemPreset_ShortFast: case Config_LoRaConfig_ModemPreset_SHORT_FAST:
bw = 250; bw = 250;
cr = 8; cr = 8;
sf = 7; sf = 7;
break; break;
case Config_LoRaConfig_ModemPreset_ShortSlow: case Config_LoRaConfig_ModemPreset_SHORT_SLOW:
bw = 250; bw = 250;
cr = 8; cr = 8;
sf = 8; sf = 8;
break; break;
case Config_LoRaConfig_ModemPreset_MedFast: case Config_LoRaConfig_ModemPreset_MEDIUM_FAST:
bw = 250; bw = 250;
cr = 8; cr = 8;
sf = 9; sf = 9;
break; break;
case Config_LoRaConfig_ModemPreset_MedSlow: case Config_LoRaConfig_ModemPreset_MEDIUM_SLOW:
bw = 250; bw = 250;
cr = 8; cr = 8;
sf = 10; sf = 10;
break; break;
case Config_LoRaConfig_ModemPreset_LongFast: case Config_LoRaConfig_ModemPreset_LONG_FAST:
bw = 250; bw = 250;
cr = 8; cr = 8;
sf = 11; sf = 11;
break; break;
case Config_LoRaConfig_ModemPreset_LongSlow: case Config_LoRaConfig_ModemPreset_LONG_SLOW:
bw = 125; bw = 125;
cr = 8; cr = 8;
sf = 12; sf = 12;
break; break;
case Config_LoRaConfig_ModemPreset_VLongSlow: case Config_LoRaConfig_ModemPreset_VERY_LONG_SLOW:
bw = 31.25; bw = 31.25;
cr = 8; cr = 8;
sf = 12; sf = 12;
@@ -479,7 +479,7 @@ size_t RadioInterface::beginSending(MeshPacket *p)
assert(!sendingPacket); assert(!sendingPacket);
// DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad()); // DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
assert(p->which_payloadVariant == MeshPacket_encrypted_tag); // It should have already been encoded by now assert(p->which_payload_variant == MeshPacket_encrypted_tag); // It should have already been encoded by now
lastTxStart = millis(); lastTxStart = millis();

View File

@@ -99,7 +99,7 @@ bool RadioLibInterface::canSendImmediately()
// TX IRQ from the radio, the radio is probably broken. // TX IRQ from the radio, the radio is probably broken.
if (busyTx && (millis() - lastTxStart > 60000)) { if (busyTx && (millis() - lastTxStart > 60000)) {
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n"); DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
RECORD_CRITICALERROR(CriticalErrorCode_TransmitFailed); RECORD_CRITICALERROR(CriticalErrorCode_TRANSMIT_FAILED);
#ifdef ARCH_ESP32 #ifdef ARCH_ESP32
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
ESP.restart(); ESP.restart();
@@ -120,10 +120,10 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
#ifndef DISABLE_WELCOME_UNSET #ifndef DISABLE_WELCOME_UNSET
if (config.lora.region != Config_LoRaConfig_RegionCode_Unset) { if (config.lora.region != Config_LoRaConfig_RegionCode_UNSET) {
if (disabled || config.lora.tx_disabled) { if (disabled || config.lora.tx_disabled) {
if (config.lora.region != Config_LoRaConfig_RegionCode_Unset) { if (config.lora.region != Config_LoRaConfig_RegionCode_UNSET) {
if (disabled || config.lora.tx_disabled) { if (disabled || config.lora.tx_disabled) {
DEBUG_MSG("send - lora_tx_disabled\n"); DEBUG_MSG("send - lora_tx_disabled\n");
packetPool.release(p); packetPool.release(p);
@@ -362,7 +362,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
addReceiveMetadata(mp); addReceiveMetadata(mp);
mp->which_payloadVariant = MeshPacket_encrypted_tag; // Mark that the payload is still encrypted at this point mp->which_payload_variant = MeshPacket_encrypted_tag; // Mark that the payload is still encrypted at this point
assert(((uint32_t)payloadLen) <= sizeof(mp->encrypted.bytes)); assert(((uint32_t)payloadLen) <= sizeof(mp->encrypted.bytes));
memcpy(mp->encrypted.bytes, payload, payloadLen); memcpy(mp->encrypted.bytes, payload, payloadLen);
mp->encrypted.size = payloadLen; mp->encrypted.size = payloadLen;
@@ -393,7 +393,7 @@ ErrorCode RadioLibInterface::send(MeshPacket *p)
int res = iface->startTransmit(radiobuf, numbytes); int res = iface->startTransmit(radiobuf, numbytes);
if (res != RADIOLIB_ERR_NONE) { if (res != RADIOLIB_ERR_NONE) {
RECORD_CRITICALERROR(CriticalErrorCode_RadioSpiBug); RECORD_CRITICALERROR(CriticalErrorCode_RADIO_SPI_BUG);
// This send failed, but make sure to 'complete' it properly // This send failed, but make sure to 'complete' it properly
completeSending(); completeSending();

View File

@@ -115,7 +115,7 @@ MeshPacket *Router::allocForSending()
{ {
MeshPacket *p = packetPool.allocZeroed(); MeshPacket *p = packetPool.allocZeroed();
p->which_payloadVariant = MeshPacket_decoded_tag; // Assume payload is decoded at start. p->which_payload_variant = MeshPacket_decoded_tag; // Assume payload is decoded at start.
p->from = nodeDB.getNodeNum(); p->from = nodeDB.getNodeNum();
p->to = NODENUM_BROADCAST; p->to = NODENUM_BROADCAST;
if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) { if (config.lora.hop_limit && config.lora.hop_limit <= HOP_MAX) {
@@ -206,11 +206,11 @@ ErrorCode Router::send(MeshPacket *p)
// If the packet hasn't yet been encrypted, do so now (it might already be encrypted if we are just forwarding it) // If the packet hasn't yet been encrypted, do so now (it might already be encrypted if we are just forwarding it)
assert(p->which_payloadVariant == MeshPacket_encrypted_tag || assert(p->which_payload_variant == MeshPacket_encrypted_tag ||
p->which_payloadVariant == MeshPacket_decoded_tag); // I _think_ all packets should have a payload by now p->which_payload_variant == MeshPacket_decoded_tag); // I _think_ all packets should have a payload by now
// If the packet is not yet encrypted, do so now // If the packet is not yet encrypted, do so now
if (p->which_payloadVariant == MeshPacket_decoded_tag) { if (p->which_payload_variant == MeshPacket_decoded_tag) {
ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it ChannelIndex chIndex = p->channel; // keep as a local because we are about to change it
#if HAS_WIFI #if HAS_WIFI
@@ -277,7 +277,7 @@ bool perhapsDecode(MeshPacket *p)
// DEBUG_MSG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant); // DEBUG_MSG("\n\n** perhapsDecode payloadVariant - %d\n\n", p->which_payloadVariant);
if (p->which_payloadVariant == MeshPacket_decoded_tag) if (p->which_payload_variant == MeshPacket_decoded_tag)
return true; // If packet was already decoded just return return true; // If packet was already decoded just return
// assert(p->which_payloadVariant == MeshPacket_encrypted_tag); // assert(p->which_payloadVariant == MeshPacket_encrypted_tag);
@@ -304,7 +304,7 @@ bool perhapsDecode(MeshPacket *p)
DEBUG_MSG("Invalid portnum (bad psk?)!\n"); DEBUG_MSG("Invalid portnum (bad psk?)!\n");
} else { } else {
// parsing was successful // parsing was successful
p->which_payloadVariant = MeshPacket_decoded_tag; // change type to decoded p->which_payload_variant = MeshPacket_decoded_tag; // change type to decoded
p->channel = chIndex; // change to store the index instead of the hash p->channel = chIndex; // change to store the index instead of the hash
/* /*
@@ -349,7 +349,7 @@ bool perhapsDecode(MeshPacket *p)
Routing_Error perhapsEncode(MeshPacket *p) Routing_Error perhapsEncode(MeshPacket *p)
{ {
// If the packet is not yet encrypted, do so now // If the packet is not yet encrypted, do so now
if (p->which_payloadVariant == MeshPacket_decoded_tag) { if (p->which_payload_variant == MeshPacket_decoded_tag) {
static uint8_t bytes[MAX_RHPACKETLEN]; // we have to use a scratch buffer because a union static uint8_t bytes[MAX_RHPACKETLEN]; // we have to use a scratch buffer because a union
size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded); size_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded);
@@ -407,7 +407,7 @@ Routing_Error perhapsEncode(MeshPacket *p)
// Copy back into the packet and set the variant type // Copy back into the packet and set the variant type
memcpy(p->encrypted.bytes, bytes, numbytes); memcpy(p->encrypted.bytes, bytes, numbytes);
p->encrypted.size = numbytes; p->encrypted.size = numbytes;
p->which_payloadVariant = MeshPacket_encrypted_tag; p->which_payload_variant = MeshPacket_encrypted_tag;
} }
return Routing_Error_NONE; return Routing_Error_NONE;

View File

@@ -116,15 +116,15 @@ bool SX126xInterface<T>::reconfigure()
// configure publicly accessible settings // configure publicly accessible settings
int err = lora.setSpreadingFactor(sf); int err = lora.setSpreadingFactor(sf);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora.setBandwidth(bw); err = lora.setBandwidth(bw);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
err = lora.setCodingRate(cr); err = lora.setCodingRate(cr);
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
// Hmm - seems to lower SNR when the signal levels are high. Leaving off for now... // Hmm - seems to lower SNR when the signal levels are high. Leaving off for now...
// TODO: Confirm gain registers are okay now // TODO: Confirm gain registers are okay now
@@ -142,7 +142,7 @@ bool SX126xInterface<T>::reconfigure()
err = lora.setFrequency(getFreq()); err = lora.setFrequency(getFreq());
if (err != RADIOLIB_ERR_NONE) if (err != RADIOLIB_ERR_NONE)
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting); RECORD_CRITICALERROR(CriticalErrorCode_INVALID_RADIO_SETTING);
if (power > 22) // This chip has lower power limits than some if (power > 22) // This chip has lower power limits than some
power = 22; power = 22;

View File

@@ -114,7 +114,7 @@ void StreamAPI::emitRebooted()
{ {
// In case we send a FromRadio packet // In case we send a FromRadio packet
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch)); memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
fromRadioScratch.which_payloadVariant = FromRadio_rebooted_tag; fromRadioScratch.which_payload_variant = FromRadio_rebooted_tag;
fromRadioScratch.rebooted = true; fromRadioScratch.rebooted = true;
// DEBUG_MSG("Emitting reboot packet for serial shell\n"); // DEBUG_MSG("Emitting reboot packet for serial shell\n");

View File

@@ -610,7 +610,7 @@ void handleReport(HTTPRequest *req, HTTPResponse *res)
// data->wifi // data->wifi
String ipStr; String ipStr;
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) { if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) {
ipStr = String(WiFi.softAPIP().toString()); ipStr = String(WiFi.softAPIP().toString());
} else { } else {
ipStr = String(WiFi.localIP().toString()); ipStr = String(WiFi.localIP().toString());

View File

@@ -28,7 +28,7 @@ DNSServer dnsServer;
WiFiUDP ntpUDP; WiFiUDP ntpUDP;
#ifndef DISABLE_NTP #ifndef DISABLE_NTP
NTPClient timeClient(ntpUDP, config.device.ntp_server); NTPClient timeClient(ntpUDP, config.network.ntp_server);
#endif #endif
uint8_t wifiDisconnectReason = 0; uint8_t wifiDisconnectReason = 0;
@@ -59,10 +59,10 @@ static WifiSleepObserver wifiSleepObserver;
static int32_t reconnectWiFi() static int32_t reconnectWiFi()
{ {
const char *wifiName = config.wifi.ssid; const char *wifiName = config.network.wifi_ssid;
const char *wifiPsw = config.wifi.psk; const char *wifiPsw = config.network.wifi_psk;
if (config.wifi.enabled && needReconnect && !WiFi.isConnected()) { if (config.network.wifi_enabled && needReconnect && !WiFi.isConnected()) {
// if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) { // if (radioConfig.has_preferences && needReconnect && !WiFi.isConnected()) {
if (!*wifiPsw) // Treat empty password as no password if (!*wifiPsw) // Treat empty password as no password
@@ -114,7 +114,7 @@ bool isWifiAvailable()
return true; return true;
} }
const char *wifiName = config.wifi.ssid; const char *wifiName = config.network.wifi_ssid;
if (*wifiName) { if (*wifiName) {
return true; return true;
@@ -184,18 +184,18 @@ bool initWifi(bool forceSoftAP)
{ {
forcedSoftAP = forceSoftAP; forcedSoftAP = forceSoftAP;
if (config.wifi.enabled && ((config.wifi.ssid[0]) || forceSoftAP)) { if (config.network.wifi_enabled && ((config.network.wifi_ssid[0]) || forceSoftAP)) {
// if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) { // if ((radioConfig.has_preferences && config.wifi.ssid[0]) || forceSoftAP) {
const char *wifiName = config.wifi.ssid; const char *wifiName = config.network.wifi_ssid;
const char *wifiPsw = config.wifi.psk; const char *wifiPsw = config.network.wifi_psk;
if (forceSoftAP) { if (forceSoftAP) {
DEBUG_MSG("WiFi ... Forced AP Mode\n"); DEBUG_MSG("WiFi ... Forced AP Mode\n");
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint) { } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT) {
DEBUG_MSG("WiFi ... AP Mode\n"); DEBUG_MSG("WiFi ... AP Mode\n");
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) { } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) {
DEBUG_MSG("WiFi ... Hidden AP Mode\n"); DEBUG_MSG("WiFi ... Hidden AP Mode\n");
} else if (config.wifi.mode == Config_WiFiConfig_WiFiMode_Client) { } else if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_CLIENT) {
DEBUG_MSG("WiFi ... Client Mode\n"); DEBUG_MSG("WiFi ... Client Mode\n");
} else { } else {
DEBUG_MSG("WiFi ... WiFi Disabled\n"); DEBUG_MSG("WiFi ... WiFi Disabled\n");
@@ -207,7 +207,7 @@ bool initWifi(bool forceSoftAP)
wifiPsw = NULL; wifiPsw = NULL;
if (*wifiName || forceSoftAP) { if (*wifiName || forceSoftAP) {
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || forceSoftAP) { if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || forceSoftAP) {
IPAddress apIP(192, 168, 42, 1); IPAddress apIP(192, 168, 42, 1);
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
@@ -222,7 +222,7 @@ bool initWifi(bool forceSoftAP)
} else { } else {
// If AP is configured to be hidden hidden // If AP is configured to be hidden hidden
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden) { if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN) {
// The configurations on softAP are from the espresif library // The configurations on softAP are from the espresif library
int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4); int ok = WiFi.softAP(wifiName, wifiPsw, 1, 1, 4);
@@ -377,7 +377,7 @@ static void WiFiEvent(WiFiEvent_t event)
void handleDNSResponse() void handleDNSResponse()
{ {
if (config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPoint || config.wifi.mode == Config_WiFiConfig_WiFiMode_AccessPointHidden || isSoftAPForced()) { if (config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT || config.network.wifi_mode == Config_NetworkConfig_WiFiMode_ACCESS_POINT_HIDDEN || isSoftAPForced()) {
dnsServer.processNextRequest(); dnsServer.processNextRequest();
} }
} }

View File

@@ -38,7 +38,7 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
bool handled = false; bool handled = false;
assert(r); assert(r);
switch (r->which_variant) { switch (r->which_payload_variant) {
/** /**
* Getters * Getters
@@ -129,10 +129,10 @@ bool AdminModule::handleReceivedProtobuf(const MeshPacket &mp, AdminMessage *r)
if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) { if (handleResult == AdminMessageHandleResult::HANDLED_WITH_RESPONSE) {
myReply = allocDataProtobuf(res); myReply = allocDataProtobuf(res);
} else if (mp.decoded.want_response) { } else if (mp.decoded.want_response) {
DEBUG_MSG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_variant); DEBUG_MSG("We did not responded to a request that wanted a respond. req.variant=%d\n", r->which_payload_variant);
} else if (handleResult != AdminMessageHandleResult::HANDLED) { } else if (handleResult != AdminMessageHandleResult::HANDLED) {
// Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages // Probably a message sent by us or sent to our local node. FIXME, we should avoid scanning these messages
DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_variant); DEBUG_MSG("Ignoring nonrelevant admin %d\n", r->which_payload_variant);
} }
break; break;
} }
@@ -171,43 +171,43 @@ void AdminModule::handleSetOwner(const User &o)
void AdminModule::handleSetConfig(const Config &c) void AdminModule::handleSetConfig(const Config &c)
{ {
bool requiresReboot = false; bool requiresReboot = false;
switch (c.which_payloadVariant) { switch (c.which_payload_variant) {
case Config_device_tag: case Config_device_tag:
DEBUG_MSG("Setting config: Device\n"); DEBUG_MSG("Setting config: Device\n");
config.has_device = true; config.has_device = true;
config.device = c.payloadVariant.device; config.device = c.payload_variant.device;
break; break;
case Config_position_tag: case Config_position_tag:
DEBUG_MSG("Setting config: Position\n"); DEBUG_MSG("Setting config: Position\n");
config.has_position = true; config.has_position = true;
config.position = c.payloadVariant.position; config.position = c.payload_variant.position;
break; break;
case Config_power_tag: case Config_power_tag:
DEBUG_MSG("Setting config: Power\n"); DEBUG_MSG("Setting config: Power\n");
config.has_power = true; config.has_power = true;
config.power = c.payloadVariant.power; config.power = c.payload_variant.power;
break; break;
case Config_wifi_tag: case Config_network_tag:
DEBUG_MSG("Setting config: WiFi\n"); DEBUG_MSG("Setting config: WiFi\n");
config.has_wifi = true; config.has_network = true;
config.wifi = c.payloadVariant.wifi; config.network = c.payload_variant.network;
requiresReboot = true; requiresReboot = true;
break; break;
case Config_display_tag: case Config_display_tag:
DEBUG_MSG("Setting config: Display\n"); DEBUG_MSG("Setting config: Display\n");
config.has_display = true; config.has_display = true;
config.display = c.payloadVariant.display; config.display = c.payload_variant.display;
break; break;
case Config_lora_tag: case Config_lora_tag:
DEBUG_MSG("Setting config: LoRa\n"); DEBUG_MSG("Setting config: LoRa\n");
config.has_lora = true; config.has_lora = true;
config.lora = c.payloadVariant.lora; config.lora = c.payload_variant.lora;
requiresReboot = true; requiresReboot = true;
break; break;
case Config_bluetooth_tag: case Config_bluetooth_tag:
DEBUG_MSG("Setting config: Bluetooth\n"); DEBUG_MSG("Setting config: Bluetooth\n");
config.has_bluetooth = true; config.has_bluetooth = true;
config.bluetooth = c.payloadVariant.bluetooth; config.bluetooth = c.payload_variant.bluetooth;
requiresReboot = true; requiresReboot = true;
break; break;
} }
@@ -223,41 +223,41 @@ void AdminModule::handleSetConfig(const Config &c)
void AdminModule::handleSetModuleConfig(const ModuleConfig &c) void AdminModule::handleSetModuleConfig(const ModuleConfig &c)
{ {
switch (c.which_payloadVariant) { switch (c.which_payload_variant) {
case ModuleConfig_mqtt_tag: case ModuleConfig_mqtt_tag:
DEBUG_MSG("Setting module config: MQTT\n"); DEBUG_MSG("Setting module config: MQTT\n");
moduleConfig.has_mqtt = true; moduleConfig.has_mqtt = true;
moduleConfig.mqtt = c.payloadVariant.mqtt; moduleConfig.mqtt = c.payload_variant.mqtt;
break; break;
case ModuleConfig_serial_tag: case ModuleConfig_serial_tag:
DEBUG_MSG("Setting module config: Serial\n"); DEBUG_MSG("Setting module config: Serial\n");
moduleConfig.has_serial = true; moduleConfig.has_serial = true;
moduleConfig.serial = c.payloadVariant.serial; moduleConfig.serial = c.payload_variant.serial;
break; break;
case ModuleConfig_external_notification_tag: case ModuleConfig_external_notification_tag:
DEBUG_MSG("Setting module config: External Notification\n"); DEBUG_MSG("Setting module config: External Notification\n");
moduleConfig.has_external_notification = true; moduleConfig.has_external_notification = true;
moduleConfig.external_notification = c.payloadVariant.external_notification; moduleConfig.external_notification = c.payload_variant.external_notification;
break; break;
case ModuleConfig_store_forward_tag: case ModuleConfig_store_forward_tag:
DEBUG_MSG("Setting module config: Store & Forward\n"); DEBUG_MSG("Setting module config: Store & Forward\n");
moduleConfig.has_store_forward = true; moduleConfig.has_store_forward = true;
moduleConfig.store_forward = c.payloadVariant.store_forward; moduleConfig.store_forward = c.payload_variant.store_forward;
break; break;
case ModuleConfig_range_test_tag: case ModuleConfig_range_test_tag:
DEBUG_MSG("Setting module config: Range Test\n"); DEBUG_MSG("Setting module config: Range Test\n");
moduleConfig.has_range_test = true; moduleConfig.has_range_test = true;
moduleConfig.range_test = c.payloadVariant.range_test; moduleConfig.range_test = c.payload_variant.range_test;
break; break;
case ModuleConfig_telemetry_tag: case ModuleConfig_telemetry_tag:
DEBUG_MSG("Setting module config: Telemetry\n"); DEBUG_MSG("Setting module config: Telemetry\n");
moduleConfig.has_telemetry = true; moduleConfig.has_telemetry = true;
moduleConfig.telemetry = c.payloadVariant.telemetry; moduleConfig.telemetry = c.payload_variant.telemetry;
break; break;
case ModuleConfig_canned_message_tag: case ModuleConfig_canned_message_tag:
DEBUG_MSG("Setting module config: Canned Message\n"); DEBUG_MSG("Setting module config: Canned Message\n");
moduleConfig.has_canned_message = true; moduleConfig.has_canned_message = true;
moduleConfig.canned_message = c.payloadVariant.canned_message; moduleConfig.canned_message = c.payload_variant.canned_message;
break; break;
} }
@@ -282,7 +282,7 @@ void AdminModule::handleGetOwner(const MeshPacket &req)
AdminMessage res = AdminMessage_init_default; AdminMessage res = AdminMessage_init_default;
res.get_owner_response = owner; res.get_owner_response = owner;
res.which_variant = AdminMessage_get_owner_response_tag; res.which_payload_variant = AdminMessage_get_owner_response_tag;
myReply = allocDataProtobuf(res); myReply = allocDataProtobuf(res);
} }
} }
@@ -295,39 +295,39 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
switch (configType) { switch (configType) {
case AdminMessage_ConfigType_DEVICE_CONFIG: case AdminMessage_ConfigType_DEVICE_CONFIG:
DEBUG_MSG("Getting config: Device\n"); DEBUG_MSG("Getting config: Device\n");
res.get_config_response.which_payloadVariant = Config_device_tag; res.get_config_response.which_payload_variant = Config_device_tag;
res.get_config_response.payloadVariant.device = config.device; res.get_config_response.payload_variant.device = config.device;
break; break;
case AdminMessage_ConfigType_POSITION_CONFIG: case AdminMessage_ConfigType_POSITION_CONFIG:
DEBUG_MSG("Getting config: Position\n"); DEBUG_MSG("Getting config: Position\n");
res.get_config_response.which_payloadVariant = Config_position_tag; res.get_config_response.which_payload_variant = Config_position_tag;
res.get_config_response.payloadVariant.position = config.position; res.get_config_response.payload_variant.position = config.position;
break; break;
case AdminMessage_ConfigType_POWER_CONFIG: case AdminMessage_ConfigType_POWER_CONFIG:
DEBUG_MSG("Getting config: Power\n"); DEBUG_MSG("Getting config: Power\n");
res.get_config_response.which_payloadVariant = Config_power_tag; res.get_config_response.which_payload_variant = Config_power_tag;
res.get_config_response.payloadVariant.power = config.power; res.get_config_response.payload_variant.power = config.power;
break; break;
case AdminMessage_ConfigType_WIFI_CONFIG: case AdminMessage_ConfigType_WIFI_CONFIG:
DEBUG_MSG("Getting config: WiFi\n"); DEBUG_MSG("Getting config: WiFi\n");
res.get_config_response.which_payloadVariant = Config_wifi_tag; res.get_config_response.which_payload_variant = Config_network_tag;
res.get_config_response.payloadVariant.wifi = config.wifi; res.get_config_response.payload_variant.network = config.network;
writeSecret(res.get_config_response.payloadVariant.wifi.psk, config.wifi.psk); writeSecret(res.get_config_response.payload_variant.network.wifi_psk, config.network.wifi_psk);
break; break;
case AdminMessage_ConfigType_DISPLAY_CONFIG: case AdminMessage_ConfigType_DISPLAY_CONFIG:
DEBUG_MSG("Getting config: Display\n"); DEBUG_MSG("Getting config: Display\n");
res.get_config_response.which_payloadVariant = Config_display_tag; res.get_config_response.which_payload_variant = Config_display_tag;
res.get_config_response.payloadVariant.display = config.display; res.get_config_response.payload_variant.display = config.display;
break; break;
case AdminMessage_ConfigType_LORA_CONFIG: case AdminMessage_ConfigType_LORA_CONFIG:
DEBUG_MSG("Getting config: LoRa\n"); DEBUG_MSG("Getting config: LoRa\n");
res.get_config_response.which_payloadVariant = Config_lora_tag; res.get_config_response.which_payload_variant = Config_lora_tag;
res.get_config_response.payloadVariant.lora = config.lora; res.get_config_response.payload_variant.lora = config.lora;
break; break;
case AdminMessage_ConfigType_BLUETOOTH_CONFIG: case AdminMessage_ConfigType_BLUETOOTH_CONFIG:
DEBUG_MSG("Getting config: Bluetooth\n"); DEBUG_MSG("Getting config: Bluetooth\n");
res.get_config_response.which_payloadVariant = Config_bluetooth_tag; res.get_config_response.which_payload_variant = Config_bluetooth_tag;
res.get_config_response.payloadVariant.bluetooth = config.bluetooth; res.get_config_response.payload_variant.bluetooth = config.bluetooth;
break; break;
} }
// NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. // NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior.
@@ -337,7 +337,7 @@ void AdminModule::handleGetConfig(const MeshPacket &req, const uint32_t configTy
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private // hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password); // and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag; // r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
res.which_variant = AdminMessage_get_config_response_tag; res.which_payload_variant = AdminMessage_get_config_response_tag;
myReply = allocDataProtobuf(res); myReply = allocDataProtobuf(res);
} }
} }
@@ -350,39 +350,39 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
switch (configType) { switch (configType) {
case AdminMessage_ModuleConfigType_MQTT_CONFIG: case AdminMessage_ModuleConfigType_MQTT_CONFIG:
DEBUG_MSG("Getting module config: MQTT\n"); DEBUG_MSG("Getting module config: MQTT\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_mqtt_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_mqtt_tag;
res.get_module_config_response.payloadVariant.mqtt = moduleConfig.mqtt; res.get_module_config_response.payload_variant.mqtt = moduleConfig.mqtt;
break; break;
case AdminMessage_ModuleConfigType_SERIAL_CONFIG: case AdminMessage_ModuleConfigType_SERIAL_CONFIG:
DEBUG_MSG("Getting module config: Serial\n"); DEBUG_MSG("Getting module config: Serial\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_serial_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_serial_tag;
res.get_module_config_response.payloadVariant.serial = moduleConfig.serial; res.get_module_config_response.payload_variant.serial = moduleConfig.serial;
break; break;
case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG: case AdminMessage_ModuleConfigType_EXTNOTIF_CONFIG:
DEBUG_MSG("Getting module config: External Notification\n"); DEBUG_MSG("Getting module config: External Notification\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_external_notification_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_external_notification_tag;
res.get_module_config_response.payloadVariant.external_notification = res.get_module_config_response.payload_variant.external_notification =
moduleConfig.external_notification; moduleConfig.external_notification;
break; break;
case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG: case AdminMessage_ModuleConfigType_STOREFORWARD_CONFIG:
DEBUG_MSG("Getting module config: Store & Forward\n"); DEBUG_MSG("Getting module config: Store & Forward\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_store_forward_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_store_forward_tag;
res.get_module_config_response.payloadVariant.store_forward = moduleConfig.store_forward; res.get_module_config_response.payload_variant.store_forward = moduleConfig.store_forward;
break; break;
case AdminMessage_ModuleConfigType_RANGETEST_CONFIG: case AdminMessage_ModuleConfigType_RANGETEST_CONFIG:
DEBUG_MSG("Getting module config: Range Test\n"); DEBUG_MSG("Getting module config: Range Test\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_range_test_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_range_test_tag;
res.get_module_config_response.payloadVariant.range_test = moduleConfig.range_test; res.get_module_config_response.payload_variant.range_test = moduleConfig.range_test;
break; break;
case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG: case AdminMessage_ModuleConfigType_TELEMETRY_CONFIG:
DEBUG_MSG("Getting module config: Telemetry\n"); DEBUG_MSG("Getting module config: Telemetry\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_telemetry_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_telemetry_tag;
res.get_module_config_response.payloadVariant.telemetry = moduleConfig.telemetry; res.get_module_config_response.payload_variant.telemetry = moduleConfig.telemetry;
break; break;
case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG: case AdminMessage_ModuleConfigType_CANNEDMSG_CONFIG:
DEBUG_MSG("Getting module config: Canned Message\n"); DEBUG_MSG("Getting module config: Canned Message\n");
res.get_module_config_response.which_payloadVariant = ModuleConfig_canned_message_tag; res.get_module_config_response.which_payload_variant = ModuleConfig_canned_message_tag;
res.get_module_config_response.payloadVariant.canned_message = moduleConfig.canned_message; res.get_module_config_response.payload_variant.canned_message = moduleConfig.canned_message;
break; break;
} }
@@ -393,7 +393,7 @@ void AdminModule::handleGetModuleConfig(const MeshPacket &req, const uint32_t co
// hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private // hideSecret(r.get_radio_response.preferences.wifi_ssid); // hmm - leave public for now, because only minimally private
// and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password); // and useful for users to know current provisioning) hideSecret(r.get_radio_response.preferences.wifi_password);
// r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag; // r.get_config_response.which_payloadVariant = Config_ModuleConfig_telemetry_tag;
res.which_variant = AdminMessage_get_module_config_response_tag; res.which_payload_variant = AdminMessage_get_module_config_response_tag;
myReply = allocDataProtobuf(res); myReply = allocDataProtobuf(res);
} }
} }
@@ -406,7 +406,7 @@ void AdminModule::handleGetDeviceMetadata(const MeshPacket &req) {
deviceMetadata.device_state_version = DEVICESTATE_CUR_VER; deviceMetadata.device_state_version = DEVICESTATE_CUR_VER;
r.get_device_metadata_response = deviceMetadata; r.get_device_metadata_response = deviceMetadata;
r.which_variant = AdminMessage_get_device_metadata_response_tag; r.which_payload_variant = AdminMessage_get_device_metadata_response_tag;
myReply = allocDataProtobuf(r); myReply = allocDataProtobuf(r);
} }
@@ -416,7 +416,7 @@ void AdminModule::handleGetChannel(const MeshPacket &req, uint32_t channelIndex)
// We create the reply here // We create the reply here
AdminMessage r = AdminMessage_init_default; AdminMessage r = AdminMessage_init_default;
r.get_channel_response = channels.getByIndex(channelIndex); r.get_channel_response = channels.getByIndex(channelIndex);
r.which_variant = AdminMessage_get_channel_response_tag; r.which_payload_variant = AdminMessage_get_channel_response_tag;
myReply = allocDataProtobuf(r); myReply = allocDataProtobuf(r);
} }
} }

View File

@@ -100,17 +100,17 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
} }
bool validEvent = false; bool validEvent = false;
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_UP)) { if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_UP)) {
DEBUG_MSG("Canned message event UP\n"); DEBUG_MSG("Canned message event UP\n");
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_UP; this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_UP;
validEvent = true; validEvent = true;
} }
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_DOWN)) { if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_DOWN)) {
DEBUG_MSG("Canned message event DOWN\n"); DEBUG_MSG("Canned message event DOWN\n");
this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_DOWN; this->runState = CANNED_MESSAGE_RUN_STATE_ACTION_DOWN;
validEvent = true; validEvent = true;
} }
if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_KEY_SELECT)) { if (event->inputEvent == static_cast<char>(ModuleConfig_CannedMessageConfig_InputEventChar_SELECT)) {
DEBUG_MSG("Canned message event Select\n"); DEBUG_MSG("Canned message event Select\n");
// when inactive, call the onebutton shortpress instead. Activate Module only on up/down // when inactive, call the onebutton shortpress instead. Activate Module only on up/down
if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) { if ((this->runState == CANNED_MESSAGE_RUN_STATE_INACTIVE) || (this->runState == CANNED_MESSAGE_RUN_STATE_DISABLED)) {
@@ -309,7 +309,7 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
{ {
AdminMessageHandleResult result; AdminMessageHandleResult result;
switch (request->which_variant) { switch (request->which_payload_variant) {
case AdminMessage_get_canned_message_module_messages_request_tag: case AdminMessage_get_canned_message_module_messages_request_tag:
DEBUG_MSG("Client is getting radio canned messages\n"); DEBUG_MSG("Client is getting radio canned messages\n");
this->handleGetCannedMessageModuleMessages(mp, response); this->handleGetCannedMessageModuleMessages(mp, response);
@@ -334,7 +334,7 @@ void CannedMessageModule::handleGetCannedMessageModuleMessages(const MeshPacket
DEBUG_MSG("*** handleGetCannedMessageModuleMessages\n"); DEBUG_MSG("*** handleGetCannedMessageModuleMessages\n");
assert(req.decoded.want_response); assert(req.decoded.want_response);
response->which_variant = AdminMessage_get_canned_message_module_messages_response_tag; response->which_payload_variant = AdminMessage_get_canned_message_module_messages_response_tag;
strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages); strcpy(response->get_canned_message_module_messages_response, cannedMessageModuleConfig.messages);
} }

View File

@@ -34,8 +34,8 @@ bool PositionModule::handleReceivedProtobuf(const MeshPacket &mp, Position *pptr
// Log packet size and list of fields // Log packet size and list of fields
DEBUG_MSG("POSITION node=%08x l=%d %s%s%s%s%s%s%s%s%s%s%s%s%s\n", getFrom(&mp), mp.decoded.payload.size, DEBUG_MSG("POSITION node=%08x l=%d %s%s%s%s%s%s%s%s%s%s%s%s%s\n", getFrom(&mp), mp.decoded.payload.size,
p.latitude_i ? "LAT " : "", p.longitude_i ? "LON " : "", p.altitude ? "MSL " : "", p.altitude_hae ? "HAE " : "", p.latitude_i ? "LAT " : "", p.longitude_i ? "LON " : "", p.altitude ? "MSL " : "", p.altitude_hae ? "HAE " : "",
p.alt_geoid_sep ? "GEO " : "", p.PDOP ? "PDOP " : "", p.HDOP ? "HDOP " : "", p.VDOP ? "VDOP " : "", p.PDOP ? "PDOP " : "", p.HDOP ? "HDOP " : "", p.VDOP ? "VDOP " : "",
p.sats_in_view ? "SIV " : "", p.fix_quality ? "FXQ " : "", p.fix_type ? "FXT " : "", p.pos_timestamp ? "PTS " : "", p.sats_in_view ? "SIV " : "", p.fix_quality ? "FXQ " : "", p.fix_type ? "FXT " : "", p.timestamp ? "PTS " : "",
p.time ? "TIME " : ""); p.time ? "TIME " : "");
if (p.time) { if (p.time) {
@@ -70,29 +70,26 @@ MeshPacket *PositionModule::allocReply()
p.longitude_i = node->position.longitude_i; p.longitude_i = node->position.longitude_i;
p.time = node->position.time; p.time = node->position.time;
if (pos_flags & Config_PositionConfig_PositionFlags_POS_ALTITUDE) { if (pos_flags & Config_PositionConfig_PositionFlags_ALTITUDE) {
if (pos_flags & Config_PositionConfig_PositionFlags_POS_ALT_MSL) if (pos_flags & Config_PositionConfig_PositionFlags_ALTITUDE_MSL)
p.altitude = node->position.altitude; p.altitude = node->position.altitude;
else else
p.altitude_hae = node->position.altitude_hae; p.altitude_hae = node->position.altitude_hae;
if (pos_flags & Config_PositionConfig_PositionFlags_POS_GEO_SEP)
p.alt_geoid_sep = node->position.alt_geoid_sep;
} }
if (pos_flags & Config_PositionConfig_PositionFlags_POS_DOP) { if (pos_flags & Config_PositionConfig_PositionFlags_DOP) {
if (pos_flags & Config_PositionConfig_PositionFlags_POS_HVDOP) { if (pos_flags & Config_PositionConfig_PositionFlags_HVDOP) {
p.HDOP = node->position.HDOP; p.HDOP = node->position.HDOP;
p.VDOP = node->position.VDOP; p.VDOP = node->position.VDOP;
} else } else
p.PDOP = node->position.PDOP; p.PDOP = node->position.PDOP;
} }
if (pos_flags & Config_PositionConfig_PositionFlags_POS_SATINVIEW) if (pos_flags & Config_PositionConfig_PositionFlags_SATINVIEW)
p.sats_in_view = node->position.sats_in_view; p.sats_in_view = node->position.sats_in_view;
if (pos_flags & Config_PositionConfig_PositionFlags_POS_TIMESTAMP) if (pos_flags & Config_PositionConfig_PositionFlags_TIMESTAMP)
p.pos_timestamp = node->position.pos_timestamp; p.timestamp = node->position.timestamp;
// Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other // Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other
// nodes shouldn't trust it anyways) Note: we allow a device with a local GPS to include the time, so that gpsless // nodes shouldn't trust it anyways) Note: we allow a device with a local GPS to include the time, so that gpsless
@@ -144,7 +141,7 @@ int32_t PositionModule::runOnce()
bool requestReplies = currentGeneration != radioGeneration; bool requestReplies = currentGeneration != radioGeneration;
currentGeneration = radioGeneration; currentGeneration = radioGeneration;
DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.pos_timestamp, requestReplies); DEBUG_MSG("Sending pos@%x:6 to mesh (wantReplies=%d)\n", node->position.timestamp, requestReplies);
sendOurPosition(NODENUM_BROADCAST, requestReplies); sendOurPosition(NODENUM_BROADCAST, requestReplies);
} }
} else { } else {
@@ -183,7 +180,7 @@ int32_t PositionModule::runOnce()
bool requestReplies = currentGeneration != radioGeneration; bool requestReplies = currentGeneration != radioGeneration;
currentGeneration = radioGeneration; currentGeneration = radioGeneration;
DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, d=%d, dtt=%d, tt=%d)\n", node2->position.pos_timestamp, DEBUG_MSG("Sending smart pos@%x:6 to mesh (wantReplies=%d, d=%d, dtt=%d, tt=%d)\n", node2->position.timestamp,
requestReplies, distance, distanceTravelThreshold, timeTravel); requestReplies, distance, distanceTravelThreshold, timeTravel);
sendOurPosition(NODENUM_BROADCAST, requestReplies); sendOurPosition(NODENUM_BROADCAST, requestReplies);

View File

@@ -55,9 +55,9 @@ RemoteHardwareModule::RemoteHardwareModule()
bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr) bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, HardwareMessage *pptr)
{ {
auto p = *pptr; auto p = *pptr;
DEBUG_MSG("Received RemoteHardware typ=%d\n", p.typ); DEBUG_MSG("Received RemoteHardware typ=%d\n", p.type);
switch (p.typ) { switch (p.type) {
case HardwareMessage_Type_WRITE_GPIOS: case HardwareMessage_Type_WRITE_GPIOS:
// Print notification to LCD screen // Print notification to LCD screen
screen->print("Write GPIOs\n"); screen->print("Write GPIOs\n");
@@ -81,7 +81,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, Hardwar
// Send the reply // Send the reply
HardwareMessage r = HardwareMessage_init_default; HardwareMessage r = HardwareMessage_init_default;
r.typ = HardwareMessage_Type_READ_GPIOS_REPLY; r.type = HardwareMessage_Type_READ_GPIOS_REPLY;
r.gpio_value = res; r.gpio_value = res;
r.gpio_mask = p.gpio_mask; r.gpio_mask = p.gpio_mask;
MeshPacket *p2 = allocDataProtobuf(r); MeshPacket *p2 = allocDataProtobuf(r);
@@ -104,7 +104,7 @@ bool RemoteHardwareModule::handleReceivedProtobuf(const MeshPacket &req, Hardwar
break; // Ignore - we might see our own replies break; // Ignore - we might see our own replies
default: default:
DEBUG_MSG("Hardware operation %d not yet implemented! FIXME\n", p.typ); DEBUG_MSG("Hardware operation %d not yet implemented! FIXME\n", p.type);
break; break;
} }
@@ -125,7 +125,7 @@ int32_t RemoteHardwareModule::runOnce()
// Something changed! Tell the world with a broadcast message // Something changed! Tell the world with a broadcast message
HardwareMessage r = HardwareMessage_init_default; HardwareMessage r = HardwareMessage_init_default;
r.typ = HardwareMessage_Type_GPIOS_CHANGED; r.type = HardwareMessage_Type_GPIOS_CHANGED;
r.gpio_value = curVal; r.gpio_value = curVal;
MeshPacket *p = allocDataProtobuf(r); MeshPacket *p = allocDataProtobuf(r);
service.sendToMesh(p); service.sendToMesh(p);

View File

@@ -91,7 +91,7 @@ int32_t SerialModule::runOnce()
uint32_t baud = 0; uint32_t baud = 0;
if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_Default) { if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_DEFAULT) {
baud = 38400; baud = 38400;
} else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) { } else if (moduleConfig.serial.baud == ModuleConfig_SerialConfig_Serial_Baud_BAUD_110) {
@@ -237,13 +237,13 @@ ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
} else { } else {
if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_Default || if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_DEFAULT ||
moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_SIMPLE) { moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_SIMPLE) {
// DEBUG_MSG("* * Message came from the mesh\n"); // DEBUG_MSG("* * Message came from the mesh\n");
// Serial2.println("* * Message came from the mesh"); // Serial2.println("* * Message came from the mesh");
Serial2.printf("%s", p.payload.bytes); Serial2.printf("%s", p.payload.bytes);
} else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_MODE_PROTO) { } else if (moduleConfig.serial.mode == ModuleConfig_SerialConfig_Serial_Mode_PROTO) {
} }
} }

View File

@@ -21,7 +21,7 @@ int32_t StoreForwardModule::runOnce()
if (moduleConfig.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
if (config.device.role == Config_DeviceConfig_Role_Router) { if (config.device.role == Config_DeviceConfig_Role_ROUTER) {
// Send out the message queue. // Send out the message queue.
if (this->busy) { if (this->busy) {
@@ -397,7 +397,7 @@ StoreForwardModule::StoreForwardModule()
if (moduleConfig.store_forward.enabled) { if (moduleConfig.store_forward.enabled) {
// Router // Router
if (config.device.role == Config_DeviceConfig_Role_Router) { if (config.device.role == Config_DeviceConfig_Role_ROUTER) {
DEBUG_MSG("Initializing Store & Forward Module - Enabled as Router\n"); DEBUG_MSG("Initializing Store & Forward Module - Enabled as Router\n");
if (ESP.getPsramSize()) { if (ESP.getPsramSize()) {
if (ESP.getFreePsram() >= 1024 * 1024) { if (ESP.getFreePsram() >= 1024 * 1024) {

View File

@@ -288,7 +288,7 @@ String MQTT::downstreamPacketToJson(MeshPacket *mp)
msgType = "telemetry"; msgType = "telemetry";
Telemetry scratch; Telemetry scratch;
Telemetry *decoded = NULL; Telemetry *decoded = NULL;
if (mp->which_payloadVariant == MeshPacket_decoded_tag) { if (mp->which_payload_variant == MeshPacket_decoded_tag) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Telemetry_msg, &scratch)) { if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Telemetry_msg, &scratch)) {
decoded = &scratch; decoded = &scratch;
@@ -318,7 +318,7 @@ String MQTT::downstreamPacketToJson(MeshPacket *mp)
msgType = "nodeinfo"; msgType = "nodeinfo";
User scratch; User scratch;
User *decoded = NULL; User *decoded = NULL;
if (mp->which_payloadVariant == MeshPacket_decoded_tag) { if (mp->which_payload_variant == MeshPacket_decoded_tag) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &User_msg, &scratch)) { if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &User_msg, &scratch)) {
decoded = &scratch; decoded = &scratch;
@@ -338,13 +338,13 @@ String MQTT::downstreamPacketToJson(MeshPacket *mp)
msgType = "position"; msgType = "position";
Position scratch; Position scratch;
Position *decoded = NULL; Position *decoded = NULL;
if (mp->which_payloadVariant == MeshPacket_decoded_tag) { if (mp->which_payload_variant == MeshPacket_decoded_tag) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Position_msg, &scratch)) { if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Position_msg, &scratch)) {
decoded = &scratch; decoded = &scratch;
msgPayload = Json::object{ msgPayload = Json::object{
{"time", (int)decoded->time}, {"time", (int)decoded->time},
{"pos_timestamp", (int)decoded->pos_timestamp}, {"pos_timestamp", (int)decoded->timestamp},
{"latitude_i", decoded->latitude_i}, {"latitude_i", decoded->latitude_i},
{"longitude_i", decoded->longitude_i}, {"longitude_i", decoded->longitude_i},
{"altitude", decoded->altitude} {"altitude", decoded->altitude}
@@ -360,7 +360,7 @@ String MQTT::downstreamPacketToJson(MeshPacket *mp)
msgType = "position"; msgType = "position";
Waypoint scratch; Waypoint scratch;
Waypoint *decoded = NULL; Waypoint *decoded = NULL;
if (mp->which_payloadVariant == MeshPacket_decoded_tag) { if (mp->which_payload_variant == MeshPacket_decoded_tag) {
memset(&scratch, 0, sizeof(scratch)); memset(&scratch, 0, sizeof(scratch));
if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Waypoint_msg, &scratch)) { if (pb_decode_from_bytes(mp->decoded.payload.bytes, mp->decoded.payload.size, &Waypoint_msg, &scratch)) {
decoded = &scratch; decoded = &scratch;

View File

@@ -74,9 +74,9 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
if (doublepressed > 0 && (doublepressed + (30 * 1000)) > millis()) { if (doublepressed > 0 && (doublepressed + (30 * 1000)) > millis()) {
DEBUG_MSG("User has set BLE pairing mode to fixed-pin\n"); DEBUG_MSG("User has set BLE pairing mode to fixed-pin\n");
config.bluetooth.mode = Config_BluetoothConfig_PairingMode_FixedPin; config.bluetooth.mode = Config_BluetoothConfig_PairingMode_FIXED_PIN;
nodeDB.saveToDisk(); nodeDB.saveToDisk();
} else if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_RandomPin) { } else if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_RANDOM_PIN) {
DEBUG_MSG("Using random passkey\n"); DEBUG_MSG("Using random passkey\n");
// This is the passkey to be entered on peer - we pick a number >100,000 to ensure 6 digits // This is the passkey to be entered on peer - we pick a number >100,000 to ensure 6 digits
passkey = random(100000, 999999); passkey = random(100000, 999999);
@@ -135,7 +135,7 @@ void NimbleBluetooth::setup()
NimBLEDevice::init(getDeviceName()); NimBLEDevice::init(getDeviceName());
NimBLEDevice::setPower(ESP_PWR_LVL_P9); NimBLEDevice::setPower(ESP_PWR_LVL_P9);
if (config.bluetooth.mode != Config_BluetoothConfig_PairingMode_NoPin) { if (config.bluetooth.mode != Config_BluetoothConfig_PairingMode_NO_PIN) {
NimBLEDevice::setSecurityAuth(true, true, true); NimBLEDevice::setSecurityAuth(true, true, true);
NimBLEDevice::setSecurityIOCap(BLE_HS_IO_DISPLAY_ONLY); NimBLEDevice::setSecurityIOCap(BLE_HS_IO_DISPLAY_ONLY);
} }
@@ -154,7 +154,7 @@ void NimbleBluetooth::setupService()
NimBLECharacteristic *ToRadioCharacteristic; NimBLECharacteristic *ToRadioCharacteristic;
NimBLECharacteristic *FromRadioCharacteristic; NimBLECharacteristic *FromRadioCharacteristic;
// Define the characteristics that the app is looking for // Define the characteristics that the app is looking for
if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_NoPin) { if (config.bluetooth.mode == Config_BluetoothConfig_PairingMode_NO_PIN) {
ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE); ToRadioCharacteristic = bleService->createCharacteristic(TORADIO_UUID, NIMBLE_PROPERTY::WRITE);
FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ); FromRadioCharacteristic = bleService->createCharacteristic(FROMRADIO_UUID, NIMBLE_PROPERTY::READ);
fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ); fromNumCharacteristic = bleService->createCharacteristic(FROMNUM_UUID, NIMBLE_PROPERTY::NOTIFY | NIMBLE_PROPERTY::READ);

View File

@@ -146,7 +146,7 @@ static void waitEnterSleep()
delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives) delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
RECORD_CRITICALERROR(CriticalErrorCode_SleepEnterWait); RECORD_CRITICALERROR(CriticalErrorCode_SLEEP_ENTER_WAIT);
assert(0); // FIXME - for now we just restart, need to fix bug #167 assert(0); // FIXME - for now we just restart, need to fix bug #167
break; break;
} }