Browse Source

aligned radios

pull/1197/head
lumapu 1 year ago
parent
commit
09c4397491
  1. 16
      src/hms/hmsPayload.h
  2. 14
      src/hms/hmsRadio.h

16
src/hms/hmsPayload.h

@ -151,12 +151,12 @@ class HmsPayload {
DBGPRINTLN(String(iv->powerLimit[0]));
}
iv->powerLimitAck = false;
mRadio->sendControlPacket(&iv->radioId.u64, iv->devControlCmd, iv->powerLimit, false);
mRadio->sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, false);
mPayload[iv->id].txCmd = iv->devControlCmd;
//iv->clearCmdQueue();
//iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
} else if(((rec->ts + HMS_TIMEOUT_SEC) < *mTimestamp) && (mIvCmd56Cnt[iv->id] < 3)) {
mRadio->switchFrequency(&iv->radioId.u64, HOY_BOOT_FREQ_KHZ, WORK_FREQ_KHZ);
mRadio->switchFrequency(iv->radioId.u64, HOY_BOOT_FREQ_KHZ, WORK_FREQ_KHZ);
mIvCmd56Cnt[iv->id]++;
} else {
if(++mIvCmd56Cnt[iv->id] == 10)
@ -167,7 +167,7 @@ class HmsPayload {
DBGPRINT(F("prepareDevInformCmd 0x"));
DBGHEXLN(cmd);
}
mRadio->prepareDevInformCmd(&iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false);
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false);
mPayload[iv->id].txCmd = cmd;
}
}
@ -261,7 +261,7 @@ class HmsPayload {
} else if(iv->devControlCmd == ActivePowerContr) {
DPRINT_IVID(DBG_INFO, iv->id);
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 {
if(false == mPayload[iv->id].gotFragment) {
DPRINT_IVID(DBG_WARN, iv->id);
@ -272,7 +272,7 @@ class HmsPayload {
DBGPRINTLN(F("nothing received: complete retransmit"));
mPayload[iv->id].txCmd = iv->getQueuedCmd();
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + 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 {
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) {
@ -305,7 +305,7 @@ class HmsPayload {
DBGPRINT(F("prepareDevInformCmd 0x"));
DBGHEXLN(mPayload[iv->id].txCmd);
}
mRadio->prepareDevInformCmd(&iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true);
mRadio->prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmLastId, true);
}
} else { // payload complete
if (mSerialDebug) {
@ -386,7 +386,7 @@ class HmsPayload {
DBGHEXLN(cmd);
}
mStat->rxSuccess++;
mRadio->prepareDevInformCmd(&iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false);
mRadio->prepareDevInformCmd(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmLastId, false);
mPayload[iv->id].txCmd = cmd;
*/
mHighPrioIv = iv;
@ -434,7 +434,7 @@ class HmsPayload {
for (uint8_t i = 0; i < mPayload[iv->id].maxPackId; i++) {
if (mPayload[iv->id].len[i] > 0) {
if (i == (mPayload[iv->id].maxPackId - 1)) {
crc = ah::crc16(mPayload[iv->id].data[i], mPayload[iv->id].len[i] - 1, crc);
crc = ah::crc16(mPayload[iv->id].data[i], mPayload[iv->id].len[i] - 2, crc);
crcRcv = (mPayload[iv->id].data[i][mPayload[iv->id].len[i] - 2] << 8) | (mPayload[iv->id].data[i][mPayload[iv->id].len[i] - 1]);
} else
crc = ah::crc16(mPayload[iv->id].data[i], mPayload[iv->id].len[i], crc);

14
src/hms/hmsRadio.h

@ -64,7 +64,7 @@ class CmtRadio {
return mCmtAvail;
}
void sendControlPacket(const uint64_t *ivId, uint8_t cmd, uint16_t *data, bool isRetransmit) {
void sendControlPacket(uint64_t ivId, uint8_t cmd, uint16_t *data, bool isRetransmit) {
DPRINT(DBG_INFO, F("sendControlPacket cmd: 0x"));
DBGHEXLN(cmd);
initPacket(ivId, TX_REQ_DEVCONTROL, SINGLE_FRAME);
@ -82,7 +82,7 @@ class CmtRadio {
sendPacket(cnt, isRetransmit);
}
bool switchFrequency(const uint64_t *ivId, uint32_t fromkHz, uint32_t tokHz) {
bool switchFrequency(uint64_t ivId, uint32_t fromkHz, uint32_t tokHz) {
uint8_t fromCh = mCmt.freq2Chan(fromkHz);
uint8_t toCh = mCmt.freq2Chan(tokHz);
@ -95,7 +95,7 @@ class CmtRadio {
return true;
}
void prepareDevInformCmd(const uint64_t *ivId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg.
void prepareDevInformCmd(uint64_t ivId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId, bool isRetransmit, uint8_t reqfld=TX_REQ_INFO) { // might not be necessary to add additional arg.
initPacket(ivId, reqfld, ALL_FRAMES);
mTxBuf[10] = cmd;
CP_U32_LittleEndian(&mTxBuf[12], ts);
@ -107,7 +107,7 @@ class CmtRadio {
}
void sendCmdPacket(uint64_t ivId, uint8_t mid, uint8_t pid, bool isRetransmit) {
initPacket(&ivId, mid, pid);
initPacket(ivId, mid, pid);
sendPacket(10, isRetransmit);
}
@ -160,7 +160,7 @@ class CmtRadio {
mRqstGetRx = false;
}
inline void sendSwitchChCmd(const uint64_t *ivId, uint8_t ch) {
inline void sendSwitchChCmd(uint64_t ivId, uint8_t ch) {
/** ch:
* 0x00: 860.00 MHz
* 0x01: 860.25 MHz
@ -179,9 +179,9 @@ class CmtRadio {
mRqstGetRx = true;
}
void initPacket(const uint64_t *ivId, uint8_t mid, uint8_t pid) {
void initPacket(uint64_t ivId, uint8_t mid, uint8_t pid) {
mTxBuf[0] = mid;
CP_U32_BigEndian(&mTxBuf[1], (*ivId) >> 8);
CP_U32_BigEndian(&mTxBuf[1], ivId >> 8);
CP_U32_LittleEndian(&mTxBuf[5], mDtuSn);
mTxBuf[9] = pid;
memset(&mTxBuf[10], 0x00, 17);

Loading…
Cancel
Save