This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Read Thread MAC address

Hello All, 

I am developing a product based on thread protocol. 

I am using nRF52840 development kit and nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8 SDK. 

I am new to thread protocol so I would like to know getting started example for my project. 

I have referred the thread related document from Nordic info center. 

With reference to CoAP server and client example test setup I ran CoAP server on 1 dev-kit and CoAP client on another dev-kit. It worked as per explanation. 

Project Requirement, 

-> My final project contains 2 parts, 1) nRF52840 as RF device (i.e.,Node)  which based on Thread and 2) is Thread based Gateway ( this any Gateway) 

-> my node should connect to gateway (like how Zigbee base Node and Coordinator connect)  and there will be some command exchange(like for example light_bulb from Zibgee) 

I have 3 queries which are listed below, 

1) I going to use base example as CoAP server example? Is this correct example for my requirement? 

2) Assuming CoAP  server is my getting started code for development I did some test here to Get MAC address. But I am not sure whether it is correct response or not? 

   below is the snippet which I used to read MAC. I modified the thread_utils.c file thread_init() function. I used otLinkGetFactoryAssignedIeeeEui64(); function to read MAC id. 

 a)  I am not sure about function parameter passed are correct? Please check the snippet and let me know your feedback. 

 b) With above function, I got one value which as below, but I am not sure the representation of data means MSB is [0] postion or MSB is [7] position?let me know your feedback.

[0]:0xf4

[1]:0xce

[2]:0x36

[3]:0x2f

[4]:0xac

[5]:0xe2

[6]:0xc1

[7]:0x9d

void thread_init(const thread_configuration_t * p_config)
{
    otExtAddress ieeeEUI64;
    otError error;

    otSysInit(0, NULL);

#if defined(MULTIPROTOCOL_802154_CONFIG_PRESENT) && defined(MULTIPROTOCOL_802154_MODE)
    uint32_t retval = multiprotocol_802154_mode_set((multiprotocol_802154_mode_t)MULTIPROTOCOL_802154_MODE);
    ASSERT(retval == NRF_SUCCESS);
#endif

#if !defined OPENTHREAD_RADIO
    platform_init();
#endif

#if FEM_CONTROL_DEFAULT_ENABLE
    fem_init();
#endif

    mp_ot_instance = otInstanceInitSingle();
    ASSERT(mp_ot_instance != NULL);

    NRF_LOG_INFO("Thread version   : %s", (uint32_t)otGetVersionString());
    NRF_LOG_INFO("Network name     : %s",
                 (uint32_t)otThreadGetNetworkName(mp_ot_instance));
    
     otLinkGetFactoryAssignedIeeeEui64(mp_ot_instance,&ieeeEUI64); //read mac address

     NRF_LOG_INFO("IeeeEUi64 Id     : %x",ieeeEUI64.m8);

..................
.................// code default
.............
}

3) Is there any other way to get MAC address of device other than programming(means which using API/function) ? 

Thanks and Regards

Rohit R

  • Hi Charlie, 

    Update from my side. 

    With reference to above steps. I found makefile and removed the cli lib, 

    $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-cli-mtd.a \

    but I am still getting multiple definitions of UART. 

    error - 

    ../../../../../../../../external/openthread/lib/nrf52840/gcc/libopenthread-nrf52840-transport.a(uart.c.o): in function `UARTE0_UART0_IRQHandler':multiple definition of `UARTE0_UART0_IRQHandler'; Output/thread_cli_mtd_uart_pca10056 Release/Obj/nrfx_uart.o:D:\Project\Eurotronics\Thread_Radiator\nRF5_SDK_for_Thread_and_Zigbee_v4.1.0_32ce5f8\modules\nrfx\drivers\src/nrfx_uart.c:649: first defined here
    can you please help me how to make UART0 free for my custom requirement. 
    Thanks and Regards
    Rohit R
  • Hi Rohit,

    The guidance you mentioned is too old for nRF5_SDK_for_Thread_and_Zigbee_v4.1.0. You can follow the following steps to disable the OT CLI library and use UART0 for your application:

    1. Delete "libopenthread-cli-ftd.a" and replace "libopenthread-nrf52840-transport.a" with "libopenthread-nrf52840-transport-none.a"
    2. Modify sdk_config.h to enable UART0, see the simple_coap_client_uart0 sample.
    3. Add Drivers and Libraries to the project, you need to add:
      nRF_Drivers:
      integration\nrfx\legacy\nrf_drv_uart.c
      modules\nrfx\drivers\src\nrfx_uart.c

      nRF_Libraries
      components\libraries\fifo\app_fifo.c
      components\libraries\uart\app_uart_fifo.c
      components\libraries\uart\retarget.c

    4. Add header files path:

      Delete "UART_ENABLED=0" in Preprocessor Definitions, add more include directories to User Include Directories:
      ../../../../../../components/libraries/fifo
      ../../../../../../components/libraries/uart
      ../../../../../../integration/nrfx/legacy
      ../../../../../../modules/nrfx/drivers/include
    5. Use UART0 in your application code, the simple_coap_client_uart0 sample print "Hello World!" at the beginning of main.c.

    simple_coap_client_uart0.zip

    Best regards,

    Charlie

Related