Merge branch 'bugfix/esp_prov_ble_rw_except' into 'master'

esp_prov : Catch DBus exception when reading/writing to BLE GATT characteristic

See merge request idf/esp-idf!4503
pull/3216/head
Angus Gratton 2019-03-15 21:10:53 +08:00
commit f6665cf90b
1 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -162,8 +162,17 @@ class BLE_Bluez_Client:
path = self.characteristics[characteristic_uuid]
except KeyError:
raise RuntimeError("Invalid characteristic : " + characteristic_uuid)
path.WriteValue([ord(c) for c in data], {}, dbus_interface='org.bluez.GattCharacteristic1')
return ''.join(chr(b) for b in path.ReadValue({}, dbus_interface='org.bluez.GattCharacteristic1'))
try:
path.WriteValue([ord(c) for c in data], {}, dbus_interface='org.bluez.GattCharacteristic1')
except dbus.exceptions.DBusException as e:
raise RuntimeError("Failed to write value to characteristic " + characteristic_uuid + ": " + str(e))
try:
readval = path.ReadValue({}, dbus_interface='org.bluez.GattCharacteristic1')
except dbus.exceptions.DBusException as e:
raise RuntimeError("Failed to read value from characteristic " + characteristic_uuid + ": " + str(e))
return ''.join(chr(b) for b in readval)
# --------------------------------------------------------------------