-
Notifications
You must be signed in to change notification settings - Fork 78
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
ArduinoCloudTCP: Separate the logic of the device and the logic of the thing in two different state machines #425
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #425 +/- ##
=======================================
Coverage 95.00% 95.00%
=======================================
Files 27 27
Lines 1221 1221
=======================================
Hits 1160 1160
Misses 61 61 ☔ View full report in Codecov by Sentry. |
Memory usage change @ e745256
Click for full report table
Click for full report CSV
|
8b8e483
to
5675efc
Compare
|
||
#ifndef ARDUINO_AIOTC_TYPES_H_ | ||
#define ARDUINO_AIOTC_TYPES_H_ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include <stdint.h> | |
TYPEDEF | ||
******************************************************************************/ | ||
|
||
typedef enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typedef enum | |
typedef enum: uint8_t |
We don't need and entire int32 to represent the R/W modes
Memory usage change @ 63ff024
Click for full report table
Click for full report CSV
|
This PR aims to separate the logic of the device (connect to the physical network, connect to MQTT, connect to device topics...) from the logic of the thing (receive the thing id, connect to the thing topics, sync and send telemetry) splitting the whole connection logic in two different state machines.
To achieve this, a new ArduinoIoTCloudTCPThing class has been created as member of the ArduinoIoTCloudTCP class.
The new class implement a state machine dedicated to the thing logic. The device logic has been kept in the ArduinoIoTCloudTCP.
From the user perspective, the only difference is that now the device state machine is not blocked anymore waiting the thing id when the thing id is not provided by the backend. The device state machine is independent from the thing configuration and, theoretically, is able to perform an OTA even if not attached to a thing (theoretically because the backend does not allow this).
From the developer perspective, this refactor allows a better logical separation of behaviours, improved readability and maintainability, and it's preparatory to future enhancements of the OTA feature.