From 1465a5bcea6501fcd8969d4b3095694dbbf24586 Mon Sep 17 00:00:00 2001 From: Pete Skeggs Date: Fri, 10 Jan 2025 16:30:49 -0800 Subject: [PATCH] samples: cellular: nrf_cloud_ble_gateway: Licenses Add licenses. Update apricity board files. Address compliance failures. Signed-off-by: Pete Skeggs --- .../boards/apricity_gateway_nrf9160_ns.conf | 2 - .../apricity_gateway_nrf9160/CMakeLists.txt | 4 +- .../arm/apricity_gateway_nrf9160/Kconfig | 4 +- .../apricity_gateway_nrf9160/Kconfig.board | 4 +- .../Kconfig.defconfig | 7 +- .../apricity_gateway_nrf9160.dts | 8 +- .../apricity_gateway_nrf9160.yaml | 1 - .../apricity_gateway_nrf9160_common.dts | 18 ++- .../apricity_gateway_nrf9160_defconfig | 3 + .../apricity_gateway_nrf9160_ns.dts | 4 +- .../apricity_gateway_nrf9160_ns.yaml | 6 +- .../apricity_gateway_nrf9160_ns_defconfig | 10 +- ...pricity_gateway_nrf9160_partition_conf.dts | 6 +- .../arm/apricity_gateway_nrf9160/board.cmake | 11 +- .../nordic,nrf9160dk-nrf52840-boot.yaml | 4 +- .../nordic,nrf9160dk-nrf52840-interface.yaml | 4 +- .../nordic,nrf9160dk-nrf52840-reset.yaml | 4 +- .../apricity_gateway_nrf9160/nrf52840_reset.c | 5 +- .../pre_dt_board.cmake | 4 +- .../boards/nrf9160dk_nrf9160_0_14_0.overlay | 10 +- .../nrf_cloud_ble_gateway/src/ble/README.rst | 122 ++++++++++------ .../ble/apricity_gateway_nrf9160ns.overlay | 5 - .../nrf_cloud_ble_gateway/src/ble/ble.c | 19 +-- .../nrf_cloud_ble_gateway/src/ble/ble.h | 5 +- .../nrf_cloud_ble_gateway/src/ble/ble_codec.c | 32 +++-- .../nrf_cloud_ble_gateway/src/ble/ble_codec.h | 7 +- .../src/ble/ble_conn_mgr.c | 7 +- .../src/ble/ble_conn_mgr.h | 7 +- .../src/ble/certificates.h | 27 ---- .../nrf_cloud_ble_gateway/src/ble/cli.c | 75 ++++------ .../src/ble/dfu/peripheral_dfu.c | 131 +++++++++--------- .../src/ble/dfu/peripheral_dfu.h | 7 +- .../src/ble/flash/CMakeLists.txt | 4 +- .../src/ble/flash/flash_test.c | 13 +- .../src/ble/flash/include/flash_test.h | 5 + .../nrf_cloud_ble_gateway/src/ble/gateway.c | 9 +- .../nrf_cloud_ble_gateway/src/ble/gateway.h | 5 + .../src/ble/ui/CMakeLists.txt | 4 +- .../nrf_cloud_ble_gateway/src/ble/ui/Kconfig | 2 +- .../src/ble/ui/include/led_effect.h | 5 +- .../src/ble/ui/include/led_pwm.h | 6 +- .../src/ble/ui/include/ui.h | 8 +- .../src/ble/ui/led_pwm.c | 5 +- .../nrf_cloud_ble_gateway/src/ble/ui/ui.c | 5 +- .../src/cloud_connection.c | 2 +- .../nrf_cloud_ble_gateway/src/fota_support.c | 2 +- .../nrf_cloud_ble_gateway/src/fota_support.h | 2 +- .../nrf_cloud_ble_gateway/src/message_queue.c | 2 +- 48 files changed, 332 insertions(+), 310 deletions(-) delete mode 100644 samples/cellular/nrf_cloud_ble_gateway/src/ble/apricity_gateway_nrf9160ns.overlay delete mode 100644 samples/cellular/nrf_cloud_ble_gateway/src/ble/certificates.h diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/apricity_gateway_nrf9160_ns.conf b/samples/cellular/nrf_cloud_ble_gateway/boards/apricity_gateway_nrf9160_ns.conf index f1a81f3399a8..057fb3d976db 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/apricity_gateway_nrf9160_ns.conf +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/apricity_gateway_nrf9160_ns.conf @@ -6,5 +6,3 @@ # Apricity CONFIG_ENTER_52840_MCUBOOT_VIA_BUTTON=y -CONFIG_NRF_CLOUD_HOST_NAME="mqtt.beta.nrfcloud.com" -CONFIG_NRF_CLOUD_SEC_TAG=42 diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/CMakeLists.txt b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/CMakeLists.txt index 1bc049576d08..fd96983f872e 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/CMakeLists.txt +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/CMakeLists.txt @@ -1,8 +1,8 @@ # Kconfig - APRICITY GATEWAY NRF9160 board configuration # -# Copyright (c) 2020 Nordic Semiconductor ASA +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause zephyr_library() zephyr_library_sources(nrf52840_reset.c) diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig index ee2a314ecb7d..eedfc09b2a47 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig @@ -1,8 +1,8 @@ # Apricity Gateway nRF9160 board configuration # -# Copyright (c) 2020 Nordic Semiconductor ASA +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause module=BOARD module-dep=LOG diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.board b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.board index a1b9b0597777..0b3c8207e1a6 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.board +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.board @@ -1,8 +1,8 @@ # Apricity Gateway nRF9160 board configuration # -# Copyright (c) 2020 Nordic Semiconductor ASA +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause if SOC_NRF9160_SICA diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.defconfig b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.defconfig index b904a05ef101..af8da70dae3c 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.defconfig +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/Kconfig.defconfig @@ -1,8 +1,8 @@ # Apricity Gateway nRF9160 board configuration # -# Copyright (c) 2020 Nordic Semiconductor ASA +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause if BOARD_APRICITY_GATEWAY_NRF9160 || BOARD_APRICITY_GATEWAY_NRF9160_NS @@ -34,9 +34,6 @@ endif # BUILD_WITH_TFM # Apply this configuration below by setting the Kconfig symbols used by # the linker according to the information extracted from DT partitions. -# Workaround for not being able to have commas in macro arguments -DT_CHOSEN_Z_CODE_PARTITION := zephyr,code-partition - config FLASH_LOAD_SIZE default $(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_CODE_PARTITION)) depends on BOARD_APRICITY_GATEWAY_NRF9160 && TRUSTED_EXECUTION_SECURE diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.dts b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.dts index ce68675fd446..b9724ab24b0c 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.dts +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.dts @@ -1,7 +1,7 @@ /* - * Copyright (c) 2020 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /dts-v1/; @@ -10,10 +10,8 @@ / { chosen { - zephyr,sram = &sram0_s; + zephyr,sram = &sram0; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; - zephyr,sram-secure-partition = &sram0_s; - zephyr,sram-non-secure-partition = &sram0_ns; }; }; diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.yaml b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.yaml index fab8c739c5b2..595d702ab954 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.yaml +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160.yaml @@ -13,5 +13,4 @@ supported: - i2c - pwm - spi - - watchdog - counter diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_common.dts b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_common.dts index 7b7895bc6ad1..d36ad93eff12 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_common.dts +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_common.dts @@ -1,7 +1,7 @@ /* - * Copyright (c) 2024 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ / { @@ -12,7 +12,7 @@ zephyr,console = &uart0; zephyr,shell-uart = &uart0; zephyr,uart-mcumgr = &uart0; - zephyr,bt-uart=&uart1; + zephyr,bt-hci=&bt_hci_uart; }; buttons { @@ -266,6 +266,10 @@ pinctrl-0 = <&uart1_default>; pinctrl-1 = <&uart1_sleep>; pinctrl-names = "default", "sleep"; + bt_hci_uart: bt_hci_uart { + compatible = "zephyr,bt-hci-uart"; + status = "okay"; + }; }; &flash0 { @@ -294,8 +298,12 @@ slot1_ns_partition: partition@c0000 { label = "image-1-nonsecure"; }; + scratch_partition: partition@f0000 { + label = "image-scratch"; + reg = <0x000f0000 0xa000>; + }; /* 0xf0000 to 0xf7fff reserved for TF-M partitions */ - storage_partition: partition@f8000 { + storage_partition: partition@fa000 { label = "storage"; reg = <0x000f8000 0x00008000>; }; @@ -313,7 +321,7 @@ /* Secure image memory */ }; - sram0_modem: image_modem@20016000 { + sram0_bsd: image_modem@20010000 { /* Modem (shared) memory */ }; diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_defconfig b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_defconfig index 79a88714e5d1..0c1655816494 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_defconfig +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_defconfig @@ -23,3 +23,6 @@ CONFIG_SERIAL=y # Enable console CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y + +# Disable entropy driver, as it's not yet implemented for nRF9160 +CONFIG_ENTROPY_NRF5_RNG=n diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.dts b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.dts index 187b7f905fed..a74979467523 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.dts +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.dts @@ -1,7 +1,7 @@ /* - * Copyright (c) 2020 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /dts-v1/; diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.yaml b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.yaml index d650d41d2884..0b6839722f22 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.yaml +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns.yaml @@ -1,18 +1,16 @@ -identifier: apricity_gateway_nrf9160ns +identifier: apricity_gateway_nrf9160_ns name: APRICITY_GATEWAY-nRF9160-Non-Secure type: mcu arch: arm toolchain: - gnuarmemb - - xtools - zephyr ram: 128 -flash: 192 +flash: 256 supported: - serial - spi - i2c - pwm - - watchdog - netif:modem - gpio diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns_defconfig b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns_defconfig index 66877143339b..bd35a4c5c36c 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns_defconfig +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_ns_defconfig @@ -28,4 +28,12 @@ CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y # Disable entropy driver, as it's not yet implemented for nRF9160 -#CONFIG_ENTROPY_NRF5_RNG=n +CONFIG_ENTROPY_NRF5_RNG=n + +# Enable SPI +CONFIG_SPI=y + +# Disable entropy driver, as it's not yet implemented for nRF9160 +CONFIG_ENTROPY_NRF5_RNG=n + +CONFIG_BOOTLOADER_MCUBOOT=y diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_partition_conf.dts b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_partition_conf.dts index c3a90d0d71f0..505b07fc6028 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_partition_conf.dts +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/apricity_gateway_nrf9160_partition_conf.dts @@ -1,7 +1,7 @@ /* - * Copyright (c) 2020 Nordic Semiconductor ASA + * Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /* @@ -51,7 +51,7 @@ reg = <0x20000000 DT_SIZE_K(88)>; }; -&sram0_modem { +&sram0_bsd { reg = <0x20016000 DT_SIZE_K(40)>; }; diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/board.cmake b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/board.cmake index bc21208cf87f..3452af649bcc 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/board.cmake +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/board.cmake @@ -1,16 +1,11 @@ -# Copyright (c) 2019 Nordic Semiconductor ASA. -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic - -if(CONFIG_BOARD_APRICITY_GATEWAY_NRF9160_NS) - set(TFM_PUBLIC_KEY_FORMAT "full") -endif() +# Copyright (c) 2025 Nordic Semiconductor ASA. +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause if(CONFIG_TFM_FLASH_MERGED_BINARY) set_property(TARGET runners_yaml_props_target PROPERTY hex_file tfm_merged.hex) endif() -board_runner_args(jlink "--device=nRF9160_xxAA" "--speed=4000") +board_runner_args(jlink "--device=cortex-m33" "--speed=4000") board_runner_args(nrfjprog "--softreset") include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) -include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-boot.yaml b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-boot.yaml index 8c5b92d908ce..82b332dc562e 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-boot.yaml +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-boot.yaml @@ -1,5 +1,5 @@ -# Copyright (c) 2023 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # NOTE: This file is replicated in nrf9160dk_nrf9160 and nrf9160dk_nrf52840. # Any changes should be done in both instances. diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-interface.yaml b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-interface.yaml index 4b58b15317a5..5a841580581a 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-interface.yaml +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-interface.yaml @@ -1,5 +1,5 @@ -# Copyright (c) 2021 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # NOTE: This file is replicated in nrf9160dk_nrf9160 and nrf9160dk_nrf52840. # Any changes should be done in both instances. diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-reset.yaml b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-reset.yaml index 1804fc51d4a0..22ee6a22529f 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-reset.yaml +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/dts/bindings/nordic,nrf9160dk-nrf52840-reset.yaml @@ -1,5 +1,5 @@ -# Copyright (c) 2021 Nordic Semiconductor ASA -# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # NOTE: This file is replicated in nrf9160dk_nrf9160 and nrf9160dk_nrf52840. # Any changes should be done in both instances. diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/nrf52840_reset.c b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/nrf52840_reset.c index 0eb7095dcaba..75bd8f3038c9 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/nrf52840_reset.c +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/nrf52840_reset.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2020 Nordic Semiconductor ASA. + * Copyright (c) 2025 Nordic Semiconductor ASA. * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include @@ -242,4 +242,3 @@ int bt_hci_transport_setup(struct device *h4) #else #warning "Reset and/or boot node is missing" #endif /* DT_NODE_HAS_STATUS(RESET_NODE, okay) && DT_NODE_HAS_STATUS(BOOT_NODE, okay) */ - diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/pre_dt_board.cmake b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/pre_dt_board.cmake index c8267afd1b47..4959e498ccfe 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/pre_dt_board.cmake +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/arm/apricity_gateway_nrf9160/pre_dt_board.cmake @@ -1,5 +1,5 @@ -# Copyright (c) 2021 Linaro Limited -# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2025 Nordic Semiconductor ASA +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # Suppress "unique_unit_address_if_enabled" to handle the following overlaps: # - flash-controller@39000 & kmu@39000 diff --git a/samples/cellular/nrf_cloud_ble_gateway/boards/nrf9160dk_nrf9160_0_14_0.overlay b/samples/cellular/nrf_cloud_ble_gateway/boards/nrf9160dk_nrf9160_0_14_0.overlay index 1fc0994a6ef4..6d30ec7279d1 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/boards/nrf9160dk_nrf9160_0_14_0.overlay +++ b/samples/cellular/nrf_cloud_ble_gateway/boards/nrf9160dk_nrf9160_0_14_0.overlay @@ -1,13 +1,13 @@ /* * Copyright (c) 2021 Nordic Semiconductor ASA * - * SPDX-License-Identifier: Apache-2.0 + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /* -#include -#include -#include -*/ + * #include + * #include + * #include + */ #include &nrf52840_reset { diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/README.rst b/samples/cellular/nrf_cloud_ble_gateway/src/ble/README.rst index ec9b44149a97..cd1076aa804f 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/README.rst +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/README.rst @@ -30,7 +30,8 @@ Requirements * For the Apricity Gateway nRF9160, `nrfcloud_gateway_controller`_ must be programmed in the nRF52 board controller. * For the nRF9160 DK, `hci_lpuart`_ must instead be programmed in the nRF52 board controller. -* The sample is configured to compile and run as a non-secure application on nRF91's Cortex-M33. Therefore, it automatically includes the `secure_partition_manager`_ that prepares the required peripherals to be available for the application. +* The sample is configured to compile and run as a non-secure application on nRF91's Cortex-M33. + Therefore, it automatically includes the `secure_partition_manager`_ that prepares the required peripherals to be available for the application. .. _nrfcloud_ble_gateway_user_interface: @@ -40,21 +41,22 @@ Key Features Hardware -------- - Runs on either the Apricity Gateway hardware or the nRF9160DK -- 700-960 MHz + 1710-2200 MHz LTE band support. The following bands, based on geographic regions, are used: - - USA – 2, 4, 12, and 13 - - EU – 3, 8, 20, and 28 +- 700-960 MHz + 1710-2200 MHz LTE band support. + The following bands, based on geographic regions, are used: + - USA 2, 4, 12, and 13 + - EU 3, 8, 20, and 28 - Certifications: CE, FCC - LTE-M/NB-IoT and Bluetooth LE antennas - Nano/4FF Subscriber Identity Module (SIM) card slot - 64 megabit SPI serial Flash memory - PC connection through USB -- Normal operating temperature range: 5°C ~ 35°C +- Normal operating temperature range: 5C ~ 35C Apricity Gateway hardware distinguishing features: -- Single button with multiple uses – power, reset, and update enable +- Single button with multiple uses power, reset, and update enable - Dual RGB LEDs for status indication of LTE and BLE connections -- Larger LTE and BLE antennas +- Larger LTE and BLE antennas - Rechargeable 3.7V Li-Po battery with 2000 mAh capacity - Charging through Universal Serial Bus (USB) or external power supply with barrel jack connector - Rigid, wall mountable enclosure @@ -72,7 +74,8 @@ Firmware User interface ************** -One can locally manage the gateway with a USB connection and a terminal program. See :ref:`Shell` for details. +One can locally manage the gateway with a USB connection and a terminal program. +See :ref:`Shell` for details. The Apricity Gateway button has the following functions: @@ -134,8 +137,8 @@ Program nRF9160 Application Processor 1. Checkout this repository. #. Execute the following to pull down all other required repositories:: - west update - + west update + #. Execute the following to build for the Apricity Gateway hardware:: west build -d build_ag -b apricity_gateway_nrf9160ns @@ -155,14 +158,17 @@ Program nRF52840 Board Controller For the Apricity Gateway hardware, follow the same instructions as above in the folder for its repository, except use ``apricity_gateway_nrf52840`` instead of ``apricity_gateway_nrf9160ns``, and connect the Tag Connect to ``NRF52:J1``. -For the nRF9160 DK, `hci_lpuart`_ must instead be programmed in the nRF52 board controller. This should be done from the root of the lte-gateway repo so that the required device tree overlays in the `boards <./boards>`_ folder are utilized. +For the nRF9160 DK, `hci_lpuart`_ must instead be programmed in the nRF52 board controller. +This should be done from the root of the lte-gateway repo so that the required device tree overlays in the `boards <./boards>`_ folder are utilized. Program The nRF9160 Modem Processor ----------------------------------- `Modem Firmware v1.3.0`_ -For either the Apricity Gateway or the nRF9160 DK, you must also flash the modem firmware. Version ``mfw_1.3.0`` or higher is required. Program this using `nRF Connect Programmer`_ application. +For either the Apricity Gateway or the nRF9160 DK, you must also flash the modem firmware. +Version ``mfw_1.3.0`` or higher is required. +Program this using `nRF Connect Programmer`_ application. Generating Certificates @@ -174,7 +180,8 @@ Create Self-Signed CA Certs --------------------------- This step is done using the `Create CA Cert`_ Python 3 script. -Check out this repository, install the specified prerequisite Python 3 packages, and then follow the instructions to create a CA cert. This only needs to be done once per customer. +Check out this repository, install the specified prerequisite Python 3 packages, and then follow the instructions to create a CA cert. +This only needs to be done once per customer. Install Device Certificates --------------------------- @@ -188,12 +195,18 @@ Using the generated ``provision.csv`` file, go on to the next step. NOTES: -- The ``-A`` (all ports) option will be necessary if using the nRF9160DK, in order to find the board. If you have more than one board powered on and connected to your PC via USB, you will need to select which board to use. Otherwise, it will use the first one detected. -- The ``-g`` (gateway) option forces the program to assume this device has a shell which uses the expected Gateway commands in order to send and receive modem ``AT`` commands. Usually the program will detect this automatically. +- The ``-A`` (all ports) option will be necessary if using the nRF9160DK, in order to find the board. + If you have more than one board powered on and connected to your PC via USB, you will need to select which board to use. + Otherwise, it will use the first one detected. +- The ``-g`` (gateway) option forces the program to assume this device has a shell which uses the expected Gateway commands in order to send and receive modem ``AT`` commands. + Usually the program will detect this automatically. - The ``-a`` (append) option allows you to build up a CSV file for multiple devices, and then add them all at once to your account with a single curl command. -- The ``-d`` (delete) option will remove any previous certificates from the ``SECTAG`` being used. A ``SECTAG`` is a programming slot for certificates in the modem. The ``SECTAG`` here must match the ``CONFIG_NRF_CLOUD_SEC_TAG`` Kconfig option in the prj.conf file. +- The ``-d`` (delete) option will remove any previous certificates from the ``SECTAG`` being used. + A ``SECTAG`` is a programming slot for certificates in the modem. + The ``SECTAG`` here must match the ``CONFIG_NRF_CLOUD_SEC_TAG`` Kconfig option in the prj.conf file. -The provision.csv file lists the device ID (UUID) in the first column. It is also displayed by the Device Credentials Installer script. +The provision.csv file lists the device ID (UUID) in the first column. +It is also displayed by the Device Credentials Installer script. Provisioning and Associating with nRF Cloud ******************************************* @@ -205,8 +218,9 @@ There are two ways to provision and associate using the provision.csv file you g 1. Via the nRF Cloud website: `nRF Cloud Provision Devices`_ #. Programmatically using `nRF Cloud ProvisionDevices REST API`_ -On the `nRF Cloud Provision Devices`_ page, you can drag and drop the CSV file, or click the button to browse for and select it. -Click the Upload and Provision button to begin the process. The status will be displayed in the table below. +On the `nRF Cloud Provision Devices`_ page, you can drag and drop the CSV file, or click the button to browse for and select it. +Click the Upload and Provision button to begin the process. +The status will be displayed in the table below. Instead of using the website, you can instead use curl or Postman to submit the csv file to the `nRF Cloud ProvisionDevices REST API`_ directly. You will need to find your nRF Cloud account API Key on your account settings page, and use it in place of $API_KEY below. @@ -238,7 +252,9 @@ After programming the application and all prerequisites to your board, test the 1. Connect the board to the computer using a USB cable. The board is assigned a COM port (Windows) or ttyACM or ttyS device (Linux). -#. Connect to the board with a terminal emulator, for example, PuTTY, Tera Term, or LTE Link Monitor. Turn off local echo. Output CR and LF when either is received. The shell uses VT100-compatible escape sequences for coloration. +#. Connect to the board with a terminal emulator, for example, PuTTY, Tera Term, or LTE Link Monitor. + Turn off local echo. Output CR and LF when either is received. + The shell uses VT100-compatible escape sequences for coloration. #. Reset the board if it was already on. #. Observe in the terminal window that the board starts up in the Secure Partition Manager and that the application starts. This is indicated by output similar to the following lines:: @@ -249,7 +265,9 @@ After programming the application and all prerequisites to your board, test the login: -#. For PuTTY_ or `LTE Link Monitor`_, you will need to reconnect terminal. (Bluetooth LE HCI control resets the terminal output and needs to be reconnected). `Tera Term`_ automatically reconnects. +#. For PuTTY_ or `LTE Link Monitor`_, you will need to reconnect terminal. + (Bluetooth LE HCI control resets the terminal output and needs to be reconnected). + `Tera Term`_ automatically reconnects. #. Log in with the default password:: nordic @@ -258,13 +276,16 @@ After programming the application and all prerequisites to your board, test the log enable inf -#. Open a web browser and navigate to https://nrfcloud.com/. Click on Device Management then Gateways. Click on your device's Device ID (UUID), which takes you to the detailed view of your gateway. +#. Open a web browser and navigate to https://nrfcloud.com/. + Click on Device Management then Gateways. + Click on your device's Device ID (UUID), which takes you to the detailed view of your gateway. #. The first time you start the application, the device will be added to your account automatically. a. Observe that the LED(s) indicate that the device is connected. #. If the LED(s) indicate an error, check the details of the error in the terminal window. -#. Add BLE devices by clicking on the + sign. Read, write, and enable notifications on connected peripheral and observe data being received on the nRF Cloud. +#. Add BLE devices by clicking on the + sign. + Read, write, and enable notifications on connected peripheral and observe data being received on the nRF Cloud. #. Optionally send AT commands from the terminal, and observe that the response is received. @@ -272,7 +293,8 @@ After programming the application and all prerequisites to your board, test the Using the Management Interface (Shell) ************************************** -The shell is available via a USB serial port, through one of the two provided serial connections. Using a 3rd party terminal program such as PuTTY_ or `Tera Term`_, you can log in and administer the gateway directly. +The shell is available via a USB serial port, through one of the two provided serial connections. +Using a 3rd party terminal program such as PuTTY_ or `Tera Term`_, you can log in and administer the gateway directly. Once logged in at the login: prompt, you can get help using the tab key or by typing help. :: @@ -285,13 +307,17 @@ Once logged in at the login: prompt, you can get help using the tab key or by ty passwd reboot resize session shell shutdown gateway:# -Many commands have sub commands. The shell offers command completion; you can type the start of a command and hit tab, and it will offer available choices. :: +Many commands have sub commands. +The shell offers command completion. +Type the start of a command and hit tab, and it will offer available choices. :: at - | exit> Execute an AT command. Use first to remain in AT command mode until 'exit'. -This command, plus the parameter 'enable' places the shell into AT command mode. In this mode, the only available commands are nrf9160 -modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT Command Reference`_ for more information about AT commands. :: +This command, plus the parameter 'enable' places the shell into AT command mode. +In this mode, the only available commands are nrf9160 +modem AT commands or 'exit' to return to normal shell mode. +See the `nRF91 AT Command Reference`_ for more information about AT commands. :: ble - Bluetooth commands Subcommands: @@ -306,7 +332,7 @@ modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT C fota: [ver] [crc] [sec_tag] [frag_size] [apn] start BLE firmware over-the-air update. test: Set BLE FOTA download test mode. - + clear - Clear the terminal. cpu_load - debug command to see how busy the nrf9160 is. date - > - display or change the current @@ -316,7 +342,7 @@ modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT C over-the-air update. history - display previous commands entered in the shell. Up arrow will move backward one by one, making it easy to repeat - previous commands. + previous commands. info - Informational commands Subcommands: @@ -329,7 +355,7 @@ modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT C modem: Modem information. param: List parameters. scan: Bluetooth scan results. - + kernel - Kernel commands Subcommands: cycles: Kernel cycles. @@ -338,21 +364,21 @@ modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT C threads: List kernel threads. uptime: Kernel uptime. version: Kernel version. - + log - Commands for controlling logger Subcommands: backend: Logger backends commands. disable: 'log disable .. ' disables - logs in specified modules (all if no modules - specified). + logs in specified modules (all if no modules + specified). enable: 'log enable ... ' enables logs up to given level in specified modules - (all if no modules specified). + (all if no modules specified). go: Resume logging halt: Halt logging list_backends: Lists logger backends. status: Logger status - + login - the default first command after reboot and after logout. logout - lock shell until user logs in again with correct password. passwd - change the password. @@ -365,24 +391,26 @@ modem AT commands or 'exit' to return to normal shell mode. See the `nRF91 AT C Subcommands: backspace_mode: Toggle backspace key mode. Some terminals are not sending separate escape code - for backspace and delete button. This command forces - shell to interpret delete key as backspace. + for backspace and delete button. This command forces + shell to interpret delete key as backspace. colors: Toggle colored syntax. echo: Toggle shell echo. stats: Shell statistics. - + shutdown - Disconnect from nRF Cloud and the LTE network, then power down the gateway. Press the button to restart. - - + + Updating Firmware with FOTA *************************** -The nRF9160 modem, application firmware, and bootloader, can all be updated over the air by nRF Cloud. This can be done when the gateway is connected to the cloud via https://nrfcloud.com/#/updates-dashboard. +The nRF9160 modem, application firmware, and bootloader, can all be updated over the air by nRF Cloud. +This can be done when the gateway is connected to the cloud via https://nrfcloud.com/#/updates-dashboard. Modem ----- -Incremental modem updates are supported. Full modem updates using external flash memory on board the Apricity gateway hardware is possible but not enabled yet. +Incremental modem updates are supported. +Full modem updates using external flash memory on board the Apricity gateway hardware is possible but not enabled yet. nRF9160 ------- @@ -390,13 +418,19 @@ Application and MCUboot firmware updates are supported. nRF52840 -------- -The nRF52840 cannot be updated over the air yet; it must be updated over USB on the Apricity Gateway. See the Button Behavior and LED Indicator Behavior sections for the process to enter MCUboot mode. Once in that mode, nRF Connect Desktop Programmer can update the firmware using the MCUBoot mode, by clicking the Enable MCUBoot checkbox. +The nRF52840 cannot be updated over the air yet; it must be updated over USB on the Apricity Gateway. +See the Button Behavior and LED Indicator Behavior sections for the process to enter MCUboot mode. +Once in that mode, nRF Connect Desktop Programmer can update the firmware using the MCUBoot mode, by clicking the Enable MCUBoot checkbox. The nRF52840 can be updated on an nRF9160DK using the built-in Segger J-Link programming hardware and the already established methods for flashing (nRF Connect for Desktop Programmer, west, nrfjprog, etc.). BLE Devices ----------- -Bluetooth devices running the nRF5SDK and its buttonless secure DFU bootloader can be updated as well. Create a device group in nRF Cloud for one or more indentical Bluetooth peripherals that are connected to your gateway. Then in the Updates Dashboard, upload the firmware bundle using the Bundles ... menu, then click Create Update. Select the device group and the firmware bundle, and click Save. Then click Apply Update. +Bluetooth devices running the nRF5SDK and its buttonless secure DFU bootloader can be updated as well. +Create a device group in nRF Cloud for one or more indentical Bluetooth peripherals that are connected to your gateway. +Then in the Updates Dashboard, upload the firmware bundle using the Bundles ... menu, then click Create Update. +Select the device group and the firmware bundle, and click Save. +Then click Apply Update. Known Issues and Limitations **************************** diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/apricity_gateway_nrf9160ns.overlay b/samples/cellular/nrf_cloud_ble_gateway/src/ble/apricity_gateway_nrf9160ns.overlay deleted file mode 100644 index 4408786898ca..000000000000 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/apricity_gateway_nrf9160ns.overlay +++ /dev/null @@ -1,5 +0,0 @@ -/ { - chosen { - zephyr,bt-uart=&uart1; - }; -}; diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.c index 358f3ff48a58..54169f7a7f2f 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.c @@ -1,7 +1,6 @@ -/* - * Copyright (c) 2018 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include @@ -97,7 +96,7 @@ struct gatt_read_cache_entry { const struct bt_conn *conn; struct uuid_handle_pair *uhp; bool pending; - bool last; + bool last; } gatt_read_cache[CONFIG_BT_MAX_CONN]; /* Convert ble address string to uppcase */ @@ -348,7 +347,7 @@ static void send_ble_read_data(int unused1, int unused2, int unused3) BT_UUID_GATT_CCC_VAL_STR, path, ((char *)rx_data->data), - rx_data->length, + rx_data->length, &output, false); } else { err = device_value_changed_encode(rx_data->ble_mac_addr_str, @@ -360,11 +359,6 @@ static void send_ble_read_data(int unused1, int unused2, int unused3) LOG_ERR("Unable to encode: %d", err); goto cleanup; } - /* - LOG_DBG("UUID %s, path %s, len %u, json %s", - uuid, path, - rx_data->length, (char *)output.data.ptr); - */ err = g2c_send(&output.data); k_mutex_unlock(&output.lock); if (err) { @@ -519,6 +513,7 @@ static uint8_t gatt_read_callback(struct bt_conn *conn, uint8_t err, */ uint16_t offset = MIN(params->single.offset, BT_MAX_VALUE_LEN); uint16_t this_len = MIN(length, (BT_MAX_VALUE_LEN - offset)); + uhp->value_len = offset + this_len; memcpy(&uhp->value[offset], data, this_len); } @@ -658,7 +653,7 @@ int gatt_write(const char *ble_mac_addr_str, const char *chrc_uuid, uint8_t *dat return err; } -int gatt_write_without_response(const char *ble_mac_addr_str,const char *chrc_uuid, +int gatt_write_without_response(const char *ble_mac_addr_str, const char *chrc_uuid, uint8_t *data, uint16_t data_len) { int err; @@ -931,7 +926,7 @@ int ble_subscribe_handle(const char *ble_mac_addr_str, uint16_t handle, uint8_t int err; LOG_DBG("Addr %s handle %u value_type %u", ble_mac_addr_str, - handle, (unsigned)value_type); + handle, (unsigned int)value_type); err = ble_conn_mgr_get_conn_by_addr(ble_mac_addr_str, &conn_ptr); if (err == 0) { err = ble_conn_mgr_get_uuid_by_handle(handle, uuid, conn_ptr); diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.h index 5eb9303b60ef..885a0ccbb969 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble.h @@ -1,7 +1,6 @@ -/* - * Copyright (c) 2018 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #ifndef _BLE_H_ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.c index 307cf6519213..c6e6b26380d1 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #include #include #include @@ -33,10 +38,10 @@ LOG_MODULE_REGISTER(ble_codec, CONFIG_NRFCLOUD_BLE_GATEWAY_LOG_LEVEL); typedef int (*gateway_state_handler_t)(void *root_obj); extern void nrf_cloud_register_gateway_state_handler(gateway_state_handler_t handler); -extern int nrf_cloud_modem_info_json_encode(const struct nrf_cloud_modem_info *const mod_inf, - cJSON *const mod_inf_obj); -extern int nrf_cloud_service_info_json_encode(const struct nrf_cloud_svc_info *const svc_inf, - cJSON *const svc_inf_obj); +extern int nrf_cloud_modem_info_json_encode(const struct nrf_cloud_modem_info * const mod_inf, + cJSON * const mod_inf_obj); +extern int nrf_cloud_service_info_json_encode(const struct nrf_cloud_svc_info * const svc_inf, + cJSON * const svc_inf_obj); extern int nrf_cloud_shadow_delta_response_encode(cJSON *input_obj, bool accept, struct nrf_cloud_data *const output); @@ -47,7 +52,7 @@ static char service_buffer[MAX_SERVICE_BUF_SIZE]; static bool first_service = true; static bool first_chrc = true; -static bool desired_conns_strings = false; +static bool desired_conns_strings; #define JSON_KEY_SRVC_INFO "serviceInfo" @@ -499,7 +504,7 @@ int device_descriptor_value_encode(const char *ble_address, char *uuid, CJADDSTRCS(root_obj, "gatewayId", gateway_id); CJADDNULLCS(root_obj, "requestId"); - CJADDSTRCS(event, "type", changed ? + CJADDSTRCS(event, "type", changed ? "device_descriptor_value_changed" : "device_descriptor_value_read_result"); CJADDSTRCS(event, "timestamp", get_time_str(str, sizeof(str))); @@ -561,8 +566,8 @@ int device_chrc_read_encode(char *ble_address, char *uuid, char *path, CJADDSTRCS(event, "type", "device_characteristic_value_changed"); /** This used to use "device_characteristic_value_read_result" - * but that no longer works in the cloud backend. - */ + * but that no longer works in the cloud backend. + */ CJADDSTRCS(event, "timestamp", get_time_str(str, sizeof(str))); CJADDSTRCS(device, "id", ble_address); @@ -671,9 +676,8 @@ static int create_device_wrapper(char *ble_address, bool conn_status, int device_shadow_data_encode(const char *ble_address, bool connecting, bool connected, struct gw_msg *msg) { - int ret = -ENOMEM; __ASSERT_NO_MSG(msg != NULL); - + int ret = -ENOMEM; cJSON *root_obj = cJSON_CreateObject(); cJSON *state_obj = cJSON_CreateObject(); cJSON *reported_obj = cJSON_CreateObject(); @@ -714,9 +718,8 @@ int device_shadow_data_encode(const char *ble_address, bool connecting, int gateway_reported_encode(struct gw_msg *msg) { - int ret = -ENOMEM; __ASSERT_NO_MSG(msg != NULL); - + int ret = -ENOMEM; cJSON *root_obj = cJSON_CreateObject(); cJSON *state_obj = cJSON_CreateObject(); cJSON *reported_obj = cJSON_CreateObject(); @@ -750,9 +753,8 @@ int gateway_reported_encode(struct gw_msg *msg) int gateway_desired_list_encode(const struct desired_conn *desired, int num_desired, struct gw_msg *msg) { - int ret = -ENOMEM; __ASSERT_NO_MSG(msg != NULL); - + int ret = -ENOMEM; cJSON *root_obj = cJSON_CreateObject(); cJSON *state_obj = cJSON_CreateObject(); cJSON *desired_obj = cJSON_CreateObject(); @@ -1184,6 +1186,7 @@ int desired_conns_handler(cJSON *desired_connections_obj) } char *ptr = cJSON_Print(desired_connections_obj); + LOG_INF("Desired conns: %s", ptr); nrf_cloud_free(ptr); @@ -1312,4 +1315,3 @@ void ble_codec_init(void) { /* Nothing to do. */ } - diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.h index 2cdc51f5ce35..2c63391218e4 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_codec.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #ifndef BLE_CODEC_H_ #define BLE_CODEC_H_ @@ -37,7 +42,7 @@ int device_disconnect_result_encode(char *ble_address, bool conn_status, int gateway_shadow_data_encode(void *modem_ptr, struct gw_msg *msg); int device_shadow_data_encode(const char *ble_address, bool connecting, bool connected, struct gw_msg *msg); -int gateway_desired_list_encode(const struct desired_conn *desired,int num_desired, +int gateway_desired_list_encode(const struct desired_conn *desired, int num_desired, struct gw_msg *msg); int gateway_reported_encode(struct gw_msg *msg); void get_uuid_str(struct uuid_handle_pair *uuid_handle, char *str, size_t len); diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.c index 6e9f7e8d0497..8a27f421a7a3 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #include #include #include @@ -847,7 +852,7 @@ int get_num_connected(void) return num_connected; } -void ble_conn_mgr_init() +void ble_conn_mgr_init(void) { num_connected = 0; for (int i = 0; i < CONFIG_BT_MAX_CONN; i++) { diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.h index 29de9aac1f6a..f2018d8a4b75 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ble_conn_mgr.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #ifndef _BLE_CONN_MGR_H_ #define _BLE_CONN_MGR_H_ @@ -79,7 +84,7 @@ int ble_conn_mgr_get_handle_by_uuid(uint16_t *handle, const char *uuid, const struct ble_device_conn *conn_ptr); struct uuid_handle_pair *ble_conn_mgr_get_uhp_by_uuid(const char *uuid, const struct ble_device_conn *conn_ptr); -void ble_conn_mgr_init(); +void ble_conn_mgr_init(void); int ble_conn_set_connected(struct ble_device_conn *conn_ptr, bool connected); int ble_conn_mgr_set_subscribed(uint16_t handle, uint8_t sub_index, const struct ble_device_conn *conn_ptr); diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/certificates.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/certificates.h deleted file mode 100644 index 84fbcc3a660f..000000000000 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/certificates.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic - */ - -#ifndef _CERTIFICATES_H_ -#define _CERTIFICATES_H_ - -#define NRF_CLOUD_CLIENT_ID "my-client-id" - -#define NRF_CLOUD_CLIENT_PRIVATE_KEY \ - "-----BEGIN RSA PRIVATE KEY-----\n" \ - "NRF_CLOUD_CLIENT_PRIVATE_KEY\n" \ - "-----END RSA PRIVATE KEY-----\n" - -#define NRF_CLOUD_CLIENT_PUBLIC_CERTIFICATE \ - "-----BEGIN CERTIFICATE-----\n" \ - "NRF_CLOUD_CLIENT_PUBLIC_CERTIFICATE\n" \ - "-----END CERTIFICATE-----\n" - -#define NRF_CLOUD_CA_CERTIFICATE \ - "-----BEGIN CERTIFICATE-----\n" \ - "NRF_CLOUD_CA_CERTIFICATE\n" \ - "-----END CERTIFICATE-----\n" - -#endif /* _CERTIFICATES_H_ */ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/cli.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/cli.c index 698f83c9fe51..80d5d4e4583e 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/cli.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/cli.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #undef __XSI_VISIBLE #define __XSI_VISIBLE 1 #undef _XOPEN_SOURCE @@ -159,14 +164,6 @@ int heap_shell(const struct shell *shell, size_t argc, char **argv) shell_print(shell, "system heap statistics:"); shell_print(shell, "max. size: %6ld", MAX_HEAP_SIZE); -#if 0 /* TODO: PETE */ - struct mallinfo system_stats; - - system_stats = mallinfo(); - shell_print(shell, "size: %6d", system_stats.arena); - shell_print(shell, "free: %6d", system_stats.fordblks); - shell_print(shell, "allocated: %6d", system_stats.uordblks); -#endif return 0; } @@ -348,18 +345,6 @@ void print_connection_status(const struct shell *shell) } else { shell_print(shell, "LTE functional mode: \t%d", (int)fmode); } - -#if 0 /* TODO: PETE */ - shell_print(shell, "LTE connection: \t%s", - get_lte_connection_status() ? - "connected" : "disconnected"); - shell_print(shell, "cloud connection: \t%s", - get_cloud_connection_status() ? - "connected" : "disconnected"); - shell_print(shell, "cloud ready: \t\t%s", - get_cloud_ready_status() ? - "ready" : "not ready"); -#endif } static void print_cloud_info(const struct shell *shell) @@ -464,7 +449,7 @@ static void print_conn_info(const struct shell *shell, bool show_path, struct uuid_handle_pair *up; char uuid_str[BT_UUID_STR_LEN]; char path[BT_MAX_PATH_LEN]; - const char *types[] = {"svc", "chr", "---", "ccc"}; + static const char *types[] = {"svc", "chr", "---", "ccc"}; if (!notify) { shell_print(shell, " MAC, connected, discovered, shadow" @@ -1290,8 +1275,7 @@ static int app_cmd_at(const struct shell *shell, size_t argc, char **argv) shell_set_root_cmd("at"); set_at_prompt(shell, true); return 0; - } - else if (strcmp(argv[1], "exit") == 0) { + } else if (strcmp(argv[1], "exit") == 0) { set_at_prompt(shell, false); return 0; } @@ -1351,8 +1335,8 @@ static int cmd_shutdown(const struct shell *shell, size_t argc, char **argv) } /* -example: -fota firmware.nrfcloud.com 3c7003c6-45a0-4a74-9023-1e006ceeb835/APP*30f6ce17*1.4.0/app_update.bin + * example: + * fota firmware.nrfcloud.com 3c7003c6-45a0-4a74-9023-1e006ceeb835/APP*30f6ce17*1.4.0/app_update.bin */ static int cmd_fota(const struct shell *shell, size_t argc, char **argv) { @@ -1381,6 +1365,7 @@ static int cmd_fota(const struct shell *shell, size_t argc, char **argv) shell_print(shell, "mcuboot download detected"); } int err = fota_download_start(host, path, sec_tag, 0, frag); + if (err) { shell_error(shell, "Error %d starting download", err); } @@ -1392,16 +1377,16 @@ static int cmd_fota(const struct shell *shell, size_t argc, char **argv) } /* -example: -ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ - APP*f1078fc9*2.2.0/app_thingy_s132.bin 155272 1 2.2.0 -ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ - APP*56693cf8*2.2.0/app_thingy_s132dat.bin 135 1 2.2.0 -ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ - APP*f15b85a8*s132/sd_bl.bin 153344 0 s132 -ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ - APP*3fb54637*s132/sd_bl_dat.bin 139 1 s132 -*/ + * example: + * ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ + * APP*f1078fc9*2.2.0/app_thingy_s132.bin 155272 1 2.2.0 + * ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ + * APP*56693cf8*2.2.0/app_thingy_s132dat.bin 135 1 2.2.0 + * ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ + * APP*f15b85a8*s132/sd_bl.bin 153344 0 s132 + * ble fota C2:6B:AC:6D:05:A3 firmware.beta.nrfcloud.com ba1752ef-0d36-4fcf-8748-3cad9f8801b0/ + * APP*3fb54637*s132/sd_bl_dat.bin 139 1 s132 + */ #if CONFIG_GATEWAY_BLE_FOTA static int cmd_ble_fota(const struct shell *shell, size_t argc, char **argv) { @@ -1526,7 +1511,7 @@ int set_passwd(char *passwd) static int cmd_login(const struct shell *shell, size_t argc, char **argv) { - static uint32_t attempts = 0; + static uint32_t attempts; if (argc < 2) { shell_print(shell, "Access requires: "); @@ -1547,15 +1532,13 @@ static int cmd_login(const struct shell *shell, size_t argc, char **argv) shell_print(shell, "\nHit tab for help.\n"); return 0; - } else { - shell_error(shell, "Incorrect password!"); - attempts++; - if (attempts > 3) { - k_sleep(K_SECONDS(attempts)); - } - return -EINVAL; } - return 0; + shell_error(shell, "Incorrect password!"); + attempts++; + if (attempts > 3) { + k_sleep(K_SECONDS(attempts)); + } + return -EINVAL; } static int cmd_passwd(const struct shell *shell, size_t argc, char **argv) @@ -1600,7 +1583,7 @@ void cli_init(void) if (shell) { /* * Zephyr commit: SHA-1: 2b5723d4558619a9283683499c095e0b344d32d7 - * shell: add init backend configuration + * shell: add init backend configuration * broke the config system regarding obscure, so for now, * set it manually on */ @@ -1654,7 +1637,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_ble, #if CONFIG_GATEWAY_BLE_FOTA SHELL_CMD(fota, &dynamic_ble_fota, " [ver] [crc] [sec_tag] [frag_size] [apn] " - "BLE firmware over-the-air update.", NULL), + "BLE firmware over-the-air update.", NULL), SHELL_CMD(test, NULL, "Set BLE FOTA download test mode.", cmd_ble_test), #endif SHELL_SUBCMD_SET_END /* Array terminated. */ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.c index c012ce309643..30d5fa8be22c 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #include #include #include @@ -34,61 +39,60 @@ LOG_MODULE_REGISTER(peripheral_dfu, CONFIG_NRF_CLOUD_FOTA_LOG_LEVEL); } else { \ LOG_INF(__VA_ARGS__); \ } \ - } while (false) + } while (false) enum nrf_dfu_op_t { - NRF_DFU_OP_PROTOCOL_VERSION = 0x00, - NRF_DFU_OP_OBJECT_CREATE = 0x01, - NRF_DFU_OP_RECEIPT_NOTIF_SET = 0x02, - NRF_DFU_OP_CRC_GET = 0x03, - NRF_DFU_OP_OBJECT_EXECUTE = 0x04, - NRF_DFU_OP_OBJECT_SELECT = 0x06, - NRF_DFU_OP_MTU_GET = 0x07, - NRF_DFU_OP_OBJECT_WRITE = 0x08, - NRF_DFU_OP_PING = 0x09, - NRF_DFU_OP_HARDWARE_VERSION = 0x0A, - NRF_DFU_OP_FIRMWARE_VERSION = 0x0B, - NRF_DFU_OP_ABORT = 0x0C, - NRF_DFU_OP_RESPONSE = 0x60, - NRF_DFU_OP_INVALID = 0xFF + NRF_DFU_OP_PROTOCOL_VERSION = 0x00, + NRF_DFU_OP_OBJECT_CREATE = 0x01, + NRF_DFU_OP_RECEIPT_NOTIF_SET = 0x02, + NRF_DFU_OP_CRC_GET = 0x03, + NRF_DFU_OP_OBJECT_EXECUTE = 0x04, + NRF_DFU_OP_OBJECT_SELECT = 0x06, + NRF_DFU_OP_MTU_GET = 0x07, + NRF_DFU_OP_OBJECT_WRITE = 0x08, + NRF_DFU_OP_PING = 0x09, + NRF_DFU_OP_HARDWARE_VERSION = 0x0A, + NRF_DFU_OP_FIRMWARE_VERSION = 0x0B, + NRF_DFU_OP_ABORT = 0x0C, + NRF_DFU_OP_RESPONSE = 0x60, + NRF_DFU_OP_INVALID = 0xFF }; enum nrf_dfu_result_t { - NRF_DFU_RES_CODE_INVALID = 0x00, - NRF_DFU_RES_CODE_SUCCESS = 0x01, - NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED = 0x02, - NRF_DFU_RES_CODE_INVALID_PARAMETER = 0x03, - NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES = 0x04, - NRF_DFU_RES_CODE_INVALID_OBJECT = 0x05, - NRF_DFU_RES_CODE_UNSUPPORTED_TYPE = 0x07, - NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED = 0x08, - NRF_DFU_RES_CODE_OPERATION_FAILED = 0x0A, - NRF_DFU_RES_CODE_EXT_ERROR = 0x0B + NRF_DFU_RES_CODE_INVALID = 0x00, + NRF_DFU_RES_CODE_SUCCESS = 0x01, + NRF_DFU_RES_CODE_OP_CODE_NOT_SUPPORTED = 0x02, + NRF_DFU_RES_CODE_INVALID_PARAMETER = 0x03, + NRF_DFU_RES_CODE_INSUFFICIENT_RESOURCES = 0x04, + NRF_DFU_RES_CODE_INVALID_OBJECT = 0x05, + NRF_DFU_RES_CODE_UNSUPPORTED_TYPE = 0x07, + NRF_DFU_RES_CODE_OPERATION_NOT_PERMITTED = 0x08, + NRF_DFU_RES_CODE_OPERATION_FAILED = 0x0A, + NRF_DFU_RES_CODE_EXT_ERROR = 0x0B }; -typedef enum -{ - NRF_DFU_EXT_ERROR_NO_ERROR = 0x00, - NRF_DFU_EXT_ERROR_INVALID_ERROR_CODE = 0x01, - NRF_DFU_EXT_ERROR_WRONG_COMMAND_FORMAT = 0x02, - NRF_DFU_EXT_ERROR_UNKNOWN_COMMAND = 0x03, - NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID = 0x04, - NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE = 0x05, - NRF_DFU_EXT_ERROR_HW_VERSION_FAILURE = 0x06, - NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE = 0x07, - NRF_DFU_EXT_ERROR_SIGNATURE_MISSING = 0x08, - NRF_DFU_EXT_ERROR_WRONG_HASH_TYPE = 0x09, - NRF_DFU_EXT_ERROR_HASH_FAILED = 0x0A, - NRF_DFU_EXT_ERROR_WRONG_SIGNATURE_TYPE = 0x0B, - NRF_DFU_EXT_ERROR_VERIFICATION_FAILED = 0x0C, - NRF_DFU_EXT_ERROR_INSUFFICIENT_SPACE = 0x0D, +typedef enum { + NRF_DFU_EXT_ERROR_NO_ERROR = 0x00, + NRF_DFU_EXT_ERROR_INVALID_ERROR_CODE = 0x01, + NRF_DFU_EXT_ERROR_WRONG_COMMAND_FORMAT = 0x02, + NRF_DFU_EXT_ERROR_UNKNOWN_COMMAND = 0x03, + NRF_DFU_EXT_ERROR_INIT_COMMAND_INVALID = 0x04, + NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE = 0x05, + NRF_DFU_EXT_ERROR_HW_VERSION_FAILURE = 0x06, + NRF_DFU_EXT_ERROR_SD_VERSION_FAILURE = 0x07, + NRF_DFU_EXT_ERROR_SIGNATURE_MISSING = 0x08, + NRF_DFU_EXT_ERROR_WRONG_HASH_TYPE = 0x09, + NRF_DFU_EXT_ERROR_HASH_FAILED = 0x0A, + NRF_DFU_EXT_ERROR_WRONG_SIGNATURE_TYPE = 0x0B, + NRF_DFU_EXT_ERROR_VERIFICATION_FAILED = 0x0C, + NRF_DFU_EXT_ERROR_INSUFFICIENT_SPACE = 0x0D, } nrf_dfu_ext_error_code_t; enum nrf_dfu_firmware_type_t { - NRF_DFU_FIRMWARE_TYPE_SOFTDEVICE = 0x00, - NRF_DFU_FIRMWARE_TYPE_APPLICATION = 0x01, - NRF_DFU_FIRMWARE_TYPE_BOOTLOADER = 0x02, - NRF_DFU_FIRMWARE_TYPE_UNKNOWN = 0xFF + NRF_DFU_FIRMWARE_TYPE_SOFTDEVICE = 0x00, + NRF_DFU_FIRMWARE_TYPE_APPLICATION = 0x01, + NRF_DFU_FIRMWARE_TYPE_BOOTLOADER = 0x02, + NRF_DFU_FIRMWARE_TYPE_UNKNOWN = 0xFF }; struct dfu_notify_packet { @@ -120,18 +124,16 @@ struct dfu_notify_packet { } fw; uint8_t ext_err_code; }; -} __attribute__((packed)); +} __packed; -enum ble_dfu_buttonless_op_code_t -{ +enum ble_dfu_buttonless_op_code_t { DFU_OP_RESERVED = 0x00, DFU_OP_ENTER_BOOTLOADER = 0x01, DFU_OP_SET_ADV_NAME = 0x02, DFU_OP_RESPONSE_CODE = 0x20 }; -enum ble_dfu_buttonless_rsp_code_t -{ +enum ble_dfu_buttonless_rsp_code_t { DFU_RSP_INVALID = 0x00, DFU_RSP_SUCCESS = 0x01, DFU_RSP_OP_CODE_NOT_SUPPORTED = 0x02, @@ -145,7 +147,7 @@ struct secure_dfu_ind_packet { uint8_t resp_code; uint8_t op_code; uint8_t rsp_code; -} __attribute__((packed)); +} __packed; K_SEM_DEFINE(peripheral_dfu_active, 1, 1); static size_t download_size; @@ -231,8 +233,7 @@ static int notification_callback(const char *addr, const char *chrc_uuid, /** @TODO: implement bonded mode also */ if (strcmp(chrc_uuid, DFU_BUTTONLESS_UUID) == 0) { normal_mode = true; - } - else if (strcmp(chrc_uuid, DFU_CONTROL_POINT_UUID) == 0) { + } else if (strcmp(chrc_uuid, DFU_CONTROL_POINT_UUID) == 0) { normal_mode = false; } else { LOG_WRN("Notification received for wrong UUID:%s", chrc_uuid); @@ -380,10 +381,9 @@ static int decode_dfu(void) LOG_ERR("Extended DFU error: 0x%02X", p->ext_err_code); } return -EFAULT; - } else { - LOG_WRN("DFU operation failed: %d", p->result); - return -EPROTO; } + LOG_WRN("DFU operation failed: %d", p->result); + return -EPROTO; } int peripheral_dfu_init(void) @@ -849,9 +849,9 @@ static void cancel_dfu(enum nrf_cloud_fota_error error) static uint8_t peripheral_dfu(const char *buf, size_t len) { - static size_t prev_percent = 0; - static size_t prev_update_percent = 0; - static uint32_t prev_crc = 0; + static size_t prev_percent; + static size_t prev_update_percent; + static uint32_t prev_crc; size_t percent = 0; int err = 0; @@ -1077,8 +1077,7 @@ static uint8_t peripheral_dfu(const char *buf, size_t len) if (dfu_notify_packet_data->crc.offset != completed_size) { err = -EIO; - } - else if (dfu_notify_packet_data->crc.crc != + } else if (dfu_notify_packet_data->crc.crc != prev_crc) { err = -EBADMSG; } else { @@ -1164,9 +1163,10 @@ static int send_data(char *ble_addr, const char *buf, size_t len) while (idx < len) { uint8_t size = MIN(MAX_CHUNK_SIZE, (len - idx)); + LOG_DBG("Sending write without response: %d, %d", size, idx); err = gatt_write_without_response(ble_addr, DFU_PACKET_UUID, - (uint8_t *)&buf[idx], size); + (uint8_t *)&buf[idx], size); if (err) { LOG_ERR("Error writing chunk at %d size %u: %d", idx, size, err); @@ -1213,9 +1213,9 @@ static int do_cmd(char *ble_addr, bool normal_mode, uint8_t *buf, uint16_t len, static int send_switch_to_dfu(char *ble_addr) { char smol_buf[1]; - + smol_buf[0] = DFU_OP_ENTER_BOOTLOADER; - + return do_cmd(ble_addr, true, smol_buf, sizeof(smol_buf), "DFU", true); } @@ -1373,7 +1373,8 @@ int write_image_size_to_dfu_packet(char *ble_addr, int image_size) * 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 * all lengths are little endian * - * https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v11.0.0%2Fbledfu_transport_bleservice.html + * https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter. + * sdk5.v11.0.0%2Fbledfu_transport_bleservice.html */ #define SIZE_LEN 12 /* Size of 3 uint32s */ char buf[SIZE_LEN]; diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.h index 6f8908463c5a..76b982ec13a4 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/dfu/peripheral_dfu.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #ifndef PERIPHERAL_DFU_H_ #define PERIPHERAL_DFU_H_ @@ -8,4 +13,4 @@ int peripheral_dfu_start(const char *host, const char *file, int sec_tag, const char *apn, size_t fragment_size); int peripheral_dfu_cleanup(void); -#endif \ No newline at end of file +#endif diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/CMakeLists.txt b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/CMakeLists.txt index 3fe4fac0abbc..4f724759867d 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/CMakeLists.txt +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/CMakeLists.txt @@ -1,7 +1,7 @@ # -# Copyright (c) 2019 Nordic Semiconductor +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # zephyr_include_directories(include) diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/flash_test.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/flash_test.c index 083811d1c0f5..d26575e275fa 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/flash_test.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/flash_test.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #include #include #include @@ -20,8 +25,10 @@ #define MEMCTRL_GPIO_CTRL DT_GPIO_CTLR(MEMCTRL_NODE, gpios) #define MEMCTRL_GPIO_PIN DT_GPIO_PIN(MEMCTRL_NODE, gpios) -/**@brief Set the external mem control pin to high to - * enable access to the external memory chip. */ +/** + * Set the external mem control pin to high to + * enable access to the external memory chip. + */ static int flash_test_init(void) { const struct device *port; @@ -112,7 +119,7 @@ int flash_test(void) const uint8_t *rp = buf; const uint8_t *rpe = rp + len; - ret= -EFAULT; + ret = -EFAULT; printk("FAIL - %d\n", ret); while (rp < rpe) { printk("%08x wrote %02x read %02x %s\n", diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/include/flash_test.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/include/flash_test.h index 2aae7e89279f..bdfb13ad5376 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/include/flash_test.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/flash/include/flash_test.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #ifndef _FLASH_TEST_H_ int flash_test(void); diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.c index 72739231a912..b3a0429e6994 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.c @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #include #include #include @@ -89,6 +94,7 @@ int gateway_shadow_accepted_handler(const struct nrf_cloud_obj *desired) ARG_UNUSED(desired); int err = nrf_cloud_shadow_transform_request("state.desired.desiredConnections", 1024); + if (err) { LOG_ERR("Error requesting shadow tf: %d", err); } @@ -641,7 +647,7 @@ void device_shutdown(bool reboot) LOG_PANIC(); if (!reboot) { LOG_INF("Shutting down..."); -#if defined(CONFIG_MODEM_WAKEUP_PIN) +#if defined(CONFIG_MODEM_WAKEUP_PIN) nrf_gpio_cfg_input(CONFIG_MODEM_WAKEUP_PIN, NRF_GPIO_PIN_PULLUP); nrf_gpio_cfg_sense_set(CONFIG_MODEM_WAKEUP_PIN, @@ -688,4 +694,3 @@ void device_shutdown(bool reboot) NRF_REGULATORS_NS->SYSTEMOFF = 1; } } - diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.h index 68f48bea0f62..31ed9b8e3c04 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/gateway.h @@ -1,3 +1,8 @@ +/* Copyright (c) 2025 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + #ifndef GATEWAY_CLOUD_TRANSPORT__ #define GATEWAY_CLOUD_TRANSPORT__ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/CMakeLists.txt b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/CMakeLists.txt index cf301233299c..01ac0a2ff0bd 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/CMakeLists.txt +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/CMakeLists.txt @@ -1,7 +1,7 @@ # -# Copyright (c) 2019 Nordic Semiconductor +# Copyright (c) 2025 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # zephyr_include_directories(include) diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/Kconfig b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/Kconfig index e2bc97a2ca76..391c036147a8 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/Kconfig +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/Kconfig @@ -1,7 +1,7 @@ # # Copyright (c) 2019 Nordic Semiconductor ASA # -# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # config USE_UI_MODULE diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_effect.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_effect.h index ffd8b9e58c5b..131dacb7492a 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_effect.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_effect.h @@ -1,7 +1,6 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #ifndef LED_EFFECT_H__ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_pwm.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_pwm.h index ae8366a94907..07763d2b5a12 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_pwm.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/led_pwm.h @@ -1,8 +1,8 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ + /**@file * * @brief LED control for the User Interface module. The module uses PWM to diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/ui.h b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/ui.h index e811c670857e..66d688ee55d4 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/ui.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/include/ui.h @@ -1,7 +1,6 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ /**@file @@ -98,8 +97,7 @@ extern "C" { #endif /* CONFIG_UI_LED_USE_PWM */ /**@brief UI LED state pattern definitions. */ -enum ui_led_pattern -{ +enum ui_led_pattern { #ifdef CONFIG_UI_LED_USE_PWM UI_LTE_DISCONNECTED, UI_LTE_CONNECTING, diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/led_pwm.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/led_pwm.c index 8ffe303fcbf6..cbf515dee04c 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/led_pwm.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/led_pwm.c @@ -1,5 +1,4 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ @@ -329,4 +328,4 @@ int ui_led_set_rgb(uint8_t red, uint8_t green, uint8_t blue, uint8_t led_num) } return 0; -} \ No newline at end of file +} diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/ui.c b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/ui.c index 445fb79edfeb..93108055a12b 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/ui.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/ble/ui/ui.c @@ -1,7 +1,6 @@ -/* - * Copyright (c) 2019 Nordic Semiconductor ASA +/* Copyright (c) 2025 Nordic Semiconductor ASA * - * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ #include diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/cloud_connection.c b/samples/cellular/nrf_cloud_ble_gateway/src/cloud_connection.c index f40aea8de21c..4e3e4c58e88b 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/cloud_connection.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/cloud_connection.c @@ -173,7 +173,7 @@ void register_general_dev_msg_handler(dev_msg_handler_cb_t handler_cb) /* This function causes the cloud to disconnect, and updates internal state accordingly. * - * It is also triggerd by cloud disconnection, to update internal state. + * It is also triggered by cloud disconnection, to update internal state. * * In this latter case, an unnecessary "Disconnecting from nRF Cloud" and * "Already disconnected from nRF Cloud" will be printed. diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.c b/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.c index de1fe4c0ac23..a9d7ce931119 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.c @@ -17,7 +17,7 @@ void on_fota_downloaded(void) sample_reboot_normal(); } -struct dfu_target_fmfu_fdev * get_full_modem_fota_fdev(void) +struct dfu_target_fmfu_fdev *get_full_modem_fota_fdev(void) { if (IS_ENABLED(CONFIG_NRF_CLOUD_FOTA_FULL_MODEM_UPDATE)) { static struct dfu_target_fmfu_fdev ext_flash_dev = { diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.h b/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.h index 389fd06c4e61..b0d65ed4bbed 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.h +++ b/samples/cellular/nrf_cloud_ble_gateway/src/fota_support.h @@ -31,6 +31,6 @@ void on_fota_downloaded(void); * enabled. * */ -struct dfu_target_fmfu_fdev * get_full_modem_fota_fdev(void); +struct dfu_target_fmfu_fdev *get_full_modem_fota_fdev(void); #endif /* _FOTA_SUPPORT_H_ */ diff --git a/samples/cellular/nrf_cloud_ble_gateway/src/message_queue.c b/samples/cellular/nrf_cloud_ble_gateway/src/message_queue.c index 29188451d634..45679b260f57 100644 --- a/samples/cellular/nrf_cloud_ble_gateway/src/message_queue.c +++ b/samples/cellular/nrf_cloud_ble_gateway/src/message_queue.c @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(message_queue, CONFIG_NRFCLOUD_BLE_GATEWAY_LOG_LEVEL); -/* Message Queue for enqueing outgoing messages during offline periods. */ +/* Message Queue for enqueuing outgoing messages during offline periods. */ K_MSGQ_DEFINE(device_message_queue, sizeof(struct nrf_cloud_obj *), CONFIG_MAX_OUTGOING_MESSAGES,