Matching new ndef naming conventions

This commit is contained in:
Fabio Manganiello 2020-08-17 17:10:28 +02:00
parent d5292e068d
commit 62e5d03931

View file

@ -76,7 +76,7 @@ class NfcBackend(Backend):
'record_name': record.name, 'record_name': record.name,
} }
if isinstance(record, ndef.TextRecord): if isinstance(record, ndef.text.TextRecord):
try: try:
r = { r = {
**r, **r,
@ -89,46 +89,46 @@ class NfcBackend(Backend):
'type': 'text', 'type': 'text',
'text': record.text, 'text': record.text,
} }
elif isinstance(record, ndef.UriRecord): elif isinstance(record, ndef.uri.UriRecord):
r = { r = {
**r, **r,
'type': 'uri', 'type': 'uri',
'uri': record.uri, 'uri': record.uri,
'iri': record.iri, 'iri': record.iri,
} }
elif isinstance(record, ndef.SmartposterRecord): elif isinstance(record, ndef.smartposter.SmartposterRecord):
r = { r = {
**r, **r,
'type': 'smartposter', 'type': 'smartposter',
**{attr: getattr(record, attr) for attr in ['resource', 'titles', 'title', 'action', 'icon', **{attr: getattr(record, attr) for attr in ['resource', 'titles', 'title', 'action', 'icon',
'icons', 'resource_size', 'resource_type']}, 'icons', 'resource_size', 'resource_type']},
} }
elif isinstance(record, ndef.DeviceInformationRecord): elif isinstance(record, ndef.deviceinfo.DeviceInformationRecord):
r = { r = {
**r, **r,
'type': 'device_info', 'type': 'device_info',
**{attr: getattr(record, attr) for attr in ['vendor_name', 'model_name', 'unique_name', **{attr: getattr(record, attr) for attr in ['vendor_name', 'model_name', 'unique_name',
'uuid_string', 'version_string']}, 'uuid_string', 'version_string']},
} }
elif isinstance(record, ndef.WifiSimpleConfigRecord): elif isinstance(record, ndef.wifi.WifiSimpleConfigRecord):
r = { r = {
**r, **r,
'type': 'wifi_simple_config', 'type': 'wifi_simple_config',
**{attr: record[attr] for attr in record.attribute_names()} **{attr: record[attr] for attr in record.attribute_names()}
} }
elif isinstance(record, ndef.WifiPeerToPeerRecord): elif isinstance(record, ndef.wifi.WifiPeerToPeerRecord):
r = { r = {
**r, **r,
'type': 'wifi_peer_to_peer', 'type': 'wifi_peer_to_peer',
**{attr: record[attr] for attr in record.attribute_names()} **{attr: record[attr] for attr in record.attribute_names()}
} }
elif isinstance(record, ndef.BluetoothEasyPairingRecord): elif isinstance(record, ndef.bluetooth.BluetoothEasyPairingRecord):
r = { r = {
**r, **r,
'type': 'bluetooth_easy_pairing', 'type': 'bluetooth_easy_pairing',
**{attr: getattr(record, attr) for attr in ['device_address', 'device_name', 'device_class']}, **{attr: getattr(record, attr) for attr in ['device_address', 'device_name', 'device_class']},
} }
elif isinstance(record, ndef.BluetoothLowEnergyRecord): elif isinstance(record, ndef.bluetooth.BluetoothLowEnergyRecord):
r = { r = {
**r, **r,
'type': 'bluetooth_low_energy', 'type': 'bluetooth_low_energy',
@ -137,7 +137,7 @@ class NfcBackend(Backend):
'secure_connections_confirmation_value', 'secure_connections_confirmation_value',
'secure_connections_random_value']}, 'secure_connections_random_value']},
} }
elif isinstance(record, ndef.SignatureRecord): elif isinstance(record, ndef.signature.SignatureRecord):
r = { r = {
**r, **r,
'type': 'signature', 'type': 'signature',