-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom OT requests #138
base: master
Are you sure you want to change the base?
Conversation
Приветствую Думаю делать запрос в шину из |
@@ -9,6 +9,30 @@ class OpenThermTask : public Task { | |||
delete this->instance; | |||
} | |||
|
|||
struct ReadResult{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переименовать в ExternalRequest
@@ -9,6 +9,30 @@ class OpenThermTask : public Task { | |||
delete this->instance; | |||
} | |||
|
|||
struct ReadResult{ | |||
bool valid = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавить поле status:
OpenThermStatus status = OpenThermStatus::NOT_INITIALIZED;
uint16_t value = 0; | ||
}; | ||
|
||
ReadResult readRequest(byte messageId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вместо этого добавить метод sendExternalRequest(OpenThermMessageID id, unsigned int data)
, который будет заполнять структуру ExternalRequest. При вызове метода устанавливать статус OpenThermStatus::RESPONSE_WAITING
.
И было бы здорово иметь возможность отправлять данные, а не только читать значение по ID'у :)
Добавить метод bool hasReadyExternalRequest()
, который будет проверять статус.
Добавить метод unsigned long getResponseExternalRequest()
, который будет возвращать респонс из ExternalRequest
.
Внутри OpenThermTask::loop()
проверять статус ExternalRequest
, если он OpenThermStatus::RESPONSE_WAITING
, то делать this->instance->sendRequest(...)
и заполнять ExternalRequest
. Статус после выполнения запроса поменять на OpenThermStatus::RESPONSE_READY
.
doc.clear(); | ||
doc.shrinkToFit(); | ||
|
||
auto result = tOt->readRequest(messageId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вместо этого вызывать tOt->sendExternalRequest(...)
doc[FPSTR(S_VALUE)] = result.value; | ||
doc.shrinkToFit(); | ||
|
||
this->bufferedWebServer->send(200, F("application/json"), doc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Просто вернуть пустой ответ с кодом 200
doc.shrinkToFit(); | ||
|
||
this->bufferedWebServer->send(200, F("application/json"), doc); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавить обработчик для чтения данных через tOt->getResponseExternalRequest()
если tOt->hasReadyExternalRequest() == true
и вывод клиенту json с данными
@@ -522,6 +522,107 @@ const setupUpgradeForm = (formSelector) => { | |||
}); | |||
} | |||
|
|||
const setupOTReadForm = (formSelector) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше переместить в opentherm_request.html
Код поправить:
- Сначала отправить запрос на отправку запроса
- Проверять каждые 2-5 сек наличие ответа, после получения ответа разблокировать кнопку отправки и сбросить таймер/интервал
See https://t.me/otgateway/9331/10060
This will be useful to quickly detect which messages the boiler supports.
WRT the safety of calling
sendRequest
from another task. As far as I can see,OpenTherm
is essentially a state machine and won't attempt to put anything on the wire until inREADY
state. Given that the request from the web form uses the same object (and thus state) there should not be any concurrency concerns.Screencast:
OTGateway-custom-message-demo.mov