NRF.setScan() hangs

Posted on
  • Sample code for NRF.setScan(xxx) hangs during scanning. Where you see the block cursor in the attachment is the last character that was sent to the console. Typing reset() doesn't do anything. Cycling power on Puck works though to reset.

    Also, calling NRF.setScan() with no argument (in order to stop scanning) isn't working. packets variable continues to decrement, and scanning proceeds.

    Reproduced on 2 Pucks, both running 1v91.

    Edit: I added console.log(process.memory());, and I can see free blocks dropping by about 500 as each packet is processed.

    1 Attachment

    • nrf_setscan_hangs.png
  • Chances are you have so many advertising packets being received that it can't output the characters fast enough over BLE. Hence it not appearing to stop - it probably did stop but there was such a backlog it was taking ages.

    The sample code definitely does work, but just not if you have a lot of devices or devices that advertise quickly

    If you want to use setScan rather than findDevices, make sure you can handle the data fast enough - for instance by just writing everything into an array (arr[]=d)

  • Thanks!

    By array, I assume you mean object? Otherwise, that works!

    >xxx = [];
    =[  ]
    >xxx["abc"] = "def";
    =[  ]
    =[  ]
    >nnn = {}
    ={  }
    >nnn["abc"] = "def";
      "abc": "def"
  • Yes, object - thanks :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

NRF.setScan() hangs

Posted by Avatar for oesterle @oesterle