Browse Source

improve communication

pull/935/head
lumapu 2 years ago
parent
commit
7afd0b80fe
  1. 20
      src/hms/hmsRadio.h

20
src/hms/hmsRadio.h

@ -41,19 +41,22 @@ class CmtRadio {
bool loop() { bool loop() {
mCmt.loop(); mCmt.loop();
if(0x00 != mIrqRcvd) if((!mIrqRcvd) && (!mRqstGetRx))
return false; return false;
mIrqRcvd--;
getRx(); getRx();
mCmt.goRx(); if(CMT_SUCCESS == mCmt.goRx()) {
return true; mIrqRcvd = false;
mRqstGetRx = false;
return true;
} else
return false;
} }
void tickSecond() { void tickSecond() {
} }
void handleIntr(void) { void handleIntr(void) {
mIrqRcvd++; mIrqRcvd = true;
} }
void enableDebug() { void enableDebug() {
@ -130,7 +133,8 @@ class CmtRadio {
mSendCnt = 0; mSendCnt = 0;
mRetransmits = 0; mRetransmits = 0;
mSerialDebug = false; mSerialDebug = false;
mIrqRcvd = 0; mIrqRcvd = false;
mRqstGetRx = false;
} }
inline void sendSwitchChCmd(const uint64_t *ivId, uint8_t ch) { inline void sendSwitchChCmd(const uint64_t *ivId, uint8_t ch) {
@ -149,6 +153,7 @@ class CmtRadio {
mTxBuf[12] = ch; mTxBuf[12] = ch;
mTxBuf[13] = 0x14; mTxBuf[13] = 0x14;
sendPacket(14, false); sendPacket(14, false);
mRqstGetRx = true;
} }
void initPacket(const uint64_t *ivId, uint8_t mid, uint8_t pid) { void initPacket(const uint64_t *ivId, uint8_t mid, uint8_t pid) {
@ -183,7 +188,8 @@ class CmtRadio {
uint32_t mDtuSn; uint32_t mDtuSn;
uint8_t mTxBuf[27]; uint8_t mTxBuf[27];
bool mSerialDebug; bool mSerialDebug;
volatile uint8_t mIrqRcvd; bool mIrqRcvd;
bool mRqstGetRx;
}; };
#endif /*__HMS_RADIO_H__*/ #endif /*__HMS_RADIO_H__*/

Loading…
Cancel
Save