Changeset 3091
- Timestamp:
- 07/06/08 15:27:00 (5 years ago)
- Location:
- branch/BluetoothScanner/umitBluetooth
- Files:
-
- 1 added
- 3 modified
-
__init__.py (modified) (1 diff)
-
btcore.py (modified) (5 diffs)
-
interface.py (modified) (5 diffs)
-
main.py (added)
Legend:
- Unmodified
- Added
- Removed
-
branch/BluetoothScanner/umitBluetooth/__init__.py
r2956 r3091 19 19 # along with this program; if not, write to the Free Software 20 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 22 23 __author__ = "Devtar Singh <devtar@gmail.com>" 24 __date__ = "7 July 2008" 25 __version__ = "100" # build version -
branch/BluetoothScanner/umitBluetooth/btcore.py
r3056 r3091 26 26 import interface 27 27 28 btname = [""] 29 btmac = [""] 30 btmanu = [""] 31 btsdp = [""] 32 sdpstatus = "" 33 28 34 class btcore: 29 35 30 36 def __init__(self): 31 self.btname = [""] 32 self.btmac = [""] 33 self.btmanu = [""] 34 self.btsdp = [""] 37 global btname 38 global btmac 39 global btmanu 40 global btsdp 41 global sdpstatus 35 42 #entry_text = entry.get_active_text() 36 43 #print "BT Address Entered: %s" % entry_text … … 38 45 def scan(self, interface): 39 46 print "Refresh Interface" 40 interface.progb.set_text("") 41 interface.progb.set_fraction(0) 42 #interface.mapmodel.clear() 43 self.btname = [""] 44 self.btmac = [""] 45 self.btmanu = [""] 46 self.btsdp = [""] 47 self.clear_int(interface) 48 global btname 49 global btmac 50 global btsdp 51 global sdpstatus 52 count = 1 47 53 btdevices = bluetooth.discover_devices(lookup_names = True) 48 54 for addr, name in btdevices: 49 55 if (name == ""): 50 56 name = "N/A" 51 self.btname.append(name) 52 self.btmac.append(addr) 57 btname.append(name) 58 btmac.append(addr) 59 print sdpstatus 60 if (sdpstatus == "Enabled"): 61 # first entry of btdevice is at index 1 hence +1 on initial 62 self.sdp_scan(count) 63 count+=1 53 64 print "\n" + name + "\n" + addr + "\n" 54 65 # BTMAC input test 55 66 interface.progb.set_text("40%") 56 67 interface.progb.set_fraction(.4) 57 self.manufac( self.btmac)68 self.manufac() 58 69 interface.progb.set_text("75%") 59 70 interface.progb.set_fraction(.75) 60 self.map( self.btname, self.btmanu,interface)71 self.map(interface) 61 72 interface.progb.set_text("100%") 62 73 interface.progb.set_fraction(1) 63 74 message_id = interface.status_bar.push(interface.context_id, "Scanning Completed") 64 75 65 #def get_scan 76 def sdp_scan(self, btid): 77 global sdpstatus 78 global btmac 79 global btsdp 80 print "BTID: " + str(btid) 81 sdpservices=bluetooth.find_service(address=btmac[btid]) 82 if len(sdpservices) > 0: 83 for svc in sdpservices: 84 sdpbrowseinfo = "\nService Name: " + str(svc["name"]) + "\n Description: " + str(svc["description"]) + "\n Provided By: " + str(svc["provider"]) + "\n Protocol: " + str(svc["protocol"]) + "\n channel/PSM: " + str(svc["port"]) + "\n svc classes: " + str(svc["service-classes"]) + "\n profiles: " + str(svc["profiles"]) + "\n service id: " + str(svc["service-id"]) 85 btsdp.append("\nFound " + str(len(sdpservices)) + " services\n\n" + sdpbrowseinfo) 86 print sdpbrowseinfo 87 else: 88 sdpbrowseinfo = "no services found" 89 btsdp.append(sdpbrowseinfo) 90 print sdpbrowseinfo 91 66 92 67 def manufac(self, btmac): 93 def manufac(self): 94 global btname 95 global btmac 96 global btmanu 68 97 print "manufacturer detection" 69 98 #Running from source directory … … 73 102 btmacsearch = [""] 74 103 btnamesearch = [""] 75 while ((len( self.btname)-1) > count):104 while ((len(btname)-1) > count): 76 105 count+= 1 77 106 count2 = 0 … … 94 123 btmacsearch.append(btbuf1) 95 124 btnamesearch.append(btbuf2) 96 if( self.btmac[count][:8] == btmacsearch[count2]):97 self.btmanu.append(btnamesearch[count2])98 print " Manufacturer detected : " + self.btmac[count] + "\n" + self.btmanu[count]125 if(btmac[count][:8] == btmacsearch[count2]): 126 btmanu.append(btnamesearch[count2]) 127 print "Count: " + str(count) + "\nNAME: " + btname[count] + "\nMAC : " + btmac[count] + "\nManufacturer detected : " + btmanu[count] 99 128 endsearch = True 100 129 endread = True 101 130 print "Status : " + str(endsearch) 102 131 if(endsearch == False): 103 print "Null: " + __main__.btmac[count][:8]104 self.btmanu.append("null")132 print "Null: " + btmac[count][:8] 133 btmanu.append("null") 105 134 btdb.close() 106 135 107 def map(self, btname, btmanu, interface): 136 def map(self, interface): 137 global btname 138 global btmac 139 global btmanu 108 140 count = 0 109 while ((len( self.btname)-1) > count):141 while ((len(btname)-1) > count): 110 142 count+=1 111 143 if(btmanu[count].find("Nokia") > -1 ): … … 122 154 interface.mapmodel.append([btname[count], pixbuf]) 123 155 124 def onclick(self, interface): 125 print "Selected: " + interface.btmap.get_selected_items() 126 127 156 def set_info(self, interface, btid): 157 global btname 158 global btmac 159 global btmanu 160 global sdpstatus 161 btid+=1 162 print "Selected: " + str(interface.btmap.get_selected_items()) + "\n" + str(btid) 163 interface.label.set_text("Device Details\t\t\t\t\n\nName: " + btname[btid] + "\nMAC: " + btmac[btid] + "\nManufacturer: " + btmanu[btid]) 164 if (sdpstatus == "Enabled"): 165 interface.sdpview.get_buffer().set_text(btsdp[btid]) 128 166 129 def sdpscan(self): 130 print "sdpinfo" 167 def set_sdp(self, status): 168 # Status of Enabled or Disabled 169 global sdpstatus 170 sdpstatus = status 171 172 def clear_int(self, interface): 173 interface.progb.set_text("") 174 interface.progb.set_fraction(0) 175 #interface.mapmodel.clear() 131 176 132 177 133 -
branch/BluetoothScanner/umitBluetooth/interface.py
r3057 r3091 26 26 import about 27 27 import btcore 28 28 29 29 30 class interface: … … 128 129 129 130 # Labels 130 self.btname_label = "" 131 self.btmac_label = "" 132 self.btmanu_label = "" 133 self.label = gtk.Label("Device Details\t\t\t\t\n\nName: " + self.btname_label + "\nMAC: " + self.btmac_label + "\nManufacturer: " + self.btmanu_label) 131 self.label = gtk.Label("Device Details\t\t\t\t\n\nName: " + "\nMAC: " + "\nManufacturer: ") 134 132 self.label.set_selectable(True) 135 133 self.label.set_alignment(0.4,0) … … 155 153 #Output test 156 154 pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.abspath(os.path.join("pixmaps", "bt.png"))) 157 self.mapmodel.append(["Test1", pixbuf])158 self.mapmodel.append(["Test2", pixbuf])155 #self.mapmodel.append(["Test1", pixbuf]) 156 #self.mapmodel.append(["Test2", pixbuf]) 159 157 160 158 self.window.show_all() … … 170 168 171 169 def sdp_cb(self, action): 172 # action has not toggled yet 173 text = ('Enabled', 'Disabled')[action.get_active()==False] 174 message_id = self.status_bar.push(self.context_id, "SDP Browsing is %s"%text) 175 return 170 # action has not toggled yet 171 text = ('Enabled', 'Disabled')[action.get_active()==False] 172 message_id = self.status_bar.push(self.context_id, "SDP Browsing is %s"%text) 173 btcore.btcore().set_sdp(text) 174 return 176 175 177 176 def iconclick_cb(self, path, action): 178 print "clicked"179 177 iter = self.btmap.get_cursor() 178 buffer = str(iter[0])[:2].replace("(","") 179 btid = int(buffer) 180 print "Clicked Icon: "+ str(buffer) 181 btcore.btcore().set_info(self, btid) 180 182 #outputs the location of the icon numerically 181 print "\n" + str(iter[0])[:2].replace("(","")182 183 183 184 def on_about(self, action): … … 185 186 self._about = about.about_dialog() 186 187 self._about.get_about() 187 188 if __name__ == '__main__':189 ubt = interface()190 gtk.main()
