123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- /**
- * @file protocol.h
- * @brief declaration of fuction in protocol.c
- * @author qinlang
- * @date 2022.05.06
- * @par email:
- * @par email:qinlang.chen@tuya.com
- * @copyright HANGZHOU TUYA INFORMATION TECHNOLOGY CO.,LTD
- * @par company
- * http://www.tuya.com
- */
- #ifndef __PROTOCOL_H_
- #define __PROTOCOL_H_
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- /******************************************************************************
- 配置产品类别须知:
- 1:根据实际设计电路板,设置产品SKU,必须修改参数“switchSKU”为对应产品类别
- 2:根据涂鸦ZigBee固件类别,需设置对应的宏定义
- OTA设置须知:
- 1.开启OTA(需先下载“BootLoader”程序),宏定义“SUPPORT_MCU_OTA”打开,并设置编译下载环境参数,IROM1:0x8003000,0x6800
- 2.关闭OTA, 注释宏定义“SUPPORT_MCU_OTA”,并设置编译下载环境参数:IROM1:0x8000000,0x20000
- ******************************************************************************/
- #define REALSE 1 //生产模式,看门狗打开
- //#define DOOR 1 //干触点开关
- #define switchSKU 0x04//产品SKU, 混合面板bit7=1;纯场景面板,bit3=1;
- //04:中山4键,
- //14:臣仕C4键,
- //chensir 4键系列
- //#define ZIGBEE_ZS_T4_CS 1//定义该开关为芯科4键开关-CHENSIR C
- //中山6键轻触系列 --通用定义
- #define ZIGBEE_ZS_T4 1//轻触4键开关
- /////////////////////////背光参数/////////////////////////////////////////////
- //臣仕C系列 --1-4键
- #if (defined ZIGBEE_ZS_T4_CS)
- #define mKeyLedWeaknight 1 //弱光1/120,按键灯夜晚背光,臣仕2
- #define mKeyLedWeakday 6 //弱光6/120,按键灯白天背光,臣仕5
- #define mKeyLedBrightLight 30 //强光 30/120,继电器触发,按键灯高亮,臣仕15
- #define mBLedWeaknight 10 //弱光10/100,氛围灯夜晚背光,臣仕10
- #define mBLedWeakday 20 //弱光20/100,氛围灯白天背光,臣仕20
- //中山高成本 --触摸按键1-4
- #elif (defined ZIGBEE_ZS_T4)
- #define mKeyLedWeaknight 8 //中山弱光8/120,按键灯夜晚背光,臣仕2
- #define mKeyLedWeakday 20 //中山弱光20/120,按键灯白天背光,臣仕5
- #define mKeyLedBrightLight 100 //强光 100/120,继电器触发,按键灯高亮,臣仕15
- #define mBLedWeaknight 40 //弱光40/100,氛围灯夜晚背光
- #define mBLedWeakday 70 //弱光70/100,氛围灯白天背光
- //以下为默认参数
- #else
- #define mKeyLedWeaknight 4 //弱光4/120,按键灯夜晚背光
- #define mKeyLedWeakday 10 //弱光10/120,按键灯白天背光
- #define mKeyLedBrightLight 50 //强光 50/120,继电器触发,按键灯高亮
- #define mBLedWeaknight 10 //弱光10/100,氛围灯夜晚背光
- #define mBLedWeakday 20 //弱光20/100,氛围灯白天背光
- #endif
- /////////////////////////背光参数/////////////////////////////////////////////
- ///< product INFORMATION
- ///< mcu version
- //#define MCU_VER "1.0.1" // MAX 3.3.15 BIT 7~0 XX.XX.XXXX
- #define PRODUCT_KEY "nkx3lalp" //开发平台创建产品后生成的16位字符产品唯一标识
- #define MCU_VER "1.0.0" // MAX 3.3.15 BIT 7~0 XX.XX.XXXX
- #define ZIGBEE_UART_QUEUE_LMT 256 // using to save data received from uart
- #define ZIGBEE_UART_RECV_BUF_LMT 128 //
- #define ZIGBEE_UART_SEND_BUF_LMT 128 //
- typedef enum
- {
- MCU_TYPE_DC_POWER = 1,
- MCU_TYPE_LOWER_POWER,
- MCU_TYPE_SCENE
- } MCU_TYPE_E;
- /**
- * if mcu need to support the time function, this macro definition should be opened
- * and need complete mcu_write_rtctime function
- *
- */
- //#define SUPPORT_MCU_RTC_CHECK //start time calibration
- /**
- * if mcu need to support OTA, this macro definition should be opened
- */
- #define SUPPORT_MCU_OTA //support mcu ota
- //modify by zzw 20221010 开启MCU OTA功能
- /**
- * if mcu need to support mcu type checking, this macro definition should be opened
- *
- */
- //#define CHECK_MCU_TYPE //support mcu type check
- /**
- * if mcu need to support zigbee network parameter setting, this macro definition should be opened
- *
- */
- //#define SET_ZIGBEE_NWK_PARAMETER //support zigbee nwk parameter setting
- /**
- * if mcu need to send a broadcast data, this macro definition should be opened
- *
- */
- //#define BROADCAST_DATA_SEND //support broadcast data sending
- /**
- * DP data list,this code will be generate by cloud platforms
- */
- /******************************************************************************
- 1:dp数据与涂鸦平台创建的产品对应
- **此为自动生成代码,如在开发平台有相关修改请重新下载MCU_SDK**
- ******************************************************************************/
- //备注:
- //开关(可下发可上报)
- //备注:
- #define DPID_SWITCH 1
- //工作模式(可下发可上报)
- //备注:
- #define DPID_MODE 2
- //工作状态(只上报)
- //备注:
- #define DPID_WORK_STATE 3
- //目标温度(可下发可上报)
- //备注:
- #define DPID_TEMP_SET 16
- //当前温度(只上报)
- //备注:
- #define DPID_TEMP_CURRENT 24
- //档位(可下发可上报)
- //备注:
- #define DPID_LEVEL 28
- //工作状态(可下发可上报)
- //备注:
- #define DPID_WORK_STATE1 101
- //地暖目标温度(可下发可上报)
- //备注:
- #define DPID_TEMP_DN 102
- //地暖开关(可下发可上报)
- //备注:
- #define DPID_SWITCH_FLOOR_HEAT 103
- //新风开关(可下发可上报)
- //备注:
- #define DPID_SWITCH_FAN 104
- //新风风速档位(可下发可上报)
- //备注:
- #define DPID_LEVEL_FAN 105
- void zigbee_notify_factory_new_hanlde(void);
- /**
- * @brief encapsulates a generic send function, developer should use their own function to completing this fuction
- * @param[in] {value} send signle data
- * @return void
- */
- void uart_transmit_output(unsigned char value);
- /**
- * @brief Upload all dp information of the system, and realize the synchronization of APP and muc data
- * @param[in] {void}
- * @return void
- */
- void all_data_update(void);
- /**
- * @brief mcu check local RTC time
- * @param[in] {time} timestamp
- * @return void
- */
- void mcu_write_rtctime(unsigned char time[]);
- /**
- * @brief Zigbee functional test feedback
- * @param[in] {void}
- * @return void
- */
- void zigbee_test_result(void);
- /**
- * @brief this function will handle uart received frame data
- * @param[in] {dpid} dp id
- * @param[in] {value} dp data
- * @param[in] {length} lenght of dp data
- * @return handle result
- */
- unsigned char dp_download_handle(unsigned char dpid, const unsigned char value[], unsigned short length);
- /**
- * @brief get received cmd total number
- * @param[in] {void}
- * @return received cmd total number
- */
- unsigned char get_download_cmd_total(void);
- /**
- * @brief received zigbee net_work state handle
- * @param[in] {zigbee_work_state} zigbee current network state
- * @return void
- */
- void zigbee_work_state_event(unsigned char zigbee_work_state);
- /**
- * @brief received reset zigbee response
- * @param[in] {state} response state
- * @return void
- */
- void mcu_reset_zigbee_event(unsigned char state);
- /**
- * @brief check mcu version response
- * @param[in] {void}
- * @return void
- */
- void response_mcu_ota_version_event(void);
- #ifdef SUPPORT_MCU_OTA
- /**
- * @brief mcu ota update notify response
- * @param[in] {offset} offset of file
- * @return void
- */
- void response_mcu_ota_notify_event(unsigned char offset);
- /**
- * @brief received mcu ota data request response
- * @param[in] {fw_offset} offset of file
- * @param[in] {data} received data
- * @return void
- */
- void reveived_mcu_ota_data_handle(unsigned int fw_offset, char *data);
- /**
- * @brief mcu send ota data request
- * @param[in] {offset} offset of file
- * @return void
- */
- void mcu_ota_fw_request_event(unsigned char offset);
- /**
- * @brief mcu ota data result notify
- * @param[in] {offset} offset of file
- * @return void
- */
- void mcu_ota_result_event(unsigned char offset);
- /**
- * @brief mcu ota data handle
- * @param[in] {fw_offset} frame offset
- * @param[in] {data} received data
- * @return void
- */
- void ota_fw_data_handle(unsigned int fw_offset, char *data, unsigned char data_len);
- #endif
- #ifdef BEACON_TEST
- /**
- * @brief beacon test notify,which used in testing
- * @param[in] {void}
- * @return void
- */
- void mcu_received_beacon_test_handle(void);
- #endif
- #ifdef CHECK_ZIGBEE_NETWORK
- /**
- * @brief check zigbee nwkstate,before start join nwk, check nwk if state is not 0x02,can start jion,
- * else delay 5s
- *
- * @param[in] {void}
- * @return void
- */
- void mcu_check_zigbee_nwk_state(void);
- #endif
- #ifdef READ_DP_DATA_NOTIFY
- /**
- * @brief when gateway repower or relink clould, or zigbee module join sucess, repower, this commod will notify
- * mcu, to sys dp data, mcu itself decide whether report.
- *
- * @param[in] {void}
- * @return void
- */
- void read_dp_data_notify_hanlde(void);
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|