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

nrf52840 802.15.4 start command

Hi,

I'm trying to use the command "mlme_start_req" to setup the device as a pan coordinator to send beacons to the others devices in the network, but after submit the command the callback is not called. For instance, if I don't set a short address before the start the callback is called with the error code 153 (should be the 236, based on the struct mac_status_t), this means that the callback is working but only when something is wrong.

This is the start request:

    static void a_start(void * p_data)
        {
        	mlme_start_req_t startReq =
        	{
        			.pan_id  = 0x1234,
        			.logical_channel = 17,
        			.start_time = 0x000000,
        			.beacon_order = 0,
        			.superframe_order = 0,
        			.pan_coordinator = true,
        			.battery_life_extension = false,
        			.coord_realignment = false,
        	};
        	mlme_start_req( &startReq, mlme_start_conf);
}

This is the call back:

static void mlme_start_conf(mlme_start_conf_t * conf)
{
    fsm_event_data_t data =
    {
        .m_start_conf = conf,
    };
    fsm_event_post(E_START_DONE, &data);
}

Anyone have idea of what is happening?

fsm.c fsm.h main.c

Regards, Jose

Parents
  • Hi Jose,

    I'm sorry for the long delayed response to this issue. We now have a debug setup available, which should reduce debug time on similar cases in the future.

    The reason for this issue is that the parameter startReq in function a_start() is not declared static. The pointer to this structure is stored in library’s global data and used for calling the confirmation callback. When the parameter is not declared static, the variable will be out of scope when exiting a_start(), leading to a Hardfault when library trying to access callback address.

    Changing your code to this should solve the problem:

    static void a_start(void * p_data)
    {
    	static mlme_start_req_t startReq =
    	{
    		.pan_id  = 0x1234,
    		.logical_channel = 17,
    		.start_time = 0x000000,
    		.beacon_order = 0,
    		.superframe_order = 0,
    		.pan_coordinator = true,
    		.battery_life_extension = false,
    		.coord_realignment = false,
    	};
    	mlme_start_req( &startReq, mlme_start_conf);
    }
    

    Unfortunately it is not documented in the API reference that the MAC parameters need to be declared static.

    Best regards,

    Jørgen

Reply
  • Hi Jose,

    I'm sorry for the long delayed response to this issue. We now have a debug setup available, which should reduce debug time on similar cases in the future.

    The reason for this issue is that the parameter startReq in function a_start() is not declared static. The pointer to this structure is stored in library’s global data and used for calling the confirmation callback. When the parameter is not declared static, the variable will be out of scope when exiting a_start(), leading to a Hardfault when library trying to access callback address.

    Changing your code to this should solve the problem:

    static void a_start(void * p_data)
    {
    	static mlme_start_req_t startReq =
    	{
    		.pan_id  = 0x1234,
    		.logical_channel = 17,
    		.start_time = 0x000000,
    		.beacon_order = 0,
    		.superframe_order = 0,
    		.pan_coordinator = true,
    		.battery_life_extension = false,
    		.coord_realignment = false,
    	};
    	mlme_start_req( &startReq, mlme_start_conf);
    }
    

    Unfortunately it is not documented in the API reference that the MAC parameters need to be declared static.

    Best regards,

    Jørgen

Children
Related