-
Notifications
You must be signed in to change notification settings - Fork 80
Thing id discovery protocol #297
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #297 +/- ##
=======================================
Coverage 94.87% 94.87%
=======================================
Files 27 27
Lines 1113 1113
=======================================
Hits 1056 1056
Misses 57 57 Continue to review full report at Codecov.
|
2efd398
to
ff1d6c6
Compare
ff1d6c6
to
58b2603
Compare
684b5b0
to
9305761
Compare
9305761
to
de65b3f
Compare
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.
This PR is quite hard for me to review due to lack of knowledge of the background info re thing id update, consequently the value of my advice is probably limited. Nonetheless, here are a couple of thoughts 🙇.
src/ArduinoIoTCloudTCP.cpp
Outdated
std::for_each(ota_property_list.cbegin(), | ||
ota_property_list.cend(), | ||
std::list<String> ota_property_list {"OTA_CAP", "OTA_ERROR", "OTA_SHA256"}; | ||
if (include_ota_req) |
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.
I'd suggest to either enclose the expression below within braces, i.e.
if (include_ota_req) {
ota_property_list.push_back("OTA_REQ");
}
or to leave one free line below the statement before and the statement after. Otherwise one get's all expressions clustered up and its not easy to see what belongs to the if statement and what not.
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.
src/ArduinoIoTCloudTCP.cpp
Outdated
@@ -69,6 +69,11 @@ extern "C" void updateTimezoneInfo() | |||
ArduinoCloud.updateInternalTimezoneInfo(); | |||
} | |||
|
|||
extern "C" void setThingIdOutdated() |
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.
Where is this function called? Why is there an extern "C"
declaration necessary? (Looks like it's passed to C code as a callback function).
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.
This function is used as callback function fot the update event of the _thing_id
property. Each time a new thing_id value is received this function is called to restart a new configuration process. It should not be necessary, i think i've copy pasted from
extern "C" void updateTimezoneInfo()
that i have again copy pasted from
extern "C" unsigned long getTime()
but i think it is safe to remove all three extern "C"
declarations
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.
Allright, but where is this function registered as a callback?
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.
Here db3e943 i think i've messed up a bit rebasing this firsts commits. I'll fix it keeping
addPropertyReal(_thing_id, _device_property_container, "thing_id", Permission::ReadWrite)
in the first and adding
onUpdate(setThingIdOutdated);
in the second one
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.
i've fixed the history and force pushed so now also the first commit builds correctly and the other are consistent.
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.
I've also added a new commit to remove the extern "C" declaration
see 0541f7b
src/ArduinoIoTCloudTCP.cpp
Outdated
/* Unsubscribe from old things topics and go oi with a new subsctiption */ | ||
_mqttClient.unsubscribe(_shadowTopicIn); | ||
_mqttClient.unsubscribe(_dataTopicIn); | ||
/* Unsubscribe from old things topics and go oi with a new subsctiption */ |
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.
Typo in comment, oi
-> on
(I guess).
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.
yes, it was already fixed here defe4dd i know it has nothig to do with delay macros... i will create a separate commit and squash it to the original one
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.
src/ArduinoIoTCloudTCP.cpp
Outdated
_time_service.setTimeZoneData(_tz_offset, _tz_dst_until); | ||
execCloudEventCallback(ArduinoIoTCloudEvent::SYNC); | ||
_last_sync_request_cnt = 0; | ||
_last_sync_request_tick = 0; | ||
_state = State::Connected; | ||
_next_state = State::Connected; |
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.
Is it really necessary to hold _next_state
as a private member variable and therefore make it part of the overall state of an ArduinoIoTCloudTCP
object? I'm sceptical of any additional member variable since each member variable equals at least two (bool) or many more possible states. Therefore many member variables equal exploding state space which makes it more easy to introduce new bugs and more hard to test all possible state transition paths.
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.
need to doublecheck, but i'm quite confident this commit can be dropped, because State::CheckDeviceConfig
logic as changed after this commit.
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.
i've dropped this commit since at the end of the whole work it wasn't necessary.
de65b3f
to
068ae20
Compare
i've found a stray debug print, in the first commit so i will force push again in a while |
068ae20
to
d436d33
Compare
dropping 912b068 and force-pushing again since setThingId() it is still needed for LORA device |
… to append OTA_REQ property
…other messages on device topic
…dle_Disconnect() function
…is not attached to a thing
…vice_topic for OTA properties
…DevicePropertiesToCloud(). Provide functions to clear OTA_REQ flag and update OTA_ERROR and OTA_URL.
…"Disconnected from Arduino IoT Cloud" on serial monitor
1fdd6ad
to
d373405
Compare
583ec5b
to
93d6fa8
Compare
Memory usage change @ 93d6fa8
Click for full report table
Click for full report CSV
|
The Goal of this PR is to remove the hardcoded thing_id from the sketch and improve OTA flow.
Properties spit:
Thing_id:
OTA flow:
f2d0bdf and 9305761 are here only for testing purpose and will be dropped before merging.
Thing ID configuration ✔️
Attach/Detach action
OTA ✔️
Deferred OTA ✔️