-
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
Introduce a type-safe API for single-attribute subscriptions #12758
Introduce a type-safe API for single-attribute subscriptions #12758
Conversation
1160743
to
9c496a2
Compare
PR #12758: Size comparison from 4584707 to 9c496a2 Increases above 0.2%:
Increases (3 builds for esp32, linux, mbed)
Decreases (1 build for linux)
Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
9c496a2
to
8b5ee95
Compare
PR #12758: Size comparison from bba082b to 8b5ee95 Increases above 0.2%:
Increases (2 builds for esp32, linux)
Decreases (1 build for linux)
Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
/rebase |
8b5ee95
to
c480263
Compare
PR #12758: Size comparison from 6ea2c90 to c480263 Increases above 0.2%:
Increases (2 builds for esp32, linux)
Decreases (1 build for linux)
Full report (32 builds for efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
@msandstedt @saurabhst @jmartinez-silabs @jepenven-silabs @LuDuda @Damian-Nordic @chrisdecenzo Please take a look? |
fast track: change created and approved by domain owner, up sufficient time for all timezones to have a chance to review. |
* The ReadClient object MUST continue to exist after this call is completed. The application shall wait until it | ||
* receives an OnDone call before it shuts down the object. | ||
* The ReadClient object MUST continue to exist after this call is completed. The application shall not shut down the | ||
* object until after this call has returned, and shall not delete the object until OnDone is called. |
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 this actually true? Why can't I shut down this object at any time during the lifetime of this object, including before the subscription is established? I'd think that's actually possible, since that would terminate the open exchange and release this object back into the pool.
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.
More-over, ReadClient has still yet to be converted to being application-allocated, so deletion as a concept does not yet apply here.
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.
That's fair; I think I had lost track of these things being pool allocated (which we want to change) when I was changing the comments here...
I think calling Shutdown "not from inside one of the handlers" is always fine. Doing it from inside the handlers can get us into various corrupted states, though.....
CHIP_ERROR SubscribeAttribute(void * context, ClusterId clusterId, AttributeId attributeId, | ||
ReadResponseSuccessCallback<DecodableArgType> reportCb, ReadResponseFailureCallback failureCb, | ||
uint16_t minIntervalFloorSeconds, uint16_t maxIntervalCeilingSeconds, | ||
SubscriptionEstablishedCallback subscriptionEstablishedCb = nullptr) |
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.
How do you terminate a subscription after it's been established with such an API? If you were to repeatedly call this with new subscription requests, would that not leak ReadClient's to the point that subscriptions could not be further established?
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.
How do you terminate a subscription after it's been established with such an API?
You don't, just like the API it's a replacement for.
The best you can do is create a new subscription to the same server, which kills the first one on the server and then eventually that gets notified and the ReadClient shut down.
That said, we might in fact want to change this API to hand out the ReadClient so you can shut down the subscription. We want to get our ReadClient lifetime/handle story straight first, right?
Problem
Our subscription APIs are not very type-safe and can't represent all Matter types.
Change overview
Introduce an API that subscribes to a single attribute that can do both.
Testing
Modified chip-tool command line to use the new API and tested using that.