Zigbee example: add rcp and gateway
* provide Zigbee rcp and Zigbee gateway example * minor comment fix for light example
This commit is contained in:
@@ -16,9 +16,6 @@ This test code shows how to configure Zigbee end device and use it as a light sw
|
||||
|
||||
## Configure the project
|
||||
|
||||
[**Mandatory**] Download esp-zboss-lib packages from [Espressif's component serivce](https://components.espressif.com/).
|
||||
You can add them to your project via `idf.py add-dependency espressif/esp-zboss-lib==0.0.2`
|
||||
|
||||
Before project configuration and build, make sure to set the correct chip target using `idf.py set-target esp32h2`.
|
||||
|
||||
## Build and Flash
|
||||
@@ -32,18 +29,18 @@ Build the project, flash it to the board, and start the monitor tool to view the
|
||||
As you run the example, you will see the following log:
|
||||
|
||||
light switch:
|
||||
I (9423) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
|
||||
I (9523) ESP_ZB_SWITCH: status: -1
|
||||
I (9523) ESP_ZB_SWITCH: Zigbee stack initialized
|
||||
I (9523) ESP_ZB_SWITCH: Start network steering
|
||||
I (11263) ESP_ZB_SWITCH: Joined network successfully (Extended PAN ID: f9:54:2d:01:a0:03:f7:84, PAN ID: 0xf5b5)
|
||||
I (13433) ESP_ZB_SWITCH: Found bulb addr: 0x434a ep: 10
|
||||
I (16433) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (17663) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (18693) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (19833) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (20753) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (21363) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (9423) gpio: GPIO[9]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
|
||||
I (9523) ESP_ZB_SWITCH: status: -1
|
||||
I (9523) ESP_ZB_SWITCH: Zigbee stack initialized
|
||||
I (9523) ESP_ZB_SWITCH: Start network steering
|
||||
I (11263) ESP_ZB_SWITCH: Joined network successfully (Extended PAN ID: f9:54:2d:01:a0:03:f7:84, PAN ID: 0xf5b5)
|
||||
I (13433) ESP_ZB_SWITCH: Found bulb addr: 0x434a ep: 10
|
||||
I (16433) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (17663) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (18693) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (19833) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (20753) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
I (21363) ESP_ZB_SWITCH: Send ON/OFF toggle command
|
||||
|
||||
## Light Control Functions
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "esp_zb_switch.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_zb_switch.h"
|
||||
|
||||
/**
|
||||
* @note Make sure set idf.py menuconfig in zigbee component as zigbee end device!
|
||||
@@ -284,12 +284,14 @@ void zboss_signal_handler(zb_uint8_t bufid)
|
||||
void app_main()
|
||||
{
|
||||
zb_ret_t zb_err_code;
|
||||
zb_ieee_addr_t g_ieee_addr;
|
||||
zb_esp_platform_config_t config = {
|
||||
.radio_config = ZB_ESP_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ZB_ESP_DEFAULT_HOST_CONFIG(),
|
||||
};
|
||||
|
||||
/* initialize Zigbee stack */
|
||||
ESP_ERROR_CHECK(zb_esp_platform_config(&config));
|
||||
/* initialize Zigbee stack. */
|
||||
ZB_INIT("light_switch");
|
||||
esp_read_mac(g_ieee_addr, ESP_MAC_IEEE802154);
|
||||
zb_set_long_address(g_ieee_addr);
|
||||
zb_set_network_ed_role(IEEE_CHANNEL_MASK);
|
||||
zb_set_nvram_erase_at_start(ERASE_PERSISTENT_CONFIG);
|
||||
zb_set_ed_timeout(ED_AGING_TIMEOUT_64MIN);
|
||||
|
||||
@@ -34,9 +34,10 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "switch_driver.h"
|
||||
#include "zboss_api.h"
|
||||
#include "zboss_api_zcl.h"
|
||||
#include "zb_ha.h"
|
||||
#include "switch_driver.h"
|
||||
|
||||
/* Zigbee configuration */
|
||||
#define IEEE_CHANNEL_MASK (1l << 13) /* ZigBee default setting is channel 13 for light example usage */
|
||||
@@ -60,3 +61,12 @@ typedef struct {
|
||||
zb_zcl_on_off_attrs_t on_off_attr;
|
||||
light_switch_bulb_params_t bulb_params;
|
||||
} switch_device_ctx_t;
|
||||
#define ZB_ESP_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_NATIVE, \
|
||||
}
|
||||
|
||||
#define ZB_ESP_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_NONE, \
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp-zboss-lib: "~=0.0.4"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=4.1.0"
|
||||
# # Put list of dependencies here
|
||||
# # For components maintained by Espressif:
|
||||
# component: "~1.0.0"
|
||||
# # For 3rd party components:
|
||||
# username/component: ">=1.0.0,<2.0.0"
|
||||
# username2/component2:
|
||||
# version: "~1.0.0"
|
||||
# # For transient dependencies `public` flag can be set.
|
||||
# # `public` flag doesn't have an effect dependencies of the `main` component.
|
||||
# # All dependencies of `main` are public by default.
|
||||
# public: true
|
||||
@@ -35,11 +35,11 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "switch_driver.h"
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include "freertos/queue.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/queue.h"
|
||||
#include "switch_driver.h"
|
||||
|
||||
/**
|
||||
* @brief:
|
||||
|
||||
Reference in New Issue
Block a user