Conversation
|
Приветствую Думаю делать запрос в шину из |
| delete this->instance; | ||
| } | ||
|
|
||
| struct ReadResult{ |
| } | ||
|
|
||
| struct ReadResult{ | ||
| bool valid = false; |
There was a problem hiding this comment.
Добавить поле status:
OpenThermStatus status = OpenThermStatus::NOT_INITIALIZED;
| uint16_t value = 0; | ||
| }; | ||
|
|
||
| ReadResult readRequest(byte messageId) { |
There was a problem hiding this comment.
Вместо этого добавить метод 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.
Вместо этого вызывать 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.
Просто вернуть пустой ответ с кодом 200
| doc.shrinkToFit(); | ||
|
|
||
| this->bufferedWebServer->send(200, F("application/json"), doc); | ||
| }); |
There was a problem hiding this comment.
Добавить обработчик для чтения данных через tOt->getResponseExternalRequest() если tOt->hasReadyExternalRequest() == true и вывод клиенту json с данными
| }); | ||
| } | ||
|
|
||
| const setupOTReadForm = (formSelector) => { |
There was a problem hiding this comment.
Лучше переместить в 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
sendRequestfrom another task. As far as I can see,OpenThermis essentially a state machine and won't attempt to put anything on the wire until inREADYstate. 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