Move serveral methods from the HoymilesRadio_NRF class to the HoymilesRadio base class
This commit is contained in:
parent
8404dd57a7
commit
41e2ba7fcf
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "HoymilesRadio.h"
|
#include "HoymilesRadio.h"
|
||||||
#include "Hoymiles.h"
|
#include "Hoymiles.h"
|
||||||
|
#include "crc.h"
|
||||||
|
|
||||||
serial_u HoymilesRadio::DtuSerial()
|
serial_u HoymilesRadio::DtuSerial()
|
||||||
{
|
{
|
||||||
@ -27,6 +28,29 @@ serial_u HoymilesRadio::convertSerialToRadioId(serial_u serial)
|
|||||||
return radioId;
|
return radioId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HoymilesRadio::checkFragmentCrc(fragment_t* fragment)
|
||||||
|
{
|
||||||
|
uint8_t crc = crc8(fragment->fragment, fragment->len - 1);
|
||||||
|
return (crc == fragment->fragment[fragment->len - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HoymilesRadio::sendRetransmitPacket(uint8_t fragment_id)
|
||||||
|
{
|
||||||
|
CommandAbstract* cmd = _commandQueue.front().get();
|
||||||
|
|
||||||
|
CommandAbstract* requestCmd = cmd->getRequestFrameCommand(fragment_id);
|
||||||
|
|
||||||
|
if (requestCmd != nullptr) {
|
||||||
|
sendEsbPacket(requestCmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HoymilesRadio::sendLastPacketAgain()
|
||||||
|
{
|
||||||
|
CommandAbstract* cmd = _commandQueue.front().get();
|
||||||
|
sendEsbPacket(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void HoymilesRadio::dumpBuf(const char* info, uint8_t buf[], uint8_t len)
|
void HoymilesRadio::dumpBuf(const char* info, uint8_t buf[], uint8_t len)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,11 @@ protected:
|
|||||||
static serial_u convertSerialToRadioId(serial_u serial);
|
static serial_u convertSerialToRadioId(serial_u serial);
|
||||||
void dumpBuf(const char* info, uint8_t buf[], uint8_t len);
|
void dumpBuf(const char* info, uint8_t buf[], uint8_t len);
|
||||||
|
|
||||||
|
bool checkFragmentCrc(fragment_t* fragment);
|
||||||
|
virtual void sendEsbPacket(CommandAbstract* cmd) = 0;
|
||||||
|
void sendRetransmitPacket(uint8_t fragment_id);
|
||||||
|
void sendLastPacketAgain();
|
||||||
|
|
||||||
serial_u _dtuSerial;
|
serial_u _dtuSerial;
|
||||||
std::queue<std::shared_ptr<CommandAbstract>> _commandQueue;
|
std::queue<std::shared_ptr<CommandAbstract>> _commandQueue;
|
||||||
};
|
};
|
||||||
@ -5,7 +5,6 @@
|
|||||||
#include "HoymilesRadio_NRF.h"
|
#include "HoymilesRadio_NRF.h"
|
||||||
#include "Hoymiles.h"
|
#include "Hoymiles.h"
|
||||||
#include "commands/RequestFrameCommand.h"
|
#include "commands/RequestFrameCommand.h"
|
||||||
#include "crc.h"
|
|
||||||
#include <Every.h>
|
#include <Every.h>
|
||||||
#include <FunctionalInterrupt.h>
|
#include <FunctionalInterrupt.h>
|
||||||
|
|
||||||
@ -215,11 +214,7 @@ void HoymilesRadio_NRF::switchRxCh()
|
|||||||
_radio->startListening();
|
_radio->startListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HoymilesRadio_NRF::checkFragmentCrc(fragment_t* fragment)
|
|
||||||
{
|
|
||||||
uint8_t crc = crc8(fragment->fragment, fragment->len - 1);
|
|
||||||
return (crc == fragment->fragment[fragment->len - 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HoymilesRadio_NRF::sendEsbPacket(CommandAbstract* cmd)
|
void HoymilesRadio_NRF::sendEsbPacket(CommandAbstract* cmd)
|
||||||
{
|
{
|
||||||
@ -250,21 +245,3 @@ void HoymilesRadio_NRF::sendEsbPacket(CommandAbstract* cmd)
|
|||||||
_busyFlag = true;
|
_busyFlag = true;
|
||||||
_rxTimeout.set(cmd->getTimeout());
|
_rxTimeout.set(cmd->getTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HoymilesRadio_NRF::sendRetransmitPacket(uint8_t fragment_id)
|
|
||||||
{
|
|
||||||
CommandAbstract* cmd = _commandQueue.front().get();
|
|
||||||
|
|
||||||
CommandAbstract* requestCmd = cmd->getRequestFrameCommand(fragment_id);
|
|
||||||
|
|
||||||
if (requestCmd != nullptr) {
|
|
||||||
sendEsbPacket(requestCmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void HoymilesRadio_NRF::sendLastPacketAgain()
|
|
||||||
{
|
|
||||||
CommandAbstract* cmd = _commandQueue.front().get();
|
|
||||||
sendEsbPacket(cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -31,11 +31,8 @@ private:
|
|||||||
void switchRxCh();
|
void switchRxCh();
|
||||||
void openReadingPipe();
|
void openReadingPipe();
|
||||||
void openWritingPipe(serial_u serial);
|
void openWritingPipe(serial_u serial);
|
||||||
bool checkFragmentCrc(fragment_t* fragment);
|
|
||||||
|
|
||||||
void sendEsbPacket(CommandAbstract* cmd);
|
void sendEsbPacket(CommandAbstract* cmd);
|
||||||
void sendRetransmitPacket(uint8_t fragment_id);
|
|
||||||
void sendLastPacketAgain();
|
|
||||||
|
|
||||||
std::unique_ptr<SPIClass> _spiPtr;
|
std::unique_ptr<SPIClass> _spiPtr;
|
||||||
std::unique_ptr<RF24> _radio;
|
std::unique_ptr<RF24> _radio;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user