Skip to content

Commit

Permalink
Remove not required F() macro. Frees ~20kb flash.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbnobody authored and helgeerbe committed Apr 5, 2023
1 parent dab5b4d commit ca0b8e9
Show file tree
Hide file tree
Showing 33 changed files with 868 additions and 868 deletions.
8 changes: 4 additions & 4 deletions lib/Hoymiles/src/Hoymiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void HoymilesClass::loop()
if (_radio->isIdle()) {
std::shared_ptr<InverterAbstract> iv = getInverterByPos(inverterPos);
if (iv != nullptr) {
_messageOutput->print(F("Fetch inverter: "));
_messageOutput->print("Fetch inverter: ");
_messageOutput->println(iv->serial(), HEX);

iv->sendStatsRequest(_radio.get());
Expand All @@ -54,19 +54,19 @@ void HoymilesClass::loop()

// Set limit if required
if (iv->SystemConfigPara()->getLastLimitCommandSuccess() == CMD_NOK) {
_messageOutput->println(F("Resend ActivePowerControl"));
_messageOutput->println("Resend ActivePowerControl");
iv->resendActivePowerControlRequest(_radio.get());
}

// Set power status if required
if (iv->PowerCommand()->getLastPowerCommandSuccess() == CMD_NOK) {
_messageOutput->println(F("Resend PowerCommand"));
_messageOutput->println("Resend PowerCommand");
iv->resendPowerControlRequest(_radio.get());
}

// Fetch dev info (but first fetch stats)
if (iv->Statistics()->getLastUpdate() > 0 && (iv->DevInfo()->getLastUpdateAll() == 0 || iv->DevInfo()->getLastUpdateSimple() == 0)) {
_messageOutput->println(F("Request device info"));
_messageOutput->println("Request device info");
iv->sendDevInfoRequest(_radio.get());
}
}
Expand Down
38 changes: 19 additions & 19 deletions lib/Hoymiles/src/HoymilesRadio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ void HoymilesRadio::init(SPIClass* initialisedSpiBus, uint8_t pinCE, uint8_t pin
_radio->setRetries(0, 0);
_radio->maskIRQ(true, true, false); // enable only receiving interrupts
if (_radio->isChipConnected()) {
Hoymiles.getMessageOutput()->println(F("Connection successful"));
Hoymiles.getMessageOutput()->println("Connection successful");
} else {
Hoymiles.getMessageOutput()->println(F("Connection error!!"));
Hoymiles.getMessageOutput()->println("Connection error!!");
}

attachInterrupt(digitalPinToInterrupt(pinIRQ), std::bind(&HoymilesRadio::handleIntr, this), FALLING);
Expand All @@ -44,7 +44,7 @@ void HoymilesRadio::loop()
}

if (_packetReceived) {
Hoymiles.getMessageOutput()->println(F("Interrupt received"));
Hoymiles.getMessageOutput()->println("Interrupt received");
while (_radio->available()) {
if (!(_rxBuffer.size() > FRAGMENT_BUFFER_SIZE)) {
fragment_t f;
Expand All @@ -56,7 +56,7 @@ void HoymilesRadio::loop()
_radio->read(f.fragment, f.len);
_rxBuffer.push(f);
} else {
Hoymiles.getMessageOutput()->println(F("Buffer full"));
Hoymiles.getMessageOutput()->println("Buffer full");
_radio->flush_rx();
}
}
Expand All @@ -76,11 +76,11 @@ void HoymilesRadio::loop()
dumpBuf(buf, f.fragment, f.len);
inv->addRxFragment(f.fragment, f.len);
} else {
Hoymiles.getMessageOutput()->println(F("Inverter Not found!"));
Hoymiles.getMessageOutput()->println("Inverter Not found!");
}

} else {
Hoymiles.getMessageOutput()->println(F("Frame kaputt"));
Hoymiles.getMessageOutput()->println("Frame kaputt");
}

// Remove paket from buffer even it was corrupted
Expand All @@ -89,46 +89,46 @@ void HoymilesRadio::loop()
}

