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

update mqttClient to catch empty clientNames #2897

Closed
wants to merge 4 commits into from
Closed
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
6 changes: 6 additions & 0 deletions Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,18 @@ bool MqttClient::setWill(const String& topic, const String& message, uint8_t fla
bool MqttClient::connect(const Url& url, const String& clientName)
{
this->url = url;

bool useSsl{url.Scheme == URI_SCHEME_MQTT_SECURE};
if(!useSsl && url.Scheme != URI_SCHEME_MQTT) {
debug_e("Only mqtt and mqtts protocols are allowed");
return false;
}

if(clientName==""){
debug_e("clientName cannot be empty");
return false;
}

if(getConnectionState() != eTCS_Ready) {
close();
debug_d("MQTT closed previous connection");
Expand Down
Loading