Skip to content

Commit

Permalink
Catch situations where mqttClient::connect is called with an empty cl…
Browse files Browse the repository at this point in the history
…ientName.
  • Loading branch information
pljakobs authored Oct 28, 2024
1 parent 66a258b commit 0447ab4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sming/Components/Network/src/Network/Mqtt/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,16 @@ 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();
Expand Down

0 comments on commit 0447ab4

Please sign in to comment.