This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2541: Maximum number of packets that could be received while scanning

Part Number: CC2541

I've few queries regarding scanning, would really appreciate if snyone can comment on the same.

Suppose if the system has around 30  sensors advertising every 90 seconds and my controller CC2541 is configured as Peripheral-Observer role. Observer during the scanning and peripheral to communicate with mobile app.

1.What would be the ideal scan window, scan interval and scan duration to capture all the packets from sensors well? (without much of missing packets)

2. Ideally, how many number of maximum packets could be processed by CC2541 with the optimum scanning parameters values here. 

3. Is it possible to capture all the packets well with CC2541 if I set a timeout of 12 mins ?

Best,

Varun

  • Hi Varun,

    1.What would be the ideal scan window, scan interval and scan duration to capture all the packets from sensors well? (without much of missing packets)

    To reduce the probability of missing a packet, we suggest that you set the scan duration to be twice the length of the advertising interval of the device. You will have a tradeoff here with responsiveness though. You will need to stop scanning in order to parse the scan results.

    2. Ideally, how many number of maximum packets could be processed by CC2541 with the optimum scanning parameters values here. 

    This will depend on the heap size. I would instead recommend scanning frequently and restarting frequently rather than scanning forever.

    3. Is it possible to capture all the packets well with CC2541 if I set a timeout of 12 mins ?

    If you're asking whether you should set the scan duration to 12 minutes, I would recommend against it because you may run out of memory space and you will not even be able to process results until the scan is complete.

    Best,

    Nate

  • HI Nate,

    As always, Many thanks for your precise and clear reply. While parsing packets, I didn't stop scanning. Now I am doing it and results are better.

    I willl close this thread with this follow up quesion:

    What would be the best way to have the scan continuously and restart while not connected to a device? Say if the peripheral device is advertising at 500 ms interval and advertising duration is 2s.

    Is this a good way?

    Setting DEFAULT_SCAN_DURATION to 0 (to enable scanning indefenitely )

    GAP_SetParamValue(TGAP_GEN_DISC_SCAN, DEFAULT_SCAN_DURATION);

    GAP_SetParamValue(TGAP_LIM_DISC_SCAN, DEFAULT_SCAN_DURATION);

    GAPCentralRole_StartDiscovery( DEVDISC_MODE_ALL, TRUE, FALSE );

    case GAP_DEVICE_INFO_EVENT:
    
    GAPCentralRole_CancelDiscovery(); // cancels scan, resets the scan buffer related to scanRes ? 
    OnDeviceDiscovered(&event->deviceInfo);
    
    GAPCentralRole_StartDiscovery( DEVDISC_MODE_ALL, TRUE, FALSE );
    
    
    break;
    
    case GAP_LINK_ESTABLISHED_EVENT:
    if (event->linkCmpl.hdr.status == SUCCESS)
    {
    
    GAPCentralRole_CancelDiscovery();
    currentConnection = event->linkCmpl.connectionHandle;
    filteredRssi = -80;
    Status_t result = GAPCentralRole_StartRssi(event->linkCmpl.connectionHandle, RSSI_PERIOD);
    Debug_AssertExtra(result == SUCCESS, __FILE__, __LINE__);
    }
    else
    {
    currentConnection = INVALID_CONNHANDLE;
    }
    break;
    
    case GAP_LINK_TERMINATED_EVENT:
    
    GAPCentralRole_StartDiscovery( DEVDISC_MODE_ALL, TRUE, FALSE );
    currentConnection = INVALID_CONNHANDLE;
    break;

    Does GAPCentralRole_CancelDiscovery() clears scan buffer related to scanRes ? 

    Looking forward.

    Best,

    Varun

  • Hey Varun,

    Setting the scan duration to 0 would set the device to scan indefinitely. You can try this and see if it works for you. I would recommend trying out duration set to 0 and then adding an application timer to start/stop the scan at the intervals you desire.

    I would perform a quick test by printing out the scanRes buffer before and after calling GAPCentralRole_CancelDiscovery(). This way you can know if it is cleared. I would think so, otherwise you would quickly run out of heap in the stack if it is not cleared each scan. It is up to the application to keep the devices that are relevant when scanning.