Skip to content

Improve 'subscribe_command` callbacks (CON-1960)#1690

Open
tomasmcguinness wants to merge 2 commits intoespressif:mainfrom
tomasmcguinness:main
Open

Improve 'subscribe_command` callbacks (CON-1960)#1690
tomasmcguinness wants to merge 2 commits intoespressif:mainfrom
tomasmcguinness:main

Conversation

@tomasmcguinness
Copy link
Contributor

@tomasmcguinness tomasmcguinness commented Feb 3, 2026

Description

This PR makes two main changes to the subscribe_command

First, a new subscription_established_cb_t has been added along with a new parameter established_cb.
Second, the existing subscribe_done_cb_t has been renamed to subscription_terminated_cb to better reflect what it means.

The new established_cb allows a controller to know when the subscribe_command has been sent and processed.

Renaming done_cb -> terminated_cb makes the callback's use much clearer. Done usually means success, but in this case it refers to subscriptions being terminated.

The existing constructors remain so no breaking changes should be introduced.

Testing

I have tested this in my controller:

 subscribe_command *cmd = chip::Platform::New<subscribe_command>(node->node_id,
                                                                            std::move(attr_paths),
                                                                            std::move(event_paths),
                                                                            min_interval,
                                                                            max_interval,
                                                                            false,
                                                                            attribute_data_cb,
                                                                            nullptr,
                                                                            node_subscription_established_cb,
                                                                            node_subscription_terminated_cb,
                                                                            node_subscribe_failed_cb,
                                                                            false);

Session establishment is reported

I (214853) chip[DMG]: SubscribeResponse is received
I (214853) chip[DMG]: Subscription established in 1508ms with SubscriptionID = 0x029ec2e9 MinInterval = 0s MaxInterval = 300s Peer = 01:00000000000003E9
I (214853) read_command: Subscription 0x29ec2e9 established
I (214853) app_main: Successfully subscribed, node 1001, subscription id 0x029EC2E9
I (214853) chip[DMG]: Refresh LivenessCheckTime for 344277 milliseconds with SubscriptionId = 0x029ec2e9 Peer = 01:00000000000003E9

Termination is reported

E (559133) chip[DMG]: Subscription Liveness timeout with SubscriptionID = 0x029ec2e9, Peer = 01:00000000000003E9
I (559143) chip[SC]: SecureSession[0x3fce9d4c, LSID:46647]: State change 'kActive' --> 'kDefunct'
E (559143) read_command: Subscribe Error: Error CHIP:0x00000032
I (559143) read_command: Subscription 0x29ec2e9 Done for remote node 0x3e9
I (559143) app_main: Subscription terminated, node 1001, subscription id 0x029EC2E9

Failure to subscribe is reported:

E (512513) chip[EM]: <<5 [E:39943i S:0 M:152332148] (U) Msg Retransmission to 0:0000000000000000 failure (max retries:4)
E (522283) chip[SC]: CASESession timed out while waiting for a response from peer <00000000000003E8, 1>. Current state was 1
E (522283) app_main: Failed to subscribe (context: 0x3fcf1be4)

Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

@github-actions github-actions bot changed the title Improve 'subscribe_command` callbacks Improve 'subscribe_command` callbacks (CON-1960) Feb 3, 2026
@tomasmcguinness tomasmcguinness marked this pull request as ready for review February 3, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments