Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zboss: Add ZBOSS library #166

Merged
merged 2 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 Nordic Semiconductor
# Copyright (c) 2019 - 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
Expand All @@ -15,3 +15,4 @@ add_subdirectory_ifdef(CONFIG_MPSL mpsl)
add_subdirectory_ifdef(CONFIG_BSD_LIBRARY bsdlib)
add_subdirectory_ifdef(CONFIG_NRFXLIB_CRYPTO crypto)
add_subdirectory_ifdef(CONFIG_NORDIC_SECURITY_BACKEND nrf_security)
add_subdirectory_ifdef(CONFIG_ZIGBEE zboss)
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ doc/* @b-gent
/mpsl/ @joerchan @rugeGerritsen
/nfc/ @anangl @grochu
/nrf_security/ @frkv @tejlmand
/zboss/ @tomchy
/zephyr/ @carlescufi
3 changes: 2 additions & 1 deletion Kconfig.nrfxlib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019 Nordic Semiconductor
# Copyright (c) 2019 - 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
Expand All @@ -12,5 +12,6 @@ rsource "ble_controller/Kconfig"
rsource "mpsl/Kconfig"
rsource "crypto/Kconfig"
rsource "nrf_security/Kconfig"
rsource "zboss/Kconfig"

endmenu
98 changes: 98 additions & 0 deletions zboss/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

include(${NRFXLIB_DIR}/common.cmake)

# Define a separate interface library for Nordic's extensions to ZBOSS stack
zephyr_interface_library_named(zboss-extensions)

# Common includes, not related to ZBOSS source code.
target_include_directories(zboss-extensions INTERFACE
src/zb_error
include/addons
)

# Suppress bitfield compatibility warning.
# This has to be included in all files, that uses ZBOSS headers.
# Those options will be inherited by the ZBOSS target as well as everything
# that links to it.
target_compile_options(zboss-extensions INTERFACE
-Wno-packed-bitfield-compat
)

# Add compile-time definition, indicating which ZBOSS library will be linked
# This definition adjusts ZBOSS headers, by making non-applicable API for
# a given Zigbee role invisible.
# Those options will be inherited by the ZBOSS target as well as everything
# that links to it.
if (CONFIG_ZIGBEE_ROLE_END_DEVICE)
target_compile_definitions(zboss-extensions INTERFACE
ZB_ED_ROLE
)
endif()


# Create a library for Nordic's extensions to ZBOSS stack.
# The target name is generated based on the path and is not meant to be
# explicitly linked in other modules.
# It will be pulled if the module links to the ZBOSS interface library.
zephyr_library()

# Add source files
zephyr_library_sources(src/zb_error/zb_error_to_string.c)

# Link with ZBOSS extensions interface library, which is linked to the main
# ZBOSS interface library.
zephyr_library_link_libraries(zboss)

# Precompiled libraries -only part.
# Use the CONFIG_ZBOSS_SOURCES_AVAILABLE Kconfig option is defined in ZBOSS
# platform module to check if user uses ZOI repositories for building
# application.
# If so, the user still may select libraries from nrfxlib to link with
# verified state of ZBOSS (CONFIG_ZBOSS_LIBRARY_PRECOMPILED symbol).
if ((NOT DEFINED CONFIG_ZBOSS_SOURCES_AVAILABLE) OR
(CONFIG_ZBOSS_LIBRARY_PRECOMPILED))

nrfxlib_calculate_lib_path(lib_path)
set(ZBOSS_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${lib_path})
if(NOT EXISTS ${ZBOSS_LIB_PATH})
message(WARNING "This combination of SoC and floating point ABI is not supported by the ZBOSS lib."
"(${ZBOSS_LIB_PATH} doesn't exist.)")
endif()

# Define an interface library for Nordic's ZBOSS stack.
# This library contains official ZBOSS headers, platform-specific configuration
# and links to Nordic's extensions of ZBOSS API.
# This target definition is defined in both - nrfxlib and ZBOSS platform for
# NCS due to the lack of control on the order of Zephyr module inclusion.
zephyr_interface_library_named(zboss)

# Extend ZBOSS interface libraries by headers placed in nrfxlib.
target_include_directories(zboss INTERFACE
include
include/zcl
include/ha
include/se
include/osif
)

# Include the static library to the ZBOSS interface definition and select
# ZBOSS configuration header file by defining compile-time definition.
if (CONFIG_ZIGBEE_ROLE_COORDINATOR OR CONFIG_ZIGBEE_ROLE_ROUTER)
target_link_libraries(zboss INTERFACE ${ZBOSS_LIB_PATH}/libzboss.a)
target_compile_definitions(zboss INTERFACE LIBZBOSS_CONFIG_FILE="libzboss_config.h")
elseif (CONFIG_ZIGBEE_ROLE_END_DEVICE)
target_link_libraries(zboss INTERFACE ${ZBOSS_LIB_PATH}/libzboss.ed.a)
target_compile_definitions(zboss INTERFACE LIBZBOSS_CONFIG_FILE="libzboss_config.ed.h")
else()
message( FATAL_ERROR "Unsupported Zigbee role. Exiting." )
endif()

# Link with Nordic's ZBOSS extensions as well as common compile time options
# and definitions.
target_link_libraries(zboss INTERFACE zboss-extensions)
endif()
10 changes: 10 additions & 0 deletions zboss/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

config APP_LINK_WITH_ZBOSS
bool
help
Link application with ZBOSS library
16 changes: 16 additions & 0 deletions zboss/include/addons/zboss_api_addons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

#ifndef ZBOSS_API_ADDONS_H__
#define ZBOSS_API_ADDONS_H__

#include "zboss_api.h"

#include "zboss_api_zcl_addons.h"
#include "zboss_api_af_addons.h"


#endif /* ZBOSS_API_ADDONS_H__ */
66 changes: 66 additions & 0 deletions zboss/include/addons/zboss_api_af_addons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

