-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vrxiaojie
committed
Aug 17, 2024
0 parents
commit 20f05b9
Showing
255 changed files
with
532,937 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.pio | ||
.vscode/.browse.c_cpp.db* | ||
.vscode/c_cpp_properties.json | ||
.vscode/launch.json | ||
.vscode/ipch | ||
src/test.cpp | ||
main.cpp.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ef41392249af0ad41db08f55cc2ac0efbb77f04c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
tests/bin | ||
.pioenvs | ||
.piolibdeps | ||
.clang_complete | ||
.gcc-flags.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"type": "library", "name": "PubSubClient", "version": "2.8.0", "spec": {"owner": "knolleary", "id": 89, "name": "PubSubClient", "requirements": null, "uri": null}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sudo: false | ||
language: cpp | ||
compiler: | ||
- g++ | ||
script: cd tests && make && make test | ||
os: | ||
- linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
2.8 | ||
* Add setBufferSize() to override MQTT_MAX_PACKET_SIZE | ||
* Add setKeepAlive() to override MQTT_KEEPALIVE | ||
* Add setSocketTimeout() to overide MQTT_SOCKET_TIMEOUT | ||
* Added check to prevent subscribe/unsubscribe to empty topics | ||
* Declare wifi mode prior to connect in ESP example | ||
* Use `strnlen` to avoid overruns | ||
* Support pre-connected Client objects | ||
|
||
2.7 | ||
* Fix remaining-length handling to prevent buffer overrun | ||
* Add large-payload API - beginPublish/write/publish/endPublish | ||
* Add yield call to improve reliability on ESP | ||
* Add Clean Session flag to connect options | ||
* Add ESP32 support for functional callback signature | ||
* Various other fixes | ||
|
||
2.4 | ||
* Add MQTT_SOCKET_TIMEOUT to prevent it blocking indefinitely | ||
whilst waiting for inbound data | ||
* Fixed return code when publishing >256 bytes | ||
|
||
2.3 | ||
* Add publish(topic,payload,retained) function | ||
|
||
2.2 | ||
* Change code layout to match Arduino Library reqs | ||
|
||
2.1 | ||
* Add MAX_TRANSFER_SIZE def to chunk messages if needed | ||
* Reject topic/payloads that exceed MQTT_MAX_PACKET_SIZE | ||
|
||
2.0 | ||
* Add (and default to) MQTT 3.1.1 support | ||
* Fix PROGMEM handling for Intel Galileo/ESP8266 | ||
* Add overloaded constructors for convenience | ||
* Add chainable setters for server/callback/client/stream | ||
* Add state function to return connack return code | ||
|
||
1.9 | ||
* Do not split MQTT packets over multiple calls to _client->write() | ||
* API change: All constructors now require an instance of Client | ||
to be passed in. | ||
* Fixed example to match 1.8 api changes - dpslwk | ||
* Added username/password support - WilHall | ||
* Added publish_P - publishes messages from PROGMEM - jobytaffey | ||
|
||
1.8 | ||
* KeepAlive interval is configurable in PubSubClient.h | ||
* Maximum packet size is configurable in PubSubClient.h | ||
* API change: Return boolean rather than int from various functions | ||
* API change: Length parameter in message callback changed | ||
from int to unsigned int | ||
* Various internal tidy-ups around types | ||
1.7 | ||
* Improved keepalive handling | ||
* Updated to the Arduino-1.0 API | ||
1.6 | ||
* Added the ability to publish a retained message | ||
|
||
1.5 | ||
* Added default constructor | ||
* Fixed compile error when used with arduino-0021 or later | ||
|
||
1.4 | ||
* Fixed connection lost handling | ||
|
||
1.3 | ||
* Fixed packet reading bug in PubSubClient.readPacket | ||
|
||
1.2 | ||
* Fixed compile error when used with arduino-0016 or later | ||
|
||
|
||
1.1 | ||
* Reduced size of library | ||
* Added support for Will messages | ||
* Clarified licensing - see LICENSE.txt | ||
|
||
|
||
1.0 | ||
* Only Quality of Service (QOS) 0 messaging is supported | ||
* The maximum message size, including header, is 128 bytes | ||
* The keepalive interval is set to 30 seconds | ||
* No support for Will messages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2008-2020 Nicholas O'Leary | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Arduino Client for MQTT | ||
|
||
This library provides a client for doing simple publish/subscribe messaging with | ||
a server that supports MQTT. | ||
|
||
## Examples | ||
|
||
The library comes with a number of example sketches. See File > Examples > PubSubClient | ||
within the Arduino application. | ||
|
||
Full API documentation is available here: https://pubsubclient.knolleary.net | ||
|
||
## Limitations | ||
|
||
- It can only publish QoS 0 messages. It can subscribe at QoS 0 or QoS 1. | ||
- The maximum message size, including header, is **256 bytes** by default. This | ||
is configurable via `MQTT_MAX_PACKET_SIZE` in `PubSubClient.h` or can be changed | ||
by calling `PubSubClient::setBufferSize(size)`. | ||
- The keepalive interval is set to 15 seconds by default. This is configurable | ||
via `MQTT_KEEPALIVE` in `PubSubClient.h` or can be changed by calling | ||
`PubSubClient::setKeepAlive(keepAlive)`. | ||
- The client uses MQTT 3.1.1 by default. It can be changed to use MQTT 3.1 by | ||
changing value of `MQTT_VERSION` in `PubSubClient.h`. | ||
|
||
|
||
## Compatible Hardware | ||
|
||
The library uses the Arduino Ethernet Client api for interacting with the | ||
underlying network hardware. This means it Just Works with a growing number of | ||
boards and shields, including: | ||
|
||
- Arduino Ethernet | ||
- Arduino Ethernet Shield | ||
- Arduino YUN – use the included `YunClient` in place of `EthernetClient`, and | ||
be sure to do a `Bridge.begin()` first | ||
- Arduino WiFi Shield - if you want to send packets > 90 bytes with this shield, | ||
enable the `MQTT_MAX_TRANSFER_SIZE` define in `PubSubClient.h`. | ||
- Sparkfun WiFly Shield – [library](https://github.com/dpslwk/WiFly) | ||
- TI CC3000 WiFi - [library](https://github.com/sparkfun/SFE_CC3000_Library) | ||
- Intel Galileo/Edison | ||
- ESP8266 | ||
- ESP32 | ||
|
||
The library cannot currently be used with hardware based on the ENC28J60 chip – | ||
such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an | ||
[alternative library](https://github.com/njh/NanodeMQTT) available. | ||
|
||
## License | ||
|
||
This code is released under the MIT License. |
43 changes: 43 additions & 0 deletions
43
.pio/libdeps/esp32-s3-devkitc-1/PubSubClient/examples/mqtt_auth/mqtt_auth.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Basic MQTT example with Authentication | ||
- connects to an MQTT server, providing username | ||
and password | ||
- publishes "hello world" to the topic "outTopic" | ||
- subscribes to the topic "inTopic" | ||
*/ | ||
|
||
#include <SPI.h> | ||
#include <Ethernet.h> | ||
#include <PubSubClient.h> | ||
|
||
// Update these with values suitable for your network. | ||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; | ||
IPAddress ip(172, 16, 0, 100); | ||
IPAddress server(172, 16, 0, 2); | ||
|
||
void callback(char* topic, byte* payload, unsigned int length) { | ||
// handle message arrived | ||
} | ||
|
||
EthernetClient ethClient; | ||
PubSubClient client(server, 1883, callback, ethClient); | ||
|
||
void setup() | ||
{ | ||
Ethernet.begin(mac, ip); | ||
// Note - the default maximum packet size is 128 bytes. If the | ||
// combined length of clientId, username and password exceed this use the | ||
// following to increase the buffer size: | ||
// client.setBufferSize(255); | ||
|
||
if (client.connect("arduinoClient", "testuser", "testpass")) { | ||
client.publish("outTopic","hello world"); | ||
client.subscribe("inTopic"); | ||
} | ||
} | ||
|
||
void loop() | ||
{ | ||
client.loop(); | ||
} |
77 changes: 77 additions & 0 deletions
77
.pio/libdeps/esp32-s3-devkitc-1/PubSubClient/examples/mqtt_basic/mqtt_basic.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
Basic MQTT example | ||
This sketch demonstrates the basic capabilities of the library. | ||
It connects to an MQTT server then: | ||
- publishes "hello world" to the topic "outTopic" | ||
- subscribes to the topic "inTopic", printing out any messages | ||
it receives. NB - it assumes the received payloads are strings not binary | ||
It will reconnect to the server if the connection is lost using a blocking | ||
reconnect function. See the 'mqtt_reconnect_nonblocking' example for how to | ||
achieve the same result without blocking the main loop. | ||
*/ | ||
|
||
#include <SPI.h> | ||
#include <Ethernet.h> | ||
#include <PubSubClient.h> | ||
|
||
// Update these with values suitable for your network. | ||
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; | ||
IPAddress ip(172, 16, 0, 100); | ||
IPAddress server(172, 16, 0, 2); | ||
|
||
void callback(char* topic, byte* payload, unsigned int length) { | ||
Serial.print("Message arrived ["); | ||
Serial.print(topic); | ||
Serial.print("] "); | ||
for (int i=0;i<length;i++) { | ||
Serial.print((char)payload[i]); | ||
} | ||
Serial.println(); | ||
} | ||
|
||
EthernetClient ethClient; | ||
PubSubClient client(ethClient); | ||
|
||
void reconnect() { | ||
// Loop until we're reconnected | ||
while (!client.connected()) { | ||
Serial.print("Attempting MQTT connection..."); | ||
// Attempt to connect | ||
if (client.connect("arduinoClient")) { | ||
Serial.println("connected"); | ||
// Once connected, publish an announcement... | ||
client.publish("outTopic","hello world"); | ||
// ... and resubscribe | ||
client.subscribe("inTopic"); | ||
} else { | ||
Serial.print("failed, rc="); | ||
Serial.print(client.state()); | ||
Serial.println(" try again in 5 seconds"); | ||
// Wait 5 seconds before retrying | ||
delay(5000); | ||
} | ||
} | ||
} | ||
|
||
void setup() | ||
{ | ||
Serial.begin(57600); | ||
|
||
client.setServer(server, 1883); | ||
client.setCallback(callback); | ||
|
||
Ethernet.begin(mac, ip); | ||
// Allow the hardware to sort itself out | ||
delay(1500); | ||
} | ||
|
||
void loop() | ||
{ | ||
if (!client.connected()) { | ||
reconnect(); | ||
} | ||
client.loop(); | ||
} |
Oops, something went wrong.