Add very simple method differ between requests
The last request is required to use the right parser for the received payload as the package type is not encoded in the received data
This commit is contained in:
parent
b2271373a4
commit
c4e911cecf
@ -37,5 +37,6 @@ bool HM_Abstract::sendStatsRequest(HoymilesRadio* radio)
|
||||
|
||||
clearRxFragmentBuffer();
|
||||
radio->enqueTransaction(&payload);
|
||||
setLastRequest(RequestType::Stats);
|
||||
return true;
|
||||
}
|
||||
@ -104,7 +104,7 @@ uint8_t InverterAbstract::verifyAllFragments()
|
||||
return FRAGMENT_CRC_ERROR;
|
||||
}
|
||||
|
||||
// todo: hier muss noch ein check bzgl. packet type usw rein (ist ja nicht alles statistik)
|
||||
if (getLastRequest() == RequestType::Stats) {
|
||||
// Move all fragments into target buffer
|
||||
memset(_payloadStats, 0, MAX_RF_FRAGMENT_COUNT * MAX_RF_PAYLOAD_SIZE);
|
||||
uint8_t offs = 0;
|
||||
@ -113,6 +113,7 @@ uint8_t InverterAbstract::verifyAllFragments()
|
||||
offs += (_rxFragmentBuffer[i].len);
|
||||
}
|
||||
_lastStatsUpdate = millis();
|
||||
}
|
||||
|
||||
return FRAGMENT_OK;
|
||||
}
|
||||
@ -122,6 +123,16 @@ uint32_t InverterAbstract::getLastStatsUpdate()
|
||||
return _lastStatsUpdate;
|
||||
}
|
||||
|
||||
void InverterAbstract::setLastRequest(RequestType request)
|
||||
{
|
||||
_lastRequest = request;
|
||||
}
|
||||
|
||||
RequestType InverterAbstract::getLastRequest()
|
||||
{
|
||||
return _lastRequest;
|
||||
}
|
||||
|
||||
uint8_t InverterAbstract::getChannelCount()
|
||||
{
|
||||
const byteAssign_t* b = getByteAssignment();
|
||||
|
||||
@ -66,6 +66,10 @@ enum {
|
||||
FRAGMENT_OK = 0
|
||||
};
|
||||
|
||||
enum class RequestType {
|
||||
Stats
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t fieldId; // field id
|
||||
uint8_t unitId; // uint id
|
||||
@ -130,6 +134,10 @@ public:
|
||||
virtual bool sendStatsRequest(HoymilesRadio* radio) = 0;
|
||||
uint32_t getLastStatsUpdate();
|
||||
|
||||
protected:
|
||||
void setLastRequest(RequestType request);
|
||||
RequestType getLastRequest();
|
||||
|
||||
private:
|
||||
serial_u _serial;
|
||||
char _name[MAX_NAME_LENGTH];
|
||||
@ -141,4 +149,6 @@ private:
|
||||
uint8_t _payloadStats[MAX_RF_FRAGMENT_COUNT * MAX_RF_PAYLOAD_SIZE];
|
||||
uint32_t _lastStatsUpdate = 0;
|
||||
uint16_t _chanMaxPower[CH4];
|
||||
|
||||
RequestType _lastRequest;
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user