commit 6c4d64ce0e4a53765cac7ee360951acc7dbb46ba
parent f25a53908402b280f0090cf75e91c9ea8d379675
Author: Daniel Barlow <dan@telent.net>
Date: Sun, 1 Feb 2026 16:45:53 +0000
demonstrate reading/writing a characteristic
Diffstat:
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/client/ble.py b/client/ble.py
@@ -0,0 +1,28 @@
+import code
+import readline
+import rlcompleter
+import asyncio
+from bleak import BleakClient,BleakScanner
+
+readline.parse_and_bind("tab: complete")
+
+address = "FF:E4:05:1A:8F:FF"
+CURRENT_INDEX_UUID = "76be25c2-0803-44fc-a97c-bcb56c69c926"
+
+
+async def main(address):
+ print("go")
+ devices = await BleakScanner.discover()
+ for d in devices:
+ print(d)
+
+ async with BleakClient(address, timeout=30) as client:
+ current_index = await client.read_gatt_char(CURRENT_INDEX_UUID)
+ print(f"Model Number: {current_index}")
+ current_index = ord(current_index) + 1
+ await client.write_gatt_char(CURRENT_INDEX_UUID, bytes([current_index]))
+ current_index = await client.read_gatt_char(CURRENT_INDEX_UUID)
+ print(f"Model Number: {current_index}")
+
+
+asyncio.run(main(address))
diff --git a/ecu-esp32/src/wibble.rs b/ecu-esp32/src/wibble.rs
@@ -30,7 +30,7 @@ struct WifiProvisioningService {
#[characteristic(uuid = "76be25c2-0802-44fc-a97c-bcb56c69c926", read, notify, value = 0)]
max_network_index: u8,
- #[characteristic(uuid = "76be25c2-0803-44fc-a97c-bcb56c69c926", write, value = 0)]
+ #[characteristic(uuid = "76be25c2-0803-44fc-a97c-bcb56c69c926", read, write, value = 0)]
current_network_index: u8,
// for arrays > 32 we must supply a default value : see
diff --git a/shell.nix b/shell.nix
@@ -7,6 +7,7 @@
python = (pkgs.python3.withPackages (python-pkgs: [
python-pkgs.pynacl
python-pkgs.zeroconf
+ python-pkgs.bleak
]));
in
pkgs.mkShell rec {