Skip to content

Commit

Permalink
osif: Adapt ZBOSS thread routine in NCP mode
Browse files Browse the repository at this point in the history
There is an implementation of zboss_app_main() in the ZBOSS library.
The modification is to use it in NCP mode instead of the previous
stack thread procedure as the latter has become incompatible.

The mentioned implementation has been slightly adapted to nRF5,
hence the update of libncp-dev as well.

Signed-off-by: Adam Zelik <[email protected]>
  • Loading branch information
AdamZelikNS committed Dec 3, 2024
1 parent d3e2e90 commit 9c0a45b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/zboss/production/include/osif/zb_ncp_nrf_platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2020 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/* PURPOSE: NCP platform API elements for nRF SoC.
*/

#ifndef ZB_NCP_NRF_PLATFORM_H__
#define ZB_NCP_NRF_PLATFORM_H__

/* Main ZBOSS stack routine in NCP mode.
*
* The implementation is in the ZBOSS library.
* The name and signature are determined by the MAIN macro in zb_config_platform.h
* and this is established at the library building stage.
*/
int zboss_app_main(void);

/* Callout function called in zboss_app_main() right after starting ZBOSS. */
void zb_ncp_app_fw_custom_post_start(void);

#endif /* ZB_NCP_NRF_PLATFORM_H__ */
Binary file modified lib/zboss/production/lib/cortex-m33/hard-float/libncp-dev.a
Binary file not shown.
Binary file modified lib/zboss/production/lib/cortex-m33/hard-float/libncp-dev.ed.a
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions subsys/osif/zb_nrf_platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "zb_nrf_crypto.h"

#ifdef CONFIG_ZIGBEE_LIBRARY_NCP_DEV
#include <zb_ncp_nrf_platform.h>
#define SYS_REBOOT_NCP 0x10
#endif /* CONFIG_ZIGBEE_LIBRARY_NCP_DEV */

Expand Down Expand Up @@ -342,8 +343,19 @@ int zigbee_init(void)
return 0;
}

#if IS_ENABLED(CONFIG_ZIGBEE_LIBRARY_NCP_DEV)
void zb_ncp_app_fw_custom_post_start(void)
{
stack_is_started = true;
#ifdef CONFIG_ZIGBEE_SHELL
zb_shell_configure_endpoint();
#endif /* defined(CONFIG_ZIGBEE_SHELL) */
}
#endif

static void zboss_thread(void *arg1, void *arg2, void *arg3)
{
#if !IS_ENABLED(CONFIG_ZIGBEE_LIBRARY_NCP_DEV)
zb_ret_t zb_err_code;

zb_err_code = zboss_start_no_autostart();
Expand All @@ -357,6 +369,13 @@ static void zboss_thread(void *arg1, void *arg2, void *arg3)
while (1) {
zboss_main_loop_iteration();
}

#else /* CONFIG_ZIGBEE_LIBRARY_NCP_DEV */
/* For NCP mode, the thread implementation (i.e. some initialization part
* and main loop) is in the ZBOSS library.
*/
zboss_app_main();
#endif
}

zb_bool_t zb_osif_is_inside_isr(void)
Expand Down

0 comments on commit 9c0a45b

Please sign in to comment.