title: Bluetooth Low Energy : Passive Scan - but do not loop forever?
body: <p>Referencing this <a href="https://stackoverflow.com/questions/16151360/use-bluez-stack-as-a-peripheral-advertiser">post</a> I have successfully managed to get a Linux Device (A Raspberry Pi Model A+) to switch my Bluetooth 4.0 USB dongle into the 'advertising' state:</p>
  
  <pre><code>sudo hciconfig hci0 leadv 3
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sudo hciconfig hci0 leadv 0
  </code></pre>
  
  <p>I verified this using an Ipod running the <a href="https://itunes.apple.com/gb/app/lightblue-explorer-bluetooth/id557428110?mt=8" rel="nofollow noreferrer">'LightBlue Explorer'</a> App.</p>
  
  <p>All good so far.</p>
  
  <p>From another Linux box (another Pi) which also has a Bluetooth 4.0 dongle; I can also see the device, using this command:</p>
  
  <pre><code>sudo hcitool lescan --passive
  </code></pre>
  
  <p>Which returns something like this:</p>
  
  <pre><code>LE Scan ...
  xx:xx:xx:xx:xx:xx (unknown)
  yy:yy:yy:yy:yy:yy (unknown)
  xx:xx:xx;xx:xx:xx (unknown)
  </code></pre>
  
  <p>But the command loops around constantly refreshing the list of devices.</p>
  
  <p>So my main question is: is there a variation of the command that can be run, listen for (say) 5 seconds; return the list of devices that it found to be advertising and exit ?</p>
  
  <p>I want to build a simple script (or Python program ideally) that will periodically wake up, listen (passively) for advertising traffic for a few seconds, and then return the list of source devices.</p>
  
  <p>Additionally: I'm not sure why the the command shows 'unknown' for the devices it finds. (Whereas the LightBlue does identify the name).</p>