Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
andete committed Mar 3, 2014
1 parent 5b3e7ac commit b8ee45e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ble.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def handle_attclient_group_found(self, sender, args):
self.service_result.emit(handle, uuid, args['start'], args['end'])

def handle_attclient_information_found(self, sender, args):
print args
#print args
handle = args['connection']
char = args['chrhandle']
uuid = args['uuid'][::-1]
Expand Down
28 changes: 27 additions & 1 deletion data/texas_instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,33 @@
push_butt = ([0xFF, 0xE0], "TI Simple Key"),
)

attr = dict()
attr = dict(
ti_st_11 = ([0xF0, 0x00, 0xAA, 0x01, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor Data"),
ti_st_12 = ([0xF0, 0x00, 0xAA, 0x02, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor Configuration"),

ti_st_21 = ([0xF0, 0x00, 0xAA, 0x11, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer Data"),
ti_st_22 = ([0xF0, 0x00, 0xAA, 0x12, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer Configuration"),
ti_st_23 = ([0xF0, 0x00, 0xAA, 0x13, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer Period"),

ti_st_31 = ([0xF0, 0x00, 0xAA, 0x21, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Humidity Sensor Data"),
ti_st_32 = ([0xF0, 0x00, 0xAA, 0x22, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Humidity Sensor Configuration"),

ti_st_41 = ([0xF0, 0x00, 0xAA, 0x31, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer Data"),
ti_st_42 = ([0xF0, 0x00, 0xAA, 0x32, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer Configuration"),
ti_st_43 = ([0xF0, 0x00, 0xAA, 0x33, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer Period"),

ti_st_51 = ([0xF0, 0x00, 0xAA, 0x41, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure Data"),
ti_st_52 = ([0xF0, 0x00, 0xAA, 0x42, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure Configuration"),
ti_st_53 = ([0xF0, 0x00, 0xAA, 0x43, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure Calibration"),

ti_st_61 = ([0xF0, 0x00, 0xAA, 0x51, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Gyroscope Data"),
ti_st_62 = ([0xF0, 0x00, 0xAA, 0x52, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Gyroscope Configuration"),

ti_st_71 = ([0xF0, 0x00, 0xAA, 0x61, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Test Data"),
ti_st_72 = ([0xF0, 0x00, 0xAA, 0x62, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Test Configuration"),

push_butt_data = ([0xFF, 0xE1], "TI Simple Key Data"),
)

class Vendor:

Expand Down
44 changes: 35 additions & 9 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,35 @@ def __init__(self, ble, handle, mac):
self.handle = handle
self.mac = mac
self.view = QtGui.QTreeView()
self.view.setExpandsOnDoubleClick(True)
self.view.setRootIsDecorated(False)
self.model = QtGui.QStandardItemModel()
self.model.setColumnCount(5)
self.model.setHorizontalHeaderLabels(['type', 'service/type','name','handle', 'value'])
self.root = self.model.invisibleRootItem()
self.view.setModel(self.model)
#self.view.doubleClicked.connect(self.double_click)
self.selection_model = QtGui.QItemSelectionModel(self.model, self.view)
self.view.setSelectionModel(self.selection_model)
self.selection_model.currentRowChanged.connect(self.row_changed)
self.current = None

def row_changed(self, current, previous):
self.current = current

"""
def double_click(self):
if self.current is None: return
current = self.current
print current, current.parent()
while current.parent() != QtCore.QModelIndex():
current = current.parent()
print current, current.parent()
for i in range(self.root.rowCount()):
child = self.root.child(i, 0).index()
print "child: ", child, current
self.view.setExpanded(child, child == current)
"""

def primary(self):
self.type = 'primary'
Expand All @@ -38,7 +61,7 @@ def s(x):
service = n
break
uuids = ''.join(["%02X" % c for c in uuid])
print uuids
#print uuids
p = s(self.type)
p.setData(uuid)
self.model.appendRow([p, s(uuids), s(service), s("%s-%s" % (start, end)), s('')])
Expand All @@ -56,7 +79,7 @@ def scan(self):
(starts, ends) = range_str.split('-')
start = int(starts)
end = int(ends)
print uuid, start, end
#print uuid, start, end
self.ble.find_information(self.handle, start, end)

def continue_scan(self):
Expand All @@ -69,7 +92,7 @@ def continue_scan(self):
(starts, ends) = range_str.split('-')
start = int(starts)
end = int(ends)
print uuid, start, end
#print uuid, start, end
self.ble.find_information(self.handle, start, end)
return True

Expand Down Expand Up @@ -100,7 +123,7 @@ def __init__(self):
fileMenu = menuBar.addMenu('&File')
self.add_action(fileMenu, '&Quit', self.close, 'Ctrl+Q')
deviceMenu = menuBar.addMenu('&Device')
self.add_action(deviceMenu, '&Connect', self.connect)
self.add_action(deviceMenu, '&Connect', self.double_click)
helpMenu = menuBar.addMenu('&Help')
self.add_action(helpMenu, '&About', self.about)
self.qtab = QtGui.QTabWidget()
Expand Down Expand Up @@ -151,8 +174,8 @@ def _add(text, slot = None):
self.collect_view.addAction(action)
if slot != None: action.triggered.connect(slot)
else: action.setDisabled(True)
_add('&Connect', self.connect)
self.collect_view.doubleClicked.connect(self.connect)
_add('&Connect', self.double_click)
self.collect_view.doubleClicked.connect(self.double_click)
self.collect_model = QtGui.QStandardItemModel()
self.collect_model.setColumnCount(4)
self.collect_model.setHorizontalHeaderLabels(['time','from', 'name', 'data'])
Expand Down Expand Up @@ -232,7 +255,7 @@ def connection_status(self, handle, mac, status):
device.primary()
self.ble.primary_service_discovery(handle)

def connect(self):
def double_click(self):
idx = self.tab_exists(self.selected_device)
if idx is None:
if not self.selected_device is None:
Expand All @@ -245,8 +268,11 @@ def service_result(self, handle, uuid, start, end):
device.service_result(uuid, start, end)

def info_found(self, handle, char, uuid):
device = self.handle_to_device[handle]
device.info_found(char, uuid)
try:
device = self.handle_to_device[handle]
device.info_found(char, uuid)
except KeyError:
print "ignoring message for unknown handle", handle

def procedure_completed(self, handle):
print "procedure completed", handle, self.running
Expand Down

0 comments on commit b8ee45e

Please sign in to comment.