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 Reply
  • 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

Children
  • Hi Andreas,

    I am happy to hear that!

    Andreas3T said:
    passive scan returns MAC_NO_BEACON which might be correct

    This sounds like the correct behavior. With passive scan the device can locate a coordinator transmitting beacon frames within its personal operating space (POS). The device does not, however, transmit a beacon requests during a passive scan.

    Andreas3T said:
    I'm not sure if a Zigbee coordinator requires some additional settings to periodically send a beacon signal.

    To periodically send beacon frames the network must be a beacon-enabled PAN. In such a network you will have at least one device transmitting beacon frames at a regular interval. When this is not the case, the coordinator will only send beacons as a response to a beacon request.

    Andreas3T said:
    Does active scan have additoinal requirements than passive and ED scans?

    The scans differ in how they work at least. With ED (energy detection) scan the device performs an energy detection measurement on the different channels, while during active scan the device transmits a beacon request and waits to receive a beacon. The Zigbee coordinator should have responded to the beacon request with a beacon frame.

    Do you know wheter macAutoRequest is set to true or false? For active and passive scans, the MLME-SCAN.confirm primitive will only include a set of PAN descriptor values of the scan is successful and macAutoRequest is set to TRUE. If not, it will contain a null set of PAN descriptor values.

    Do you have an additional nRF52840 Dongle or DK? If so, you can use it as a sniffer to capture packets using our nRF Sniffer for 802.15.4. This might help in finding out where the issue is, as you will be able to see if the device sends a beacon request during the active scan or not, and whether the Zigbee coordinator responds to the beacon. If you upload the sniffer log as a pcap file I can look at it to see if I find any issues with the network traffic.

    Best regards,

    Marte

  • 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

Related