Skip to content

Commit

Permalink
refactor(arch): Don't wait until the MQTT keep-alive timeout to send …
Browse files Browse the repository at this point in the history
…a ping
  • Loading branch information
jpfr committed Jul 31, 2024
1 parent 319b425 commit 664a250
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions arch/eventloop_mqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ findTopicConnection(MQTTConnectionManager *mcm, uintptr_t id) {
static void
MQTTKeepAliveCallback(void *app, MQTTBrokerConnection *bc) {
(void)app;
if(bc->lastSendTime + (bc->keepalive * UA_DATETIME_SEC) > UA_DateTime_nowMonotonic())
return;
mqtt_ping(&bc->client);
__mqtt_send(&bc->client);
}
Expand Down Expand Up @@ -654,7 +652,7 @@ createBrokerConnection(MQTTConnectionManager *mcm, const UA_KeyValueMap *params,

UA_EventLoop *el = mcm->cm.eventSource.eventLoop;
res = el->addCyclicCallback(el, (UA_Callback)MQTTKeepAliveCallback, NULL, bc,
(UA_Double)(bc->keepalive * UA_DATETIME_SEC),
(UA_Double)(bc->keepalive * 0.75 * UA_DATETIME_SEC),
NULL, UA_TIMER_HANDLE_CYCLEMISS_WITH_CURRENTTIME,
&bc->keepAliveCallbackId);
if(res != UA_STATUSCODE_GOOD) {
Expand Down

0 comments on commit 664a250

Please sign in to comment.