Skip to content

Commit 8d2f15b

Browse files
ubidefeoaentinger
authored andcommitted
Remove connection handling and debug messages because those tasks are now handled by 'Arduino_ConnectionHandler' and 'Arduino_DebugUtils'
1 parent a0f54fe commit 8d2f15b

22 files changed

+60
-1057
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.elf
33
*~
44
.vscode
5+
*.orig

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ before_install:
7373
- installLibrary arduino-libraries/WiFi101
7474
- installLibrary arduino-libraries/WiFiNINA
7575
- installLibrary arduino-libraries/Ethernet
76+
- installLibrary arduino-libraries/Arduino_ConnectionHandler
77+
- installLibrary arduino-libraries/Arduino_DebugUtils
7678
- buildExampleSketch() { arduino-cli compile --warnings all --fqbn $BOARD $PWD/examples/$1; }
7779
- buildExampleUtilitySketch() { arduino-cli compile --warnings all --fqbn $BOARD $PWD/examples/utility/$1; }
7880
install:

README.md

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,12 @@ The introductory tutorial linked above explains this in an easy and comprehensiv
2525

2626
## ArduinoIoTCloud library
2727

28-
The library is made of multiple classes:
28+
As of version 0.8.0 the `ConnectionManager` libraries have been migrated into their own packages, so are the debug helpers, hence the library is made of just these classes:
2929
- `ArduinoIoTCloud` is the main class. It's responsible for the connection to the MQTT Broker and to Arduino IoT Cloud.
3030
This library has multiple `begin(...)` methods allowing you to take more control of its behavior when it comes to network **Client** or to use a `ConnectionManager`
3131

32-
- `ConnectionManager` is an abstract Class defining methods to be implemented in derived classes, such as `WiFiConnectionManager`, `GSMConnectionManager` and so on. The right `ConnectionManager` is chosen on a board basis during compilation.
33-
34-
- `WiFiConnectionManager` handles connection, network time retrieval, disconnection, and reconnection to Internet for WiFi equipped boards (**MKR1000**, **MKR WIFI 1010** and upcoming implementations).
35-
36-
- `GSMConnectionManager` handles connection, network time retrieval, disconnection, and reconnection to Internet for GSM equipped boards (**MKR GSM 1400**)
37-
38-
3932
- `CloudSerial` is similar to [Serial](https://www.arduino.cc/reference/en/language/functions/communication/serial/), but used in combination with the cloud, allowing the user to send and receive custom messages using Arduino IoT Cloud as a channel.
4033

41-
42-
### ConnectionManager
43-
44-
**Connection Manager** is configured via a series of compiler directives, including the correct implementation of the class based on which board is selected.
45-
46-
### How to use it
47-
- Instantiate the class with `ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);` if you are using a WiFi board, otherwise replace **WiFi** with **GSM** or any future implementation.
48-
49-
- The `check()` method does all the work. It uses a finite state machine and is responsible for connection and reconnection to a network. The method is designed to be non-blocking by using time (milliseconds) to perform its tasks.
50-
51-
- `getTime()` returns different implementations of the `getTIme()` method based on the board used. Time is retrieved from an NTP server and is required for the SSL connection to the cloud.
52-
53-
- `&getClient()` returns a reference an instance of the `Client` class used to connect to the network.
54-
55-
- `getStatus()` returns the network connection status. The different states are defined in an `enum`
56-
5734
- `debugMessage(char *_msg, uint8_t _debugLevel, bool _timestamp = true, bool _newline = true)` is the method used to print debug messages on the physical serial. This helps providing troubleshooting information should anything go wrong.
5835

5936
- The `setDebugMessageLevel(int _debugLevel)` method is used to set a level of granularity in information output. Every debug message comes with a level which goes from 0 to 4. A higher level means more verbosity. Debug messages with level higher than `_debugLevel` will not be shown. The lowest level has a higher importance and is usually used for errors, which are always printed. Passing -1 as a parameter will disable logging entirely, **errors will also be ignored**.
@@ -68,7 +45,7 @@ This library has multiple `begin(...)` methods allowing you to take more control
6845

6946
- `disconnect()` closes the connection to the MQTT Client.
7047

71-
- The `update()` method can be called periodically in the loop of the `.ino` file. If a `ConnectionManager` is implemented it checks network connections. It also makes sure that a connection with the MQTT broker is active and tries to reconnect otherwise. During `update()` data from the Cloud is retrieved and changed values are posted to the proper MQTT topic.
48+
- The `update()` method can be called periodically in the loop of the `.ino` file. If a `ConnectionHandler` is implemented it checks network connections. It also makes sure that a connection with the MQTT broker is active and tries to reconnect otherwise. During `update()` data from the Cloud is retrieved and changed values are posted to the proper MQTT topic.
7249

7350
- `connected()` simply returns the current status of the MQTT connection.
7451

@@ -78,4 +55,7 @@ This library has multiple `begin(...)` methods allowing you to take more control
7855

7956
- `getThingId()` returns the **THING_ID**.
8057

81-
- `connectionCheck()` invokes the `check()` method from a **ConnectionManager** if it is implemented. Mainly it implements a state machine and is responsible for the connection to Arduino IoT Cloud.
58+
- `connectionCheck()` invokes the `check()` method from a **ConnectionHandler** if it is implemented. Mainly it implements a state machine and is responsible for the connection to Arduino IoT Cloud.
59+
60+
- `getIoTStatus()` returns the Cloud connection status. The different states are defined in an `enum`
61+

examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <ConnectionManager.h>
1+
#include <Arduino_ConnectionHandler.h>
22

33
/* MKR1000, MKR WiFi 1010 */
44
#if defined(BOARD_HAS_WIFI)

examples/ArduinoIoTCloud_LED_switch/thingProperties.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#include <ArduinoIoTCloud.h>
2-
#include <ConnectionManager.h>
2+
#include <Arduino_ConnectionHandler.h>
33

44
#if defined(BOARD_HAS_WIFI)
5-
#include <WiFiConnectionManager.h>
65
#elif defined(BOARD_HAS_GSM)
7-
#include <GSMConnectionManager.h>
86
#else
97
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
108
#endif
@@ -25,9 +23,7 @@ void initProperties() {
2523
}
2624

2725
#if defined(BOARD_HAS_WIFI)
28-
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
26+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
2927
#elif defined(BOARD_HAS_GSM)
30-
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
28+
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
3129
#endif
32-
33-

examples/ArduinoIoTCloud_Travis_CI/arduino_secrets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include <ConnectionManager.h>
1+
#include <Arduino_ConnectionHandler.h>
22

33
/* MKR1000, MKR WiFi 1010 */
44
#if defined(BOARD_HAS_WIFI)

examples/ArduinoIoTCloud_Travis_CI/thingProperties.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
******************************************************************************/
44

55
#include <ArduinoIoTCloud.h>
6-
#include <ConnectionManager.h>
6+
#include <Arduino_ConnectionHandler.h>
77

88
#if defined(BOARD_HAS_WIFI)
9-
#include <WiFiConnectionManager.h>
109
#elif defined(BOARD_HAS_GSM)
11-
#include <GSMConnectionManager.h>
1210
#else
1311
#error "Arduino IoT Cloud currently only supports MKR1000, MKR WiFi 1010 and MKR GSM 1400"
1412
#endif
@@ -54,10 +52,11 @@ String str_property_6;
5452
String str_property_7;
5553
String str_property_8;
5654

55+
5756
#if defined(BOARD_HAS_WIFI)
58-
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
57+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_SSID, SECRET_PASS);
5958
#elif defined(BOARD_HAS_GSM)
60-
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
59+
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_LOGIN, SECRET_PASS);
6160
#endif
6261

