Merge pull request #757 from geeksville/dev1.2

getting ready for 1.2.13
This commit is contained in:
Kevin Hester 2021-03-24 13:34:57 +08:00 committed by GitHub
commit 286686137f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 59 additions and 41 deletions

View File

@ -4,12 +4,15 @@ You probably don't care about this section - skip to the next one.
## before next release ## before next release
* TEST THIS! changing channels requires a reboot to take effect https://github.com/meshtastic/Meshtastic-device/issues/752 * DONE test latest firmware update with is_router
* add UI in android app to reset to defaults https://github.com/meshtastic/Meshtastic-Android/issues/263 * DONE firmware OTA updates of is_router true nodes fails?
* bug report with remote info request timing out * DONE add UI in android app to reset to defaults https://github.com/meshtastic/Meshtastic-Android/issues/263
* firmware OTA updates of is_router true nodes fails? * DONE TEST THIS! changing channels requires a reboot to take effect https://github.com/meshtastic/Meshtastic-device/issues/752
* move remote admin doc from forum into git * DIBE bug report with remote info request timing out
* ask for a documentation czar * DONE retest channel changing in android (using sim?)
* DONE move remote admin doc from forum into git
* DONE check crashlytics
* DONE ask for a documentation czar
* DONE timestamps on oled screen are wrong - don't seem to be updating based on message rx (actually: this is expected behavior when no node on the mesh has GPS time) * DONE timestamps on oled screen are wrong - don't seem to be updating based on message rx (actually: this is expected behavior when no node on the mesh has GPS time)
* DONE add ch-del * DONE add ch-del
* DONE channel hash suffixes are wrong on android * DONE channel hash suffixes are wrong on android

View File

@ -97,7 +97,8 @@ static void lsIdle()
static void lsExit() static void lsExit()
{ {
// setGPSPower(true); // restore GPS power // setGPSPower(true); // restore GPS power
if (gps) gps->forceWake(true); if (gps)
gps->forceWake(true);
} }
static void nbEnter() static void nbEnter()
@ -249,6 +250,11 @@ void PowerFSM_setup()
powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_CONTACT_FROM_PHONE, NULL, "Contact from phone"); powerFSM.add_transition(&stateDARK, &stateDARK, EVENT_CONTACT_FROM_PHONE, NULL, "Contact from phone");
// each time we get a new update packet make sure we are staying in the ON state so the screen stays awake (also we don't
// shutdown bluetooth if is_router)
powerFSM.add_transition(&stateDARK, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
powerFSM.add_transition(&stateON, &stateON, EVENT_FIRMWARE_UPDATE, NULL, "Got firmware update");
powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone"); powerFSM.add_transition(&stateNB, &stateDARK, EVENT_PACKET_FOR_PHONE, NULL, "Packet for phone");
powerFSM.add_timed_transition(&stateON, &stateDARK, getPref_screen_on_secs() * 1000, NULL, "Screen-on timeout"); powerFSM.add_timed_transition(&stateON, &stateDARK, getPref_screen_on_secs() * 1000, NULL, "Screen-on timeout");

View File

@ -18,6 +18,7 @@
#define EVENT_SERIAL_DISCONNECTED 12 #define EVENT_SERIAL_DISCONNECTED 12
#define EVENT_POWER_CONNECTED 13 #define EVENT_POWER_CONNECTED 13
#define EVENT_POWER_DISCONNECTED 14 #define EVENT_POWER_DISCONNECTED 14
#define EVENT_FIRMWARE_UPDATE 15 // We just received a new firmware update packet from the phone
extern Fsm powerFSM; extern Fsm powerFSM;
extern State statePOWER, stateSERIAL; extern State statePOWER, stateSERIAL;

View File

@ -1,14 +1,14 @@
#include <Arduino.h> #include <Arduino.h>
#include "../concurrency/LockGuard.h" #include "../concurrency/LockGuard.h"
#include "../graphics/Screen.h"
#include "../main.h"
#include "BluetoothSoftwareUpdate.h" #include "BluetoothSoftwareUpdate.h"
#include "NodeDB.h"
#include "PowerFSM.h" #include "PowerFSM.h"
#include "RadioLibInterface.h" #include "RadioLibInterface.h"
#include "configuration.h" #include "configuration.h"
#include "nimble/BluetoothUtil.h" #include "nimble/BluetoothUtil.h"
#include "NodeDB.h"
#include "../graphics/Screen.h"
#include "../main.h"
#include <CRC32.h> #include <CRC32.h>
#include <Update.h> #include <Update.h>
@ -51,8 +51,8 @@ int update_size_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble_
screen->startFirmwareUpdateScreen(); screen->startFirmwareUpdateScreen();
if (RadioLibInterface::instance) if (RadioLibInterface::instance)
RadioLibInterface::instance->disable(); // FIXME, nasty hack - the RF95 ISR/SPI code on ESP32 can fail while we are RadioLibInterface::instance->disable(); // FIXME, nasty hack - the RF95 ISR/SPI code on ESP32 can fail while we
// writing flash - shut the radio off during updates // are writing flash - shut the radio off during updates
} }
} }
@ -78,7 +78,7 @@ int update_data_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble_
crc.update(data, len); crc.update(data, len);
Update.write(data, len); Update.write(data, len);
updateActualSize += len; updateActualSize += len;
powerFSM.trigger(EVENT_CONTACT_FROM_PHONE); powerFSM.trigger(EVENT_FIRMWARE_UPDATE);
return 0; return 0;
} }
@ -107,8 +107,7 @@ int update_crc32_callback(uint16_t conn_handle, uint16_t attr_handle, struct ble
if (update_region == U_SPIFFS) { if (update_region == U_SPIFFS) {
DEBUG_MSG("SPIFFS updated!\n"); DEBUG_MSG("SPIFFS updated!\n");
nodeDB.saveToDisk(); // Since we just wiped spiffs, we need to save our current state nodeDB.saveToDisk(); // Since we just wiped spiffs, we need to save our current state
} } else {
else {
DEBUG_MSG("Appload updated, rebooting in 5 seconds!\n"); DEBUG_MSG("Appload updated, rebooting in 5 seconds!\n");
rebootAtMsec = millis() + 5000; rebootAtMsec = millis() + 5000;
} }

View File

@ -82,6 +82,7 @@ bool NodeDB::resetRadioConfig()
radioGeneration++; radioGeneration++;
radioConfig.has_preferences = true;
if (radioConfig.preferences.factory_reset) { if (radioConfig.preferences.factory_reset) {
DEBUG_MSG("Performing factory reset!\n"); DEBUG_MSG("Performing factory reset!\n");
installDefaultDeviceState(); installDefaultDeviceState();
@ -92,8 +93,6 @@ bool NodeDB::resetRadioConfig()
DEBUG_MSG("Setting default channel and radio preferences!\n"); DEBUG_MSG("Setting default channel and radio preferences!\n");
channels.initDefaults(); channels.initDefaults();
radioConfig.has_preferences = true;
} }
channels.onConfigChanged(); channels.onConfigChanged();
@ -487,7 +486,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) { if (mp.which_payloadVariant == 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));
@ -497,7 +496,8 @@ void NodeDB::updateFrom(const MeshPacket &mp)
info->position.time = mp.rx_time; info->position.time = mp.rx_time;
} }
info->snr = mp.rx_snr; // keep the most recent SNR we received for this node. if (mp.rx_snr)
info->snr = mp.rx_snr; // keep the most recent SNR we received for this node.
} }
} }

