Error in getting the mac address of a microcontroller with available answer in forum

Hello

I got error in getting the mac address with available answer(devzone.nordicsemi.com/.../how-to-get-mac-address-using-nrf5340_dk) in forum. I tried to paste that code in sensor client example to get mac address of bluetooth mesh connected devices

Here is the code and error

/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

/** @file
 *  @brief Nordic mesh sensor observer sample
 */
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/mesh/models.h>
#include <bluetooth/mesh/dk_prov.h>
#include <dk_buttons_and_leds.h>
#include "model_handler.h"



static void bt_ready(int *err)
{
    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());
    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)
{
    static char addr_str[BT_ADDR_STR_LEN];
    struct bt_hci_vs_static_addr addr;
    int addr_count;
    int err;
    addr_count = bt_read_static_addr(&addr, 1);
   
    if (addr_count > 0)
    {
        t_addr_to_str(&(addr.bdaddr), addr_str, sizeof(addr_str));
        printk("BT addr: %s\n", addr_str);
    }

    printk("Initializing...\n");
    err = bt_enable(bt_ready);
    if (err) {
        printk("Bluetooth init failed (err %d)\n", err);
    }
}

static char addr_str[BT_ADDR_STR_LEN];
    struct bt_hci_vs_static_addr addr;
    int addr_count;

    addr_count = bt_read_static_addr(&addr, 1);

    if (addr_count > 0)
    {
        bt_addr_to_str(&(addr.bdaddr), addr_str, sizeof(addr_str));
        printk("BT addr: %s\n", addr_str);
    }

this is the code i coped and the error is as below

Regards

Parents Reply Children
Related