diff --git a/src/CHANGES.md b/src/CHANGES.md index 1b6ec262..2afb1ece 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,10 @@ # Development Changes +## 0.7.66 - 2023-10-04 +* prepared PA-Level for CMT +* removed settings for number of retransmits, its fixed to `5` now +* added parentheses to have a excactly defined behaviour + ## 0.7.65 - 2023-10-02 * MI control command review #1197 diff --git a/src/app.cpp b/src/app.cpp index 478cd1e5..84423d4c 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -71,11 +71,11 @@ void app::setup() { }); } - mPayload.setup(this, &mSys, mConfig->nrf.maxRetransPerPyld, &mTimestamp); + mPayload.setup(this, &mSys, &mTimestamp); mPayload.enableSerialDebug(mConfig->serial.debug); mPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); if (mConfig->nrf.enabled) { - mMiPayload.setup(this, &mSys, mConfig->nrf.maxRetransPerPyld, &mTimestamp); + mMiPayload.setup(this, &mSys, &mTimestamp); mMiPayload.enableSerialDebug(mConfig->serial.debug); mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2)); } diff --git a/src/config/config.h b/src/config/config.h index 445fe35e..da027fd6 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -149,7 +149,7 @@ #define SERIAL_INTERVAL 5 // default send interval -#define SEND_INTERVAL 30 +#define SEND_INTERVAL 15 // maximum human readable inverter name length #define MAX_NAME_LENGTH 16 @@ -160,9 +160,6 @@ // maximum total payload buffers (must be greater than the number of received frame fragments) #define MAX_PAYLOAD_ENTRIES 10 -// maximum requests for retransmits per payload (per inverter) -#define DEF_MAX_RETRANS_PER_PYLD 5 - // number of seconds since last successful response, before inverter is marked inactive #define INVERTER_INACT_THRES_SEC 5*60 diff --git a/src/config/settings.h b/src/config/settings.h index a6100d99..0771c148 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -82,7 +82,6 @@ typedef struct { typedef struct { bool enabled; uint16_t sendInterval; - uint8_t maxRetransPerPyld; uint8_t pinCs; uint8_t pinCe; uint8_t pinIrq; @@ -385,7 +384,6 @@ class settings { snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME); mCfg.nrf.sendInterval = SEND_INTERVAL; - mCfg.nrf.maxRetransPerPyld = DEF_MAX_RETRANS_PER_PYLD; mCfg.nrf.pinCs = DEF_NRF_CS_PIN; mCfg.nrf.pinCe = DEF_NRF_CE_PIN; mCfg.nrf.pinIrq = DEF_NRF_IRQ_PIN; @@ -502,7 +500,6 @@ class settings { void jsonNrf(JsonObject obj, bool set = false) { if(set) { obj[F("intvl")] = mCfg.nrf.sendInterval; - obj[F("maxRetry")] = mCfg.nrf.maxRetransPerPyld; obj[F("cs")] = mCfg.nrf.pinCs; obj[F("ce")] = mCfg.nrf.pinCe; obj[F("irq")] = mCfg.nrf.pinIrq; @@ -513,7 +510,6 @@ class settings { obj[F("en")] = (bool) mCfg.nrf.enabled; } else { getVal(obj, F("intvl"), &mCfg.nrf.sendInterval); - getVal(obj, F("maxRetry"), &mCfg.nrf.maxRetransPerPyld); getVal(obj, F("cs"), &mCfg.nrf.pinCs); getVal(obj, F("ce"), &mCfg.nrf.pinCe); getVal(obj, F("irq"), &mCfg.nrf.pinIrq); diff --git a/src/defines.h b/src/defines.h index f5543752..c7d5700a 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 7 -#define VERSION_PATCH 65 +#define VERSION_PATCH 66 //------------------------------------- typedef struct { diff --git a/src/hm/hmPayload.h b/src/hm/hmPayload.h index 0efa28a4..13f4edd5 100644 --- a/src/hm/hmPayload.h +++ b/src/hm/hmPayload.h @@ -44,10 +44,10 @@ class HmPayload { public: HmPayload() {} - void setup(IApp *app, HMSYSTEM *sys, uint8_t maxRetransmits, uint32_t *timestamp) { + void setup(IApp *app, HMSYSTEM *sys, uint32_t *timestamp) { mApp = app; mSys = sys; - mMaxRetrans = maxRetransmits; + mMaxRetrans = 5; mTimestamp = timestamp; for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { reset(i); diff --git a/src/hm/miPayload.h b/src/hm/miPayload.h index 32b16696..94f7a9b3 100644 --- a/src/hm/miPayload.h +++ b/src/hm/miPayload.h @@ -44,10 +44,10 @@ class MiPayload { public: MiPayload() {} - void setup(IApp *app, HMSYSTEM *sys, uint8_t maxRetransmits, uint32_t *timestamp) { + void setup(IApp *app, HMSYSTEM *sys, uint32_t *timestamp) { mApp = app; mSys = sys; - mMaxRetrans = maxRetransmits; + mMaxRetrans = 5; mTimestamp = timestamp; for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) { reset(i, false, true); diff --git a/src/hm/radio.h b/src/hm/radio.h index 5f95fc8a..e2112586 100644 --- a/src/hm/radio.h +++ b/src/hm/radio.h @@ -66,9 +66,9 @@ class Radio { void updateCrcs(uint8_t *len, bool appendCrc16=true) { // append crc's - if (appendCrc16 && (*len > 10)) { + if (appendCrc16 && ((*len) > 10)) { // crc control data - uint16_t crc = ah::crc16(&mTxBuf[10], *len - 10); + uint16_t crc = ah::crc16(&mTxBuf[10], (*len) - 10); mTxBuf[(*len)++] = (crc >> 8) & 0xff; mTxBuf[(*len)++] = (crc ) & 0xff; } diff --git a/src/hms/cmt2300a.h b/src/hms/cmt2300a.h index a4308519..9d00ba20 100644 --- a/src/hms/cmt2300a.h +++ b/src/hms/cmt2300a.h @@ -25,6 +25,10 @@ #define CMT2300A_MASK_CHIP_MODE_STA 0x0F #define CMT2300A_CUS_CMT10 0x09 +#define CMT2300A_CUS_TX5 0x59 +#define CMT2300A_CUS_TX8 0x5C +#define CMT2300A_CUS_TX9 0x5D +#define CMT2300A_CUS_TX10 0x5E #define CMT2300A_CUS_MODE_CTL 0x60 // [7] go_switch // [6] go_tx @@ -153,6 +157,42 @@ #define CMT2300A_MASK_TX_DONE_FLG 0x08 #define CMT2300A_MASK_PKT_OK_FLG 0x01 +// this list and the TX5, TX10 registers were compiled from the output of +// HopeRF RFPDK Tool v1.54 +static uint8_t paLevelList[31][2] PROGMEM = { + {0x17, 0x01}, // -10dBm + {0x1a, 0x01}, // -09dBm + {0x1d, 0x01}, // -08dBm + {0x21, 0x01}, // -07dBm + {0x25, 0x01}, // -06dBm + {0x29, 0x01}, // -05dBm + {0x2d, 0x01}, // -04dBm + {0x33, 0x01}, // -03dBm + {0x39, 0x02}, // -02dBm + {0x41, 0x02}, // -01dBm + {0x4b, 0x02}, // 00dBm + {0x56, 0x03}, // 01dBm + {0x63, 0x03}, // 02dBm + {0x71, 0x04}, // 03dBm + {0x80, 0x04}, // 04dBm + {0x22, 0x01}, // 05dBm + {0x27, 0x04}, // 06dBm + {0x2c, 0x05}, // 07dBm + {0x31, 0x06}, // 08dBm + {0x38, 0x06}, // 09dBm + {0x3f, 0x07}, // 10dBm + {0x48, 0x08}, // 11dBm + {0x52, 0x09}, // 12dBm + {0x5d, 0x0b}, // 13dBm + {0x6a, 0x0c}, // 14dBm + {0x79, 0x0d}, // 15dBm + {0x46, 0x10}, // 16dBm + {0x51, 0x10}, // 17dBm + {0x60, 0x12}, // 18dBm + {0x71, 0x14}, // 19dBm + {0x8c, 0x1c} // 20dBm +}; + // default CMT parameters static uint8_t cmtConfig[0x60] PROGMEM { // 0x00 - 0x0f -- RSSI offset +- 0 and 13dBm @@ -168,11 +208,11 @@ static uint8_t cmtConfig[0x60] PROGMEM { 0x10, 0x00, 0xB4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x12, 0x1E, 0x00, 0xAA, 0x06, 0x00, 0x00, 0x00, // 0x40 - 0x4f - 0x00, 0x48, 0x5A, 0x48, 0x4D, 0x01, 0x1D, 0x00, + 0x00, 0x48, 0x5A, 0x48, 0x4D, 0x01, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x60, // 0x50 - 0x5f 0xFF, 0x00, 0x00, 0x1F, 0x10, 0x70, 0x4D, 0x06, - 0x00, 0x07, 0x50, 0x00, 0x42, 0x0C, 0x3F, 0x7F // - TX 13dBm + 0x00, 0x07, 0x50, 0x00, 0x5D, 0x0B, 0x3F, 0x7F // - TX 13dBm }; @@ -391,6 +431,26 @@ class Cmt2300a { return HOY_BASE_FREQ_KHZ + (mCurCh * FREQ_STEP_KHZ); } + void setPaLevel(int8_t level) { + if(level < -10) + level = -10; + if(level > 20) + level = 20; + + level += 10; // unsigned value + + if(level >= 15) { + mSpi.writeReg(CMT2300A_CUS_TX5, 0x07); + mSpi.writeReg(CMT2300A_CUS_TX10, 0x3f); + } else { + mSpi.writeReg(CMT2300A_CUS_TX5, 0x13); + mSpi.writeReg(CMT2300A_CUS_TX10, 0x18); + } + + mSpi.writeReg(CMT2300A_CUS_TX8, paLevelList[level][0]); + mSpi.writeReg(CMT2300A_CUS_TX9, paLevelList[level][1]); + } + private: void init() { mTxPending = false; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 39c97532..225c26c8 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -356,7 +356,6 @@ class RestApi { } } obj[F("interval")] = String(mConfig->nrf.sendInterval); - obj[F("retries")] = String(mConfig->nrf.maxRetransPerPyld); obj[F("max_num_inverters")] = MAX_NUM_INVERTERS; obj[F("rstMid")] = (bool)mConfig->inst.rstYieldMidNight; obj[F("rstNotAvail")] = (bool)mConfig->inst.rstValsNotAvail; diff --git a/src/web/html/setup.html b/src/web/html/setup.html index d58aa226..b9697141 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -30,7 +30,7 @@
System Config -

