Make it safer
This commit is contained in:
parent
ede0c81632
commit
b9f19c02d4
3 changed files with 13 additions and 3 deletions
|
|
@ -242,7 +242,7 @@ int main(void) {
|
|||
|
||||
RET_IF_ERR(prst_zb_factory_reset_check());
|
||||
|
||||
prst_zb_attrs_init(&dev_ctx);
|
||||
RET_IF_ERR(prst_zb_attrs_init(&dev_ctx));
|
||||
|
||||
ZB_AF_REGISTER_DEVICE_CTX(&app_template_ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
#include "prst_zb_attrs.h"
|
||||
|
||||
#include <prstlib/macros.h>
|
||||
#include <zboss_api_addons.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include "prst_zb_endpoint_defs.h"
|
||||
|
||||
void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
|
||||
LOG_MODULE_REGISTER(prst_zb_attrs, CONFIG_LOG_DEFAULT_LEVEL);
|
||||
|
||||
int prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
|
||||
dev_ctx->basic_attr.zcl_version = ZB_ZCL_VERSION;
|
||||
dev_ctx->basic_attr.power_source = ZB_ZCL_BASIC_POWER_SOURCE_BATTERY;
|
||||
ZB_ZCL_SET_STRING_VAL(
|
||||
|
|
@ -13,9 +17,13 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
|
|||
ZB_ZCL_STRING_CONST_SIZE(PRST_BASIC_MANUF_NAME));
|
||||
|
||||
char versioned_model_id[sizeof(dev_ctx->basic_attr.model_id)];
|
||||
RET_CHECK(strlen(CONFIG_PRST_ZB_MODEL_ID) + strlen(CONFIG_BOARD_REVISION) + 1 <
|
||||
sizeof(versioned_model_id),
|
||||
"Model ID too long");
|
||||
strcpy(versioned_model_id, CONFIG_PRST_ZB_MODEL_ID);
|
||||
strcat(versioned_model_id, " ");
|
||||
strcat(versioned_model_id, CONFIG_BOARD_REVISION);
|
||||
LOG_DBG("Versioned model ID: %s", versioned_model_id);
|
||||
ZB_ZCL_SET_STRING_VAL(
|
||||
dev_ctx->basic_attr.model_id,
|
||||
versioned_model_id,
|
||||
|
|
@ -33,6 +41,8 @@ void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx) {
|
|||
|
||||
dev_ctx->identify_attr.identify_time =
|
||||
ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
zb_zcl_status_t prst_zb_set_attr_value(zb_uint16_t cluster_id, zb_uint16_t attr_id, void *data) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct zb_device_ctx {
|
|||
prst_illuminancce_attrs_t illuminance_attrs;
|
||||
};
|
||||
|
||||
void prst_zb_attrs_init(struct zb_device_ctx *dev_ctx);
|
||||
int prst_zb_attrs_init(struct zb_device_ctx *dev_ctx);
|
||||
|
||||
zb_zcl_status_t prst_zb_set_attr_value(zb_uint16_t cluster_id, zb_uint16_t attr_id, void *data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue