Implemented resend of whole requests
This commit is contained in:
parent
9542cd9be3
commit
8d2b71cd04
@ -86,9 +86,13 @@ void HoymilesRadio::loop()
|
|||||||
if (nullptr != inv) {
|
if (nullptr != inv) {
|
||||||
uint8_t verifyResult = inv->verifyAllFragments();
|
uint8_t verifyResult = inv->verifyAllFragments();
|
||||||
if (verifyResult == 255) {
|
if (verifyResult == 255) {
|
||||||
Serial.println(F("Should Retransmit whole thing"));
|
if (currentTransaction.sendCount < MAX_RESEND_COUNT) {
|
||||||
// todo: irgendwas tun wenn garnichts ankam....
|
Serial.println(F("Nothing received, resend whole request"));
|
||||||
_busyFlag = false;
|
sendEsbPacket(currentTransaction.target, currentTransaction.mainCmd, currentTransaction.subCmd, currentTransaction.payload, currentTransaction.len, currentTransaction.timeout, true);
|
||||||
|
} else {
|
||||||
|
Serial.println(F("Nothing received, resend count exeeded"));
|
||||||
|
_busyFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
} else if (verifyResult == 254) {
|
} else if (verifyResult == 254) {
|
||||||
Serial.println(F("Retransmit timeout"));
|
Serial.println(F("Retransmit timeout"));
|
||||||
@ -208,17 +212,28 @@ void HoymilesRadio::sendEsbPacket(serial_u target, uint8_t mainCmd, uint8_t subC
|
|||||||
static uint8_t txBuffer[MAX_RF_PAYLOAD_SIZE];
|
static uint8_t txBuffer[MAX_RF_PAYLOAD_SIZE];
|
||||||
|
|
||||||
if (!resend) {
|
if (!resend) {
|
||||||
memset(txBuffer, 0, MAX_RF_PAYLOAD_SIZE);
|
currentTransaction.sendCount = 0;
|
||||||
|
} else {
|
||||||
txBuffer[0] = mainCmd;
|
currentTransaction.sendCount++;
|
||||||
convertSerialToPacketId(&txBuffer[1], target); // 4 byte long
|
|
||||||
convertSerialToPacketId(&txBuffer[5], DtuSerial()); // 4 byte long
|
|
||||||
txBuffer[9] = subCmd;
|
|
||||||
|
|
||||||
memcpy(&txBuffer[10], payload, len);
|
|
||||||
txBuffer[10 + len] = crc8(txBuffer, 10 + len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(txBuffer, 0, MAX_RF_PAYLOAD_SIZE);
|
||||||
|
|
||||||
|
txBuffer[0] = mainCmd;
|
||||||
|
convertSerialToPacketId(&txBuffer[1], target); // 4 byte long
|
||||||
|
convertSerialToPacketId(&txBuffer[5], DtuSerial()); // 4 byte long
|
||||||
|
txBuffer[9] = subCmd;
|
||||||
|
|
||||||
|
memcpy(&txBuffer[10], payload, len);
|
||||||
|
txBuffer[10 + len] = crc8(txBuffer, 10 + len);
|
||||||
|
|
||||||
|
currentTransaction.mainCmd = mainCmd;
|
||||||
|
currentTransaction.target = target;
|
||||||
|
currentTransaction.subCmd = subCmd;
|
||||||
|
memcpy(currentTransaction.payload, payload, len);
|
||||||
|
currentTransaction.len = len;
|
||||||
|
currentTransaction.timeout = timeout;
|
||||||
|
|
||||||
_radio->stopListening();
|
_radio->stopListening();
|
||||||
_radio->setChannel(getTxNxtChannel());
|
_radio->setChannel(getTxNxtChannel());
|
||||||
openWritingPipe(target);
|
openWritingPipe(target);
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
// number of fragments hold in buffer
|
// number of fragments hold in buffer
|
||||||
#define FRAGMENT_BUFFER_SIZE 30
|
#define FRAGMENT_BUFFER_SIZE 30
|
||||||
|
|
||||||
|
#define MAX_RESEND_COUNT 3
|
||||||
|
|
||||||
class HoymilesRadio {
|
class HoymilesRadio {
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
@ -55,4 +57,6 @@ private:
|
|||||||
serial_u _activeSerial;
|
serial_u _activeSerial;
|
||||||
|
|
||||||
bool _busyFlag = false;
|
bool _busyFlag = false;
|
||||||
|
|
||||||
|
inverter_transaction_t currentTransaction;
|
||||||
};
|
};
|
||||||
@ -14,3 +14,13 @@ typedef struct {
|
|||||||
uint8_t fragment[MAX_RF_PAYLOAD_SIZE];
|
uint8_t fragment[MAX_RF_PAYLOAD_SIZE];
|
||||||
uint8_t len;
|
uint8_t len;
|
||||||
} fragment_t;
|
} fragment_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
serial_u target;
|
||||||
|
uint8_t mainCmd;
|
||||||
|
uint8_t subCmd;
|
||||||
|
uint8_t payload[MAX_RF_PAYLOAD_SIZE];
|
||||||
|
uint8_t len;
|
||||||
|
uint32_t timeout;
|
||||||
|
uint8_t sendCount;
|
||||||
|
} inverter_transaction_t;
|
||||||
Loading…
Reference in New Issue
Block a user