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.

Application hint: Scan many slaves (approx 100)

Other Parts Discussed in Thread: CC2640

Hy,

what would be the best way to solve the following application:

I have a CC2640 in multi role (peripheral + observer) that shall scan for peripherals and detect the closest one (using rssi). Also it shall collect a list of all scanned devices that can be read out by an android master.

What I tried:

I created my own list and add every scanned device to this list. This works OK, but in an environment with many BLE devices (>100) the system is very slow, it may take several minutes to see all BLE devices.

I tried to change GAPOBSERVERROLE_MAX_SCAN_RES to a higher value but find my system instable with high values. Is there a maximum value for this?

Do you think it is possible to solve this application using a CC2640? Using the android device, I see all 100 devices in an instance, no problem. Is there a systematic limitation for discovering many devices with CC2640?

Regards

Harald

  • Hello Harald,

    Ultimately the max scan results will be RAM limited, so making sure your ICall heap is configured for the maximum value will improve results.
    One option is to scan for shorter intervals and restart the scan frequently. If the Advertisers are using a longer ADV interval, then you should be able to catch more devices this way.

    Best wishes
  • Hy,
    thanks for the quick response.
    >so making sure your ICall heap is configured for the maximum value
    Could you point me to the right position, where I can influence ICall heap size? Is this the normal RAM that defines the max heap size? I could easily save some RAM currently used for unimportant global variables in my application
    At the moment, the map file of application looks like
    name origin length used unused attr fill
    ---------------------- -------- --------- -------- -------- ---- --------
    FLASH 00000000 00010fff 0000b7ee 00005811 R X
    SRAM 20000000 000044bb 000037ad 00000d0e RW X

    and of stack:
    name origin length used unused attr fill
    ---------------------- -------- --------- -------- -------- ---- --------
    FLASH 00011000 0000e000 0000d190 00000e70 R X
    SRAM 200044bc 0000042b 00000400 0000002b RW X
    $BOUND$0x20004fec 20004fec 00000010 00000010 00000000 R IX

    So apparently, without optimizing I have 0xD0E (3,2kByte) free RAM. How many scan results would fit into this?

    > to scan for shorter intervals and restart the scan frequently

    Yes, I tried that. Still, it might take many trials to see all visible devices, especially the ones with slow advertising. Is it possible to either return a function or get a callback when the scan has discovered the given amount of devices?
    Regards
    Harald
  • Hi Harald,

    Details on how to set the heap size are in the SW Developer's Guide (SWRU393). See definition for HEAPMGR_SIZE. I would suggest profiling the heap using the guidance in the same document. This will give you an idea on how many devices you can scan.

    You will receive a GAP_DEVICE_DISCOVERY_EVENT event when each device is discovered.

    If you can share the amount of free heap space you have when you start the scan, we can provide better guidance.

    Best wishes
  • Hi Harald,

    To add, you will get a GAP_DEVICE_INFO_EVENT as soon as a device is discovered while scanning.

    Also scanning ends when either of these two cases are met:

    1. Scanning duration expires

    2. Max number of devices reached defined by GAPCENTRALROLE_MAX_SCAN_RES

    Best wishes

  • Hy,

    thanks for your responses. I advanced (a bit) in this matter:

    - I increased ICall Heap by setting HEAPMGR_SIZE=4500

    - I increased GAPOBSERVERROLE_MAX_SCAN_RES to 24

    - When I notice, that scan ends because number of devices reachesGAPCENTRALROLE_MAX_SCAN_RES I start another scan right away.

    So now, the system seems to be both stable and quite dynamic with many BLE devices.

    As for the heap metrics: I see the following figures:

    BLKCNT    84
    BLKMAX    95
    BLKFREE    40
    MEMALO    1836
    MEMMAX    3144
    MEMUB    3220

    Does that sound reasonable to you? I read these figures during a connection after the device runs for about an hour. What analysis can I do on the heap metrics? I read these metrics during a connection by writing and reading BLE characteristics. How do you recommend to use heap metris. In debugger?

    Regards

    Harald