Skip to content
Closed
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
18 changes: 18 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,21 @@ rsource "drivers/Kconfig"

config ALIRO_PRINT_READER_GROUP_ID
bool "Print reader group ID that should be provisioned into the User Device"

config ALIRO_BLE_TP
bool "Aliro BLE transport"
help
Enable the Aliro BLE transport protocol (TP). This is the transport layer
used by Reader to communicate with the User Device. It is used to send and
receive packets over BLE.

if ALIRO_BLE_TP

config ALIRO_BLE_TP_MAX_SESSIONS
int "Maximum number of BLE sessions"
default BT_MAX_CONN
help
The maximum number of BLE sessions that can be established.

rsource "lib/aliro/Kconfig.ble.defconfig"
endif # ALIRO_BLE_TP
28 changes: 16 additions & 12 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,33 @@ cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(door-lock-app)

FILE(GLOB app_sources src/*.cpp)
file(GLOB app_sources CONFIGURE_DEPENDS src/*.cpp)

add_subdirectory(src/nfc_transport_impl)
add_subdirectory(src/platform)

target_sources(app PRIVATE
${app_sources}
)
target_sources(app PRIVATE ${app_sources})

set(ALIRO_LIB_DIR ${ZEPHYR_NCS_DOOR_LOCK_APP_MODULE_DIR}/lib/aliro)
set(PUBLIC_API ${ZEPHYR_NCS_ALIRO_MODULE_DIR})

if(CONFIG_SOC_SERIES_NRF52X)
set(ALIRO_LIB_BIN_PATH ${ALIRO_LIB_DIR}/bin/cortex-m4)
set(ALIRO_LIB_PATH ${ZEPHYR_NCS_ALIRO_MODULE_DIR}/applications/doorlock/lib/aliro/bin/cortex-m4)
elseif(CONFIG_SOC_SERIES_NRF54LX OR CONFIG_SOC_SERIES_NRF53X)
set(ALIRO_LIB_BIN_PATH ${ALIRO_LIB_DIR}/bin/cortex-m33)
set(ALIRO_LIB_PATH ${ZEPHYR_NCS_ALIRO_MODULE_DIR}/applications/doorlock/lib/aliro/bin/cortex-m33)
endif()

add_library(aliro_stack STATIC IMPORTED GLOBAL)

set_target_properties(aliro_stack PROPERTIES IMPORTED_LOCATION ${ALIRO_LIB_BIN_PATH}/libaliro.a)
if(CONFIG_ALIRO_BLE_TP)
set_target_properties(aliro_stack PROPERTIES IMPORTED_LOCATION ${ALIRO_LIB_PATH}/libaliro_ble.a)
else(CONFIG_ALIRO_BLE_TP)
set_target_properties(aliro_stack PROPERTIES IMPORTED_LOCATION ${ALIRO_LIB_PATH}/libaliro.a)
endif(CONFIG_ALIRO_BLE_TP)

target_link_libraries(app PRIVATE aliro_stack)
target_link_libraries(aliro_stack INTERFACE zephyr_interface)

zephyr_include_directories(${ALIRO_LIB_DIR}/include)
zephyr_include_directories(${ALIRO_LIB_DIR}/interfaces)
zephyr_include_directories(${ALIRO_LIB_DIR}/interfaces/crypto/backend_crypto_psa)
zephyr_include_directories(
${PUBLIC_API}/include
${PUBLIC_API}/interfaces
${PUBLIC_API}/interfaces/crypto/backend_crypto_psa
)
2 changes: 1 addition & 1 deletion app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

rsource "src/nfc_transport_impl/Kconfig"
rsource "src/platform/Kconfig"
rsource "../lib/aliro/Kconfig.defconfig"

menu "Zephyr"
Expand Down
13 changes: 13 additions & 0 deletions app/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "share/sysbuild/Kconfig"

config NRF_DEFAULT_IPC_RADIO
default y

config NETCORE_IPC_RADIO_BT_HCI_IPC
default y
2 changes: 1 addition & 1 deletion app/VERSION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_MINOR = 1
PATCHLEVEL = 0
VERSION_TWEAK = 0
EXTRAVERSION =
11 changes: 10 additions & 1 deletion app/boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
nucleo_nfc@0 {
compatible = "x-nucleo-nfc";
reg = <0>;
spi-max-frequency = <4000000>;
spi-max-frequency = <DT_FREQ_M(4)>;
irq-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 10 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>;
};
};

Expand All @@ -57,3 +58,11 @@
status = "okay";
};
};

/ {
access_decision_indicator: access_decision_indicator{
status = "okay";
compatible = "access-decision-indicator";
gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
};
};
8 changes: 8 additions & 0 deletions app/boards/nrf5340dk_nrf5340_cpuapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Enable BLE Transport Protocol
CONFIG_ALIRO_BLE_TP=y
12 changes: 10 additions & 2 deletions app/boards/nrf5340dk_nrf5340_cpuapp.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

};


&spi1 {
compatible = "nordic,nrf-spim";
status = "okay";
Expand All @@ -36,7 +35,16 @@
nucleo_nfc@0 {
compatible = "x-nucleo-nfc";
reg = <0>;
spi-max-frequency = <4000000>;
spi-max-frequency = <DT_FREQ_M(5)>;
irq-gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio1 10 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>;
};
};

/ {
access_decision_indicator: access_decision_indicator{
status = "okay";
compatible = "access-decision-indicator";
gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
};
};
6 changes: 6 additions & 0 deletions app/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
compatible = "nfc-power-control";
gpios = <&gpio2 6 ( GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN )>;
};

access_decision_indicator: access_decision_indicator{
status = "okay";
compatible = "access-decision-indicator";
gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>;
};
};

&gpio0 {
Expand Down
13 changes: 10 additions & 3 deletions app/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CONFIG_ASSERT=y
CONFIG_CONSOLE=y
CONFIG_LOG=y
CONFIG_NCS_ALIRO_RFAL_LOG_LEVEL_DBG=y
CONFIG_DEBUG_STATE_MACHINE=y
CONFIG_USE_SEGGER_RTT=n
CONFIG_LOG_BACKEND_RTT=n
CONFIG_LOG_BACKEND_SHOW_COLOR=n
Expand All @@ -27,14 +28,20 @@ CONFIG_SHELL_HISTORY=n
CONFIG_SHELL_WILDCARD=n

# Increase shell buffer sizes
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=512
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=2048
CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=1024

# Adjust logs queue size
CONFIG_SHELL_BACKEND_SERIAL_LOG_MESSAGE_QUEUE_SIZE=768
CONFIG_SHELL_BACKEND_SERIAL_LOG_MESSAGE_QUEUE_SIZE=2048

# Print reader key that can be provisioned to the User Device
CONFIG_ALIRO_PRINT_READER_GROUP_ID=y

# RFAL worker stack size (TODO: optimize)
CONFIG_RFAL_WORKER_THREAD_STACK_SIZE=8192

CONFIG_ACCESS_DECISION_INDICATOR=y

# Workaournd for Murata issue:
# https://github.com/csa-access-control/aliro-actuator/issues/114
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n
3 changes: 3 additions & 0 deletions app/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ common:
integration_platforms: *platforms
tests:
app.nfc_door_lock: {}
app.nfc_door_lock_src_no:
extra_args:
- CONFIG_NCS_ALIRO_SRC=n
40 changes: 33 additions & 7 deletions app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,58 @@
#include <zephyr/logging/log.h>
#include <zephyr/shell/shell.h>

#ifdef CONFIG_ACCESS_DECISION_INDICATOR
#include "access_decision_indicator.h"
#endif // CONFIG_ACCESS_DECISION_INDICATOR

#include <cstdio>
#include <stdlib.h>

LOG_MODULE_REGISTER(door_lock_app, CONFIG_NCS_DOOR_LOCK_APP_LOG_LEVEL);

using namespace Aliro;
using namespace Aliro::Access;

int main()
{
AliroError ec{};
LOG_INF("Starting nRF Door Lock Reference Application for the nRF Connect SDK");

AliroError ec = Aliro::AliroStack::Instance().Init(
#ifdef CONFIG_ACCESS_DECISION_INDICATOR
VerifyOrReturnValue(Indicator::InitAccessDecisionIndicator() == ALIRO_NO_ERROR, EXIT_FAILURE,
LOG_ERR("Failed to initialize access decision indicator"));
#endif // CONFIG_ACCESS_DECISION_INDICATOR

const AliroConfig config{
#ifdef CONFIG_ALIRO_BLE_TP
.mMaxBleSessions = CONFIG_ALIRO_BLE_TP_MAX_SESSIONS,
#endif // CONFIG_ALIRO_BLE_TP
};

ec = AliroStack::Instance().Init(
{ .mOnAccessAttempt =
[](Aliro::Access::Status status) {
if (status == Aliro::Access::Status::Denied) {
[](Status status) {
if (status == Status::Denied) {
LOG_INF("ACCESS DENIED");
} else {
LOG_INF("ACCESS GRANTED");
#ifdef CONFIG_ACCESS_DECISION_INDICATOR
Indicator::SignalAccessGranted();
#endif // CONFIG_ACCESS_DECISION_INDICATOR
}
},
.mOnError = [](AliroError error) { LOG_ERR("Aliro error: %s", error.ToString()); } });
.mOnError = [](AliroError error) { LOG_ERR("Aliro error: %s", error.ToString()); } },
config);

VerifyOrDie(ec == ALIRO_NO_ERROR, "Aliro stack initialization failed");

ec = Aliro::AliroStack::Instance().Start();
ec = AliroStack::Instance().Start();

VerifyOrDie(ec == ALIRO_NO_ERROR, "Aliro stack start failed");

Aliro::RegisterShellCommands();
RegisterShellCommands();

LOG_INF("Application started");

return 0;
return EXIT_SUCCESS;
}
14 changes: 14 additions & 0 deletions app/src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

zephyr_include_directories(.)

add_subdirectory(nfc_transport_impl)
add_subdirectory(logger)

add_subdirectory_ifdef(CONFIG_ALIRO_BLE_TP ble)
add_subdirectory_ifdef(CONFIG_ALIRO_BLE_TP uwb_impl)
add_subdirectory_ifdef(CONFIG_ACCESS_DECISION_INDICATOR access_decision_indicator)
12 changes: 12 additions & 0 deletions app/src/platform/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

rsource "access_decision_indicator/Kconfig"
rsource "nfc_transport_impl/Kconfig"

if ALIRO_BLE_TP
rsource "uwb_impl/Kconfig"
endif # ALIRO_BLE_TP
11 changes: 11 additions & 0 deletions app/src/platform/access_decision_indicator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

zephyr_include_directories(.)

file(GLOB impl_src CONFIGURE_DEPENDS *.cpp)

zephyr_library_sources(${impl_src})
17 changes: 17 additions & 0 deletions app/src/platform/access_decision_indicator/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config ACCESS_DECISION_INDICATOR
bool "Enable access decision indicator"

config RESET_ACCESS_DECISION_INDICATOR_STATE_DELAY_MS
int "Access decision indicator reset state delay (ms)"
depends on ACCESS_DECISION_INDICATOR
default 1000
help
Specifies how long (in milliseconds) the access indicator (e.g. LED) remains active before automatically
resetting to its default state. This is useful to provide a visual indication of the access decision made
by a Aliro Access Manager (e.g. LED indication).
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include "access_decision_indicator.h"

#include "aliro/utils.h"

#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>

namespace {

constexpr int kDelayMs{ CONFIG_RESET_ACCESS_DECISION_INDICATOR_STATE_DELAY_MS };
constexpr int kLedOn{ 1 };
constexpr int kLedOff{ 0 };
constexpr gpio_dt_spec kAccessGrantedLed = GPIO_DT_SPEC_GET(DT_NODELABEL(access_decision_indicator), gpios);

static K_WORK_DELAYABLE_DEFINE(ResetIndicatorStateWork,
[]([[maybe_unused]] k_work *) { (void)gpio_pin_set_dt(&kAccessGrantedLed, kLedOff); });

} // namespace

namespace Aliro::Access::Indicator {

AliroError InitAccessDecisionIndicator()
{
VerifyOrReturnStatus(gpio_is_ready_dt(&kAccessGrantedLed), ALIRO_ERROR_INTERNAL);
VerifyOrReturnStatus(gpio_pin_configure_dt(&kAccessGrantedLed, GPIO_OUTPUT_INACTIVE) == 0,
ALIRO_ERROR_INTERNAL);

return ALIRO_NO_ERROR;
}

void SignalAccessGranted()
{
(void)gpio_pin_set_dt(&kAccessGrantedLed, kLedOn);
(void)k_work_schedule(&ResetIndicatorStateWork, K_MSEC(kDelayMs));
}

} // namespace Aliro::Access::Indicator
Loading
Loading