View File

@ -115,7 +115,8 @@ void Router::abortSendAndNak(Routing_Error err, MeshPacket *p)
packetPool.release(p); packetPool.release(p);
} }
void Router::setReceivedMessage() { void Router::setReceivedMessage()
{
setInterval(0); // Run ASAP, so we can figure out our correct sleep time setInterval(0); // Run ASAP, so we can figure out our correct sleep time
} }
@ -123,9 +124,13 @@ ErrorCode Router::sendLocal(MeshPacket *p)
{ {
// No need to deliver externally if the destination is the local node // No need to deliver externally if the destination is the local node
if (p->to == nodeDB.getNodeNum()) { if (p->to == nodeDB.getNodeNum()) {
printPacket("Enqueuing local", p); if (fromRadioQueue.enqueue(p, 0)) {
fromRadioQueue.enqueue(p); printPacket("Enqueued local", p);
setReceivedMessage(); setReceivedMessage();
} else {
printPacket("BUG! fromRadioQueue is full! Discarding!", p);
packetPool.release(p);
}
return ERRNO_OK; return ERRNO_OK;
} else if (!iface) { } else if (!iface) {
// We must be sending to remote nodes also, fail if no interface found // We must be sending to remote nodes also, fail if no interface found
@ -143,9 +148,10 @@ ErrorCode Router::sendLocal(MeshPacket *p)
} }
} }
void printBytes(const char *label, const uint8_t *p, size_t numbytes) { void printBytes(const char *label, const uint8_t *p, size_t numbytes)
{
DEBUG_MSG("%s: ", label); DEBUG_MSG("%s: ", label);
for(size_t i = 0; i < numbytes; i++) for (size_t i = 0; i < numbytes; i++)
DEBUG_MSG("%02x ", p[i]); DEBUG_MSG("%02x ", p[i]);
DEBUG_MSG("\n"); DEBUG_MSG("\n");
} }
@ -189,7 +195,7 @@ ErrorCode Router::send(MeshPacket *p)
return ERRNO_TOO_LARGE; return ERRNO_TOO_LARGE;
} }
//printBytes("plaintext", bytes, numbytes); // printBytes("plaintext", bytes, numbytes);
auto hash = channels.setActiveByIndex(p->channel); auto hash = channels.setActiveByIndex(p->channel);
if (hash < 0) { if (hash < 0) {
@ -247,19 +253,18 @@ bool Router::perhapsDecode(MeshPacket *p)
rawSize); // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf rawSize); // we have to copy into a scratch buffer, because these bytes are a union with the decoded protobuf
crypto->decrypt(p->from, p->id, rawSize, bytes); crypto->decrypt(p->from, p->id, rawSize, bytes);
//printBytes("plaintext", bytes, p->encrypted.size); // printBytes("plaintext", bytes, p->encrypted.size);
// Take those raw bytes and convert them back into a well structured protobuf we can understand // Take those raw bytes and convert them back into a well structured protobuf we can understand
memset(&p->decoded, 0, sizeof(p->decoded)); memset(&p->decoded, 0, sizeof(p->decoded));
if (!pb_decode_from_bytes(bytes, rawSize, Data_fields, &p->decoded)) { if (!pb_decode_from_bytes(bytes, rawSize, Data_fields, &p->decoded)) {
DEBUG_MSG("Invalid protobufs in received mesh packet (bad psk?)!\n"); DEBUG_MSG("Invalid protobufs in received mesh packet (bad psk?)!\n");
} else if(p->decoded.portnum == PortNum_UNKNOWN_APP) { } else if (p->decoded.portnum == PortNum_UNKNOWN_APP) {
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_payloadVariant = 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
printPacket("decoded message", p); printPacket("decoded message", p);
return true; return true;
} }
@ -293,18 +298,20 @@ void Router::handleReceived(MeshPacket *p)
// call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api // call any promiscious plugins here, make a (non promisiocous) plugin for forwarding messages to phone api
// sniffReceived(p); // sniffReceived(p);
MeshPlugin::callPlugins(*p); MeshPlugin::callPlugins(*p);
} else {
DEBUG_MSG("packet decoding failed\n");
} }
} }
void Router::perhapsHandleReceived(MeshPacket *p) void Router::perhapsHandleReceived(MeshPacket *p)
{ {
assert(radioConfig.has_preferences); assert(radioConfig.has_preferences);
bool ignore = is_in_repeated(radioConfig.preferences.ignore_incoming, getFrom(p)); bool ignore = is_in_repeated(radioConfig.preferences.ignore_incoming, p->from);
if (ignore) if (ignore)
DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from); DEBUG_MSG("Ignoring incoming message, 0x%x is in our ignore list\n", p->from);
else if (ignore |= shouldFilterReceived(p)) { else if (ignore |= shouldFilterReceived(p)) {
// DEBUG_MSG("Incoming message was filtered 0x%x\n", p->from); DEBUG_MSG("Incoming message was filtered 0x%x\n", p->from);
} }
// Note: we avoid calling shouldFilterReceived if we are supposed to ignore certain nodes - because some overrides might // Note: we avoid calling shouldFilterReceived if we are supposed to ignore certain nodes - because some overrides might

View File

@ -31,7 +31,9 @@ template <class T> class TypedQueue
bool isEmpty() { return uxQueueMessagesWaiting(h) == 0; } bool isEmpty() { return uxQueueMessagesWaiting(h) == 0; }
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY) /** euqueue a packet. Also, maxWait used to default to portMAX_DELAY, but we now want to callers to THINK about what blocking
* they want */
bool enqueue(T x, TickType_t maxWait)
{ {
if (reader) { if (reader) {
reader->setInterval(0); reader->setInterval(0);

View File

@ -280,9 +280,9 @@ StoreForwardPlugin::StoreForwardPlugin()
Uncomment the preferences below if you want to use the plugin Uncomment the preferences below if you want to use the plugin
without having to configure it from the PythonAPI or WebUI. without having to configure it from the PythonAPI or WebUI.
*/
radioConfig.preferences.store_forward_plugin_enabled = 1; radioConfig.preferences.store_forward_plugin_enabled = 1;
radioConfig.preferences.is_router = 1; radioConfig.preferences.is_router = 1;
*/
if (radioConfig.preferences.store_forward_plugin_enabled) { if (radioConfig.preferences.store_forward_plugin_enabled) {
@ -305,7 +305,7 @@ StoreForwardPlugin::StoreForwardPlugin()
DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n"); DEBUG_MSG("Store & Forward Plugin - Aborting Startup.\n");
} }
// Client // Client
} else { } else {
DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n"); DEBUG_MSG("Initializing Store & Forward Plugin - Enabled as Client\n");
} }

View File

@ -1,4 +1,4 @@
[VERSION] [VERSION]
major = 1 major = 1
minor = 2 minor = 2
build = 11 build = 13