Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a04b1a

Browse files
feat(zigbee): Add stop/start methods
1 parent 04fdc7d commit 2a04b1a

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

‎docs/en/zigbee/zigbee_core.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ This function will return ``true`` if initialization successful, ``false`` other
5151
* Zigbee mode to ``Zigbee ED (end device)``.
5252
* Partition scheme to ``Zigbee xMB with spiffs`` (where ``x`` is the number of MB of selected flash size).
5353

54+
start
55+
^^^^^
56+
Starts the Zigbee stack again, if it was stopped by calling ``stop()``.
57+
58+
.. code-block:: arduino
59+
60+
void start();
61+
62+
63+
stop
64+
^^^^
65+
Stops the Zigbee stack. This can be used after calling ``begin()`` to stop the Zigbee stack.
66+
Usage example is to save power or when you need the radio to be available for other tasks.
67+
68+
.. code-block:: arduino
69+
70+
void stop();
71+
5472
Network Status
5573
**************
5674

‎libraries/Zigbee/src/ZigbeeCore.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,24 @@ void ZigbeeCore::setNVRAMChannelMask(uint32_t mask) {
765765
log_v("Channel mask set to 0x%08x", mask);
766766
}
767767

768+
void ZigbeeCore::stop() {
769+
if (started()) {
770+
vTaskSuspend(xTaskGetHandle("Zigbee_main"));
771+
log_v("Zigbee stack stopped");
772+
_started = false;
773+
}
774+
return;
775+
}
776+
777+
void ZigbeeCore::start() {
778+
if (!started()) {
779+
vTaskResume(xTaskGetHandle("Zigbee_main"));
780+
log_v("Zigbee stack started");
781+
_started = true;
782+
}
783+
return;
784+
}
785+
768786
// Function to convert enum value to string
769787
const char *ZigbeeCore::getDeviceTypeString(esp_zb_ha_standard_devices_t deviceId) {
770788
switch (deviceId) {

‎libraries/Zigbee/src/ZigbeeCore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class ZigbeeCore {
139139
bool begin(zigbee_role_t role = ZIGBEE_END_DEVICE, bool erase_nvs = false);
140140
bool begin(esp_zb_cfg_t *role_cfg, bool erase_nvs = false);
141141
// bool end();
142+
void stop();
143+
void start();
142144

143145
bool started() {
144146
return _started;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /