mirror of
https://github.com/RfidResearchGroup/ChameleonUltra.git
synced 2026-05-12 11:22:59 -07:00
Merge pull request #35 from doegox/phil_tools_dfu
Add helper scripts to enter DFU from USB or from BLE
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import serial
|
||||
import serial.tools.list_ports as list_ports
|
||||
|
||||
DFUCMD=b'\x11\xef\x03\xf2\x00\x00\x00\x00\x0b\x00'
|
||||
|
||||
port = None
|
||||
for comport in list_ports.comports():
|
||||
if comport.vid == 0x1915 and comport.pid == 0x521f:
|
||||
print("Chameleon already in DFU mode")
|
||||
exit(0)
|
||||
if comport.vid == 0x6868 and comport.pid == 0x8686:
|
||||
port = comport.device
|
||||
break
|
||||
|
||||
if port is None:
|
||||
print("Chameleon not found")
|
||||
exit(1)
|
||||
|
||||
try:
|
||||
serial_instance = serial.Serial(port=port, baudrate=115200)
|
||||
serial_instance.dtr = 1 # must make dtr enable
|
||||
serial_instance.timeout = 0 # noblock
|
||||
serial_instance.write(DFUCMD)
|
||||
except Exception as e:
|
||||
print(f"Serial Error {e}.")
|
||||
exit(1)
|
||||
finally:
|
||||
serial_instance.close()
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import asyncio
|
||||
from bleak import BleakClient
|
||||
from bleak import BleakScanner
|
||||
|
||||
UUID_NORDIC_TX = "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
UUID_NORDIC_RX = "6e400003-b5a3-f393-e0a9-e50e24dcca9e"
|
||||
DFUCMD=b'\x11\xef\x03\xf2\x00\x00\x00\x00\x0b\x00'
|
||||
|
||||
async def main():
|
||||
print("Searching ChameleonUltra...")
|
||||
device = await BleakScanner.find_device_by_name("ChameleonUltra")
|
||||
if device is None:
|
||||
print("Could not find ChameleonUltra")
|
||||
return
|
||||
print("Found!")
|
||||
print("Sending DFU command")
|
||||
async with BleakClient(device) as client:
|
||||
c=DFUCMD
|
||||
await client.write_gatt_char(UUID_NORDIC_TX, bytearray(DFUCMD), False)
|
||||
print("Done!")
|
||||
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user