Skip to content

Commit 34d5878

Browse files
maxd-nordicnordicjm
authored andcommitted
lib: hwid: use static BLE MAC
Use bt_id_get to get BLE MAC so it matches the static one used for advertising. Signed-off-by: Maximilian Deubel <[email protected]>
1 parent cedf3ce commit 34d5878

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

lib/hw_id/hw_id.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ int hw_id_get(char *buf, size_t buf_len)
3535
return -EINVAL;
3636
}
3737

38-
struct bt_le_oob oob;
39-
int ret = bt_le_oob_get_local(BT_ID_DEFAULT, &oob);
38+
bt_addr_le_t addr = {0};
39+
int ret = 1;
4040

41-
if (ret) {
41+
bt_id_get(&addr, &ret);
42+
43+
if (ret != 1) {
4244
return -EIO;
4345
}
4446

4547
snprintk(buf, buf_len, "%02X%02X%02X%02X%02X%02X",
46-
oob.addr.a.val[5],
47-
oob.addr.a.val[4],
48-
oob.addr.a.val[3],
49-
oob.addr.a.val[2],
50-
oob.addr.a.val[1],
51-
oob.addr.a.val[0]);
48+
addr.a.val[5],
49+
addr.a.val[4],
50+
addr.a.val[3],
51+
addr.a.val[2],
52+
addr.a.val[1],
53+
addr.a.val[0]);
5254
return 0;
5355
}
5456
#endif /* defined(CONFIG_HW_ID_LIBRARY_SOURCE_BLE_MAC) */

tests/lib/hw_id/src/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
DEFINE_FFF_GLOBALS;
2424

25-
FAKE_VALUE_FUNC(int, bt_le_oob_get_local, uint8_t, struct bt_le_oob *);
25+
FAKE_VOID_FUNC(bt_id_get, bt_addr_le_t *, size_t *);
2626
FAKE_VALUE_FUNC(int, modem_jwt_get_uuids, struct nrf_device_uuid *, struct nrf_modem_fw_uuid *);
2727
FAKE_VALUE_FUNC(struct net_if *, net_if_get_default);
2828
FAKE_VALUE_FUNC(ssize_t, z_impl_hwinfo_get_device_id, uint8_t *, size_t);
@@ -38,20 +38,20 @@ static struct net_if net_if_example = {
3838
.if_dev = &net_if_dev_example
3939
};
4040

41-
static struct bt_le_oob bt_le_oob_example = {
42-
.addr.a.val = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}
41+
static bt_addr_le_t bt_addr_example = {
42+
.a.val = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}
4343
};
4444
static uint8_t serial_nr[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
4545
static struct nrf_device_uuid uuid_example = {
4646
.str = "7439023c-5467-11ed-a841-1b85829d924f"
4747
};
4848
static const char imei[] = "985802356545846";
4949

50-
static int custom_bt_le_oob_get_local(uint8_t id, struct bt_le_oob *oob)
50+
static void custom_bt_id_get(bt_addr_le_t *addrs, size_t *count)
5151
{
52-
TEST_ASSERT_EQUAL(BT_ID_DEFAULT, id);
53-
*oob = bt_le_oob_example;
54-
return 0;
52+
TEST_ASSERT_EQUAL(*count, 1);
53+
*addrs = bt_addr_example;
54+
*count = 1;
5555
}
5656

5757
static ssize_t custom_z_impl_hwinfo_get_device_id(uint8_t *buffer, size_t length)
@@ -80,12 +80,12 @@ static int custom_nrf_modem_at_cmd(void *buf, size_t len, const char *fmt, va_li
8080

8181
void setUp(void)
8282
{
83-
RESET_FAKE(bt_le_oob_get_local);
83+
RESET_FAKE(bt_id_get);
8484
RESET_FAKE(modem_jwt_get_uuids);
8585
RESET_FAKE(net_if_get_default);
8686
RESET_FAKE(z_impl_hwinfo_get_device_id);
8787
RESET_FAKE(nrf_modem_at_cmd);
88-
bt_le_oob_get_local_fake.custom_fake = custom_bt_le_oob_get_local;
88+
bt_id_get_fake.custom_fake = custom_bt_id_get;
8989
modem_jwt_get_uuids_fake.custom_fake = custom_modem_jwt_get_uuids;
9090
net_if_get_default_fake.return_val = &net_if_example;
9191
z_impl_hwinfo_get_device_id_fake.custom_fake = custom_z_impl_hwinfo_get_device_id;

0 commit comments

Comments
 (0)