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 pubsubclient to v2.11.0 by thingsboard #683

Merged
merged 8 commits into from
Dec 9, 2024
6 changes: 3 additions & 3 deletions BSB_LAN/include/mqtt_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ bool mqtt_connect() {
mqtt_client= new ComClient();
MQTTPubSubClient = new PubSubClient(mqtt_client[0]);
MQTTPubSubClient->setBufferSize(2048);
MQTTPubSubClient->setKeepAlive(30);
MQTTPubSubClient->setSocketTimeout(120);
MQTTPubSubClient->setKeepAlive(90); // raise to higher value so broker does not disconnect on latency
mqtt_reconnect_timer = 0;
first_connect = true;
}
Expand Down Expand Up @@ -225,6 +224,7 @@ bool mqtt_connect() {
MQTTPubSubClient->setServer(mqtt_host, mqtt_port);
printFmtToDebug("Client ID: %s\r\n", mqtt_get_client_id());
printFmtToDebug("Will topic: %s\r\n", mqtt_get_will_topic());
MQTTPubSubClient->setSocketTimeout(MQTT_SOCKET_TIMEOUT); // reset to default
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reset is required if the connection is retried after disconnect!

MQTTPubSubClient->connect(mqtt_get_client_id(), MQTTUser, MQTTPass, mqtt_get_will_topic(), 1, true, "offline");
if (!MQTTPubSubClient->connected()) {
printlnToDebug("Failed to connect to MQTT broker, retrying...");
Expand All @@ -237,7 +237,7 @@ bool mqtt_connect() {
strcat(tempTopic, "/#");
MQTTPubSubClient->subscribe(tempTopic, 1); //Luposoft: set the topic listen to
printFmtToDebug("Subscribed to topic '%s'\r\n", tempTopic);
MQTTPubSubClient->setKeepAlive(120); //Luposoft: just for savety
MQTTPubSubClient->setSocketTimeout(120); // uschindler: set socket timeout to higher value after connection
MQTTPubSubClient->setCallback(mqtt_callback); //Luposoft: set to function is called when incoming message
MQTTPubSubClient->publish(mqtt_get_will_topic(), "online", true);
printFmtToDebug("Published status 'online' to topic '%s'\r\n", mqtt_get_will_topic());
Expand Down
2 changes: 2 additions & 0 deletions BSB_LAN/src/PubSubClient/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.9
* Add ability to use function for callback not just for ESP boards
2.8
* Add setBufferSize() to override MQTT_MAX_PACKET_SIZE
* Add setKeepAlive() to override MQTT_KEEPALIVE
Expand Down
8 changes: 8 additions & 0 deletions BSB_LAN/src/PubSubClient/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## ThingsBoard note

This is a fork of the main repository, which was last updated in 2020.
Since we have an SDK based on this client, we decided to continue with this repository.
We also believe that this library provides a lot of opportunities for people who want to build their own IoT devices.
As with our other open source repositories, we appreciate every contribution to this library.


# Arduino Client for MQTT

This library provides a client for doing simple publish/subscribe messaging with
Expand Down
11 changes: 6 additions & 5 deletions BSB_LAN/src/PubSubClient/library.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "PubSubClient",
"keywords": "ethernet, mqtt, m2m, iot",
"name": "TBPubSubClient",
"keywords": "ethernet, mqtt, m2m, iot, thingsboard, messages",
"description": "A client library for MQTT messaging. MQTT is a lightweight messaging protocol ideal for small devices. This library allows you to send and receive MQTT messages. It supports the latest MQTT 3.1.1 protocol and can be configured to use the older MQTT 3.1 if needed. It supports all Arduino Ethernet Client compatible hardware, including the Intel Galileo/Edison, ESP8266 and TI CC3000.",
"repository": {
"type": "git",
"url": "https://github.com/knolleary/pubsubclient.git"
"url": "https://github.com/thingsboard/pubsubclient.git"
},
"version": "2.8",
"version": "2.10.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason they forgot to update the version number in the JSON file of release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they already forgot this on last release 2.10.1. I don't know for what the JSON file is used.

"exclude": "tests",
"examples": "examples/*/*.ino",
"frameworks": "arduino",
"platforms": [
"atmelavr",
"espressif8266",
"espressif32"
"espressif32",
"rp2040"
]
}
8 changes: 4 additions & 4 deletions BSB_LAN/src/PubSubClient/library.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name=PubSubClient
version=2.8
author=Nick O'Leary <[email protected]>
maintainer=Nick O'Leary <[email protected]>
name=TBPubSubClient
version=2.10.0
author=ThingsBoard <[email protected]>
maintainer=ThingsBoard Team
sentence=A client library for MQTT messaging.
paragraph=MQTT is a lightweight messaging protocol ideal for small devices. This library allows you to send and receive MQTT messages. It supports the latest MQTT 3.1.1 protocol and can be configured to use the older MQTT 3.1 if needed. It supports all Arduino Ethernet Client compatible hardware, including the Intel Galileo/Edison, ESP8266 and TI CC3000.
category=Communication
Expand Down
Loading