6362
/******************************************************************************

examples/GSM_Cloud_Blink/GSM_Cloud_Blink.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
*/
88

99
#include <ArduinoIoTCloud.h>
10-
#include <ConnectionManager.h>
11-
#include <GSMConnectionManager.h>
10+
#include <Arduino_ConnectionHandler.h>
1211

1312
#include "arduino_secrets.h"
1413

1514
String cloudSerialBuffer = ""; // the string used to compose network messages from the received characters
1615
// handles connection to the network
17-
ConnectionManager * ArduinoIoTPreferredConnection = new GSMConnectionManager(SECRET_PIN, SECRET_APN, SECRET_USER_NAME, SECRET_PASSWORD);
16+
GSMConnectionHandler ArduinoIoTPreferredConnection(SECRET_PIN, SECRET_APN, SECRET_USER_NAME, SECRET_PASSWORD);
1817

1918
void setup() {
2019
setDebugMessageLevel(3); // used to set a level of granularity in information output [0...4]

examples/MultiValue_example/thingProperties.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <ArduinoIoTCloud.h>
2-
#include <WiFiConnectionManager.h>
2+
#include <Arduino_ConnectionHandler.h>
33

44
// Set the Thing Id value
55
const char THING_ID[] = "";
@@ -21,4 +21,4 @@ void initProperties() {
2121
ArduinoCloud.addProperty(color, READWRITE, ON_CHANGE, onColorChange);
2222
}
2323

24-
ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SSID, PASS);
24+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

examples/WiFi_Cloud_Blink/WiFi_Cloud_Blink.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
*/
99

1010
#include <ArduinoIoTCloud.h>
11-
#include <ConnectionManager.h>
12-
#include <WiFiConnectionManager.h>
11+
#include <Arduino_ConnectionHandler.h>
1312

1413
#include "arduino_secrets.h"
1514

1615
String cloudSerialBuffer = ""; // the string used to compose network messages from the received characters
1716
// handles connection to the network
18-
ConnectionManager * ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
17+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SECRET_WIFI_NAME, SECRET_PASSWORD);
1918

2019
void setup() {
2120
setDebugMessageLevel(3); // used to set a level of granularity in information output [0...4]

0 commit comments

Comments
 (0)