Hi Nordic Team!
I am working with nRF5340 DK and nRF Connect SDK 1.5.0
I wanted to use Firmware Upgrade (FOTA) feature with the mesh . So, I have started with Bluetooth: Mesh light (example based on mesh topology) and SMP Server Sample (example based on point to point topology).
I have tested these two examples individually, but the firmware upgrade does not work as expected when they are combined. I am attaching the main.c file in attachment for your reference.
The observation of the issue I face are as follows:
>I am able to see the SMP service in nRF connect app , and the DFU button on top right of GUI.
>When I tried to send the mesh_light.bin file as a upgrade , it hangs at 26% for a while and returns to previous screen which shows the services.
>When I tried to send a small file blinky.bin , then for about 50% of the time i am able to upgrade successfully (though even blinky.bin fails to upgrade by hanging at most times)
>The main.c file and prj.conf that I have modified for mesh light example is placed in attachment
With reference to the observations and the implementation procedure, I have a few doubts regarding this. Is it possible to implement a point to point BLE topology along with the mesh profile without disabling or suspending the mesh profile? As the SMP sample is a point to point BLE topology model, can it be combined with the mesh profile directly?. Otherwise the only working option would be to disable mesh provisioning and start the generic BLE peripheral advertising as referenced in this ticket BLE mesh and FOTA upgrade - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)
I found a zephyr sample code in C:\..\v1.5.0\zephyr\samples\boards\nrf\mesh\onoff_level_lighting_vnd_app onoff_level_lighting_vnd_app. And, I was successfully able to build and flash this onoff_level_lighting_vnd_app one in my nRF5340 with prj_smp_svr.conf .But what I observed was the same issue that the upgrade hangs in midway . And, if the upgrade hangs, the only way to make the SoC advertise again is by pressing the reset button.
From this github_commit, I believe that FOTA is possible in mesh without disabling the mesh bt_mesh_suspend() provisioning.
I am attaching some screenshots for reference. I am a beginner in BLE development and any help is very much appreciated in this regard. I kindly request you to support me in this issue.
#
# Copyright (c) 2019 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
CONFIG_NCS_SAMPLES_DEFAULTS=y
# General configuration
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_SETTINGS=y
CONFIG_HWINFO=y
CONFIG_LOG=y
CONFIG_LOG_PRINTK=y
CONFIG_DK_LIBRARY=y
CONFIG_BT_MESH_DK_PROV=y
# Bluetooth configuration
CONFIG_BT=y
CONFIG_BT_COMPANY_ID=0x0059
CONFIG_BT_DEVICE_NAME="Mesh Light"
#CONFIG_BT_L2CAP_RX_MTU=69 --->as made below
#CONFIG_BT_L2CAP_TX_MTU=69 --->as made below
CONFIG_BT_L2CAP_TX_BUF_COUNT=8
CONFIG_BT_LL_SW_SPLIT=y
CONFIG_BT_OBSERVER=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_SETTINGS=y
CONFIG_BT_TINYCRYPT_ECC=y
# Disable unused Bluetooth features
CONFIG_BT_CTLR_DUP_FILTER_LEN=0
CONFIG_BT_CTLR_LE_ENC=n
CONFIG_BT_DATA_LEN_UPDATE=n
CONFIG_BT_PHY_UPDATE=n
CONFIG_BT_CTLR_CHAN_SEL_2=n
CONFIG_BT_CTLR_MIN_USED_CHAN=n
CONFIG_BT_CTLR_PRIVACY=n
# Bluetooth mesh configuration
CONFIG_BT_MESH=y
CONFIG_BT_MESH_RELAY=y
CONFIG_BT_MESH_FRIEND=y
CONFIG_BT_MESH_ADV_BUF_COUNT=13
CONFIG_BT_MESH_TX_SEG_MAX=10
CONFIG_BT_MESH_PB_GATT=y
CONFIG_BT_MESH_GATT_PROXY=y
# Bluetooth mesh models
CONFIG_BT_MESH_ONOFF_SRV=y
#.........FOTA CONFIGs........................
# Enable mcumgr.
CONFIG_MCUMGR=y
# Some command handlers require a large stack.
#CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 ---> already declared above
# Ensure an MCUboot-compatible binary is generated.
CONFIG_BOOTLOADER_MCUBOOT=y
# Enable the Bluetooth mcumgr transports.
# CONFIG_MCUMGR_SMP_BT=y
# commented the above one as it is enabled through overlay file
# Enable flash operations.
CONFIG_FLASH=y
#dbg_m: Required by the `taskstat` command in os_mgmt.
CONFIG_THREAD_MONITOR=y
# Enable statistics and statistic names.
#CONFIG_STATS=y
#CONFIG_STATS_NAMES=y
#an entry in the stats can be named if STATS_NAMES is enabled.
# Enable most core commands.
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
#CONFIG_MCUMGR_CMD_STAT_MGMT=y
# Enable logging
CONFIG_LOG=y
# Print a banner on the UART on startup.
CONFIG_BOOT_BANNER=y
# Enable console and printk()
CONFIG_PRINTK=y
CONFIG_STDOUT_CONSOLE=y
# ............BT TINY CONFIG ............
# Allow for large Bluetooth data packets.
CONFIG_BT_L2CAP_TX_MTU=252
CONFIG_BT_L2CAP_RX_MTU=252
CONFIG_BT_RX_BUF_LEN=260
# Enable the Bluetooth (unauthenticated) and UART mcumgr transports.
CONFIG_MCUMGR_SMP_BT=y
CONFIG_MCUMGR_SMP_BT_AUTHEN=n
#CONFIG_MCUMGR_SMP_UART=y
# Disable Bluetooth unused features
CONFIG_BT_GATT_READ_MULTIPLE=n
# Disable statistics and statistic names.
#CONFIG_STATS_NAMES=n
/*
* Copyright (c) 2019 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/** @file
* @brief Nordic mesh light sample
*/
#include <bluetooth/bluetooth.h>
#include <bluetooth/mesh/models.h>
#include <bluetooth/mesh/dk_prov.h>
#include <dk_buttons_and_leds.h>
#include "model_handler.h"
#include "common.h"
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA_BYTES(BT_DATA_UUID128_ALL,
0x84, 0xaa, 0x60, 0x74, 0x52, 0x8a, 0x8b, 0x86,
0xd3, 0x4c, 0xb7, 0x1d, 0x1d, 0xdc, 0x53, 0x8d),
};
static void bt_ready(int err)
{
printk("dbg_m In function bt_ready");
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
printk("Bluetooth initialized\n");
dk_leds_init();
dk_buttons_init(NULL);
err = bt_mesh_init(bt_mesh_dk_prov_init(), model_handler_init()); //dbg_m After calling this API, the node will not automatically advertise as unprovisioned, rather the bt_mesh_prov_enable() API needs to be called to enable unprovisioned advertising on one or more provisioning bearers.
if (err) {
printk("Initializing mesh failed (err %d)\n", err);
return;
}
if (IS_ENABLED(CONFIG_SETTINGS)) {
settings_load();
}
/* This will be a no-op if settings_load() loaded provisioning info */
bt_mesh_prov_enable(BT_MESH_PROV_ADV | BT_MESH_PROV_GATT);
printk("Mesh initialized\n");
}
void main(void)
{
int err;
printk("Initializing...\n");
os_mgmt_register_group();
img_mgmt_register_group();
err = bt_enable(bt_ready);
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
}
/* Initialize the Bluetooth mcumgr transport. */
smp_bt_register(); //dbg_m: register the SMP GATT service.
}
Thanks and Regards,
S Mohan