if (_busyFlag && _rxTimeout.occured()) {
Hoymiles.getMessageOutput()->println(F("RX Period End"));
Hoymiles.getMessageOutput()->println("RX Period End");
std::shared_ptr<InverterAbstract> inv = Hoymiles.getInverterBySerial(_commandQueue.front().get()->getTargetAddress());

if (nullptr != inv) {
CommandAbstract* cmd = _commandQueue.front().get();
uint8_t verifyResult = inv->verifyAllFragments(cmd);
if (verifyResult == FRAGMENT_ALL_MISSING_RESEND) {
Hoymiles.getMessageOutput()->println(F("Nothing received, resend whole request"));
Hoymiles.getMessageOutput()->println("Nothing received, resend whole request");
sendLastPacketAgain();

} else if (verifyResult == FRAGMENT_ALL_MISSING_TIMEOUT) {
Hoymiles.getMessageOutput()->println(F("Nothing received, resend count exeeded"));
Hoymiles.getMessageOutput()->println("Nothing received, resend count exeeded");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult == FRAGMENT_RETRANSMIT_TIMEOUT) {
Hoymiles.getMessageOutput()->println(F("Retransmit timeout"));
Hoymiles.getMessageOutput()->println("Retransmit timeout");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult == FRAGMENT_HANDLE_ERROR) {
Hoymiles.getMessageOutput()->println(F("Packet handling error"));
Hoymiles.getMessageOutput()->println("Packet handling error");
_commandQueue.pop();
_busyFlag = false;

} else if (verifyResult > 0) {
// Perform Retransmit
Hoymiles.getMessageOutput()->print(F("Request retransmit: "));
Hoymiles.getMessageOutput()->print("Request retransmit: ");
Hoymiles.getMessageOutput()->println(verifyResult);
sendRetransmitPacket(verifyResult);

} else {
// Successful received all packages
Hoymiles.getMessageOutput()->println(F("Success"));
Hoymiles.getMessageOutput()->println("Success");
_commandQueue.pop();
_busyFlag = false;
}
} else {
// If inverter was not found, assume the command is invalid
Hoymiles.getMessageOutput()->println(F("RX: Invalid inverter found"));
Hoymiles.getMessageOutput()->println("RX: Invalid inverter found");
_commandQueue.pop();
_busyFlag = false;
}
Expand All @@ -142,7 +142,7 @@ void HoymilesRadio::loop()
inv->clearRxFragmentBuffer();
sendEsbPacket(cmd);
} else {
Hoymiles.getMessageOutput()->println(F("TX: Invalid inverter found"));
Hoymiles.getMessageOutput()->println("TX: Invalid inverter found");
_commandQueue.pop();
}
}
Expand Down Expand Up @@ -252,11 +252,11 @@ void HoymilesRadio::sendEsbPacket(CommandAbstract* cmd)
openWritingPipe(s);
_radio->setRetries(3, 15);

Hoymiles.getMessageOutput()->print(F("TX "));
Hoymiles.getMessageOutput()->print("TX ");
Hoymiles.getMessageOutput()->print(cmd->getCommandName());
Hoymiles.getMessageOutput()->print(F(" Channel: "));
Hoymiles.getMessageOutput()->print(" Channel: ");
Hoymiles.getMessageOutput()->print(_radio->getChannel());
Hoymiles.getMessageOutput()->print(F(" --> "));
Hoymiles.getMessageOutput()->print(" --> ");
cmd->dumpDataPayload(Hoymiles.getMessageOutput());
_radio->write(cmd->getDataPayload(), cmd->getDataSize());

Expand Down Expand Up @@ -294,5 +294,5 @@ void HoymilesRadio::dumpBuf(const char* info, uint8_t buf[], uint8_t len)
for (uint8_t i = 0; i < len; i++) {
Hoymiles.getMessageOutput()->printf("%02X ", buf[i]);
}
Hoymiles.getMessageOutput()->println(F(""));
Hoymiles.getMessageOutput()->println("");
}
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_1CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool HM_1CH::isValidSerial(uint64_t serial)

String HM_1CH::typeName()
{
return F("HM-300, HM-350, HM-400");
return "HM-300, HM-350, HM-400";
}

const std::list<byteAssign_t>* HM_1CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_2CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ bool HM_2CH::isValidSerial(uint64_t serial)

String HM_2CH::typeName()
{
return F("HM-600, HM-700, HM-800");
return "HM-600, HM-700, HM-800";
}

const std::list<byteAssign_t>* HM_2CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_4CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool HM_4CH::isValidSerial(uint64_t serial)

String HM_4CH::typeName()
{
return F("HM-1000, HM-1200, HM-1500");
return "HM-1000, HM-1200, HM-1500";
}

const std::list<byteAssign_t>* HM_4CH::getByteAssignment()
Expand Down
6 changes: 3 additions & 3 deletions lib/Hoymiles/src/inverters/InverterAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
{
// All missing
if (_rxFragmentLastPacketId == 0) {
Hoymiles.getMessageOutput()->println(F("All missing"));
Hoymiles.getMessageOutput()->println("All missing");
if (cmd->getSendCount() <= MAX_RESEND_COUNT) {
return FRAGMENT_ALL_MISSING_RESEND;
} else {
Expand All @@ -180,7 +180,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)

// Last fragment is missing (the one with 0x80)
if (_rxFragmentMaxPacketId == 0) {
Hoymiles.getMessageOutput()->println(F("Last missing"));
Hoymiles.getMessageOutput()->println("Last missing");
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
return _rxFragmentLastPacketId + 1;
} else {
Expand All @@ -192,7 +192,7 @@ uint8_t InverterAbstract::verifyAllFragments(CommandAbstract* cmd)
// Middle fragment is missing
for (uint8_t i = 0; i < _rxFragmentMaxPacketId - 1; i++) {
if (!_rxFragmentBuffer[i].wasReceived) {
Hoymiles.getMessageOutput()->println(F("Middle missing"));
Hoymiles.getMessageOutput()->println("Middle missing");
if (_rxFragmentRetransmitCnt++ < MAX_RETRANSMIT_COUNT) {
return i + 1;
} else {
Expand Down
Loading

0 comments on commit ca0b8e9

Please sign in to comment.