#ifndef ZBOSS_API_AF_ADDONS_H__
#define ZBOSS_API_AF_ADDONS_H__

#include "zboss_api.h"

/*! \addtogroup zboss_api_af_addons */
/*! @{ */

/**@brief Redefinition of __CAT__ as variadic macro.
*
* @param[IN] a Mandatory argument to concatenate.
* @param[IN] b Mandatory argument to concatenate.
* @param[IN] ... Optional argument to concatenate.
*/
#define __CAT_VA__(a, b, ...) a## __VA_ARGS__## b

/**@brief Redefinition of ZB_AF_SIMPLE_DESC_TYPE as variadic macro.
*
* @param[IN] ... Optional argument to concatenate to the type name.
*/
#define ZB_AF_SIMPLE_DESC_TYPE_VA(in_num, out_num, ...) __CAT_VA__(zb_af_simple_desc_, _t, __VA_ARGS__)

/**@brief Redefinition of ZB_DECLARE_SIMPLE_DESC as variadic macro.
*
* @param[IN] in_clusters_count Number of input clusters.
* @param[IN] out_clusters_count Number of output clusters.
* @param[IN] ... Optional argument to concatenate to the type name.
*/
#define ZB_DECLARE_SIMPLE_DESC_VA(in_clusters_count, out_clusters_count, ...) \
typedef ZB_PACKED_PRE struct zb_af_simple_desc_## __VA_ARGS__## _s \
{ \
zb_uint8_t endpoint; /* Endpoint */ \
zb_uint16_t app_profile_id; /* Application profile identifier */ \
zb_uint16_t app_device_id; /* Application device identifier */ \
zb_bitfield_t app_device_version:4; /* Application device version */ \
zb_bitfield_t reserved:4; /* Reserved */ \
zb_uint8_t app_input_cluster_count; /* Application input cluster count */ \
zb_uint8_t app_output_cluster_count; /* Application output cluster count */ \
/* Application input and output cluster list */ \
zb_uint16_t app_cluster_list[(in_clusters_count) + (out_clusters_count)]; \
zb_uint8_t cluster_encryption[((in_clusters_count) + (out_clusters_count) + 7)/8]; \
} ZB_PACKED_STRUCT zb_af_simple_desc_## __VA_ARGS__## _t

/**@brief Redefinition of ZBOSS_DECLARE_DEVICE_CTX_N_EP as variadic macro.
*
* @param[IN] device_ctx_name Device context variable name.
* @param[IN] ... Variables holding context for endpoints.
*/
#define ZBOSS_DECLARE_DEVICE_CTX_EP_VA(device_ctx_name, ...) \
zb_af_endpoint_desc_t *ep_list_##device_ctx_name[] = { \
__VA_ARGS__ \
}; \
ZBOSS_DECLARE_DEVICE_CTX(device_ctx_name, ep_list_##device_ctx_name, \
(ZB_ZCL_ARRAY_SIZE(ep_list_##device_ctx_name, zb_af_endpoint_desc_t*)))



/** @} */

#endif /* ZBOSS_API_AF_ADDONS_H__ */
22 changes: 22 additions & 0 deletions zboss/include/addons/zboss_api_zcl_addons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

#ifndef ZBOSS_API_ZCL_ADDONS_H__
#define ZBOSS_API_ZCL_ADDONS_H__

#include "zboss_api.h"

#include "zcl/zb_zcl_basic_addons.h"
#include "zcl/zb_zcl_color_control_addons.h"
#include "zcl/zb_zcl_door_lock_addons.h"
#include "zcl/zb_zcl_groups_addons.h"
#include "zcl/zb_zcl_identify_addons.h"
#include "zcl/zb_zcl_level_control_addons.h"
#include "zcl/zb_zcl_scenes_addons.h"
#include "zcl/zb_zcl_on_off_addons.h"
#include "zcl/zb_zcl_temp_measurement_addons.h"

#endif /* ZBOSS_API_ZCL_ADDONS_H__ */
33 changes: 33 additions & 0 deletions zboss/include/addons/zcl/zb_zcl_basic_addons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

#ifndef ZB_ZCL_BASIC_ADDONS_H__
#define ZB_ZCL_BASIC_ADDONS_H__

#include "zboss_api.h"

/*! \addtogroup zb_zcl_basic_addons */
/*! @{ */

/** @brief Basic cluster attributes according to ZCL Spec 3.2.2.2 */
typedef struct
{
zb_uint8_t zcl_version;
zb_uint8_t app_version;
zb_uint8_t stack_version;
zb_uint8_t hw_version;
zb_char_t mf_name[32];
zb_char_t model_id[32];
zb_char_t date_code[16];
zb_uint8_t power_source;
zb_char_t location_id[15];
zb_uint8_t ph_env;
zb_char_t sw_ver[17];
} zb_zcl_basic_attrs_ext_t;

/** @} */

#endif /* ZB_ZCL_BASIC_ADDONS_H__ */
Loading