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

Parents
  • Hi Charlie, 

    I have built my project which uses UART0 for my communication with other device. 

    But when I include UART related files and my command it gave me below error, 

    1> C:\bamboo\xml-data\build-dir\KNG-OL54-BOLO\sdk\sdk\nrf5\external\openthread\project\nrf52840\plat_nrf52840\uart\armgcc/../../../../openthread/examples/platforms/nrf528xx/src/transport/uart.c:287: multiple definition of `UARTE0_UART0_IRQHandler'; Output/Radiator_thd_v0.9.0 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
    Build failed

    When I searched about error, I found this is because of CLI library. 

    Can you please help how to disable this CLI library in CoAP server/ cli code and make UART available for my custom development. 

    my custom hardware uses P0.6 and P0.8 as Tx/Rx pins. 

    Please help as early as possible. It is urgent to test my custom boards so requesting query in current ticket only. 

    Thanks for understanding. 

    Please find the attached project for reference.

    Radiator_thd_v0.9.0.zip

    Regards,

    Rohit R

  • Hi Rohit,

    Sorry for the late reply, I just come back from vacation. It would be better if you can create a new ticket for your new question next time so that my colleague can give you a timely reply.

    The Thread examples use prebuild OT library for certification and compatibility reasons, uart0 is used by default. You need to set up UARTE1 for your own usage. You can find many discussions on how to UARTE1 by searching Devzone.-

    Best regards,

    Charlie

  • Hi Charlie, 

    Sorry for the late reply, I just come back from vacation.

    - Okay, not a problem.

    It would be better if you can create a new ticket for your new question next time so that my colleague can give you a timely reply.

    - It was urgent so asked here only. Next time if any other problem I will make new ticket. 

    The Thread examples use prebuild OT library for certification and compatibility reasons, uart0 is used by default. You need to set up UARTE1 for your own usage. You can find many discussions on how to UARTE1 by searching Devzone.-

    - Yes, I know the libraries are  prebuild. But as my hardware is ready with uart pin as P0.6 and P0.8. My all UART functions are written using UART0  and are proven. So i don't want to switch to UARTE1. I want to use as it is with UART0. So it must to disable this library and use my custom requirement. 

    I request kindly guide me to disable this uart library and use for custom requirement. 

    Thanks and Regards

    Rohit R 

Reply
  • Hi Charlie, 

    Sorry for the late reply, I just come back from vacation.

    - Okay, not a problem.

    It would be better if you can create a new ticket for your new question next time so that my colleague can give you a timely reply.

    - It was urgent so asked here only. Next time if any other problem I will make new ticket. 

    The Thread examples use prebuild OT library for certification and compatibility reasons, uart0 is used by default. You need to set up UARTE1 for your own usage. You can find many discussions on how to UARTE1 by searching Devzone.-

    - Yes, I know the libraries are  prebuild. But as my hardware is ready with uart pin as P0.6 and P0.8. My all UART functions are written using UART0  and are proven. So i don't want to switch to UARTE1. I want to use as it is with UART0. So it must to disable this library and use my custom requirement. 

    I request kindly guide me to disable this uart library and use for custom requirement. 

    Thanks and Regards

    Rohit R 

Children
  • Hi Rohit,

    There is no better solution for your current situation. As discussed on this ticket: Adding UARTE1 to CLI OpenThread Example - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com).

    You need to use UARTE1 and assign non-conflict pins for your custom UART communication.

    Best regards,

    Charlie

  • Hi Charlie, 

    Thank you so much for the feedback, 

    In above link I saw that we can disable the CLI library and use UART0 for custom. But I am not understanding his steps and unable to find Make file in segger. 

    Can you please help me to identify the Makefile in segger and understand his steps. 

    Below is steps suggested by engineer, 

    If you do not want to use CLI, simply do not initialize it. I cannot post files via comment section, but the steps are pretty simple, so you can reproduce them. I have modified the OpenThread CLI form Thread SDK, as it's the simplest, but you can apply these steps to any Thread example:

    1. Add OT UART header : #include <openthread/platform/uart.h>
    2. Replace otCliUartInit(p_instance); with otPlatUartEnable(); to enable UART0 (CLI does it by itself).
    3. Create receive handler, for example:
    void otPlatUartReceived(const uint8_t *aBuf, uint16_t aBufLength)
    {
        (void)aBuf;
        (void)aBufLength;
        bsp_board_led_invert(BSP_BOARD_LED_3);
    }
    
    1. In a Makefile, remove the line that linked CLI library: $(SDK_ROOT)/external/openthread/lib/gcc/libopenthread-cli-ftd.a \

    After reproducing these steps you will be able to control UART0 manually from the application.

    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