Skip to content

Commit adac4c2

Browse files
authored
Merge pull request #11791 from espressif/feat/zigbee-start-stop
feat(zigbee): Add stop/start methods + add missing license headers
2 parents 44aba4f + 70ff6a3 commit adac4c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+836
-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/Zigbee.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
// Zigbee library header file for includes of all Zigbee library headers.
216

317
#pragma once

libraries/Zigbee/src/ZigbeeCore.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Zigbee Core Functions */
216

317
#include "ZigbeeCore.h"
@@ -756,6 +770,24 @@ void ZigbeeCore::setNVRAMChannelMask(uint32_t mask) {
756770
log_v("Channel mask set to 0x%08x", mask);
757771
}
758772

773+
void ZigbeeCore::stop() {
774+
if (started()) {
775+
vTaskSuspend(xTaskGetHandle("Zigbee_main"));
776+
log_v("Zigbee stack stopped");
777+
_started = false;
778+
}
779+
return;
780+
}
781+
782+
void ZigbeeCore::start() {
783+
if (!started()) {
784+
vTaskResume(xTaskGetHandle("Zigbee_main"));
785+
log_v("Zigbee stack started");
786+
_started = true;
787+
}
788+
return;
789+
}
790+
759791
// Function to convert enum value to string
760792
const char *ZigbeeCore::getDeviceTypeString(esp_zb_ha_standard_devices_t deviceId) {
761793
switch (deviceId) {

libraries/Zigbee/src/ZigbeeCore.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Zigbee core class */
216

317
#pragma once
@@ -124,6 +138,8 @@ class ZigbeeCore {
124138
bool begin(zigbee_role_t role = ZIGBEE_END_DEVICE, bool erase_nvs = false);
125139
bool begin(esp_zb_cfg_t *role_cfg, bool erase_nvs = false);
126140
// bool end();
141+
void stop();
142+
void start();
127143

128144
bool started() {
129145
return _started;

libraries/Zigbee/src/ZigbeeEP.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Common Class for Zigbee End Point */
216

317
#include "ZigbeeEP.h"

libraries/Zigbee/src/ZigbeeEP.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Common Class for Zigbee End point */
216

317
#pragma once

libraries/Zigbee/src/ZigbeeHandlers.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Zigbee Common Functions */
216
#include "ZigbeeCore.h"
317
#include "Arduino.h"

libraries/Zigbee/src/ZigbeeTypes.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#pragma once
216

317
#include "esp_zigbee_core.h"

libraries/Zigbee/src/ep/ZigbeeAnalog.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#include "ZigbeeAnalog.h"
216
#if CONFIG_ZB_ENABLED
317
#include <cfloat>

libraries/Zigbee/src/ep/ZigbeeAnalog.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2025 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
/* Class of Zigbee Analog sensor endpoint inherited from common EP class */
216

317
#pragma once

0 commit comments

Comments
 (0)