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

zigbee: Add zigbee support #2208

Merged
merged 3 commits into from
May 22, 2020
Merged

Conversation

maciekfabia
Copy link
Contributor

Add Zigbee support with accompanying samples.
It uses ZBOSS stack that has a separate pull request:
nrfconnect/sdk-nrfxlib#166

@NordicBuilder
Copy link
Contributor

NordicBuilder commented May 5, 2020

All checks are passing now.

checkpatch (informational only, not a failure)

No additional types will be considered - file 'scripts/checkpatch/typedefsfile': No such file or directory
-:591: WARNING:NEW_TYPEDEFS: do not add new typedefs
#591: FILE: samples/zigbee/light_bulb/src/main.c:106:
+typedef struct {

-:908: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'device_cb_param->cb_param.set_attr_value_param.cluster_id'
#908: FILE: samples/zigbee/light_bulb/src/main.c:423:
+		cluster_id = device_cb_param->cb_param.
+			     set_attr_value_param.cluster_id;

-:910: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'device_cb_param->cb_param.set_attr_value_param.attr_id'
#910: FILE: samples/zigbee/light_bulb/src/main.c:425:
+		attr_id = device_cb_param->cb_param.
+			  set_attr_value_param.attr_id;

-:923: WARNING:MULTILINE_DEREFERENCE: Avoid multiple line dereference - prefer 'device_cb_param->cb_param.set_attr_value_param.values.data16'
#923: FILE: samples/zigbee/light_bulb/src/main.c:438:
+			u16_t value = device_cb_param->cb_param.
+				      set_attr_value_param.values.data16;

-:1372: WARNING:LONG_LINE_STRING: line over 80 characters
#1372: FILE: samples/zigbee/network_coordinator/src/main.c:136:
+			LOG_ERR("Failed to initialize Zigbee stack using NVRAM data (status: %d)",

-:1380: WARNING:LONG_LINE_STRING: line over 80 characters
#1380: FILE: samples/zigbee/network_coordinator/src/main.c:144:
+				LOG_INF("Allow pre-Zigbee 3.0 devices to join the network");

-:1941: WARNING:LONG_LINE_STRING: line over 80 characters
#1941: FILE: subsys/zigbee/common/zigbee_helpers.c:203:
+			LOG_INF("Production configuration is not present or invalid (status: %d)",

-:1988: WARNING:LONG_LINE_STRING: line over 80 characters
#1988: FILE: subsys/zigbee/common/zigbee_helpers.c:250:
+			LOG_ERR("Failed to initialize Zigbee stack (status: %d)",

-:2021: WARNING:LONG_LINE_STRING: line over 80 characters
#2021: FILE: subsys/zigbee/common/zigbee_helpers.c:283:
+			LOG_INF("Joined network successfully on reboot signal (Extended PAN ID: %s, PAN ID: 0x%04hx)",

-:2026: WARNING:LONG_LINE_STRING: line over 80 characters
#2026: FILE: subsys/zigbee/common/zigbee_helpers.c:288:
+				LOG_INF("Unable to join the network, start network steering");

-:2029: WARNING:LONG_LINE_STRING: line over 80 characters
#2029: FILE: subsys/zigbee/common/zigbee_helpers.c:291:
+				LOG_ERR("Failed to initialize Zigbee stack using NVRAM data (status: %d)",

-:2061: WARNING:LONG_LINE_STRING: line over 80 characters
#2061: FILE: subsys/zigbee/common/zigbee_helpers.c:323:
+			LOG_INF("Joined network successfully (Extended PAN ID: %s, PAN ID: 0x%04hx)",

-:2072: WARNING:LONG_LINE_STRING: line over 80 characters
#2072: FILE: subsys/zigbee/common/zigbee_helpers.c:334:
+				LOG_INF("Network steering was not successful (status: %d)",

-:2076: WARNING:LONG_LINE_STRING: line over 80 characters
#2076: FILE: subsys/zigbee/common/zigbee_helpers.c:338:
+				LOG_INF("Network steering failed on Zigbee coordinator (status: %d)",

-:2115: WARNING:LONG_LINE_STRING: line over 80 characters
#2115: FILE: subsys/zigbee/common/zigbee_helpers.c:377:
+			LOG_INF("Network formed successfully, start network steering (Extended PAN ID: %s, PAN ID: 0x%04hx)",

-:2215: WARNING:LONG_LINE_STRING: line over 80 characters
#2215: FILE: subsys/zigbee/common/zigbee_helpers.c:477:
+		LOG_INF("Device update received (short: 0x%04hx, long: %s, status: %d)",

-:2331: WARNING:LONG_LINE_STRING: line over 80 characters
#2331: FILE: subsys/zigbee/common/zigbee_helpers.c:593:
+			LOG_ERR("No free buffer available, skipping conflict resolving this time.");

-:2408: WARNING:LONG_LINE_STRING: line over 80 characters
#2408: FILE: subsys/zigbee/common/zigbee_helpers.c:670:
+			LOG_INF("Network rejoin procedure stopped as %sscheduled.",

-:2518: WARNING:LONG_LINE_STRING: line over 80 characters
#2518: FILE: subsys/zigbee/common/zigbee_helpers.c:780:
+			LOG_INF("Network rejoin procedure stopped as %sscheduled.",

-:2703: WARNING:NEW_TYPEDEFS: do not add new typedefs
#2703: FILE: subsys/zigbee/common/zigbee_helpers.h:117:
+typedef enum {

-:2851: WARNING:NEW_TYPEDEFS: do not add new typedefs
#2851: FILE: subsys/zigbee/common/zigbee_logger_eprxzcl.c:45:
+typedef struct {

-:2907: WARNING:MACRO_WITH_FLOW_CONTROL: Macros with flow control statements should be avoided
#2907: FILE: subsys/zigbee/common/zigbee_logger_eprxzcl.c:101:
+#define PRV_ADVANCE_CURR_LOG_MESSAGE_PTR(s)			\
+	do {							\
+		if ((s) < 0) {					\
+			LOG_INST_ERR(				\
+				logger.inst,			\
+				"Received ZCL command but encoding error occurred during log producing"); \
+			return ZB_FALSE;			\
+		}						\
+		log_message_curr += (s);			\
+		if (log_message_curr >= log_message_end) {	\
+			LOG_INST_ERR(				\
+				logger.inst,			\
+				"Received ZCL command but produced log is too long"); \
+			return ZB_FALSE;			\
+		}						\
+	} while (0)

-:2912: WARNING:LONG_LINE: line over 80 characters
#2912: FILE: subsys/zigbee/common/zigbee_logger_eprxzcl.c:106:
+				"Received ZCL command but encoding error occurred during log producing"); \

-:2919: WARNING:LONG_LINE: line over 80 characters
#2919: FILE: subsys/zigbee/common/zigbee_logger_eprxzcl.c:113:
+				"Received ZCL command but produced log is too long"); \

-:3626: WARNING:NEW_TYPEDEFS: do not add new typedefs
#3626: FILE: subsys/zigbee/osif/zb_nrf_platform.c:21:
+typedef enum {

-:3636: WARNING:NEW_TYPEDEFS: do not add new typedefs
#3636: FILE: subsys/zigbee/osif/zb_nrf_platform.c:31:
+typedef struct {

-:4063: WARNING:NEW_TYPEDEFS: do not add new typedefs
#4063: FILE: subsys/zigbee/osif/zb_nrf_platform.h:13:
+typedef enum {

-:4276: WARNING:NEW_TYPEDEFS: do not add new typedefs
#4276: FILE: subsys/zigbee/osif/zb_nrf_timer.c:17:
+typedef struct {

-:4441: WARNING:NEW_TYPEDEFS: do not add new typedefs
#4441: FILE: subsys/zigbee/osif/zb_nrf_transceiver.c:25:
+typedef struct nrf_802154_rx_frame {

-:5802: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5802: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:11:
+typedef char               zb_char_t;

-:5804: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5804: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:13:
+typedef unsigned char      zb_uchar_t;

-:5806: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5806: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:15:
+typedef unsigned char      zb_uint8_t;

-:5808: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5808: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:17:
+typedef signed char        zb_int8_t;

-:5810: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5810: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:19:
+typedef unsigned short     zb_uint16_t;

-:5812: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5812: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:21:
+typedef signed short       zb_int16_t;

-:5814: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5814: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:23:
+typedef void               zb_void_t;

-:5818: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5818: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:27:
+typedef enum zb_bool_e zb_bool_t;

-:5819: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5819: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:28:
+typedef unsigned int       zb_uint32_t;

-:5821: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5821: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:30:
+typedef zb_uint32_t zb_time_t;

-:5827: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5827: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:36:
+typedef zb_uint8_t zb_64bit_addr_t[8];

-:5832: WARNING:NEW_TYPEDEFS: do not add new typedefs
#5832: FILE: tests/subsys/zigbee/osif/timer/stubs/zb_types.h:41:
+typedef zb_64bit_addr_t zb_ieee_addr_t;

- total: 0 errors, 41 warnings, 5740 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Your patch has style problems, please review.

NOTE: Ignored message types: AVOID_EXTERNS BRACES CONFIG_EXPERIMENTAL CONST_STRUCT DATE_TIME FILE_PATH_CHANGES MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE NETWORKING_BLOCK_COMMENT_STYLE PRINTK_WITHOUT_KERN_LEVEL SPLIT_STRING VOLATILE

NOTE: If any of the errors are false positives, please report
      them to the maintainers.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@ru-fu ru-fu added the doc-required PR must not be merged without tech writer approval. label May 6, 2020
@ru-fu ru-fu requested a review from greg-fer May 6, 2020 06:47
@rlubos rlubos self-requested a review May 6, 2020 08:43
@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from 460a232 to a3146c7 Compare May 6, 2020 23:40
Copy link
Contributor

@greg-fer greg-fer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied my edits, so I'm approving.
Please check my commit and squash it.

Copy link
Contributor

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gone through the first commit so far, left some feedback. It seems that checkpatch covered also a good amount of issues, please fix those.

zephyr_sources(osif/zb_nrf_transceiver.c)
zephyr_sources(osif/zb_nrf_crypto.c)
zephyr_sources(osif/zb_nrf_pwr_mgmt.c)
zephyr_sources(osif/nrf_ecb_driver.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we should soon get this into fw-nrfconnect-zephyr, please remove it from the PR after it's merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove it now? You already have the Zephyr version in the tree. Or do you prefer to leave it as it is for the initial release? @wbober?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rlubos I would be keen on ditching this. @maciekfabia what do you think? This should be fairly simple?


config ZBOSS_DEFAULT_THREAD_STACK_SIZE
int "Stack size of ZBOSS Zephyr task"
default 2048 #ToDo: TBD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, have you found out a proper value yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will use this value. #Todo removed

LOG_MODULE_REGISTER(zigbee_helpers, CONFIG_ZIGBEE_HELPERS_LOG_LEVEL);

/* Rejoin-procedure related variables. */
static zb_uint8_t stack_initialised = ZB_FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be bool? Also, since these variables do not interface any zboss APIs, why not use native types instead (bool, u8_t etc)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed variables in this group to bool

#endif
}

int to_hex_str(char *out, uint16_t out_size, const uint8_t *in,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General note: we should rather use kernel types in NCS, wherever possible (u16_t etc.), but you probably already noticed from the checkpatch output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

sizeof(zb_ieee_addr_t), true);
}

uint8_t parse_hex_digit(const char c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zephyr provides some utils for hex string conversion, please consider using them to avoid code duplication:
https://github.com/zephyrproject-rtos/zephyr/blob/master/include/sys/util.h#L153

Copy link
Contributor Author

@maciekfabia maciekfabia May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parse_hex_digit replaced with char2hex from sys/util.h.
Other string-hex functions in this file can also convert in reverse order. They cannot be fully replaced because it's not available in their counterparts in utils.h but they probably could be much shorter if they used util.h functions.
I think it can be postponed to subsequent pull requests

#include <init.h>

#include "zb_nrf_platform.h"
#include "zboss_api.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <zboss_api.h>

LOG_ERR("Fatal error occurred");
k_fatal_halt(K_ERR_KERNEL_PANIC);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line.

/* Configure event/signals to wait for in wait_for_event function */
static struct k_poll_event wait_events[] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the indentation gone wild.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed after checkpatch report

ZB_SET_TRACE_OFF();

/* Disable Zigbee stack-related peripherals to save energy. */
/*zb_osif_priph_disable();*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove dead code.

* SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
*/

/* TODO: Change function names. The 'nrf52' prefix should be removed */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be done already?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the comment removed

@@ -0,0 +1,17 @@
/* Copyright (c) 2019 Nordic Semiconductor ASA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the file has been renamed to reflect the new board name

@@ -0,0 +1,32 @@
/* Copyright (c) 2019 Nordic Semiconductor ASA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020

#include <zboss_api.h>
#include <addons/zboss_api_addons.h>
#include <zb_mem_config_med.h>
#include <zigbee_helpers.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If zigbee_helpers.h is supposed to be a public header and used in applications, it should be moved to the include directory then. include/zigbee/zigbee_helpers.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are going to move zigbee_helpers.h to include directory but it requires some cleaning, some functions need to be removed/moved to other files, some need to be rewritten to make use of zephyr utilities.
After this is done the file could be moved and documented in NCS documentation but for this PR I'd prefer it to stay at its current location

@@ -0,0 +1,32 @@
/* Copyright (c) 2019 Nordic Semiconductor ASA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020

@rlubos
Copy link
Contributor

rlubos commented May 8, 2020

Looks good overall, some nits from my side plus you need to sort out the CI failures, otherwise we coul d get it in (once nrfxlib counterpart is merged).

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from c46d505 to 4a353ef Compare May 11, 2020 01:37
@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch 4 times, most recently from d088983 to d62fdc1 Compare May 12, 2020 17:02
@lemrey lemrey requested review from b-gent and lemrey May 13, 2020 12:06
@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch 2 times, most recently from d0b6251 to dc03d60 Compare May 13, 2020 22:53
@lemrey
Copy link
Contributor

lemrey commented May 14, 2020

had a very quick look and have two comments:

  • we should group the header files in their own folder under /include
  • let's use printk to print from the sample instead of the logger

@rlubos
Copy link
Contributor

rlubos commented May 14, 2020

let's use printk to print from the sample instead of the logger

Why so? I don't think there's a well-established convention for that in Zephyr (nor in NCS). Some samples use printk while others use logger (and some even switched to logger recently , see asset_tracker). IMO, with the flexibility logger gives, it's ok to use it.

Comment on lines 7 to 19
zephyr_include_directories(common)
zephyr_include_directories(osif)
zephyr_include_directories(zb_error)

# Source files
zephyr_sources(osif/zb_nrf_platform.c)
zephyr_sources(osif/zb_nrf_logger.c)
zephyr_sources(osif/zb_nrf_nvram.c)
zephyr_sources(osif/zb_nrf_timer.c)
zephyr_sources(osif/zb_nrf_transceiver.c)
zephyr_sources(osif/zb_nrf_crypto.c)
zephyr_sources(osif/zb_nrf_pwr_mgmt.c)
zephyr_sources(osif/nrf_ecb_driver.c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in independent lib, please use zephyr_library.
No need that all those files are placed directly in libzephyr.a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

bool "Include functions for CLI logging"
default y
help
Include functions for CLI logging.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not including log functions for the user.

Instead, it enables logging inside the Zigbee subsys, correct ?
Help text is not clear on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably due to historical reasons. This controls the eprxzcl component from nRF5 for T&Z SDK.
This dumps all received ZCL packets: eprxzcl == EndPoint R(x)eceive ZCL - packet dump.
By default, it was included in the Zigbee CLI example.

add_definitions(-Wno-packed-bitfield-compat)
add_definitions(-DTIMER_DEFAULT_CONFIG_IRQ_PRIORITY=6)

include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to use find_package(Zephyr ...)


cmake_minimum_required(VERSION 3.8)

add_definitions(-Wno-packed-bitfield-compat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here.
In Zephyr, those warnings are handled in the toolchain setup:
https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/cmake/compiler/gcc/target_warnings.cmake
and can be controlled using -DW=[1|2|3].

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning is generated by ZBOSS headers. The same definition is inside ZBOSS's CMakeLists.txt file. I'd remove it here and move the discussion to the nrfxlib's PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line removed.
This warning suppression is not specified in a sample or test but propagated from ZBOSS CMakeLists.txt

cmake_minimum_required(VERSION 3.8)

add_definitions(-Wno-packed-bitfield-compat)
add_definitions(-DTIMER_DEFAULT_CONFIG_IRQ_PRIORITY=6)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something that should have been in a configuration file.
Kconfig ?
Secondly, I can't find the place where it is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed any more. Removed

# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#

cmake_minimum_required(VERSION 3.8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.13)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 13 to 15
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
set(DTC_OVERLAY_FILE "${DTC_OVERLAY_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work with when using deprecated board names nor aliased board names.
Please remove.

Board overlays are handled in Zephyr build system, when named correctly.
See https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/master/cmake/app/boilerplate.cmake#L463-L471

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overlay files have been combined into one and renamed to app.overlay

endif()

include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use: find_package(Zephyr ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment on lines 9 to 11
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay")
set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove those lines and rename dts.overlay to app.overlay

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

endif()

include($ENV{ZEPHYR_BASE}/../nrf/cmake/boilerplate.cmake)
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use: find_package(Zephyr ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@lemrey
Copy link
Contributor

lemrey commented May 14, 2020

We (I) have been trying to let samples print to the console using printk instead of the logger in NCS, and there are several reasons for that.

The first is that printk has a predictable and consistent behavior while the logger is a very configurable subsystem and it can behave totally different based on its configuration. It's good that samples print to the console consistently and that would be hard to do if they used the logger (log level/ buffer sizes/ deferred, etc). If one sample used a 4k buf for the logger, for a good reason, that'll be copy-pasted until the end of time in many samples that could have worked perfectly with the default instead; this applies of course to every option in the logger.

A second reason is readability of the output. When logging is enabled, it is enabled system-wide; that can generate a lot of output coming from subsystems and libraries (unless explicitely disabled, one by one). I argue that when running a sample, the user doesn't care much about what's happening in all subsys and libs in use, but more about what the sample is doing. If a sample prints 20 lines after booting, it's harder for the user to see if it is behaving as expected, because they have to "fish" the lines they are interested in among 20. Instead, if logging is not enabled (or enabled only for wrn/err/assert via NCS_SAMPLES_DEFAULT), the sample has full control of the output on the console and it is easy to follow what the sample is doing. It's also easy to document the expected output on the console.

asset_tracker is an application, not a sample /samples vs /application, they are different from samples and also more complex, so they are treated separately.

@rlubos
Copy link
Contributor

rlubos commented May 14, 2020

A little offtop.

@lemrey
It's not that I completely disagree with you (maybe except for the lest paragraph, I don't buy it). printk is simple and it has its use cases. But it also has its flaws - for instance if you enable logger when printk is used, the output will likely get messed up, unless you know that "special" switch to pipe printk via the logger (or use the minimal logger variant). And a lot of samples in NCS start off with logger being enabled anyway so I don't think that log bloat is the case here (you can always lower LOG_DEFAULT_LEVEL if that's a problem, I don't think that error level logs can be considerer as undesired - if they show up, something definintely is not correct).

The point is, we have not written down any "best practicies" guide for the samples, so it's hard to enforce such requests based on reviewer preference. For intstance, recently I was reviewing PR upstream, where it was explicitly requested to use logger in the sample (even though it was only writng down a greeting message), there's no consensus. I'm not saying we should follow upstream Zephyr blindy here. But if we want to have a NCS set of rules, we should at least write them down and get accepted, only then we'll have a basis to enforce them.

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from dc03d60 to 7e32f54 Compare May 14, 2020 15:26
Copy link

@ru-fu ru-fu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good!
But we're missing a few links within the documentation. And I guess library documentation and the third sample are planned for later?

@@ -21,3 +21,4 @@ They introduce you to important concepts and guide you through developing your a
ug_bootloader
ug_unity_testing
ug_thread
ug_zigbee
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one and the Thread user guide should go under ug_thingy91 (to keep the "Working with" user guides together).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved.


Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh network.
It also defines an application layer that provides interoperability among all vendors.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we link somewhere for more information? (Probably the Zigbee Alliance?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, good point.

Introduction
************

Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh network.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh network.
Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh networks.

or

Suggested change
Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh network.
Zigbee is a portable, low-power software networking protocol that provides connectivity over an 802.15.4-based mesh network.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went for the 2nd one.

Zigbee is a portable, low-power software networking protocol that provides connectivity over 802.15.4-based mesh network.
It also defines an application layer that provides interoperability among all vendors.

In combination with Zephyr RTOS and |NCS|, Zigbee allows for easy development of low-power connected solutions.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zephyr is part of the NCS package, thus either just "In combination with |NCS|," or "In combination with |NCS| and the integrated Zephyr RTOS,".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2nd option adopted.


See :ref:`zigbee_samples` for the list of available Zigbee samples.

.. |zboss_lib| replace:: The |NCS|'s Zigbee protocol uses the ZBOSS library, a third-party precompiled Zigbee stack.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to ZBOSS?

Copy link
Contributor

@greg-fer greg-fer May 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, once it's available. Will work on this with @b-gent .


This Zigbee network coordinator sample establishes the Zigbee network and commissions Zigbee devices that want to join it.

You can use this sample together with :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` and Zigbee light switch to set up a basic Zigbee network.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can use this sample together with :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` and Zigbee light switch to set up a basic Zigbee network.
You can use this sample together with the :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` and Zigbee light switch to set up a basic Zigbee network.


* One or both of the following samples:

* The :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` application programmed on one or more separate devices.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` application programmed on one or more separate devices.
* The :ref:`Zigbee light bulb <zigbee_light_bulb_sample>` sample programmed on one or more separate devices.

* |nRF52840Dongle|
* |nRF52833DK|

* The :ref:`Zigbee network coordinator <zigbee_network_coordinator_sample>` application programmed on one separate device.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* The :ref:`Zigbee network coordinator <zigbee_network_coordinator_sample>` application programmed on one separate device.
* The :ref:`Zigbee network coordinator <zigbee_network_coordinator_sample>` sample programmed on one separate device.

Indicates whether the network is open or closed.

.. note::
When you use the coordinator on the |nRF52840Dongle|, it is the LED 3 that informs about the successful network joining.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as for the other sample.


After programming the sample to your development kit, test it by performing the following steps:

1. Turn on the coordinator development kit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above ;)

@lemrey
Copy link
Contributor

lemrey commented May 14, 2020

I agree @rlubos; we had a draft for these guidelines in Confluence, perhaps we could make it available so that it is visible for everybody?

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from 7e32f54 to 8cc61dc Compare May 15, 2020 00:27
@wbober
Copy link
Contributor

wbober commented May 15, 2020

@ru-fu Light switch sample and ZBOSS lib are in separate PRs.

Copy link
Contributor

@greg-fer greg-fer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ru-fu , thank you for your comments and feedback. I've implemented the changes in a review branch: https://github.com/maciekfabia/fw-nrfconnect-nrf/tree/add_zigbee_subsystem_review
This will be merged into this one.

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch 2 times, most recently from fb61a37 to 05a3247 Compare May 18, 2020 10:04
@maciekfabia
Copy link
Contributor Author

  • we should group the header files in their own folder under /include

We are going to do so but it requires some cleaning, refinement and documenting. For this PR I'd prefer them to stay at its current location and move them in next pull requests
Also, most of the headers are for internal use only.

@maciekfabia
Copy link
Contributor Author

@tejlmand, we addressed all comments, could you please take a look?

Copy link
Contributor

@tejlmand tejlmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better, but still a couple of comments to be addressed.

Comment on lines +7 to +11
zephyr_interface_library_named(zigbee)

target_include_directories(zigbee INTERFACE common)
target_include_directories(zigbee INTERFACE osif)
target_include_directories(zigbee INTERFACE zb_error)
Copy link
Contributor

@tejlmand tejlmand May 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is an interface target needed here ?
and not simple using zephyr_library_include_directories() on the lib below.

Nevermind. Found APP_LINK_WITH_ZIGBEE in Kconfig.
Disregard this comment.

Comment on lines 15 to 17
zephyr_include_directories(${ZEPHYR_BASE}/../nrf/subsys/zigbee/osif)
zephyr_include_directories(${ZEPHYR_BASE}/../nrfxlib/zboss/include)
zephyr_include_directories(${ZEPHYR_BASE}/../nrfxlib/zboss/include/osif)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to use: ${ZEPHYR_NRFXLIB_MODULE_DIR} here, instead of: ${ZEPHYR_BASE}/../nrfxlib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with ${NRFXLIB_DIR} for now. Will be replaced with ${ZEPHYR_NRFXLIB_MODULE_DIR} once it's available in fw-nrfconnect-zephyr

target_sources(app PRIVATE
src/main.c
${ZEPHYR_BASE}/../nrf/subsys/zigbee/osif/zb_nrf_crypto.c
${ZEPHYR_BASE}/../nrf/subsys/zigbee/osif/nrf_ecb_driver.c
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to use: ${ZEPHYR_NRF_MODULE_DIR} here, instead of: ${ZEPHYR_BASE}/../nrf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced with ${NRF_DIR}

Comment on lines 9 to 11
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay")
set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines are still present.

Copy link
Contributor

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no further comments for now. Let's address the remaining issues (moving the header to public location, switching to printk) in seprate PRs, if time permits, since they're not ciritcal. And it's really cumbersome to deal with such a large PR.

@maciekfabia
Copy link
Contributor Author

maciekfabia commented May 19, 2020

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay") set(DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/dts.overlay") endif()

Lines are still present.

sorry, my mistake. Removed

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from 7896c95 to b1a97e3 Compare May 19, 2020 14:12
@rlubos
Copy link
Contributor

rlubos commented May 19, 2020

@maciekfabia Please update west.yml with correct SHA: 0b0049b

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from b1a97e3 to 7eb99d4 Compare May 19, 2020 14:36
@lemrey
Copy link
Contributor

lemrey commented May 19, 2020

I'd rather have the public headers under /include in this PR, but if we are short on time it's fine to merge this as is, as long as we agree that they are going to be moved afterwards.

@rlubos
Copy link
Contributor

rlubos commented May 19, 2020

Thanks @lemrey, @maciekfabia promised to fix this later: #2208 (comment)

@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from 7eb99d4 to 80fc3b6 Compare May 21, 2020 10:16
@CLAassistant
Copy link

CLAassistant commented May 21, 2020

CLA assistant check
All committers have signed the CLA.

Add zigbee subsystem and related tests

Signed-off-by: Maciej Fabia <[email protected]>
Add Zigbee samples:
- network coordinator
- light bulb

Signed-off-by: Maciej Fabia <[email protected]>
@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from 80fc3b6 to ef95492 Compare May 21, 2020 11:18
Add owners for zigbee subsys, samples and tests

Signed-off-by: Maciej Fabia <[email protected]>
@maciekfabia maciekfabia force-pushed the add_zigbee_subsystem branch from ef95492 to 497d509 Compare May 21, 2020 13:08
@wbober
Copy link
Contributor

wbober commented May 22, 2020

@carlescufi Can we merge this please?

@rlubos rlubos merged commit bbbd85d into nrfconnect:master May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-required PR must not be merged without tech writer approval.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants