Skip to content

Commit 7d15574

Browse files
committed
Fix formatting using black
1 parent 2497a62 commit 7d15574

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

examples/ble_json_central.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
if connection and connection.connected:
2727
service = connection[SensorService]
28-
service.settings = {
29-
'unit': 'celsius' # 'fahrenheit'
30-
}
28+
service.settings = {"unit": "celsius"} # 'fahrenheit'
3129
while connection.connected:
32-
print('Sensors: ', service.sensors)
30+
print("Sensors: ", service.sensors)

examples/ble_json_peripheral.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020
def measure(unit):
2121
temperature = random.uniform(0.0, 10.0)
2222
humidity = random.uniform(0.0, 100.0)
23-
if unit == 'fahrenheit':
23+
if unit == "fahrenheit":
2424
temperature = (temperature * 9.0 / 5.0) + 32.0
25-
return {
26-
'temperature': temperature,
27-
'humidity': humidity
28-
}
25+
return {"temperature": temperature, "humidity": humidity}
26+
2927

3028
# Advertise until another device connects, when a device connects, provide sensor data.
3129
while True:
32-
print('Advertise services')
33-
ble.stop_advertising() # you need to do this to stop any persistent old advertisement
30+
print("Advertise services")
31+
ble.stop_advertising() # you need to do this to stop any persistent old advertisement
3432
ble.start_advertising(advertisement)
3533

3634
print("Waiting for connection...")
@@ -40,10 +38,10 @@ def measure(unit):
4038
print("Connected")
4139
while ble.connected:
4240
settings = service.settings
43-
measurement = measure(settings.get('unit', 'celsius'))
41+
measurement = measure(settings.get("unit", "celsius"))
4442
service.sensors = measurement
45-
print('Settings: ', settings)
46-
print('Sensors: ', measurement)
47-
time.sleep(.25)
43+
print("Settings: ", settings)
44+
print("Sensors: ", measurement)
45+
time.sleep(0.25)
4846

49-
print('Disconnected')
47+
print("Disconnected")

examples/ble_json_service.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class SensorService(Service):
2323
settings = JSONCharacteristic(
2424
uuid=VendorUUID("e077bdec-f18b-4944-9e9e-8b3a815162b4"),
2525
properties=Characteristic.READ | Characteristic.WRITE,
26-
initial_value={
27-
'unit': 'celsius'
28-
}
26+
initial_value={"unit": "celsius"},
2927
)
3028

3129
sensors = JSONCharacteristic(

0 commit comments

Comments
 (0)