batman1292 / pybluez

Automatically exported from code.google.com/p/pybluez
GNU General Public License v2.0
0 stars 0 forks source link

[PATCH] Add non-RSSI inquiry results in example #29

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If either the local Bluetooth device or the remote one is < 2.1, RSSI can not 
be discovered by 
inquiry, a connection is necessary. This patch adds the "legacy" inquiry 
results, so at least the < 
2.1 devices will appear.

Another future improvement would be to actually connect to such devices and 
then measure RSSI. 
(Maybe I will suggest a patch myself in near future.)

--- inquiry-with-rssi.py    (revision 30)
+++ inquiry-with-rssi.py    (working copy)
@@ -108,8 +108,16 @@
                 print "uh oh..."
                 printpacket(pkt[3:7])
                 done = True
+        elif event == bluez.EVT_INQUIRY_RESULT:
+            pkt = pkt[3:]
+            nrsp = struct.unpack("B", pkt[0])[0]
+            for i in range(nrsp):
+                addr = bluez.ba2str( pkt[1+6*i:1+6*i+6] )
+                results.append( ( addr, -1 ) )
+                print "[%s] (no RRSI)" % addr
         else:
             print "unrecognized packet type 0x%02x" % ptype
+       print "event ", event

Original issue reported on code.google.com by elvis.pf...@gmail.com on 16 Apr 2010 at 11:45

GoogleCodeExporter commented 8 years ago
applied to svn, thanks for the patch.

Original comment by ashu...@gmail.com on 29 Apr 2010 at 8:17

GoogleCodeExporter commented 8 years ago

Original comment by ashu...@gmail.com on 29 Apr 2010 at 8:17