Zigbee Protocol Controller 1.6.0
zigpc_gateway_request_queue.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * # License
3 * <b>Copyright 2021 Silicon Laboratories Inc. www.silabs.com</b>
4 ******************************************************************************
5 * The licensor of this software is Silicon Laboratories Inc. Your use of this
6 * software is governed by the terms of Silicon Labs Master Software License
7 * Agreement (MSLA) available at
8 * www.silabs.com/about-us/legal/master-software-license-agreement. This
9 * software is distributed to you in Source Code format and is governed by the
10 * sections of the MSLA applicable to Source Code.
11 *
12 *****************************************************************************/
13
65#ifndef ZIGPC_GATEWAY_CALL_HPP
66#define ZIGPC_GATEWAY_CALL_HPP
67
68#include <memory>
69#include <queue>
70#include <string>
71
72// ZigPC includes
73#include <zigpc_common_zigbee.h>
74
75/* ZigbeeHost includes */
76#include <zigbee_host.h>
77
79{
86{
87 public:
94 static const size_t DEFER_CYCLES_DEFAULT = 1U;
95
103 static const size_t DEFER_CYCLES_START_BACKOFF = 20U;
104
112 static const size_t DEFER_CYCLES_LOST_CONNECTION = 50U;
113
119 static const size_t DEFER_CYCLES_MESSAGE_LIMIT_REACHED = 10U;
120
125 class Entry
126 {
127 const char *label;
128 size_t send_attempts = 0U;
129 public:
130 explicit Entry(const char *label);
131 virtual ~Entry() = default;
132
138 const char *getLabel(void) const;
139
145 size_t getSendAttempts(void) const;
146
152
159 virtual sl_status_t invoke(void) = 0;
160 };
161
163 RequestQueue(RequestQueue &other) = delete;
164 void operator=(const RequestQueue &) = delete;
165
172
178
186
193 void enqueue(std::shared_ptr<Entry> call);
194
212
213 private:
214 std::queue<std::shared_ptr<Entry>> queue;
215 size_t defer_cycles = 0U;
217 bool dispatching_allowed = false;
220};
221
227{
228 public:
229 explicit NetworkInitRequest(void);
230 ~NetworkInitRequest() override = default;
231
232 sl_status_t invoke(void) override;
233};
234
240{
241 private:
244 public:
246 ~DiscoverDeviceRequest() override = default;
247
248 sl_status_t invoke(void) override;
249};
250
256{
257 private:
261 public:
264 ~DiscoverEndpointRequest() override = default;
265
266 sl_status_t invoke(void) override;
267};
268
274{
275 private:
278 public:
280 ~DeviceRemoveRequest() override = default;
281
282 sl_status_t invoke(void) override;
283};
284
290{
291 private:
299 public:
305 bool is_binding_req);
306 ~BindingRequestRequest() override = default;
307
308 sl_status_t invoke(void) override;
309};
310
316{
317 private:
323 public:
327 const uint8_t *report_record,
328 unsigned int record_size);
329 ~ZCLConfigureReportingRequest() override = default;
330
331 sl_status_t invoke(void) override;
332};
333
339{
340 private:
346 public:
350 const zcl_frame_t &frame);
351 ~ZCLFrameUnicastRequest() override = default;
352
353 sl_status_t invoke(void) override;
354};
355
361{
362 private:
367 public:
370 const zcl_frame_t &frame);
371 ~ZCLFrameMulticastRequest() override = default;
372
373 sl_status_t invoke(void) override;
374};
375
381{
382 private:
383 std::string filename;
385 public:
386 explicit AddOTAImageRequest(std::string &filename);
387 ~AddOTAImageRequest() override = default;
388
389 sl_status_t invoke(void) override;
390};
391
392} // namespace zigpc::gateway
393
394#endif // ZIGPC_GATEWAY_CALL_HPP
395
Call to track OTA image by the OTA server plugin.
Definition: zigpc_gateway_request_queue.hpp:381
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
~AddOTAImageRequest() override=default
std::string filename
Definition: zigpc_gateway_request_queue.hpp:383
AddOTAImageRequest(std::string &filename)
Call to send one-way bind request from device to the gateway.
Definition: zigpc_gateway_request_queue.hpp:290
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
zcl_cluster_id_t cluster_id
Definition: zigpc_gateway_request_queue.hpp:294
bool is_binding_req
Definition: zigpc_gateway_request_queue.hpp:297
BindingRequestRequest(const zigbee_eui64_t source_eui64, zigbee_endpoint_id_t source_endpoint_id, zcl_cluster_id_t cluster_id, const zigbee_eui64_t dest_eui64, zigbee_endpoint_id_t dest_endpoint_id, bool is_binding_req)
zigbee_endpoint_id_t dest_endpoint_id
Definition: zigpc_gateway_request_queue.hpp:296
~BindingRequestRequest() override=default
zigbee_eui64_t dest_eui64
Definition: zigpc_gateway_request_queue.hpp:295
zigbee_eui64_t source_eui64
Definition: zigpc_gateway_request_queue.hpp:292
zigbee_endpoint_id_t source_endpoint_id
Definition: zigpc_gateway_request_queue.hpp:293
Call to remove device on the network.
Definition: zigpc_gateway_request_queue.hpp:274
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
DeviceRemoveRequest(const zigbee_eui64_t eui64)
~DeviceRemoveRequest() override=default
zigbee_eui64_t eui64
Definition: zigpc_gateway_request_queue.hpp:276
Call to interview device on the network.
Definition: zigpc_gateway_request_queue.hpp:240
~DiscoverDeviceRequest() override=default
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
DiscoverDeviceRequest(const zigbee_eui64_t eui64)
zigbee_eui64_t eui64
Definition: zigpc_gateway_request_queue.hpp:242
Call to discover endpoint on the network.
Definition: zigpc_gateway_request_queue.hpp:256
DiscoverEndpointRequest(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id)
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
zigbee_eui64_t eui64
Definition: zigpc_gateway_request_queue.hpp:258
zigbee_endpoint_id_t endpoint_id
Definition: zigpc_gateway_request_queue.hpp:259
Call to initialize the network.
Definition: zigpc_gateway_request_queue.hpp:227
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
~NetworkInitRequest() override=default
Base class used in the RequestQueue to invoke ZigbeeHost API calls.
Definition: zigpc_gateway_request_queue.hpp:126
const char * getLabel(void) const
Get the Name of the call.
virtual sl_status_t invoke(void)=0
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
size_t getSendAttempts(void) const
Get the number of attempts made to send the message.
const char * label
Definition: zigpc_gateway_request_queue.hpp:127
size_t send_attempts
Definition: zigpc_gateway_request_queue.hpp:128
void incrementSendAttempt(void)
Increment send attempts.
The singleton ZigbeeHost Request Queue responsible for storing and dispatching calls.
Definition: zigpc_gateway_request_queue.hpp:86
bool dispatching_allowed
Definition: zigpc_gateway_request_queue.hpp:217
static const size_t DEFER_CYCLES_DEFAULT
Number of cycles to defer under normal circumstances. This is used to increase/decrease the number of...
Definition: zigpc_gateway_request_queue.hpp:94
static const size_t DEFER_CYCLES_START_BACKOFF
Number of cycles to defer when the queue is allowed to send requests either on init or post reset.
Definition: zigpc_gateway_request_queue.hpp:103
static const size_t DEFER_CYCLES_LOST_CONNECTION
Number of cycles to defer when a return status is indicative of a lost connection to the NCP.
Definition: zigpc_gateway_request_queue.hpp:112
void stopDispatching()
Prevent sending any ZigbeeHost requests due to the NCP being reset.
std::queue< std::shared_ptr< Entry > > queue
Definition: zigpc_gateway_request_queue.hpp:214
sl_status_t dispatch(void)
Dispatch a EmberAf/ZigbeeHost call from the queue.
void operator=(const RequestQueue &)=delete
void startDispatching(void)
Configure queue to allow sending ZigbeeHost requests.
size_t defer_cycles
Definition: zigpc_gateway_request_queue.hpp:215
RequestQueue(RequestQueue &other)=delete
static const size_t DEFER_CYCLES_MESSAGE_LIMIT_REACHED
Number of defer cycles when too many messages are in-flight on the network.
Definition: zigpc_gateway_request_queue.hpp:119
void enqueue(std::shared_ptr< Entry > call)
Store call data to the queue that is used to dispatch calls to EmberAf/ZigbeeHost API.
static RequestQueue & getInstance()
Retrieve singleton instance.
Call to send ZCL Configure Reporting message to device on the network.
Definition: zigpc_gateway_request_queue.hpp:316
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
zcl_frame_t frame
Definition: zigpc_gateway_request_queue.hpp:321
ZCLConfigureReportingRequest(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id, const uint8_t *report_record, unsigned int record_size)
zigbee_eui64_t eui64
Definition: zigpc_gateway_request_queue.hpp:318
zcl_cluster_id_t cluster_id
Definition: zigpc_gateway_request_queue.hpp:320
zigbee_endpoint_id_t endpoint_id
Definition: zigpc_gateway_request_queue.hpp:319
Call to send generic ZCL frame to a Zigbee Group on the network.
Definition: zigpc_gateway_request_queue.hpp:361
ZCLFrameMulticastRequest(zigbee_group_id_t group_id, zcl_cluster_id_t cluster_id, const zcl_frame_t &frame)
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
zigbee_group_id_t group_id
Definition: zigpc_gateway_request_queue.hpp:363
const zcl_frame_t frame
Definition: zigpc_gateway_request_queue.hpp:365
zcl_cluster_id_t cluster_id
Definition: zigpc_gateway_request_queue.hpp:364
Call to send generic ZCL frame to device on the network.
Definition: zigpc_gateway_request_queue.hpp:339
zigbee_endpoint_id_t endpoint_id
Definition: zigpc_gateway_request_queue.hpp:342
ZCLFrameUnicastRequest(const zigbee_eui64_t eui64, zigbee_endpoint_id_t endpoint_id, zcl_cluster_id_t cluster_id, const zcl_frame_t &frame)
zigbee_eui64_t eui64
Definition: zigpc_gateway_request_queue.hpp:341
~ZCLFrameUnicastRequest() override=default
const zcl_frame_t frame
Definition: zigpc_gateway_request_queue.hpp:344
zcl_cluster_id_t cluster_id
Definition: zigpc_gateway_request_queue.hpp:343
sl_status_t invoke(void) override
Invoke/execute the ZigbeeHost call using the infomation stored in the object.
uint8_t zigbee_eui64_t[ZIGBEE_EUI64_SIZE]
Zigbee Device EUI64 ID.
Definition: zigpc_common_zigbee.h:193
uint16_t zcl_cluster_id_t
A representation of the endpoint cluster id used in ZCL.
Definition: zigpc_common_zigbee.h:254
uint16_t zigbee_group_id_t
Zigbee Group Id The internal representation of a group_id.
Definition: zigpc_common_zigbee.h:230
uint8_t zigbee_endpoint_id_t
A representation of the endpoint id used on the Zigbee protocol.
Definition: zigpc_common_zigbee.h:248
Definition: zigpc_gateway_request_queue.hpp:79
Definition: zigpc_common_zigbee.h:293