Skip to content

Commit 0eb027a

Browse files
PavelVPVjhedberg
authored andcommitted
tests: bluetooth: tester: Fix self-update test DFU/SR/FD/BV-59-C
DFU/SR/FD/BV-59-C tests Distributor self-update. Because the actuall firmware swapping doesn't happen, we need to just simulate the swapping by setting new Firmware ID sent by LT. We use slot to take firmware id as by procedure, Fw Update Server doesn't know about it. Signed-off-by: Pavel Vasilyev <[email protected]>
1 parent 12c1fe4 commit 0eb027a

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

tests/bluetooth/tester/src/btp_mesh.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <va.h>
1818
#include <sar_cfg_internal.h>
1919
#include <string.h>
20+
#include "mesh/access.h"
2021

2122
#include <zephyr/logging/log.h>
2223
#define LOG_MODULE_NAME bttester_mesh
@@ -112,6 +113,19 @@ static const struct bt_mesh_blob_io dummy_blob_io = {
112113
#endif
113114

114115
#if defined(CONFIG_BT_MESH_DFD_SRV)
116+
static const struct bt_mesh_dfu_slot *dfu_self_update_slot;
117+
118+
static bool is_self_update(struct bt_mesh_dfd_srv *srv)
119+
{
120+
for (int i = 0; i < ARRAY_SIZE(srv->targets); i++) {
121+
if (bt_mesh_has_addr(srv->targets[i].blob.addr)) {
122+
return true;
123+
}
124+
}
125+
126+
return false;
127+
}
128+
115129
/* DFD Model data*/
116130
static int dfd_srv_recv(struct bt_mesh_dfd_srv *srv,
117131
const struct bt_mesh_dfu_slot *slot,
@@ -138,6 +152,13 @@ static int dfd_srv_send(struct bt_mesh_dfd_srv *srv,
138152

139153
*io = &dummy_blob_io;
140154

155+
dfu_self_update_slot = NULL;
156+
157+
if (is_self_update(srv)) {
158+
LOG_DBG("DFD server starts self-update...");
159+
dfu_self_update_slot = slot;
160+
}
161+
141162
return 0;
142163
}
143164

@@ -216,7 +237,7 @@ static struct bt_mesh_blob_cli blob_cli = { .cb = &blob_cli_handlers };
216237
#if defined(CONFIG_BT_MESH_DFU_SRV)
217238
const char *metadata_data = "1100000000000011";
218239

219-
static uint8_t dfu_fwid[] = {
240+
static uint8_t dfu_fwid[CONFIG_BT_MESH_DFU_FWID_MAXLEN] = {
220241
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
221242
};
222243

@@ -284,6 +305,16 @@ static int dfu_apply(struct bt_mesh_dfu_srv *srv,
284305

285306
LOG_DBG("Applying DFU transfer...");
286307

308+
#if defined(CONFIG_BT_MESH_DFD_SRV)
309+
if (is_self_update(&dfd_srv) && dfu_self_update_slot != NULL) {
310+
LOG_DBG("Swapping fwid for self-update");
311+
/* Simulate self-update by swapping fwid. */
312+
memcpy(&dfu_fwid[0], dfu_self_update_slot->fwid, dfu_self_update_slot->fwid_len);
313+
dfu_imgs[0].fwid_len = dfu_self_update_slot->fwid_len;
314+
}
315+
316+
#endif
317+
287318
return 0;
288319
}
289320

0 commit comments

Comments
 (0)