Resend and Retransmit count is now implementable per command
This commit is contained in:
parent
e2aa29f117
commit
ac7b5dba11
@ -100,4 +100,14 @@ void CommandAbstract::convertSerialToPacketId(uint8_t buffer[], uint64_t serial)
|
||||
|
||||
void CommandAbstract::gotTimeout(InverterAbstract* inverter)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t CommandAbstract::getMaxResendCount()
|
||||
{
|
||||
return MAX_RESEND_COUNT;
|
||||
}
|
||||
|
||||
uint8_t CommandAbstract::getMaxRetransmitCount()
|
||||
{
|
||||
return MAX_RETRANSMIT_COUNT;
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
#include <cstdint>
|
||||
|
||||
#define RF_LEN 32
|
||||
#define MAX_RESEND_COUNT 4 // Used if all packages are missing
|
||||
#define MAX_RETRANSMIT_COUNT 5 // Used to send the retransmit package
|
||||
|
||||
class InverterAbstract;
|
||||
|
||||
@ -39,6 +41,12 @@ public:
|
||||
virtual bool handleResponse(InverterAbstract* inverter, fragment_t fragment[], uint8_t max_fragment_id) = 0;
|
||||
virtual void gotTimeout(InverterAbstract* inverter);
|
||||
|
||||
// Sets the amount how often the specific command is resent if all fragments where missing
|
||||
virtual uint8_t getMaxResendCount();
|
||||
|
||||
// Sets the amount how often a missing fragment is re-requested if it was not available
|
||||
virtual uint8_t getMaxRetransmitCount();
|
||||
|
||||
protected:
|
||||
uint8_t _payload[RF_LEN];
|
||||
uint8_t _payload_size;
|
||||
|
||||
@ -181,7 +181,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
||||
// All missing
|
||||
if (_rxFragmentLastPacketId == 0) {
|
||||
Hoymiles.getMessageOutput()->println("All missing");
|
||||
if (cmd->getSendCount() <= MAX_RESEND_COUNT) {
|
||||
if (cmd->getSendCount() <= cmd->getMaxResendCount()) {
|
||||
return FRAGMENT_ALL_MISSING_RESEND;
|
||||
} else {
|
||||
cmd->gotTimeout(this);
|
||||
@ -192,7 +192,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
||||
// Last fragment is missing (the one with 0x80)
|
||||
if (_rxFragmentMaxPacketId == 0) {
|
||||
Hoymiles.getMessageOutput()->println("Last missing");
|
||||
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
|
||||
if (_rxFragmentRetransmitCnt++ < cmd->getMaxRetransmitCount()) {
|
||||
return _rxFragmentLastPacketId + 1;
|
||||
} else {
|
||||
cmd->gotTimeout(this);
|
||||
@ -204,7 +204,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
||||
for (uint8_t i = 0; i < _rxFragmentMaxPacketId - 1; i++) {
|
||||
if (!_rxFragmentBuffer[i].wasReceived) {
|
||||
Hoymiles.getMessageOutput()->println("Middle missing");
|
||||
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
|
||||
if (_rxFragmentRetransmitCnt++ < cmd->getMaxRetransmitCount()) {
|
||||
return i + 1;
|
||||
} else {
|
||||
cmd->gotTimeout(this);
|
||||
|
||||
@ -24,8 +24,6 @@ enum {
|
||||
};
|
||||
|
||||
#define MAX_RF_FRAGMENT_COUNT 13
|
||||
#define MAX_RETRANSMIT_COUNT 5 // Used to send the retransmit package
|
||||
#define MAX_RESEND_COUNT 4 // Used if all packages are missing
|
||||
#define MAX_ONLINE_FAILURE_COUNT 2
|
||||
|
||||
class CommandAbstract;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user