Skip to content
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

Mqtt Command Throttling #1056

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions vehicle/OVMS.V3/components/ovms_server_v3/src/ovms_server_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,13 @@ static void OvmsServerV3MongooseCallback(struct mg_connection *nc, int ev, void
msg->topic.p, (int) msg->payload.len, msg->payload.p);
if (MyOvmsServerV3)
{
MyOvmsServerV3->IncomingMsg(std::string(msg->topic.p,msg->topic.len),
std::string(msg->payload.p,msg->payload.len));
if (MyOvmsServerV3->m_accept_command == 0)
{
MyOvmsServerV3->m_accept_command = 2;
MyOvmsServerV3->IncomingMsg(
std::string(msg->topic.p,msg->topic.len),
std::string(msg->payload.p,msg->payload.len));
}
}
if (msg->qos == 1)
{
Expand Down Expand Up @@ -210,6 +215,7 @@ OvmsServerV3::OvmsServerV3(const char* name)
m_notify_data_waitcomp = 0;
m_notify_data_waittype = NULL;
m_notify_data_waitentry = NULL;
m_accept_command = 0;

ESP_LOGI(TAG, "OVMS Server v3 running");

Expand Down Expand Up @@ -877,6 +883,10 @@ void OvmsServerV3::NetmanStop(std::string event, void* data)

void OvmsServerV3::Ticker1(std::string event, void* data)
{
if (m_accept_command > 0)
{
m_accept_command--;
}
if (m_connretry > 0)
{
if (MyNetManager.m_connected_any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class OvmsServerV3 : public OvmsServer
OvmsMutex m_mgconn_mutex;
int m_connretry;
bool m_sendall;
int m_accept_command;
int m_msgid;
int m_lasttx;
int m_lasttx_sendall;
Expand Down