Pinout

+

Status LEDs

Radio (NRF24L01+)

@@ -736,11 +736,11 @@ function parsePinout(obj, type, system) { var e = document.getElementById("pinout"); - pins = [['led0', 'pinLed0'], ['led1', 'pinLed1']]; + pins = [['led0', 'pinLed0', 'At least one inverter is producing'], ['led1', 'pinLed1', 'MqTT connected']]; for(p of pins) { e.append( ml("div", {class: "row mb-3"}, [ - ml("div", {class: "col-12 col-sm-3 my-2"}, p[0].toUpperCase()), + ml("div", {class: "col-12 col-sm-3 my-2"}, p[2]), ml("div", {class: "col-12 col-sm-9"}, sel(p[1], ("ESP8266" == type) ? esp8266pins : ("ESP32-S3" == system["chip_model"]) ? esp32s3pins : esp32pins, obj[p[0]]) ) diff --git a/src/web/web.h b/src/web/web.h index 99dd5924..fabbd604 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -527,8 +527,6 @@ class Web { if (request->arg("invInterval") != "") mConfig->nrf.sendInterval = request->arg("invInterval").toInt(); - if (request->arg("invRetry") != "") - mConfig->nrf.maxRetransPerPyld = request->arg("invRetry").toInt(); mConfig->inst.rstYieldMidNight = (request->arg("invRstMid") == "on"); mConfig->inst.rstValsCommStop = (request->arg("invRstComStop") == "on"); mConfig->inst.rstValsNotAvail = (request->arg("invRstNotAvail") == "on");