-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
112 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
# (c) 2014 Productize <[email protected]> | ||
|
||
import services, productize, texas_instruments | ||
|
||
from printers import print_default, print_uuid | ||
|
||
class UUID: | ||
|
||
def __init__(self): | ||
self.service = {} | ||
self.attr = {} | ||
self.attr_by_name = {} | ||
self.vendor = [] | ||
sources = [services, productize, texas_instruments] | ||
for source in sources: | ||
self.service.update(source.service) | ||
self.attr.update(source.attr) | ||
for attr in source.attrs: | ||
self.attr[attr.suuid] = attr | ||
self.attr_by_name[attr.name] = attr | ||
self.vendor.append(source.Vendor()) | ||
self.attr_by_uuid = {} | ||
for v in self.attr.values(): | ||
if len(v) == 2: | ||
self.attr_by_uuid[print_uuid(v[0])] = (v[1], print_default) | ||
else: | ||
self.attr_by_uuid[print_uuid(v[0])] = (v[1], v[2]) | ||
|
||
def vendor_to_string(self, data): | ||
vendor_id = data[0] + 256*data[1] | ||
|
@@ -29,7 +25,7 @@ def vendor_to_string(self, data): | |
return "vendor:%04X" % vendor_id | ||
|
||
def value_to_string_by_uuid(self, uuid, value): | ||
return self.attr_by_uuid[print_uuid(uuid)][1](value) | ||
return self.attr[print_uuid(uuid)].value_to_string(value) | ||
|
||
def name_by_uuid(self, uuid): | ||
return self.attr_by_uuid[print_uuid(uuid)][0] | ||
return self.attr[print_uuid(uuid)].name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# (c) 2014 Productize <[email protected]> | ||
|
||
from printers import print_default, print_uuid | ||
|
||
class Attr: | ||
|
||
def __init__(self, uuid, name, printer=print_default): | ||
self.uuid = uuid | ||
self.name = name | ||
self.printer = printer | ||
self.suuid = print_uuid(self.uuid) | ||
|
||
def value_to_string(self, val): | ||
return self.printer(val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# (c) 2014 Productize <[email protected]> | ||
|
||
service = dict() | ||
from attr import Attr | ||
|
||
attr = dict() | ||
attrs = [] | ||
|
||
class Vendor: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,58 @@ | ||
# (c) 2014 Productize <[email protected]> | ||
|
||
from printers import print_uuid, print_string, print_char | ||
|
||
service = dict( | ||
|
||
generic = ([0x18, 0x00], "Generic Access"), | ||
generic_attr = ([0x18, 0x01], "Generic Attribute"), | ||
immediate_alert = ([0x18, 0x02], "Immediate Alert"), | ||
link_loss = ([0x18, 0x03], "Link Loss"), | ||
tx_power = ([0x18, 0x04], "Tx Power"), | ||
time = ([0x18, 0x05], "Current Time"), | ||
ref_time = ([0x18, 0x06], "Reference Time Update"), | ||
next_dst = ([0x18, 0x07], "Next DST Change Service"), | ||
glucose = ([0x18, 0x08], "Glucose"), | ||
thermo = ([0x18, 0x09], "Health Thermometer"), | ||
device_info = ([0x18, 0x0A], "Device Information"), | ||
heart_rate = ([0x18, 0x0D], "Heart Rate"), | ||
phone_alert = ([0x18, 0x0E], "Phone Alert Status"), | ||
battery = ([0x18, 0x0F], "Battery"), | ||
blood = ([0x18, 0x10], "Blood Pressure"), | ||
alert = ([0x18, 0x11], "Alert Notification"), | ||
human_interface = ([0x18, 0x12], "Human Interface"), | ||
scan_para = ([0x18, 0x13], "Scan Parameters"), | ||
run_speed = ([0x18, 0x14], "Running Speed and Cadence"), | ||
cycle_speed = ([0x18, 0x16], "Cycling Speed and Cadence"), | ||
cycle_pow = ([0x18, 0x18], "Cycling Power"), | ||
loc_nav = ([0x18, 0x19], "Location and Navigation"), | ||
|
||
) | ||
|
||
attr = dict( | ||
|
||
primary = ([0x28, 0x00], "Primary", print_uuid), | ||
secundary = ([0x28, 0x01], "Secundary", print_uuid), | ||
include = ([0x28, 0x02], "Include", print_uuid), | ||
char = ([0x28, 0x03], "Characteristic", print_char), | ||
|
||
chr_e_pro = ([0x29, 0x00], "Characteristic Extented Properties"), | ||
chr_u_dsc = ([0x29, 0x01], "Characteristic User Description", print_string), | ||
chr_c_cnf = ([0x29, 0x02], "Client Characteristic Configuration"), | ||
chr_s_cnf = ([0x29, 0x03], "Server Characteristic Configuration"), | ||
chr_p_for = ([0x29, 0x04], "Characteristic Presentation Format"), | ||
chr_a_for = ([0x29, 0x05], "Characteristic Aggregate Format"), | ||
chr_valid = ([0x29, 0x06], "Valid Range"), | ||
chr_exter = ([0x29, 0x07], "External Report Reference"), | ||
chr_repor = ([0x29, 0x08], "Report Reference"), | ||
|
||
devi_name = ([0x2A, 0x00], "Device Name", print_string), | ||
appearanc = ([0x2A, 0x01], "Appearance"), | ||
per_pri_f = ([0x2A, 0x02], "Peripheral Privacy Flag"), | ||
reconnect = ([0x2A, 0x03], "Reconnection Address"), | ||
per_pref_ = ([0x2A, 0x04], "Peripheral Preferred Connection Parameters"), | ||
service_c = ([0x2A, 0x05], "Service Changed"), | ||
) | ||
from attr import Attr | ||
|
||
attrs= [ | ||
|
||
# services | ||
Attr([0x18, 0x00], "Generic Access"), | ||
Attr([0x18, 0x01], "Generic Attribute"), | ||
Attr([0x18, 0x02], "Immediate Alert"), | ||
Attr([0x18, 0x03], "Link Loss"), | ||
Attr([0x18, 0x04], "Tx Power"), | ||
Attr([0x18, 0x05], "Current Time"), | ||
Attr([0x18, 0x06], "Reference Time Update"), | ||
Attr([0x18, 0x07], "Next DST Change Service"), | ||
Attr([0x18, 0x08], "Glucose"), | ||
Attr([0x18, 0x09], "Health Thermometer"), | ||
Attr([0x18, 0x0A], "Device Information"), | ||
Attr([0x18, 0x0D], "Heart Rate"), | ||
Attr([0x18, 0x0E], "Phone Alert Status"), | ||
Attr([0x18, 0x0F], "Battery"), | ||
Attr([0x18, 0x10], "Blood Pressure"), | ||
Attr([0x18, 0x11], "Alert Notification"), | ||
Attr([0x18, 0x12], "Human Interface"), | ||
Attr([0x18, 0x13], "Scan Parameters"), | ||
Attr([0x18, 0x14], "Running Speed and Cadence"), | ||
Attr([0x18, 0x16], "Cycling Speed and Cadence"), | ||
Attr([0x18, 0x18], "Cycling Power"), | ||
Attr([0x18, 0x19], "Location and Navigation"), | ||
|
||
# declarations | ||
Attr([0x28, 0x00], "Primary", print_uuid), | ||
Attr([0x28, 0x01], "Secundary", print_uuid), | ||
Attr([0x28, 0x02], "Include", print_uuid), | ||
Attr([0x28, 0x03], "Characteristic", print_char), | ||
|
||
Attr([0x29, 0x00], "Characteristic Extented Properties"), | ||
Attr([0x29, 0x01], "Characteristic User Description", print_string), | ||
Attr([0x29, 0x02], "Client Characteristic Configuration"), | ||
Attr([0x29, 0x03], "Server Characteristic Configuration"), | ||
Attr([0x29, 0x04], "Characteristic Presentation Format"), | ||
Attr([0x29, 0x05], "Characteristic Aggregate Format"), | ||
Attr([0x29, 0x06], "Valid Range"), | ||
Attr([0x29, 0x07], "External Report Reference"), | ||
Attr([0x29, 0x08], "Report Reference"), | ||
|
||
# characteristics | ||
Attr([0x2A, 0x00], "Device Name", print_string), | ||
Attr([0x2A, 0x01], "Appearance"), | ||
Attr([0x2A, 0x02], "Peripheral Privacy Flag"), | ||
Attr([0x2A, 0x03], "Reconnection Address"), | ||
Attr([0x2A, 0x04], "Peripheral Preferred Connection Parameters"), | ||
Attr([0x2A, 0x05], "Service Changed"), | ||
] | ||
|
||
class Vendor: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# (c) 2014 Productize <[email protected]> | ||
|
||
from attr import Attr | ||
|
||
def ti_print_ir_temp(data): | ||
ambient = (data[2] + 256*data[3])/128.0 | ||
# TODO target temp | ||
|
@@ -37,45 +39,45 @@ def ti_print_accel(data): | |
} | ||
""" | ||
|
||
service = dict( | ||
ti_st_1 = ([0xF0, 0x00, 0xAA, 0x00, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor"), | ||
ti_st_2 = ([0xF0, 0x00, 0xAA, 0x10, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer"), | ||
ti_st_3 = ([0xF0, 0x00, 0xAA, 0x20, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Humidity Sensor"), | ||
ti_st_4 = ([0xF0, 0x00, 0xAA, 0x30, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer"), | ||
ti_st_5 = ([0xF0, 0x00, 0xAA, 0x40, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure"), | ||
ti_st_6 = ([0xF0, 0x00, 0xAA, 0x50, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Gyroscope"), | ||
ti_st_7 = ([0xF0, 0x00, 0xAA, 0x60, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Test"), | ||
attrs = [ | ||
|
||
push_butt = ([0xFF, 0xE0], "TI Simple Key"), | ||
) | ||
# services | ||
Attr([0xF0, 0x00, 0xAA, 0x00, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor"), | ||
Attr([0xF0, 0x00, 0xAA, 0x10, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer"), | ||
Attr([0xF0, 0x00, 0xAA, 0x20, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Humidity Sensor"), | ||
Attr([0xF0, 0x00, 0xAA, 0x30, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer"), | ||
Attr([0xF0, 0x00, 0xAA, 0x40, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure"), | ||
Attr([0xF0, 0x00, 0xAA, 0x50, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Gyroscope"), | ||
Attr([0xF0, 0x00, 0xAA, 0x60, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Test"), | ||
Attr([0xFF, 0xE0], "TI Simple Key"), | ||
|
||
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_print_ir_temp), | ||
ti_st_12 = ([0xF0, 0x00, 0xAA, 0x02, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor Configuration"), | ||
# attributes | ||
Attr([0xF0, 0x00, 0xAA, 0x01, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI IR Temperature Sensor Data", ti_print_ir_temp), | ||
Attr([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_print_accel), | ||
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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x11, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer Data", ti_print_accel), | ||
Attr([0xF0, 0x00, 0xAA, 0x12, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Accelerometer Configuration"), | ||
Attr([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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x21, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Humidity Sensor Data"), | ||
Attr([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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x31, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer Data"), | ||
Attr([0xF0, 0x00, 0xAA, 0x32, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Magnetometer Configuration"), | ||
Attr([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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x41, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure Data"), | ||
Attr([0xF0, 0x00, 0xAA, 0x42, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Barometric Pressure Configuration"), | ||
Attr([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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x51, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Gyroscope Data"), | ||
Attr([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"), | ||
Attr([0xF0, 0x00, 0xAA, 0x61, 0x04, 0x51, 0x40, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], "TI Test Data"), | ||
Attr([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"), | ||
) | ||
Attr([0xFF, 0xE1], "TI Simple Key Data"), | ||
] | ||
|
||
class Vendor: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters