Code: Select all
async def main(address: str):
async def callback_handler(characteristic : BleakGATTCharacteristic, data: bytearray) -> None:
print(f"{characteristic.description}: {data}")
async with BleakClient(address) as client:
await client.start_notify(READ_DATA, callback_handler)
write_data = bytearray([0x00, 0x01, 0x02, 0x03])
await client.write_gatt_char(WRITE_DATA, write_data, response=False)
await asyncio.sleep(1.0)
if __name__ == "__main__":
asyncio.run(main(sys.argv[1] if len(sys.argv) == 2 else ADDRESS))
< /code>
, aber ich kann nicht dasselbe in C ++ mit SDBUs erstellen. Ich kann die 4 Bytes schreiben (denke ich): < /p>
_tempAttrProxyWrite = sdbus::createProxy("org.bluez", WRITE_DATA);
std::vector data = {0x00, 0x01, 0x02, 0x03};
std::map options;
_tempAttrProxyWrite->callMethod("WriteValue")
.onInterface(INTERFACE_CHAR)
.withArguments(data, options);