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

802.15.4 mlme_scan_req() never calls it's callback function 802.15.4 Library mlme_scan_request_primitive is not according to 802.15.4_2006 spezification

Hello,

I am adapting the 802.15.4 wireless UART example from the nRF5 SDK 15.3 to also make scans and associate with a PAN coordinator. However i am having trouble with the mlme_scan_req(). When I call this function it never calls the callback function i provided and since the Library function is precompiled I cannot debug it. Here is the function that calls the mlme_scan_req():

static void a_passive_scan(void * p_data)
{
    mp_scan_req = (mlme_scan_req_t *)sys_mm_alloc(sizeof(mlme_scan_req_t));
    ASSERT(mp_scan_req != NULL);
    mp_scan_req->scan_type = PASSIVE_SCAN;
    mp_scan_req->scan_channels = 0x00000001<<14;
    mp_scan_req->scan_duration = 1;
    
    mp_scan_req->pan_descriptors_buf_size = 5;
    mp_scan_req->pan_descriptors_buf = (mac_pan_descriptor_t *)sys_mm_alloc(sizeof(mac_pan_descriptor_t)* mp_scan_req->pan_descriptors_buf_size);
    ASSERT(mp_scan_req->pan_descriptors_buf != NULL);
    
	mp_scan_req->energy_detect_buf_size = 5;
    mp_scan_req->energy_detect_buf = (uint8_t *)sys_mm_alloc(sizeof(uint8_t)*mp_scan_req->energy_detect_buf_size);
	ASSERT(mp_scan_req->energy_detect_buf != NULL);
    
    mlme_scan_req(mp_scan_req, mlme_scan_conf);
}

Like I said the provided callback is never called. When I halt he programm with the debugger after callinf mlme_scan_req() it is in a loop in sys_queue_contains(). This is how the callstack looks like:

I have noticed that the struct mlme_scan_req_t which has to be provided to the mlme_scan_req() function is not according to the 802.15.4_2006 spezification. In the specification no pointer to the pan_descriptors_buf and energy_detect_buf have to be provided. Here is a relevant snippet of the specification:

I do not understand why these buffers need to be provided in the mlme_scan_req_t struct.

Any help with this would be highly appreciated.

Cheers, lorv

  • Hi,

    Maybe you can check if the scan request is sent or not using the nRF Sniffer? That would be a good hint to see if you should expect the callback or not.

    Regarding your question about the pan descriptor buffer and energy detect buffer in the mlme_scan_req_t struct, these are added because of this part of the specification:

    "If a Beacon frame is received when macAutoRequest is set to TRUE, the list of PAN descriptor structures shall be stored by the MAC sublayer until the scan is complete; at this time, the list shall be sent to the next higher layer in the PANDescriptorList parameter of the MLME-SCAN.confirm primitive."

    In order words, the MAC sublayer does not have internal storage for PAN descriptor structure, but instead it requires the higher layer to provide this storage.

    Let me know if you are able to get some sniffer logs.

    Best regards,

    Marjeris

  • Thanks for your answer,

    the part with the storage for the MAC sublayer for the PAN describtor list makes sense to me now.

    I changed the scan type to be active and tried to sniff the beacon request with an other donlge. It is not sent out so I guess enters the loop before that. I guess that I mess something up with the scan-request but I can't figure out what.

    Best regards,

    lorv

Related