def __init__(self, bus, index): Service.__init__(self, bus, index, uuid, True) self.add_characteristic( myCharacteristic(bus, 0, '0000fee1-0000-1000-8000-00805f9b34fb', self)) self.add_characteristic( myCharacteristic(bus, 1, '0000fee2-0000-1000-8000-00805f9b34fb', self)) self.add_characteristic( myCharacteristic(bus, 2, '0000fee3-0000-1000-8000-00805f9b34fb', self)) self.add_characteristic( myCharacteristic(bus, 3, '00002a19-0000-1000-8000-00805f9b34fb', self))
def __init__(self, bus, index): Service.__init__(self, bus, index, WIFICONF_SERVICE_UUID, True) self.add_characteristic(TxCharacteristic(bus, 0, self)) self.add_characteristic(RxCharacteristic(bus, 1, self))
def create_read_notify_service(bus, index, service_assigned_number, is_primary, chrc_table_arg): if isinstance(service_assigned_number, str): print "provided service_assigned_number is a string - trying to match known services for the assigned_number..." service_assigned_number = bt_assigned_numbers.get_gatt_service_assigned_number_for_name( service_assigned_number) print "provided service_assigned_number is a string - got match: 0x%x" % service_assigned_number chrc_df = None if chrc_table_arg: # it's a csv file sep = "," with open(chrc_table_arg, 'r') as readf: if "\t" in readf.read(): sep = "\t" chrc_df = pd.read_csv(chrc_table_arg, sep=sep, dtype=str) for required_col in CHRC_TABLE_REQUIRED_COLS: if required_col not in chrc_df.columns: raise Exception( "supplied config dataframe is missing required column: {}". format(required_col)) # check assgined_number rows dont dont start with 0x assume they're chrc 'NAME' in spec and try match them startswith_0x_mask = chrc_df.assigned_number.str.startswith("0x") needs_remap_mask = ~startswith_0x_mask chrc_df.loc[needs_remap_mask, "assigned_number"] = chrc_df.loc[ needs_remap_mask, "assigned_number"].apply( bt_assigned_numbers.get_gatt_chrc_assigned_number_for_name) chrc_df.loc[startswith_0x_mask, "assigned_number"] = chrc_df.loc[ startswith_0x_mask, "assigned_number"].apply(lambda x: int(x, 16)) chrc_df["assigned_number"] = chrc_df["assigned_number"].astype(int) print "read characteristics table:\n", chrc_df try: bt_assigned_numbers.check_service_assigned_number( service_assigned_number) except: type_, value_, traceback_ = sys.exc_info() exstr = str(traceback.format_exception(type_, value_, traceback_)) print "WARNING: failed to match a known service from specified 'assigned number' - exception:", exstr chrc_assigned_number_list = chrc_df.assigned_number.values.tolist() print "chrc_assigned_number_list type:", type( chrc_assigned_number_list), "values:", chrc_assigned_number_list try: bt_assigned_numbers.check_chrc_assigned_number_list( chrc_assigned_number_list) except: type_, value_, traceback_ = sys.exc_info() exstr = str(traceback.format_exception(type_, value_, traceback_)) print "WARNING: failed to match a known characteristic from specified 'assigned number' - exception:", exstr service = Service(bus, index, service_assigned_number, is_primary) for id, row in chrc_df.iterrows(): chrc = MqttSrcReadNotifyCharacteristic(bus, id + 1, service, row.assigned_number, row.default_val_hexdump, row.mqtt_url) service.add_characteristic(chrc) return service
def __init__(self, bus, index): Service.__init__(self, bus, index, '180a', True) self.add_characteristic(devCharacteristic(bus, 0, '2a28', self)) self.add_characteristic(devCharacteristic(bus, 1, '2a25', self)) self.add_characteristic(devCharacteristic(bus, 2, '2a29', self))
def __init__(self, bus, index): Service.__init__(self, bus, index, COVIDSAFE_UUID, True) self.add_characteristic(CovidsafeEncryptCharacteristic(bus, 0, self))