Zigbee: Add light example
* provide light example for acting as zigbee coordinator, router and end-device * remove unused componenent for example usage * remove unused variable * clean up unused header include for example * update the license header * update copyright * Add readme for instruction adding esp-zboss-lib component * esp-idf:update copy_right_check ignore file * CI: fix the ci check error from pipeline * sdkconfig: default set change for better user use * use Button (BOOT) as switch input * update the statemachine for debouncing * esp-zboss-lib: support lib 0.0.2 * fix warning issue from example
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Espressif Systems (Shanghai) CO LTD
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form, except as embedded into a Espressif Systems
|
||||
* integrated circuit in a product or a software update for such product,
|
||||
* must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* 4. Any software provided in binary form under this license must not be reverse
|
||||
* engineered, decompiled, modified and/or disassembled.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* user should configure which I/O port as toggle switch input, default is GPIO9 */
|
||||
#define GPIO_INPUT_IO_TOGGLE_SWITCH GPIO_NUM_9
|
||||
|
||||
/* config button level depends on the pull up/down setting
|
||||
push button level is on level = 1 when pull-down enable
|
||||
push button level is on level = 0 when pull-up enable
|
||||
*/
|
||||
#define GPIO_INPUT_LEVEL_ON 0
|
||||
|
||||
#define ESP_INTR_FLAG_DEFAULT 0
|
||||
|
||||
#define PAIR_SIZE(TYPE_STR_PAIR) (sizeof(TYPE_STR_PAIR) / sizeof(TYPE_STR_PAIR[0]))
|
||||
|
||||
typedef enum {
|
||||
SWITCH_IDLE,
|
||||
SWITCH_PRESS_ARMED,
|
||||
SWITCH_PRESS_DETECTED,
|
||||
SWITCH_PRESSED,
|
||||
SWITCH_RELEASE_DETECTED,
|
||||
} switch_state_t;
|
||||
|
||||
typedef enum {
|
||||
SWITCH_ON_CONTROL,
|
||||
SWITCH_OFF_CONTROL,
|
||||
SWITCH_ONOFF_TOGGLE_CONTROL,
|
||||
SWITCH_LEVEL_UP_CONTROL,
|
||||
SWITCH_LEVEL_DOWN_CONTROL,
|
||||
SWITCH_LEVEL_CYCLE_CONTROL,
|
||||
SWITCH_COLOR_CONTROL,
|
||||
} switch_func_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t pin;
|
||||
switch_func_t func;
|
||||
} switch_func_pair_t;
|
||||
|
||||
typedef void (*esp_switch_callback_t)(switch_func_pair_t param);
|
||||
|
||||
/**
|
||||
* @brief init function for switch and callback setup
|
||||
*
|
||||
* @param button_func_pair pointer of the button pair.
|
||||
* @param button_num number of button pair.
|
||||
* @param cb callback pointer.
|
||||
*/
|
||||
bool switch_driver_init(switch_func_pair_t *button_func_pair, uint8_t button_num, esp_switch_callback_t cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
Reference in New Issue
Block a user