Skip to content

Commit

Permalink
Merge pull request #209 from dzungpv/master
Browse files Browse the repository at this point in the history
Fix issue #207
  • Loading branch information
SwiCago authored Dec 4, 2023
2 parents af059f5 + b28b8e6 commit 5d1e146
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/HeatPump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ bool operator!=(const heatpumpTimers& lhs, const heatpumpTimers& rhs) {
// Constructor /////////////////////////////////////////////////////////////////

HeatPump::HeatPump() {
rxPin = 0;
txPin = 0;
lastWanted = millis();
lastSend = 0;
infoMode = 0;
Expand Down Expand Up @@ -116,7 +118,14 @@ bool HeatPump::connect(HardwareSerial *serial, int bitrate, int rx, int tx) {
#endif
} else {
#if defined(ESP32)
_HardSerial->begin(bitrate, SERIAL_8E1, rxPin, txPin);
if (rxPin > 0 && rxPin > 0) // check if custom pin previous set
{
_HardSerial->begin(bitrate, SERIAL_8E1, rxPin, txPin);
}
else // fall back to default hardware pins
{
_HardSerial->begin(bitrate, SERIAL_8E1);
}
#else
_HardSerial->begin(bitrate, SERIAL_8E1);
#endif
Expand All @@ -139,8 +148,16 @@ bool HeatPump::connect(HardwareSerial *serial, int bitrate, int rx, int tx) {
writePacket(packet, CONNECT_LEN);
while(!canRead()) { delay(10); }
int packetType = readPacket();
if(packetType != RCVD_PKT_CONNECT_SUCCESS && retry){
return connect(serial, 9600, rxPin, txPin);
if (packetType != RCVD_PKT_CONNECT_SUCCESS && retry)
{
if (rxPin > 0 && rxPin > 0) // check if custom pin previous set
{
return connect(serial, 9600, rxPin, txPin);
}
else
{
return connect(serial, 9600, rx, tx);
}
}
connected = (packetType == RCVD_PKT_CONNECT_SUCCESS);
return connected;
Expand Down

0 comments on commit 5d1e146

Please sign in to comment.