Skip to content

Commit 4288378

Browse files
p8952256dpi
authored andcommitted
add support for installing via idf component manager
1 parent 707a512 commit 4288378

File tree

3 files changed

+75
-44
lines changed

3 files changed

+75
-44
lines changed

CMakeLists.txt

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
11
# Uncompilable CMake File to enable project editing with CLion IDE
22

33
cmake_minimum_required(VERSION 3.13)
4-
project(arduino-mqtt)
5-
6-
include_directories(
7-
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino
8-
/Users/256dpi/Documents/Arduino/libraries/Ethernet/src
9-
/Users/256dpi/Documents/Arduino/libraries/WiFi101/src
10-
/Users/256dpi/Documents/Arduino/libraries/MKRGSM/src
11-
/Users/256dpi/Documents/Arduino/libraries/MKRNB/src
12-
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src
13-
/Users/256dpi/Library/Arduino15/packages/esp8266/hardware/esp8266/3.1.2/libraries/ESP8266WiFi/src
14-
/Users/256dpi/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/libraries/WiFi/src
15-
/Users/256dpi/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/libraries/WiFiClientSecure/src
16-
src)
17-
18-
include_directories(src/)
19-
20-
set(CMAKE_CXX_FLAGS -std=c++11)
21-
22-
set(SOURCE_FILES
23-
examples/AdafruitHuzzahESP8266/AdafruitHuzzahESP8266.ino
24-
examples/AdafruitHuzzahESP8266Secure/AdafruitHuzzahESP8266Secure.ino
25-
examples/ArduinoEthernetShield/ArduinoEthernetShield.ino
26-
examples/ArduinoMKRGSM1400/ArduinoMKRGSM1400.ino
27-
examples/ArduinoMKRGSM1400Secure/ArduinoMKRGSM1400Secure.ino
28-
examples/ArduinoMKRNB1500/ArduinoMKRNB1500.ino
29-
examples/ArduinoWiFi101/ArduinoWiFi101.ino
30-
examples/ArduinoWiFi101Secure/ArduinoWiFi101Secure.ino
31-
examples/ArduinoWiFiShield/ArduinoWiFiShield.ino
32-
examples/ArduinoYun/ArduinoYun.ino
33-
examples/ArduinoYunSecure/ArduinoYunSecure.ino
34-
examples/ESP32DevelopmentBoard/ESP32DevelopmentBoard.ino
35-
examples/ESP32DevelopmentBoardSecure/ESP32DevelopmentBoardSecure.ino
36-
src/lwmqtt
37-
src/MQTT.h
38-
src/MQTTClient.h
39-
src/MQTTClient.cpp)
40-
41-
add_executable(arduino-mqtt ${SOURCE_FILES})
4+
5+
if(COMMAND idf_component_register)
6+
file(GLOB SRCS "src/*.cpp" "src/lwmqtt/*.c")
7+
8+
idf_component_register(
9+
SRCS ${SRCS}
10+
INCLUDE_DIRS "src" "src/lwmqtt"
11+
)
12+
else()
13+
project(arduino-mqtt)
14+
15+
include_directories(
16+
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino
17+
/Users/256dpi/Documents/Arduino/libraries/Ethernet/src
18+
/Users/256dpi/Documents/Arduino/libraries/WiFi101/src
19+
/Users/256dpi/Documents/Arduino/libraries/MKRGSM/src
20+
/Users/256dpi/Documents/Arduino/libraries/MKRNB/src
21+
/Applications/Arduino.app/Contents/Java/libraries/Bridge/src
22+
/Users/256dpi/Library/Arduino15/packages/esp8266/hardware/esp8266/3.1.2/libraries/ESP8266WiFi/src
23+
/Users/256dpi/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/libraries/WiFi/src
24+
/Users/256dpi/Library/Arduino15/packages/esp32/hardware/esp32/2.0.11/libraries/WiFiClientSecure/src
25+
src)
26+
27+
include_directories(src/)
28+
29+
set(CMAKE_CXX_FLAGS -std=c++11)
30+
31+
set(SOURCE_FILES
32+
examples/AdafruitHuzzahESP8266/AdafruitHuzzahESP8266.ino
33+
examples/AdafruitHuzzahESP8266Secure/AdafruitHuzzahESP8266Secure.ino
34+
examples/ArduinoEthernetShield/ArduinoEthernetShield.ino
35+
examples/ArduinoMKRGSM1400/ArduinoMKRGSM1400.ino
36+
examples/ArduinoMKRGSM1400Secure/ArduinoMKRGSM1400Secure.ino
37+
examples/ArduinoMKRNB1500/ArduinoMKRNB1500.ino
38+
examples/ArduinoWiFi101/ArduinoWiFi101.ino
39+
examples/ArduinoWiFi101Secure/ArduinoWiFi101Secure.ino
40+
examples/ArduinoWiFiShield/ArduinoWiFiShield.ino
41+
examples/ArduinoYun/ArduinoYun.ino
42+
examples/ArduinoYunSecure/ArduinoYunSecure.ino
43+
examples/ESP32DevelopmentBoard/ESP32DevelopmentBoard.ino
44+
examples/ESP32DevelopmentBoardSecure/ESP32DevelopmentBoardSecure.ino
45+
src/lwmqtt
46+
src/MQTT.h
47+
src/MQTTClient.h
48+
src/MQTTClient.cpp)
49+
50+
add_executable(arduino-mqtt ${SOURCE_FILES})
51+
endif()

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,28 @@
55

