Skip to content

Commit

Permalink
Send remove inverter registration after communication timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan ten Hove committed Jun 14, 2017
1 parent d7df06b commit 95f0e0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions GoodWeCommunicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ void GoodWeCommunicator::checkOfflineInverters()
{
//check inverter timeout
for (char index = 0; index < inverters.size(); ++index)
{
inverters[index].isOnline = (millis() - inverters[index].lastSeen < OFFLINE_TIMEOUT);
sendRemoveRegistration(inverters[index].address); //send in case the inverter thinks we are online
}

}

void GoodWeCommunicator::checkIncomingData()
Expand Down Expand Up @@ -201,6 +205,8 @@ void GoodWeCommunicator::parseIncomingData(char incomingDataLength) //
if (debugMode)
Serial.println("CRC match.");



//check the contorl code and function code to see what to do
if (inputBuffer[2] == 0x00 && inputBuffer[3] == 0x80)
handleRegistration(inputBuffer + 5, 16);
Expand Down Expand Up @@ -253,7 +259,7 @@ void GoodWeCommunicator::handleRegistrationConfirmation(char address)
if (debugMode)
{
Serial.print("Handling registration information for address: ");
Serial.println(address);
Serial.println((short)address);
}
//lookup the inverter and set it to confirmed
auto inverter = getInverterInfoByAddress(address);
Expand Down Expand Up @@ -345,7 +351,7 @@ void GoodWeCommunicator::sendAllocateRegisterAddress(char * serialNumber, char a
if (debugMode)
{
Serial.print("SendAllocateRegisterAddress address: ");
Serial.println(address);
Serial.println((short)address);
}

//create our registrationpacket with serialnumber and address and send it over
Expand Down Expand Up @@ -382,6 +388,7 @@ void GoodWeCommunicator::handle()
askAllInvertersForInformation();
lastInfoUpdateSent = millis();
}
checkIncomingData();

}

Expand Down

0 comments on commit 95f0e0d

Please sign in to comment.