refactor: improved OT bus reset

This commit is contained in:
Yurii
2025-01-13 10:56:19 +03:00
parent 3ff8f40654
commit e7cae4b950
2 changed files with 39 additions and 30 deletions

View File

@@ -7,9 +7,7 @@ public:
typedef std::function<void(unsigned long, byte)> BeforeSendRequestCallback;
typedef std::function<void(unsigned long, unsigned long, OpenThermResponseStatus, byte)> AfterSendRequestCallback;
CustomOpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false) : OpenTherm(inPin, outPin, isSlave) {
this->_outPin = outPin;
}
CustomOpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false) : OpenTherm(inPin, outPin, isSlave) {}
~CustomOpenTherm() {}
CustomOpenTherm* setDelayCallback(DelayCallback callback = nullptr) {
@@ -30,22 +28,6 @@ public:
return this;
}
void reset() {
if (this->status == OpenThermStatus::NOT_INITIALIZED) {
return;
}
this->end();
this->status = OpenThermStatus::NOT_INITIALIZED;
digitalWrite(this->_outPin, LOW);
if (this->delayCallback) {
this->delayCallback(1000);
}
this->begin();
}
unsigned long sendRequest(unsigned long request, byte attempts = 5, byte _attempt = 0) {
_attempt++;
@@ -166,5 +148,4 @@ protected:
DelayCallback delayCallback;
BeforeSendRequestCallback beforeSendRequestCallback;
AfterSendRequestCallback afterSendRequestCallback;
int _outPin;
};