66
This library bundles the [lwmqtt](https://github.com/256dpi/lwmqtt) MQTT 3.1.1 client and adds a thin wrapper to get an Arduino like API.
77

8-
Download the latest version from the [release](https://github.com/256dpi/arduino-mqtt/releases) section. Or even better use the built-in Library Manager in the Arduino IDE and search for "lwmqtt".
8+
Download the latest version from the [release](https://github.com/256dpi/arduino-mqtt/releases) section.
99

10-
The library is also available on [PlatformIO](https://platformio.org/lib/show/617/MQTT). You can install it by running: `pio lib install "256dpi/MQTT"`.
10+
Or it can be installed from the following library repositories:
11+
12+
- Arduino IDE's Library Manager
13+
- By searching for "lwmqtt".
14+
- [PlatformIO](https://platformio.org/lib/show/617/MQTT)
15+
- By running `pio lib install "256dpi/MQTT"`.
16+
- [IDF Component Manager](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/tools/idf-component-manager.html)
17+
- By adding it to `idf_component.yml`.
18+
```
19+
arduino_mqtt:
20+
git: "https://github.com/256dpi/arduino-mqtt.git"
21+
version: # tag, branch, or commit hash
22+
```
1123

1224
## Compatibility
1325

1426
The following examples show how you can use the library with various Arduino compatible hardware:
1527

1628
- [Arduino Yun & Yun-Shield](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoYun/ArduinoYun.ino) ([Secure](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoYunSecure/ArduinoYunSecure.ino))
17-
- [Arduino Ethernet Shield](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoEthernetShield/ArduinoEthernetShield.ino)
29+
- [Arduino Ethernet Shield](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoEthernetShield/ArduinoEthernetShield.ino)
1830
- [Arduino WiFi Shield](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoWiFiShield/ArduinoWiFiShield.ino)
1931
- [Adafruit HUZZAH ESP8266](https://github.com/256dpi/arduino-mqtt/blob/master/examples/AdafruitHuzzahESP8266/AdafruitHuzzahESP8266.ino) ([Secure](https://github.com/256dpi/arduino-mqtt/blob/master/examples/AdafruitHuzzahESP8266Secure/AdafruitHuzzahESP8266Secure.ino))
2032
- [Arduino WiFi101 Shield](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoWiFi101/ArduinoWiFi101.ino) ([Secure](https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoWiFi101Secure/ArduinoWiFi101Secure.ino))
@@ -32,7 +44,7 @@ Other shields and boards should also work if they provide a [Client](https://www
3244

3345
- On the ESP8266 it has been reported that an additional `delay(10);` after `client.loop();` fixes many stability issues with WiFi connections.
3446

35-
- To use the library with shiftr.io, you need to provide the instance name (username) and token secret (password) as the second and third argument to `client.connect(client_id, username, password)`.
47+
- To use the library with shiftr.io, you need to provide the instance name (username) and token secret (password) as the second and third argument to `client.connect(client_id, username, password)`.
3648

3749
## Example
3850

@@ -201,7 +213,7 @@ bool connect(const char clientID[], const char username[], const char password[]
201213
```
202214
203215
- If `password` is present but `username` is absent, the client will fall back to an empty username.
204-
- If the `skip` option is set to true, the client will skip the network level connection and jump to the MQTT level connection. This option can be used in order to establish and verify TLS connections manually before giving control to the MQTT client.
216+
- If the `skip` option is set to true, the client will skip the network level connection and jump to the MQTT level connection. This option can be used in order to establish and verify TLS connections manually before giving control to the MQTT client.
205217
- The functions return a boolean that indicates if the connection has been established successfully (true).
206218
207219
Publish a message to the broker with an optional payload, which can be a string or binary:
@@ -237,7 +249,7 @@ Subscribe to a topic:
237249
238250
```c++
239251
bool subscribe(const String &topic);
240-
bool subscribe(const String &topic, int qos);
252+
bool subscribe(const String &topic, int qos);
241253
bool subscribe(const char topic[]);
242254
bool subscribe(const char topic[], int qos);
243255
```

idf_component.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dependencies:
2+
espressif/arduino-esp32:
3+
version: "^3.0.6"
4+
files:
5+
include:
6+
- "src/*.cpp"
7+
- "src/*.h"
8+
- "src/lwmqtt/*.c"
9+
- "src/lwmqtt/*.h"

0 commit comments

Comments
 (0)