Got manufacturer data to show as "b-parasite" in zigbee2mqtt
This commit is contained in:
parent
f05d1f8e3b
commit
f090b25a2c
2 changed files with 152 additions and 138 deletions
|
|
@ -19,7 +19,7 @@ CONFIG_MAIN_THREAD_PRIORITY=7
|
||||||
|
|
||||||
CONFIG_ZIGBEE=y
|
CONFIG_ZIGBEE=y
|
||||||
CONFIG_ZIGBEE_APP_UTILS=y
|
CONFIG_ZIGBEE_APP_UTILS=y
|
||||||
CONFIG_ZIGBEE_ROLE_ROUTER=y
|
CONFIG_ZIGBEE_ROLE_END_DEVICE=y
|
||||||
|
|
||||||
# Enable DK LED and Buttons library
|
# Enable DK LED and Buttons library
|
||||||
CONFIG_DK_LIBRARY=y
|
CONFIG_DK_LIBRARY=y
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,16 @@
|
||||||
* @brief Zigbee application template.
|
* @brief Zigbee application template.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <dk_buttons_and_leds.h>
|
||||||
|
#include <zb_nrf_platform.h>
|
||||||
|
#include <zboss_api.h>
|
||||||
|
#include <zboss_api_addons.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
#include <dk_buttons_and_leds.h>
|
|
||||||
|
|
||||||
#include <zboss_api.h>
|
|
||||||
#include <zigbee/zigbee_error_handler.h>
|
|
||||||
#include <zigbee/zigbee_app_utils.h>
|
#include <zigbee/zigbee_app_utils.h>
|
||||||
#include <zb_nrf_platform.h>
|
#include <zigbee/zigbee_error_handler.h>
|
||||||
#include "zb_range_extender.h"
|
|
||||||
|
|
||||||
|
#include "zb_range_extender.h"
|
||||||
|
|
||||||
/* Device endpoint, used to receive ZCL commands. */
|
/* Device endpoint, used to receive ZCL commands. */
|
||||||
#define APP_TEMPLATE_ENDPOINT 10
|
#define APP_TEMPLATE_ENDPOINT 10
|
||||||
|
|
@ -26,7 +26,8 @@
|
||||||
/* Type of power sources available for the device.
|
/* Type of power sources available for the device.
|
||||||
* For possible values see section 3.2.2.2.8 of ZCL specification.
|
* For possible values see section 3.2.2.2.8 of ZCL specification.
|
||||||
*/
|
*/
|
||||||
#define TEMPLATE_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE
|
// #define TEMPLATE_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_DC_SOURCE
|
||||||
|
#define TEMPLATE_INIT_BASIC_POWER_SOURCE ZB_ZCL_BASIC_POWER_SOURCE_BATTERY
|
||||||
|
|
||||||
/* LED indicating that device successfully joined Zigbee network. */
|
/* LED indicating that device successfully joined Zigbee network. */
|
||||||
#define ZIGBEE_NETWORK_STATE_LED DK_LED3
|
#define ZIGBEE_NETWORK_STATE_LED DK_LED3
|
||||||
|
|
@ -40,13 +41,17 @@
|
||||||
/* Button to start Factory Reset */
|
/* Button to start Factory Reset */
|
||||||
#define FACTORY_RESET_BUTTON IDENTIFY_MODE_BUTTON
|
#define FACTORY_RESET_BUTTON IDENTIFY_MODE_BUTTON
|
||||||
|
|
||||||
|
#define PRST_BASIC_MANUF_NAME "b-parasite"
|
||||||
|
|
||||||
|
#define PRST_BASIC_MODEL_ID "b-parasite 1.2.0"
|
||||||
|
|
||||||
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
|
LOG_MODULE_REGISTER(app, LOG_LEVEL_INF);
|
||||||
|
|
||||||
/* Main application customizable context.
|
/* Main application customizable context.
|
||||||
* Stores all settings and static values.
|
* Stores all settings and static values.
|
||||||
*/
|
*/
|
||||||
struct zb_device_ctx {
|
struct zb_device_ctx {
|
||||||
zb_zcl_basic_attrs_t basic_attr;
|
zb_zcl_basic_attrs_ext_t basic_attr;
|
||||||
zb_zcl_identify_attrs_t identify_attr;
|
zb_zcl_identify_attrs_t identify_attr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -57,10 +62,19 @@ ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(
|
||||||
identify_attr_list,
|
identify_attr_list,
|
||||||
&dev_ctx.identify_attr.identify_time);
|
&dev_ctx.identify_attr.identify_time);
|
||||||
|
|
||||||
ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(
|
ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST_EXT(
|
||||||
basic_attr_list,
|
basic_attr_list,
|
||||||
&dev_ctx.basic_attr.zcl_version,
|
&dev_ctx.basic_attr.zcl_version,
|
||||||
&dev_ctx.basic_attr.power_source);
|
&dev_ctx.basic_attr.app_version,
|
||||||
|
&dev_ctx.basic_attr.stack_version,
|
||||||
|
&dev_ctx.basic_attr.hw_version,
|
||||||
|
dev_ctx.basic_attr.mf_name,
|
||||||
|
dev_ctx.basic_attr.model_id,
|
||||||
|
dev_ctx.basic_attr.date_code,
|
||||||
|
&dev_ctx.basic_attr.power_source,
|
||||||
|
dev_ctx.basic_attr.location_id,
|
||||||
|
&dev_ctx.basic_attr.ph_env,
|
||||||
|
dev_ctx.basic_attr.sw_ver);
|
||||||
|
|
||||||
ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST(
|
ZB_DECLARE_RANGE_EXTENDER_CLUSTER_LIST(
|
||||||
app_template_clusters,
|
app_template_clusters,
|
||||||
|
|
@ -76,13 +90,21 @@ ZBOSS_DECLARE_DEVICE_CTX_1_EP(
|
||||||
app_template_ctx,
|
app_template_ctx,
|
||||||
app_template_ep);
|
app_template_ep);
|
||||||
|
|
||||||
|
|
||||||
/**@brief Function for initializing all clusters attributes. */
|
/**@brief Function for initializing all clusters attributes. */
|
||||||
static void app_clusters_attr_init(void)
|
static void app_clusters_attr_init(void) {
|
||||||
{
|
|
||||||
/* Basic cluster attributes data */
|
/* Basic cluster attributes data */
|
||||||
dev_ctx.basic_attr.zcl_version = ZB_ZCL_VERSION;
|
dev_ctx.basic_attr.zcl_version = ZB_ZCL_VERSION;
|
||||||
dev_ctx.basic_attr.power_source = TEMPLATE_INIT_BASIC_POWER_SOURCE;
|
dev_ctx.basic_attr.power_source = TEMPLATE_INIT_BASIC_POWER_SOURCE;
|
||||||
|
// dev_ctx.basic_attr.mf_name
|
||||||
|
ZB_ZCL_SET_STRING_VAL(
|
||||||
|
dev_ctx.basic_attr.mf_name,
|
||||||
|
PRST_BASIC_MANUF_NAME,
|
||||||
|
ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MANUF_NAME));
|
||||||
|
|
||||||
|
ZB_ZCL_SET_STRING_VAL(
|
||||||
|
dev_ctx.basic_attr.model_id,
|
||||||
|
PRST_BASIC_MODEL_ID,
|
||||||
|
ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MODEL_ID));
|
||||||
|
|
||||||
/* Identify cluster attributes data. */
|
/* Identify cluster attributes data. */
|
||||||
dev_ctx.identify_attr.identify_time =
|
dev_ctx.identify_attr.identify_time =
|
||||||
|
|
@ -93,8 +115,7 @@ static void app_clusters_attr_init(void)
|
||||||
*
|
*
|
||||||
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
||||||
*/
|
*/
|
||||||
static void toggle_identify_led(zb_bufid_t bufid)
|
static void toggle_identify_led(zb_bufid_t bufid) {
|
||||||
{
|
|
||||||
static int blink_status;
|
static int blink_status;
|
||||||
|
|
||||||
dk_set_led(IDENTIFY_LED, (++blink_status) % 2);
|
dk_set_led(IDENTIFY_LED, (++blink_status) % 2);
|
||||||
|
|
@ -105,8 +126,7 @@ static void toggle_identify_led(zb_bufid_t bufid)
|
||||||
*
|
*
|
||||||
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
||||||
*/
|
*/
|
||||||
static void identify_cb(zb_bufid_t bufid)
|
static void identify_cb(zb_bufid_t bufid) {
|
||||||
{
|
|
||||||
zb_ret_t zb_err_code;
|
zb_ret_t zb_err_code;
|
||||||
|
|
||||||
if (bufid) {
|
if (bufid) {
|
||||||
|
|
@ -125,8 +145,7 @@ static void identify_cb(zb_bufid_t bufid)
|
||||||
*
|
*
|
||||||
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
* @param bufid Unused parameter, required by ZBOSS scheduler API.
|
||||||
*/
|
*/
|
||||||
static void start_identifying(zb_bufid_t bufid)
|
static void start_identifying(zb_bufid_t bufid) {
|
||||||
{
|
|
||||||
ZVUNUSED(bufid);
|
ZVUNUSED(bufid);
|
||||||
|
|
||||||
if (ZB_JOINED()) {
|
if (ZB_JOINED()) {
|
||||||
|
|
@ -135,7 +154,6 @@ static void start_identifying(zb_bufid_t bufid)
|
||||||
*/
|
*/
|
||||||
if (dev_ctx.identify_attr.identify_time ==
|
if (dev_ctx.identify_attr.identify_time ==
|
||||||
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE) {
|
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE) {
|
||||||
|
|
||||||
zb_ret_t zb_err_code = zb_bdb_finding_binding_target(
|
zb_ret_t zb_err_code = zb_bdb_finding_binding_target(
|
||||||
APP_TEMPLATE_ENDPOINT);
|
APP_TEMPLATE_ENDPOINT);
|
||||||
|
|
||||||
|
|
@ -161,8 +179,7 @@ static void start_identifying(zb_bufid_t bufid)
|
||||||
* @param[in] has_changed Bitmask containing buttons
|
* @param[in] has_changed Bitmask containing buttons
|
||||||
* that have changed their state.
|
* that have changed their state.
|
||||||
*/
|
*/
|
||||||
static void button_changed(uint32_t button_state, uint32_t has_changed)
|
static void button_changed(uint32_t button_state, uint32_t has_changed) {
|
||||||
{
|
|
||||||
if (IDENTIFY_MODE_BUTTON & has_changed) {
|
if (IDENTIFY_MODE_BUTTON & has_changed) {
|
||||||
if (IDENTIFY_MODE_BUTTON & button_state) {
|
if (IDENTIFY_MODE_BUTTON & button_state) {
|
||||||
/* Button changed its state to pressed */
|
/* Button changed its state to pressed */
|
||||||
|
|
@ -184,8 +201,7 @@ static void button_changed(uint32_t button_state, uint32_t has_changed)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Function for initializing LEDs and Buttons. */
|
/**@brief Function for initializing LEDs and Buttons. */
|
||||||
static void configure_gpio(void)
|
static void configure_gpio(void) {
|
||||||
{
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = dk_buttons_init(button_changed);
|
err = dk_buttons_init(button_changed);
|
||||||
|
|
@ -204,8 +220,7 @@ static void configure_gpio(void)
|
||||||
* @param[in] bufid Reference to the Zigbee stack buffer
|
* @param[in] bufid Reference to the Zigbee stack buffer
|
||||||
* used to pass signal.
|
* used to pass signal.
|
||||||
*/
|
*/
|
||||||
void zboss_signal_handler(zb_bufid_t bufid)
|
void zboss_signal_handler(zb_bufid_t bufid) {
|
||||||
{
|
|
||||||
/* Update network status LED. */
|
/* Update network status LED. */
|
||||||
zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED);
|
zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED);
|
||||||
|
|
||||||
|
|
@ -222,8 +237,7 @@ void zboss_signal_handler(zb_bufid_t bufid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void)
|
void main(void) {
|
||||||
{
|
|
||||||
LOG_INF("Starting Zigbee application template example");
|
LOG_INF("Starting Zigbee application template example");
|
||||||
|
|
||||||
/* Initialize */
|
/* Initialize */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue