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

about nordic sniffer python API - getList()

Hi,

I tried to use python API to drive the nrf sniffer to capture ble device information by their advertisement packet. I can successfully target a specific ble device by .find("DeviceModelABCD").

But my final target is to capture a specific model of ble device which their device name have same prefix but different suffix. i.e. "DeviceModelABCD", "DeviceModelEFGH". So I tried to use the api .getList() to get a List so that I can check the name one by one to see which are those target devices true name. However, once I run this api, it fail and the error is that "DeviceList instance has no attribute 'getList'".


Code:

mySniffer = Sniffer.Sniffer("COM19")

mySniffer.start()

devList = mySniffer.getDevices()

ListOfDev = devList.getList()


Since this api is written in the Sniffer api guide, I don't know what have I done wrong.

By the way, is there any other way for me to achieve my target instead of calling this API?

Jones

Parents
  • Hi,

    The Python script linked in this blog post use a different method for matching the address of the device you want to follow:

    tls_dev_addr = [0xde, 0xde, 0x96, 0xdf, 0x92, 0x4a, True]
    
    for _ in range(10):
        time.sleep(1)
        devlist = sniffer.getDevices()
        found_dev = [dev for dev in devlist.devices if dev.address == tls_dev_addr]
        if found_dev:
            follow(sniffer, found_dev[0])
            break
    

    Could you try a similar method for matching the name?

    tls_dev_name = "deviceName"
    
    for _ in range(10):
        time.sleep(1)
        devlist = sniffer.getDevices()
        found_dev = [dev for dev in devlist.devices if dev.name == tls_dev_name]
        if found_dev:
            follow(sniffer, found_dev[0])
            break
    

    Or, if you only want to check for a (prefix) part of the name, you could use:

    found_dev = [dev for dev in devlist.devices if "prefix" in dev.name]
    

    Best regards,

    Jørgen

Reply
  • Hi,

    The Python script linked in this blog post use a different method for matching the address of the device you want to follow:

    tls_dev_addr = [0xde, 0xde, 0x96, 0xdf, 0x92, 0x4a, True]
    
    for _ in range(10):
        time.sleep(1)
        devlist = sniffer.getDevices()
        found_dev = [dev for dev in devlist.devices if dev.address == tls_dev_addr]
        if found_dev:
            follow(sniffer, found_dev[0])
            break
    

    Could you try a similar method for matching the name?

    tls_dev_name = "deviceName"
    
    for _ in range(10):
        time.sleep(1)
        devlist = sniffer.getDevices()
        found_dev = [dev for dev in devlist.devices if dev.name == tls_dev_name]
        if found_dev:
            follow(sniffer, found_dev[0])
            break
    

    Or, if you only want to check for a (prefix) part of the name, you could use:

    found_dev = [dev for dev in devlist.devices if "prefix" in dev.name]
    

    Best regards,

    Jørgen

Children
No Data
Related