Skip to content

Commit

Permalink
Add Zephyr OS Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mtalat committed Sep 14, 2022
1 parent be8230e commit cde6987
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
13 changes: 12 additions & 1 deletion source/interface/log_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ void vLoggingPrintf( const char * pcFormat,
#define NceOSLogError( format, ... ) vLoggingPrintf( format, ## __VA_ARGS__ )
#define NceOSLogWarn( format, ... ) vLoggingPrintf( format, ## __VA_ARGS__ )

#else
#elif defined( __ZEPHYR__ )
#include <zephyr/logging/log.h>

/**
* @brief implementation of logging macros for ZEPHYR OS.
*/
#define NceOSLogInfo( ... ) LOG_INF( __VA_ARGS__ )
#define NceOSLogDebug( ... ) LOG_DBG( __VA_ARGS__ )
#define NceOSLogError( ... ) LOG_ERR( __VA_ARGS__ )
#define NceOSLogWarn( ... ) LOG_WRN( __VA_ARGS__ )

#else /* ifdef FREERTOS */

/**
* @brief Define the abbreviated logging macros.
Expand Down
4 changes: 4 additions & 0 deletions source/nce_iot_c_sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <stdio.h>
#include "log_interface.h"

#ifdef __ZEPHYR__
LOG_MODULE_REGISTER( NCE_SDK, CONFIG_NCE_SDK_LOG_LEVEL );
#endif /* ifdef __ZEPHYR__ */

#ifdef NCE_DEVICE_AUTHENTICATOR

/**
Expand Down
17 changes: 17 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2022 1NCE
# 1NCE IoT C SDK (ZEPHYR OS Module)
#

set(NCE_SDK_DIR ${ZEPHYR_CURRENT_MODULE_DIR})
zephyr_library()
zephyr_include_directories(${NCE_SDK_DIR}/source/include)
zephyr_include_directories(${NCE_SDK_DIR}/source/interface)
zephyr_library_sources(
${NCE_SDK_DIR}/source/nce_iot_c_sdk.c
)

zephyr_compile_definitions_ifdef(CONFIG_NCE_DEVICE_AUTHENTICATOR NCE_DEVICE_AUTHENTICATOR)
zephyr_compile_definitions_ifdef(CONFIG_NCE_ENERGY_SAVER NCE_ENERGY_SAVER)
zephyr_compile_definitions(
NCE_SDK_CONNECT_ATTEMPTS=${CONFIG_NCE_SDK_CONNECT_ATTEMPTS})
33 changes: 33 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (c) 2022 1NCE
# 1NCE IoT C SDK (ZEPHYR OS Module)
#

config ZEPHYR_NCE_SDK_MODULE
bool "1NCE IoT C SDK"


if ZEPHYR_NCE_SDK_MODULE

config NCE_DEVICE_AUTHENTICATOR
bool "Enable 1NCE Device Authenticator"
default y
help
use 1nce device authenticator to retrieve DTLS Security credentials.

config NCE_ENERGY_SAVER
bool "Enable 1NCE Energy Saver"
default y
help
use 1nce energy saver to optimize payload size.

config NCE_SDK_CONNECT_ATTEMPTS
int "Max connection attempts to 1NCE server"
default 5


module = NCE_SDK
module-str = NCE_SDK
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

endif # ZEPHYR_NCE_SDK_MODULE
12 changes: 12 additions & 0 deletions zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2022 1NCE
# 1NCE IoT C SDK (ZEPHYR OS Module)
#

name: nce-sdk

build:
cmake: zephyr
kconfig: zephyr/Kconfig
depends:
- nrfxlib

0 comments on commit cde6987

Please sign in to comment.