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)
|
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>
|
#include <cstdint>
|
||||||
|
|
||||||
#define RF_LEN 32
|
#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;
|
class InverterAbstract;
|
||||||
|
|
||||||
@ -39,6 +41,12 @@ public:
|
|||||||
virtual bool handleResponse(InverterAbstract* inverter, fragment_t fragment[], uint8_t max_fragment_id) = 0;
|
virtual bool handleResponse(InverterAbstract* inverter, fragment_t fragment[], uint8_t max_fragment_id) = 0;
|
||||||
virtual void gotTimeout(InverterAbstract* inverter);
|
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:
|
protected:
|
||||||
uint8_t _payload[RF_LEN];
|
uint8_t _payload[RF_LEN];
|
||||||
uint8_t _payload_size;
|
uint8_t _payload_size;
|
||||||
|
|||||||
@ -181,7 +181,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
|||||||
// All missing
|
// All missing
|
||||||
if (_rxFragmentLastPacketId == 0) {
|
if (_rxFragmentLastPacketId == 0) {
|
||||||
Hoymiles.getMessageOutput()->println("All missing");
|
Hoymiles.getMessageOutput()->println("All missing");
|
||||||
if (cmd->getSendCount() <= MAX_RESEND_COUNT) {
|
if (cmd->getSendCount() <= cmd->getMaxResendCount()) {
|
||||||
return FRAGMENT_ALL_MISSING_RESEND;
|
return FRAGMENT_ALL_MISSING_RESEND;
|
||||||
} else {
|
} else {
|
||||||
cmd->gotTimeout(this);
|
cmd->gotTimeout(this);
|
||||||
@ -192,7 +192,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
|||||||
// Last fragment is missing (the one with 0x80)
|
// Last fragment is missing (the one with 0x80)
|
||||||
if (_rxFragmentMaxPacketId == 0) {
|
if (_rxFragmentMaxPacketId == 0) {
|
||||||
Hoymiles.getMessageOutput()->println("Last missing");
|
Hoymiles.getMessageOutput()->println("Last missing");
|
||||||
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
|
if (_rxFragmentRetransmitCnt++ < cmd->getMaxRetransmitCount()) {
|
||||||
return _rxFragmentLastPacketId + 1;
|
return _rxFragmentLastPacketId + 1;
|
||||||
} else {
|
} else {
|
||||||
cmd->gotTimeout(this);
|
cmd->gotTimeout(this);
|
||||||
@ -204,7 +204,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
|
|||||||
for (uint8_t i = 0; i < _rxFragmentMaxPacketId - 1; i++) {
|
for (uint8_t i = 0; i < _rxFragmentMaxPacketId - 1; i++) {
|
||||||
if (!_rxFragmentBuffer[i].wasReceived) {
|
if (!_rxFragmentBuffer[i].wasReceived) {
|
||||||
Hoymiles.getMessageOutput()->println("Middle missing");
|
Hoymiles.getMessageOutput()->println("Middle missing");
|
||||||
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
|
if (_rxFragmentRetransmitCnt++ < cmd->getMaxRetransmitCount()) {
|
||||||
return i + 1;
|
return i + 1;
|
||||||
} else {
|
} else {
|
||||||
cmd->gotTimeout(this);
|
cmd->gotTimeout(this);
|
||||||
|
|||||||
@ -24,8 +24,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_RF_FRAGMENT_COUNT 13
|
#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
|
#define MAX_ONLINE_FAILURE_COUNT 2
|
||||||
|
|
||||||
class CommandAbstract;
|
class CommandAbstract;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user