@@ -46,11 +46,12 @@ class subscribe_command : public ReadClient::Callback {
46
46
ScopedMemoryBufferWithSize<EventPathParams> &&event_paths, uint16_t min_interval,
47
47
uint16_t max_interval, bool auto_resubscribe = true , attribute_report_cb_t attribute_cb = nullptr ,
48
48
event_report_cb_t event_cb = nullptr , subscribe_done_cb_t done_cb = nullptr ,
49
- subscribe_failure_cb_t connect_failure_cb = nullptr )
49
+ subscribe_failure_cb_t connect_failure_cb = nullptr , bool keep_subscription = true )
50
50
: m_node_id(node_id)
51
51
, m_min_interval(min_interval)
52
52
, m_max_interval(max_interval)
53
53
, m_auto_resubscribe(auto_resubscribe)
54
+ , m_keep_subscription(keep_subscription)
54
55
, m_buffered_read_cb(*this )
55
56
, m_attr_paths(std::move(attr_paths))
56
57
, m_event_paths(std::move(event_paths))
@@ -71,11 +72,12 @@ class subscribe_command : public ReadClient::Callback {
71
72
subscribe_command_type_t command_type, uint16_t min_interval, uint16_t max_interval,
72
73
bool auto_resubscribe = true , attribute_report_cb_t attribute_cb = nullptr ,
73
74
event_report_cb_t event_cb = nullptr , subscribe_done_cb_t done_cb = nullptr ,
74
- subscribe_failure_cb_t connect_failure_cb = nullptr )
75
+ subscribe_failure_cb_t connect_failure_cb = nullptr , bool keep_subscription = true )
75
76
: m_node_id(node_id)
76
77
, m_min_interval(min_interval)
77
78
, m_max_interval(max_interval)
78
79
, m_auto_resubscribe(auto_resubscribe)
80
+ , m_keep_subscription(keep_subscription)
79
81
, m_buffered_read_cb(*this )
80
82
, on_device_connected_cb(on_device_connected_fcn, this )
81
83
, on_device_connection_failure_cb(on_device_connection_failure_fcn, this )
@@ -125,6 +127,7 @@ class subscribe_command : public ReadClient::Callback {
125
127
uint16_t m_min_interval;
126
128
uint16_t m_max_interval;
127
129
bool m_auto_resubscribe;
130
+ bool m_keep_subscription;
128
131
BufferedReadCallback m_buffered_read_cb;
129
132
uint32_t m_subscription_id = 0 ;
130
133
uint8_t m_resubscribe_retries = 0 ;
@@ -155,14 +158,16 @@ class subscribe_command : public ReadClient::Callback {
155
158
* @param[in] min_interval Minimum interval of the subscription
156
159
* @param[in] max_interval Maximum interval of the subscription
157
160
* @param[in] auto_resubscribe Auto re-subscribe flag
161
+ * @param[in] keep_subscription Keep subscription flag, terminate existing subscriptions if false
158
162
*
159
163
* @return ESP_OK on success.
160
164
* @return error in case of failure.
161
165
*/
162
166
esp_err_t send_subscribe_attr_command (uint64_t node_id, ScopedMemoryBufferWithSize<uint16_t > &endpoint_ids,
163
167
ScopedMemoryBufferWithSize<uint32_t > &cluster_ids,
164
168
ScopedMemoryBufferWithSize<uint32_t > &attribute_ids, uint16_t min_interval,
165
- uint16_t max_interval, bool auto_resubscribe = true );
169
+ uint16_t max_interval, bool auto_resubscribe = true ,
170
+ bool keep_subscription = true );
166
171
167
172
/* * Send subscribe command with multiple event paths
168
173
*
@@ -176,14 +181,16 @@ esp_err_t send_subscribe_attr_command(uint64_t node_id, ScopedMemoryBufferWithSi
176
181
* @param[in] min_interval Minimum interval of the subscription
177
182
* @param[in] max_interval Maximum interval of the subscription
178
183
* @param[in] auto_resubscribe Auto re-subscribe flag
184
+ * @param[in] keep_subscription Keep subscription flag, terminate existing subscriptions if false
179
185
*
180
186
* @return ESP_OK on success.
181
187
* @return error in case of failure.
182
188
*/
183
189
esp_err_t send_subscribe_event_command (uint64_t node_id, ScopedMemoryBufferWithSize<uint16_t > &endpoint_ids,
184
190
ScopedMemoryBufferWithSize<uint32_t > &cluster_ids,
185
191
ScopedMemoryBufferWithSize<uint32_t > &event_ids, uint16_t min_interval,
186
- uint16_t max_interval, bool auto_resubscribe = true );
192
+ uint16_t max_interval, bool auto_resubscribe = true ,
193
+ bool keep_subscription = true );
187
194
188
195
/* * Send subscribe command with single attribute path
189
196
*
@@ -197,13 +204,14 @@ esp_err_t send_subscribe_event_command(uint64_t node_id, ScopedMemoryBufferWithS
197
204
* @param[in] min_interval Minimum interval of the subscription
198
205
* @param[in] max_interval Maximum interval of the subscription
199
206
* @param[in] auto_resubscribe Auto re-subscribe flag
207
+ * @param[in] keep_subscription Keep subscription flag, terminate existing subscriptions if false
200
208
*
201
209
* @return ESP_OK on success.
202
210
* @return error in case of failure.
203
211
*/
204
212
esp_err_t send_subscribe_attr_command (uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id,
205
213
uint32_t attribute_id, uint16_t min_interval, uint16_t max_interval,
206
- bool auto_resubscribe = true );
214
+ bool auto_resubscribe = true , bool keep_subscription = true );
207
215
208
216
/* * Send subscribe command with single event path
209
217
*
@@ -217,12 +225,14 @@ esp_err_t send_subscribe_attr_command(uint64_t node_id, uint16_t endpoint_id, ui
217
225
* @param[in] min_interval Minimum interval of the subscription
218
226
* @param[in] max_interval Maximum interval of the subscription
219
227
* @param[in] auto_resubscribe Auto re-subscribe flag
228
+ * @param[in] keep_subscription Keep subscription flag, terminate existing subscriptions if false
220
229
*
221
230
* @return ESP_OK on success.
222
231
* @return error in case of failure.
223
232
*/
224
233
esp_err_t send_subscribe_event_command (uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t event_id,
225
- uint16_t min_interval, uint16_t max_interval, bool auto_resubscribe = true );
234
+ uint16_t min_interval, uint16_t max_interval, bool auto_resubscribe = true ,
235
+ bool keep_subscription = true );
226
236
227
237
/* * Shut down a subscription for given node id and subscription id
228
238
*
0 commit comments