Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

802.15.4 callback Issues

Hi,

We are developing a wireless protocol based upon 802.15.4 for nRF52840 and have some trouble with the MAC layer. To begin with, a mlme reset is requested and then an active scan.

The first issue is memory allocation, using sys_mm_alloc() to allocate memory (it is initialized beforehand) results in no callbacks after requests for either reset or scan. If swapped out for malloc instead the callbacks occur.

The reset callback seems to be fine but the scan confimation data is weird. For each channel scanned a PAN is found with id 0, the only PAN that should be found is a zigbee coordinator with an ID that is not 0 on channel 11. It also seems sys_task_run must be run for the callbacks to happen, but it is not clear whether it is required to use the system scheduler or not for 802.15.4

Questions:

1. Is the system scheduler required for using the 802.15.4 primitives?

2. Is the system memory allocater required or is using malloc fine?

3. Is there any SDK_CONFIG parameters that need to be set?

4. Is the source code available somewhere?

The sdk used is nRF5 SDK

Thanks in advance

Parents
  • Hi,

    Q1

    From what I can find it seems like calling sys_task_run() is required, but I will check with the developers to make sure.

    Q2

    It is not required to use sys_mm_alloc(). There are some other cases where using this to allocate memory leads to the scan request callback not being called: https://devzone.nordicsemi.com/f/nordic-q-a/56163/nrf-802-15-4-stack-api-mlme_scan_req-does-not-call-the-callback-function and https://devzone.nordicsemi.com/f/nordic-q-a/59282/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

    I checked internally, and I cannot find cases of sys_mm_alloc being used for the MLME-SCAN-request or MLME-RESET.request. It is used to allocate memory for packets, for example:

    test_packet_t * packet_to_send = (test_packet_t *)sys_mm_alloc(sizeof(test_packet_t));

    But scan and reset request are mostly done in the same way as in the comment of the first case I link to above:

    static mlme_reset_req_t mlme_reset_req_container =
      {
        .set_default_pib = true
      };
    
      mlme_reset_req(&mlme_reset_req_container, SetupSeqResetMlmeCb);

    Q3

    Not that I am aware of, but I will check this out.

    Q4

    No, the source code for the library is unfortunately not publicly available.

    I will talk with the developers and see if they might have any ideas as to why the scan confirmation data is as it is.

    Best regards,

    Marte

  • Thanks for the quick reply.

    I see then most of my issues seems to be resolved.

    After trying each type of scan except orphan scan, ED scan seems to work as intended, passive scan returns MAC_NO_BEACON which might be correct, a Zigbee Coordinator is setup close to the device as a test but I'm not sure if a Zigbee coordinator requires some additional settings to periodically send a beacon signal.

    However the Active scan never returns no matter what, according to the standard it should return after the scan duration with a confirm. Does active scan have additoinal requirements than passive and ED scans?

    Best Regards, Andreas

  • I have confirmed that macAutoRequest is set to true. What I find odd is that the confirm primitive is never called when an Active scan is requested regardless if there is a coordinator in the vicinity or not.

    Will come back with results from nRF sniffer, thanks.

    Best Regards, Andreas

  • Hi Andreas,

    Have you managed to get a sniffer log of the active scan?

    Best regards,

    Marte

  • Hi Marte,

    Just got hands on a second nrf52840 to use as sniffer. Will come back with logs later today or possibly tomorrow.

    Thanks for the checkup.

    Best Regards,
    Andreas

  • Due to some OS issues noticed when installing wireshark I ended up reinstalling Ubuntu from scratch and the development environment as well of course. For some reason everything started working fine after this without any changes in the code.

    If I had to guess the reason for the issue it could have been the wrong compiler version or that the 802.15.4 binary was corrupt. If anyone else have similar issues I will leave the correct code for making an active scan below.

    Note that scan type and scan duration is hardcoded in the example.

    Thanks Marte for the help.

    #define CONFIRM_SCAN_SIZE 7
    void mlme_scan_conf_cb(mlme_scan_conf_t * scan_report)
    {
       NRF_LOG_INFO("Status: %X", scan_report->status);
       if(scan_report->status == MAC_SUCCESS)
       {
          if(scan_report->result_list_size > CONFIRM_SCAN_SIZE )
          {
             NRF_LOG_INFO("Number of results surpassed memory allocated in scan");
          }
    
          NRF_LOG_INFO("Received 802.15.4 scan report");
          NRF_LOG_INFO("Found %d PANs", scan_report->result_list_size);
          NRF_LOG_INFO("unscanned channels: %X", scan_report->unscanned_channels);
    
          for(int i = 0; i < scan_report->result_list_size; i++ )
          {
             NRF_LOG_INFO("Found PAN with ID: %X", scan_report->pan_descriptor_list[i].coord_pan_id);
          }
       }
    
    }
    
    static mlme_scan_req_t *scan_request;
    void scan()
    {
       scan_request = (mlme_scan_req_t *)malloc(sizeof(mlme_scan_req_t));
       ASSERT(scan_request != NULL);
    
       scan_request->pan_descriptors_buf = (mac_pan_descriptor_t *) malloc(sizeof(mac_pan_descriptor_t) *  CONFIRM_SCAN_SIZE);
       scan_request->pan_descriptors_buf_size =  CONFIRM_SCAN_SIZE;
       scan_request->energy_detect_buf = malloc(sizeof(uint8_t) *  CONFIRM_SCAN_SIZE);
       scan_request->energy_detect_buf_size =  CONFIRM_SCAN_SIZE;
    
       ASSERT(scan_request->energy_detect_buf != NULL);
       ASSERT(scan_request->pan_descriptors_buf != NULL);
    
       uint32_t channelMask;
       channelMask = 0b00000111111111111111100000000000;
       scan_request->scan_type = 1;
       scan_request->scan_channels = channelMask;
       scan_request->scan_duration = 4;
    
       mlme_scan_req(scan_request, mlme_scan_conf_cb);
       NRF_LOG_INFO("Scanning");
    }
    

    Best Regards,
    Andreas

  • Hi Andreas,

    Good to hear that the issue solved itself, even if you had to reinstall everything Slight smile

    Thank you for sharing your code here for others to find, it is greatly appreciated!

    Best regards,

    Marte

Reply Children
  • I found the actual issue or at least what made active scan work.

    Calling

    ral_irq_handlers_import()
    was required for active scan to properly work. I have no way of telling why, I'm not using the RAL module at all and it isn't mentioned in the documentation as an requirement.

  • Hi,

    I have been trying to look internally, but I cannot find anywhere stating why this function is needed. However, I see that it is called at the beginning of main() in the 802.15.4 Wireless UART example as well. I suspect that it is necessary for RADIO IRQ to work and be handled correctly.

    Best regards,

    Marte

Related