mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-03 20:25:54 +02:00
hms related changes
This commit is contained in:
parent
3d82e127f8
commit
300fc763c1
6 changed files with 83 additions and 55 deletions
15
src/app.cpp
15
src/app.cpp
|
@ -73,6 +73,7 @@ void app::setup() {
|
||||||
if(mConfig->cmt.enabled) {
|
if(mConfig->cmt.enabled) {
|
||||||
mHmsPayload.setup(this, &mSys, &mCmtRadio, &mStat, 5, &mTimestamp);
|
mHmsPayload.setup(this, &mSys, &mCmtRadio, &mStat, 5, &mTimestamp);
|
||||||
mHmsPayload.enableSerialDebug(mConfig->serial.debug);
|
mHmsPayload.enableSerialDebug(mConfig->serial.debug);
|
||||||
|
mHmsPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*DBGPRINTLN("--- after payload");
|
/*DBGPRINTLN("--- after payload");
|
||||||
|
@ -155,17 +156,29 @@ void app::loopStandard(void) {
|
||||||
if (mConfig->serial.debug) {
|
if (mConfig->serial.debug) {
|
||||||
DPRINT(DBG_INFO, F("RX "));
|
DPRINT(DBG_INFO, F("RX "));
|
||||||
DBGPRINT(String(p->data[0]));
|
DBGPRINT(String(p->data[0]));
|
||||||
DBGPRINT(F("RSSI "));
|
DBGPRINT(F(" RSSI "));
|
||||||
DBGPRINT(String(p->rssi));
|
DBGPRINT(String(p->rssi));
|
||||||
DBGPRINT(F("dBm | "));
|
DBGPRINT(F("dBm | "));
|
||||||
ah::dumpBuf(&p->data[1], p->data[0]);
|
ah::dumpBuf(&p->data[1], p->data[0]);
|
||||||
}
|
}
|
||||||
|
mStat.frmCnt++;
|
||||||
|
|
||||||
|
Inverter<> *iv = mSys.findInverter(&p->data[2]);
|
||||||
|
if(NULL != iv) {
|
||||||
|
if(IV_HMS == iv->ivGen)
|
||||||
|
mHmsPayload.add(iv, p);
|
||||||
|
}
|
||||||
mCmtRadio.mBufCtrl.pop();
|
mCmtRadio.mBufCtrl.pop();
|
||||||
|
yield();
|
||||||
}
|
}
|
||||||
|
mHmsPayload.process(true);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
mPayload.loop();
|
mPayload.loop();
|
||||||
mMiPayload.loop();
|
mMiPayload.loop();
|
||||||
|
#if defined(ESP32)
|
||||||
|
mHmsPayload.loop();
|
||||||
|
#endif
|
||||||
|
|
||||||
if(mMqttEnabled)
|
if(mMqttEnabled)
|
||||||
mMqtt.loop();
|
mMqtt.loop();
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "hmDefines.h"
|
#include "hmDefines.h"
|
||||||
|
#include "../hms/hmsDefines.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "../config/settings.h"
|
#include "../config/settings.h"
|
||||||
|
@ -418,10 +419,16 @@ class Inverter {
|
||||||
channels = 2;
|
channels = 2;
|
||||||
}
|
}
|
||||||
else if (INV_TYPE_4CH == type) {
|
else if (INV_TYPE_4CH == type) {
|
||||||
rec->length = (uint8_t)(HM4CH_LIST_LEN);
|
if(IV_HM == ivGen) {
|
||||||
rec->assign = (byteAssign_t *)hm4chAssignment;
|
rec->length = (uint8_t)(HM4CH_LIST_LEN);
|
||||||
rec->pyldLen = HM4CH_PAYLOAD_LEN;
|
rec->assign = (byteAssign_t *)hm4chAssignment;
|
||||||
channels = 4;
|
rec->pyldLen = HM4CH_PAYLOAD_LEN;
|
||||||
|
} else if(IV_HMS == ivGen) {
|
||||||
|
rec->length = (uint8_t)(HMS4CH_LIST_LEN);
|
||||||
|
rec->assign = (byteAssign_t *)hms4chAssignment;
|
||||||
|
rec->pyldLen = HMS4CH_PAYLOAD_LEN;
|
||||||
|
}
|
||||||
|
channels = 4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rec->length = 0;
|
rec->length = 0;
|
||||||
|
|
|
@ -222,7 +222,7 @@ class HmPayload {
|
||||||
if (NULL == iv)
|
if (NULL == iv)
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if (IV_MI == iv->ivGen) // only process HM inverters
|
if (IV_HM != iv->ivGen) // only process HM inverters
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
||||||
|
|
|
@ -240,7 +240,7 @@ class MiPayload {
|
||||||
if (NULL == iv)
|
if (NULL == iv)
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if (IV_HM == iv->ivGen) // only process MI inverters
|
if (IV_MI != iv->ivGen) // only process MI inverters
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
/*if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
/*if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
||||||
|
|
|
@ -12,18 +12,18 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
//uint8_t txCmd;
|
uint8_t txCmd;
|
||||||
//uint8_t txId;
|
uint8_t txId;
|
||||||
//uint8_t invId;
|
//uint8_t invId;
|
||||||
uint32_t ts;
|
uint32_t ts;
|
||||||
//uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE];
|
uint8_t data[MAX_PAYLOAD_ENTRIES][MAX_RF_PAYLOAD_SIZE];
|
||||||
uint8_t len[MAX_PAYLOAD_ENTRIES];
|
uint8_t len[MAX_PAYLOAD_ENTRIES];
|
||||||
//bool complete;
|
bool complete;
|
||||||
//uint8_t maxPackId;
|
uint8_t maxPackId;
|
||||||
//bool lastFound;
|
bool lastFound;
|
||||||
//uint8_t retransmits;
|
uint8_t retransmits;
|
||||||
bool requested;
|
bool requested;
|
||||||
//bool gotFragment;
|
bool gotFragment;
|
||||||
} hmsPayload_t;
|
} hmsPayload_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,15 +77,7 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ivSend(Inverter<> *iv, bool highPrio = false) {
|
void ivSend(Inverter<> *iv, bool highPrio = false) {
|
||||||
if(mFirst) {
|
//if(!highPrio) {
|
||||||
mFirst = false;
|
|
||||||
mRadio->setIvBackChannel(&iv->radioId.u64);
|
|
||||||
} else {
|
|
||||||
reset(iv->id);
|
|
||||||
mPayload[iv->id].requested = true;
|
|
||||||
mRadio->prepareDevInformCmd(&iv->radioId.u64, 0x0b, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
|
||||||
}
|
|
||||||
/*if(!highPrio) {
|
|
||||||
if (mPayload[iv->id].requested) {
|
if (mPayload[iv->id].requested) {
|
||||||
if (!mPayload[iv->id].complete)
|
if (!mPayload[iv->id].complete)
|
||||||
process(false); // no retransmit
|
process(false); // no retransmit
|
||||||
|
@ -99,16 +91,16 @@ class HmsPayload {
|
||||||
iv->setQueuedCmdFinished(); // command failed
|
iv->setQueuedCmdFinished(); // command failed
|
||||||
if (mSerialDebug)
|
if (mSerialDebug)
|
||||||
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
||||||
if (mSerialDebug) {
|
/*if (mSerialDebug) {
|
||||||
DPRINT(DBG_INFO, F("(#"));
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DBGPRINT(String(iv->id));
|
DBGPRINT(String(iv->id));
|
||||||
DBGPRINT(F(") no Payload received! (retransmits: "));
|
DBGPRINT(F(") no Payload received! (retransmits: "));
|
||||||
DBGPRINT(String(mPayload[iv->id].retransmits));
|
DBGPRINT(String(mPayload[iv->id].retransmits));
|
||||||
DBGPRINTLN(F(")"));
|
DBGPRINTLN(F(")"));
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
|
|
||||||
reset(iv->id);
|
reset(iv->id);
|
||||||
mPayload[iv->id].requested = true;
|
mPayload[iv->id].requested = true;
|
||||||
|
@ -121,7 +113,7 @@ class HmsPayload {
|
||||||
DBGPRINTLN(String(iv->config->serial.u64, HEX));
|
DBGPRINTLN(String(iv->config->serial.u64, HEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iv->getDevControlRequest()) {
|
/*if (iv->getDevControlRequest()) {
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINT(DBG_INFO, F("(#"));
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
DBGPRINT(String(iv->id));
|
DBGPRINT(String(iv->id));
|
||||||
|
@ -142,20 +134,31 @@ class HmsPayload {
|
||||||
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
||||||
mPayload[iv->id].txCmd = cmd;
|
mPayload[iv->id].txCmd = cmd;
|
||||||
}*/
|
}*/
|
||||||
|
if(mFirst) {
|
||||||
|
mFirst = false;
|
||||||
|
mRadio->setIvBackChannel(&iv->radioId.u64);
|
||||||
|
} else {
|
||||||
|
uint8_t cmd = iv->getQueuedCmd();
|
||||||
|
DPRINT(DBG_INFO, F("(#"));
|
||||||
|
DBGPRINT(String(iv->id));
|
||||||
|
DBGPRINT(F(") prepareDevInformCmd")); // + String(cmd, HEX));
|
||||||
|
mRadio->prepareDevInformCmd(&iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex, false);
|
||||||
|
mPayload[iv->id].txCmd = cmd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(Inverter<> *iv, packet_t *p) {
|
void add(Inverter<> *iv, hmsPacket_t *p) {
|
||||||
/*if (p->packet[0] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
|
if (p->data[1] == (TX_REQ_INFO + ALL_FRAMES)) { // response from get information command
|
||||||
mPayload[iv->id].txId = p->packet[0];
|
mPayload[iv->id].txId = p->data[1];
|
||||||
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
|
DPRINTLN(DBG_DEBUG, F("Response from info request received"));
|
||||||
uint8_t *pid = &p->packet[9];
|
uint8_t *pid = &p->data[10];
|
||||||
if (*pid == 0x00) {
|
if (*pid == 0x00) {
|
||||||
DPRINT(DBG_DEBUG, F("fragment number zero received and ignored"));
|
DPRINT(DBG_DEBUG, F("fragment number zero received and ignored"));
|
||||||
} else {
|
} else {
|
||||||
DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX));
|
DPRINTLN(DBG_DEBUG, "PID: 0x" + String(*pid, HEX));
|
||||||
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
|
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
|
||||||
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11);
|
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->data[11], p->data[0] - 11);
|
||||||
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11;
|
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->data[0] -11;
|
||||||
mPayload[iv->id].gotFragment = true;
|
mPayload[iv->id].gotFragment = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +171,7 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command
|
} /*else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command
|
||||||
DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received"));
|
DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received"));
|
||||||
|
|
||||||
mPayload[iv->id].txId = p->packet[0];
|
mPayload[iv->id].txId = p->packet[0];
|
||||||
|
@ -197,12 +200,12 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(bool retransmit) {
|
void process(bool retransmit) {
|
||||||
/*for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||||
Inverter<> *iv = mSys->getInverterByPos(id);
|
Inverter<> *iv = mSys->getInverterByPos(id);
|
||||||
if (NULL == iv)
|
if (NULL == iv)
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if (IV_MI == iv->ivGen) // only process HM inverters
|
if (IV_HMS != iv->ivGen) // only process HMS inverters
|
||||||
continue; // skip to next inverter
|
continue; // skip to next inverter
|
||||||
|
|
||||||
if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
if ((mPayload[iv->id].txId != (TX_REQ_INFO + ALL_FRAMES)) && (0 != mPayload[iv->id].txId)) {
|
||||||
|
@ -222,10 +225,10 @@ class HmsPayload {
|
||||||
// This is required to prevent retransmissions without answer.
|
// This is required to prevent retransmissions without answer.
|
||||||
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else if(iv->devControlCmd == ActivePowerContr) {
|
} /*else if(iv->devControlCmd == ActivePowerContr) {
|
||||||
DPRINTLN(DBG_INFO, F("retransmit power limit"));
|
DPRINTLN(DBG_INFO, F("retransmit power limit"));
|
||||||
mRadio->sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
mRadio->sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
||||||
} else {
|
}*/ else {
|
||||||
if(false == mPayload[iv->id].gotFragment) {
|
if(false == mPayload[iv->id].gotFragment) {
|
||||||
|
|
||||||
//DPRINTLN(DBG_WARN, F("nothing received: Request Complete Retransmit"));
|
//DPRINTLN(DBG_WARN, F("nothing received: Request Complete Retransmit"));
|
||||||
|
@ -243,7 +246,7 @@ class HmsPayload {
|
||||||
DPRINT(DBG_WARN, F("Frame "));
|
DPRINT(DBG_WARN, F("Frame "));
|
||||||
DBGPRINT(String(i + 1));
|
DBGPRINT(String(i + 1));
|
||||||
DBGPRINTLN(F(" missing: Request Retransmit"));
|
DBGPRINTLN(F(" missing: Request Retransmit"));
|
||||||
mRadio->sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true);
|
//mRadio->sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, (SINGLE_FRAME + i), true);
|
||||||
break; // only request retransmit one frame per loop
|
break; // only request retransmit one frame per loop
|
||||||
}
|
}
|
||||||
yield();
|
yield();
|
||||||
|
@ -252,7 +255,7 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(!crcPass && pyldComplete) { // crc error on complete Payload
|
} /*else if(!crcPass && pyldComplete) { // crc error on complete Payload
|
||||||
if (mPayload[iv->id].retransmits < mMaxRetrans) {
|
if (mPayload[iv->id].retransmits < mMaxRetrans) {
|
||||||
mPayload[iv->id].retransmits++;
|
mPayload[iv->id].retransmits++;
|
||||||
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
|
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
|
||||||
|
@ -263,7 +266,7 @@ class HmsPayload {
|
||||||
DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
||||||
mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
||||||
}
|
}
|
||||||
} else { // payload complete
|
}*/ else { // payload complete
|
||||||
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
|
DPRINT(DBG_INFO, F("procPyld: cmd: 0x"));
|
||||||
DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
DBGPRINTLN(String(mPayload[iv->id].txCmd, HEX));
|
||||||
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
||||||
|
@ -272,10 +275,10 @@ class HmsPayload {
|
||||||
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
||||||
mPayload[iv->id].complete = true;
|
mPayload[iv->id].complete = true;
|
||||||
|
|
||||||
uint8_t payload[128];
|
uint8_t payload[100];
|
||||||
uint8_t payloadLen = 0;
|
uint8_t payloadLen = 0;
|
||||||
|
|
||||||
memset(payload, 0, 128);
|
memset(payload, 0, 100);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) {
|
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId); i++) {
|
||||||
memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i]));
|
memcpy(&payload[payloadLen], mPayload[iv->id].data[i], (mPayload[iv->id].len[i]));
|
||||||
|
@ -305,7 +308,7 @@ class HmsPayload {
|
||||||
iv->doCalculations();
|
iv->doCalculations();
|
||||||
notify(mPayload[iv->id].txCmd);
|
notify(mPayload[iv->id].txCmd);
|
||||||
|
|
||||||
if(AlarmData == mPayload[iv->id].txCmd) {
|
/*if(AlarmData == mPayload[iv->id].txCmd) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
uint16_t code;
|
uint16_t code;
|
||||||
uint32_t start, end;
|
uint32_t start, end;
|
||||||
|
@ -317,7 +320,7 @@ class HmsPayload {
|
||||||
(mCbAlarm)(code, start, end);
|
(mCbAlarm)(code, start, end);
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
} else {
|
} else {
|
||||||
DPRINT(DBG_ERROR, F("plausibility check failed, expected "));
|
DPRINT(DBG_ERROR, F("plausibility check failed, expected "));
|
||||||
DBGPRINT(String(rec->pyldLen));
|
DBGPRINT(String(rec->pyldLen));
|
||||||
|
@ -329,7 +332,7 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yield();
|
yield();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -344,7 +347,7 @@ class HmsPayload {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool build(uint8_t id, bool *complete) {
|
bool build(uint8_t id, bool *complete) {
|
||||||
/*DPRINTLN(DBG_VERBOSE, F("build"));
|
DPRINTLN(DBG_VERBOSE, F("build"));
|
||||||
uint16_t crc = 0xffff, crcRcv = 0x0000;
|
uint16_t crc = 0xffff, crcRcv = 0x0000;
|
||||||
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
if (mPayload[id].maxPackId > MAX_PAYLOAD_ENTRIES)
|
||||||
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||||
|
@ -361,7 +364,7 @@ class HmsPayload {
|
||||||
for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) {
|
for (uint8_t i = 0; i < mPayload[id].maxPackId; i++) {
|
||||||
if (mPayload[id].len[i] > 0) {
|
if (mPayload[id].len[i] > 0) {
|
||||||
if (i == (mPayload[id].maxPackId - 1)) {
|
if (i == (mPayload[id].maxPackId - 1)) {
|
||||||
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 2, crc);
|
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i] - 1, crc);
|
||||||
crcRcv = (mPayload[id].data[i][mPayload[id].len[i] - 2] << 8) | (mPayload[id].data[i][mPayload[id].len[i] - 1]);
|
crcRcv = (mPayload[id].data[i][mPayload[id].len[i] - 2] << 8) | (mPayload[id].data[i][mPayload[id].len[i] - 1]);
|
||||||
} else
|
} else
|
||||||
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i], crc);
|
crc = ah::crc16(mPayload[id].data[i], mPayload[id].len[i], crc);
|
||||||
|
@ -369,8 +372,7 @@ class HmsPayload {
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (crc == crcRcv) ? true : false;*/
|
return (crc == crcRcv) ? true : false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset(uint8_t id) {
|
void reset(uint8_t id) {
|
||||||
|
@ -378,11 +380,11 @@ class HmsPayload {
|
||||||
DBGPRINTLN(String(id));
|
DBGPRINTLN(String(id));
|
||||||
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES);
|
memset(mPayload[id].len, 0, MAX_PAYLOAD_ENTRIES);
|
||||||
//mPayload[id].txCmd = 0;
|
//mPayload[id].txCmd = 0;
|
||||||
//mPayload[id].gotFragment = false;
|
mPayload[id].gotFragment = false;
|
||||||
//mPayload[id].retransmits = 0;
|
//mPayload[id].retransmits = 0;
|
||||||
//mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
mPayload[id].maxPackId = MAX_PAYLOAD_ENTRIES;
|
||||||
//mPayload[id].lastFound = false;
|
mPayload[id].lastFound = false;
|
||||||
//mPayload[id].complete = false;
|
mPayload[id].complete = false;
|
||||||
mPayload[id].requested = false;
|
mPayload[id].requested = false;
|
||||||
mPayload[id].ts = *mTimestamp;
|
mPayload[id].ts = *mTimestamp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@
|
||||||
ahoywifi::ahoywifi() : mApIp(192, 168, 4, 1) {}
|
ahoywifi::ahoywifi() : mApIp(192, 168, 4, 1) {}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: ESP32 has native strongest AP support!
|
||||||
|
* WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN);
|
||||||
|
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
|
||||||
|
*/
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void ahoywifi::setup(settings_t *config, uint32_t *utcTimestamp, appWifiCb cb) {
|
void ahoywifi::setup(settings_t *config, uint32_t *utcTimestamp, appWifiCb cb) {
|
||||||
mConfig = config;
|
mConfig = config;
|
||||||
|
|
Loading…
Add table
Reference in a new issue