From f9b8863492dace50522002dce3ba039d9221ad78 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Tue, 25 May 2021 17:08:30 +0200 Subject: [PATCH] [nrfconnect] Enabled BLE advertising for DFU despite being provisioned. (#7081) Currently BLE advertising is stopped after provisioning Thread, and it cannot be restarted again. In order to perform Device Firmware Upgrade over BLE we need having BLE advertising started, so for now it is impossible to update firmware after provisioning. * Modified condition to allow starting BLE advertising despite having Thread provisioned in case of having also DFU enabled. --- examples/lighting-app/nrfconnect/README.md | 21 +++++++++++++++---- .../lighting-app/nrfconnect/main/AppTask.cpp | 3 ++- examples/lock-app/nrfconnect/README.md | 21 +++++++++++++++---- examples/lock-app/nrfconnect/main/AppTask.cpp | 3 ++- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/examples/lighting-app/nrfconnect/README.md b/examples/lighting-app/nrfconnect/README.md index ab0fbb860c7463..e73c870cf2ea46 100644 --- a/examples/lighting-app/nrfconnect/README.md +++ b/examples/lighting-app/nrfconnect/README.md @@ -462,7 +462,20 @@ CHIP-enabled Thread network. ### Testing Device Firmware Upgrade -Read the section about downloading the new image to a device on the -[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades) -page in the nRF Connect documentation to see how to upgrade your device firmware -over Bluetooth LE using a smartphone. +> **_NOTE:_** Currently performing DFU over BLE is supported only using +> smartphone with dedicated Nordic application installed. + +To upgrade your device firmware over Bluetooth LE using smartphone, complete the +following tasks: + +1. Install on your smartphone + [nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile) + or + [nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox) + application. +2. Push **Button 4** on the device to start Bluetooth LE advertising. +3. Push **Button 1** on the device to enable software update functionality. +4. Follow the instructions in the section about downloading the new image to a + device on the + [FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades) + page in the nRF Connect documentation. diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index fe7cf2360cdb7b..ec3f6598510cf7 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -415,7 +415,8 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent) if (aEvent->ButtonEvent.PinNo != BLE_ADVERTISEMENT_START_BUTTON) return; - if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned()) + // In case of having software update enabled, allow on starting BLE advertising after Thread provisioning. + if (chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned() && !sAppTask.mSoftwareUpdateEnabled) { LOG_INF("NFC Tag emulation and BLE advertisement not started - device is commissioned to a Thread network."); return; diff --git a/examples/lock-app/nrfconnect/README.md b/examples/lock-app/nrfconnect/README.md index 5d452f0fa6a06b..436212b9013d18 100644 --- a/examples/lock-app/nrfconnect/README.md +++ b/examples/lock-app/nrfconnect/README.md @@ -454,7 +454,20 @@ CHIP-enabled Thread network. ### Testing Device Firmware Upgrade -Read the section about downloading the new image to a device on the -[FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades) -page in the nRF Connect documentation to see how to upgrade your device firmware -over Bluetooth LE using a smartphone. +> **_NOTE:_** Currently performing DFU over BLE is supported only using +> smartphone with dedicated Nordic application installed. + +To upgrade your device firmware over Bluetooth LE using smartphone, complete the +following tasks: + +1. Install on your smartphone + [nRF Connect for Mobile](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-mobile) + or + [nRF Toolbox](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Toolbox) + application. +2. Push **Button 4** on the device to start Bluetooth LE advertising. +3. Push **Button 1** on the device to enable software update functionality. +4. Follow the instructions in the section about downloading the new image to a + device on the + [FOTA upgrades](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades) + page in the nRF Connect documentation. diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 065d22f96776c0..20e6fbdbf4a24a 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -416,7 +416,8 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent) if (aEvent->ButtonEvent.PinNo != BLE_ADVERTISEMENT_START_BUTTON) return; - if (ConnectivityMgr().IsThreadProvisioned()) + // In case of having software update enabled, allow on starting BLE advertising after Thread provisioning. + if (ConnectivityMgr().IsThreadProvisioned() && !sAppTask.mSoftwareUpdateEnabled) { LOG_INF("NFC Tag emulation and BLE advertisement not started - device is commissioned to a Thread network."); return;