Skip to content

ucloud: Allow None sub-records in init values. #10

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

Merged
merged 1 commit into from
Sep 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions arduino_iot_cloud/ucloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ def _build_rec_dict(self, naming_map, appendTo):

def add_to_pack(self, pack, push=False):
# This function adds records that will be pushed to (or updated from) the cloud, to the SenML pack.
# NOTE: When adding records to be pushed to the cloud (push=True) Only initialized records are added
# to the pack. And when adding records to be updated from the cloud (push=False), records whose values
# are None are allowed to be added to the pack, so they can be initialized from the cloud.
# NOTE: When pushing records to the cloud (push==True) only fully initialized records are added to
# the pack. And when updating records from the cloud (push==False), partially initialized records
# are allowed in the pack, so they can be initialized from the cloud.
# NOTE: all initialized sub-records are added to the pack whether they changed their state since the
# last update or not, because the cloud currently does not support partial objects updates.
if isinstance(self.value, dict):
for r in self.value.values():
if r._value is not None or (r._value is None and not push):
if isinstance(self._value, dict):
if not push or self.initialized:
for r in self._value.values():
pack.add(r)
elif self._value is not None or (self._value is None and not push):
elif not push or self._value is not None:
pack.add(self)
self.updated = False

Expand Down