-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Persist and reload message counters on the controller #7106
Persist and reload message counters on the controller #7106
Conversation
no need to base-64 the serialized values AGAINconnectedhomeip/src/controller/CHIPDevice.cpp Lines 517 to 524 in 6dce442
This comment was generated by todo based on a
|
6dce442
to
92ab9f0
Compare
The specification calls for only persisting the global message counters used for group messages. Session counters are only meant to persist for the life of a session, and sessions are to be reestablished from scratch if there is a sync issue or reboot. |
Size increase report for "nrfconnect-example-build" from 53e7847
Full report output
|
Size increase report for "esp32-example-build" from 53e7847
Full report output
|
Size increase report for "gn_qpg6100-example-build" from 53e7847
Full report output
|
SerializedDevice serialized; | ||
Serialize(serialized); | ||
|
||
// TODO: no need to base-64 the serialized values AGAIN |
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.
should we remove this comment? I do not see a base-64 serialization here. I realize it used to be in moved code ... guessing base64 was removed but comment was left. We can clean it up now.
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 think we are still base-64 encoding it twice right? Once because the device supports serializing to a SerializedDevice
and then again because the Darwin storage delegate converts everything to base-64
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.
it was non-obvious to me because 'inner' is not type-defined.
if it would be inner.base64 that would be understandable. However now it is inner and sizeof(inner) so everything sure looks binary to me.
Consider moving inside the serialize.inner reading/writing since this is were we say "this is binary, no need for base64".
@@ -494,6 +499,8 @@ typedef struct SerializableDevice | |||
uint8_t mDeviceTransport; | |||
uint8_t mDeviceProvisioningComplete; | |||
uint8_t mInterfaceName[kMaxInterfaceName]; | |||
uint32_t mLocalMessageCounter; /* This field is serialized in LittleEndian byte order */ |
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.
should these comments be part of the struct? I believe that this should be part of the serialize/deserialize methods like "serializes 16-bit and larger values as little endian".
) * Persist and reload message counters on the controller * Refactor CHIPDevice storage into an API on CHIPDevice * Rename PersistentStorageUtils -> PersistentStorageMacros * Fix the cluster tests * Fix ordering of initializers * Update comment to describe why counters are being stored * Moved comments around * Fix typo * Address review comments * remove unnecessary semicolon Co-authored-by: Boris Zbarsky <[email protected]>
Problem
The controller never persists message counters used for the PASE session but allows persisting the session in storage. This means that each time a connection is stored away and reused later, the counter values are lost.
Resuming these PASE sessions from storage causes the counters to go out of sync and messages get dropped.
I'm seeing this happen every time while trying to provision an M5Stack via the chip-tool cli
Change overview
Testing
How was this tested? (at least one bullet point required)