diff --git a/proto b/proto index ac4f53ed8..7c025b9a4 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit ac4f53ed8c903a5bdf3d19727e96791d6be71022 +Subproject commit 7c025b9a4d54bb410ec17ee653122861b413f177 diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index 85e08f536..09fc35e6c 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -178,10 +178,11 @@ void PowerFSM_setup() bool isLowPower = radioConfig.preferences.is_low_power || isRouter; /* To determine if we're externally powered, assumptions - 1) If we're powered up and there's no battery, we must be getting power externally. - 2) If we detect USB power from the power management chip, we must be getting power externally. + 1) If we're powered up and there's no battery, we must be getting power externally. (because we'd be dead otherwise) + + 2) If we detect USB power from the power management chip, we must be getting power externally. */ - bool hasPower = (powerStatus && !powerStatus->getHasBattery()) || (!isLowPower && powerStatus && powerStatus->getHasUSB()); + bool hasPower = !isLowPower && powerStatus && (!powerStatus->getHasBattery() || powerStatus->getHasUSB()); DEBUG_MSG("PowerFSM init, USB power=%d\n", hasPower); powerFSM.add_timed_transition(&stateBOOT, hasPower ? &statePOWER : &stateON, 3 * 1000, NULL, "boot timeout"); diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c9ee13b9d..6e2ac479b 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -179,9 +179,8 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf) // Do we have a message from the mesh? if (fromRadioScratch.which_payloadVariant != 0) { // Encapsulate as a FromRadio packet - DEBUG_MSG("encoding toPhone packet to phone variant=%d\n", fromRadioScratch.which_payloadVariant); size_t numbytes = pb_encode_to_bytes(buf, FromRadio_size, FromRadio_fields, &fromRadioScratch); - DEBUG_MSG(", %d bytes\n", numbytes); + // DEBUG_MSG("encoding toPhone packet to phone variant=%d, %d bytes\n", fromRadioScratch.which_payloadVariant, numbytes); return numbytes; } diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 966b900cc..49dc69927 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -25,9 +25,27 @@ const RegionInfo regions[] = { RDEF(KR, 921.9f, 0.2f, 8, 0), // KR channel settings (KR920-923) Start from TTN download channel // freq. (921.9f is for download, others are for uplink) RDEF(TW, 923.0f, 0.2f, 10, 0), // TW channel settings (AS2 bandplan 923-925MHz) + RDEF(RU, 868.9f, 0.2f, 2, 20), // See notes below RDEF(Unset, 903.08f, 2.16f, 13, 0) // Assume US freqs if unset, Must be last }; +/* Notes about the RU bandplan (from @denis-d in https://meshtastic.discourse.group/t/russian-band-plan-proposal/2786/2): + +According to Annex 12 to GKRCh (National Radio Frequency Commission) decision № 18-46-03-1 (September 11th 2018) https://digital.gov.ru/uploaded/files/prilozhenie-12-k-reshenyu-gkrch-18-46-03-1.pdf 1 +We have 3 options for 868 MHz: + +864,0 - 865,0 MHz ERP 25mW, Duty Cycle 0.1% (3.6 sec in hour) or LBT (Listen Before Talk), prohibited in airports. +866,0 - 868,0 MHz ERP 25mW, Duty Cycle 1% or LBT, PSD (Power Spectrum Density) 1000mW/MHz, prohibited in airports +868,7 - 869,2 MHz ERP 100mW, Duty Cycle 10% or LBT, no resctrictions +and according to RP2-1.0.2 LoRaWAN® Regional Parameters RP2-1.0.2 LoRaWAN® Regional Parameters - LoRa Alliance® +I propose to use following meshtastic bandplan: +1 channel - central frequency 868.9MHz 125kHz band +Protective band - 75kHz +2 channel - central frequency 869.1MHz 125kHz band + +RDEF(RU, 868.9f, 0.2f, 2, 20) +*/ + const RegionInfo *myRegion; void initRegion() diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index cde08b5bb..962aabeb7 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -35,9 +35,10 @@ bool ReliableRouter::shouldFilterReceived(const MeshPacket *p) // If this is the first time we saw this, cancel any retransmissions we have queued up and generate an internal ack for // the original sending process. if (stopRetransmission(getFrom(p), p->id)) { - DEBUG_MSG("Someone is retransmitting for us, generate implicit ack\n"); - if (p->want_ack) - sendAckNak(Routing_Error_NONE, getFrom(p), p->id); + DEBUG_MSG("generating implicit ack\n"); + // NOTE: we do NOT check p->wantAck here because p is the INCOMING rebroadcast and that packet is not expected to be + // marked as wantAck + sendAckNak(Routing_Error_NONE, getFrom(p), p->id); } } @@ -182,9 +183,9 @@ int32_t ReliableRouter::doRetransmissions() --p.numRetransmissions; setNextTx(&p); } - } + } - if(stillValid) { + if (stillValid) { // Update our desired sleep delay int32_t t = p.nextTxMsec - now; diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index 85bfa1a2d..9ea021f13 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -19,7 +19,8 @@ typedef enum _RegionCode { RegionCode_JP = 5, RegionCode_ANZ = 6, RegionCode_KR = 7, - RegionCode_TW = 8 + RegionCode_TW = 8, + RegionCode_RU = 9 } RegionCode; typedef enum _ChargeCurrent { @@ -123,8 +124,8 @@ typedef struct _RadioConfig { /* Helper constants for enums */ #define _RegionCode_MIN RegionCode_Unset -#define _RegionCode_MAX RegionCode_TW -#define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TW+1)) +#define _RegionCode_MAX RegionCode_RU +#define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_RU+1)) #define _ChargeCurrent_MIN ChargeCurrent_MAUnset #define _ChargeCurrent_MAX ChargeCurrent_MA1320 diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp index bba1b39a9..7e0a67074 100644 --- a/src/plugins/AdminPlugin.cpp +++ b/src/plugins/AdminPlugin.cpp @@ -24,6 +24,12 @@ void AdminPlugin::handleGetRadio(const MeshPacket &req) // We create the reply here AdminMessage r = AdminMessage_init_default; r.get_radio_response = devicestate.radio; + + // NOTE: The phone app needs to know the ls_secs value so it can properly expect sleep behavior. + // So even if we internally use 0 to represent 'use default' we still need to send the value we are + // using to the app (so that even old phone apps work with new device loads). + r.get_radio_response.preferences.ls_secs = getPref_ls_secs(); + r.which_variant = AdminMessage_get_radio_response_tag; reply = allocDataProtobuf(r); } diff --git a/version.properties b/version.properties index d16382f27..d0634458c 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 1 minor = 2 -build = 5 +build = 6