From 71f8151fe2ccc32767884216b41a9c35f8c7f47c Mon Sep 17 00:00:00 2001 From: flowswitch Date: Fri, 7 Dec 2018 01:56:11 +0100 Subject: [PATCH] Updated README Added External BMS support to fwupd --- README.md | 7 ++++++- fwupd.py | 7 +++++-- sniffer.py | 4 +++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ceec741..f24d3f1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # py9b -Ninebot/Xiaomi electric scooter communication library +Ninebot/Xiaomi electric scooter communication library and tools. + +## Tools +* fwupd.py - firmware flasher capable of flashing BLE/ESC/BMS +* readregs.py - ESC/BMS register file dumper +Other tools are higly experimental. ## Requirements * Python 2.x.x [www.python.org] diff --git a/fwupd.py b/fwupd.py index 3b2b235..4bb3530 100644 --- a/fwupd.py +++ b/fwupd.py @@ -78,9 +78,9 @@ parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpForm epilog='Example 1: %(prog)s ble ble_patched.bin - flash ble_patched.bin to BLE using default communication parameters' '\nExample 2: %(prog)s -i tcp -a 192.168.1.10:6000 bms bms115.bin - flash bms115.bin to BMS over TCP-BLE bridge at 192.168.1.10:6000' '\nExample 3: %(prog)s -i serial -a COM2 esc CFW.bin - flash CFW.bin to ESC via COM2' - '\nExample 4: %(prog)s -i ble -a 12:34:56:78:9A:BC esc CFW.bin - flash CFW.bin to ESC via BLE, use specified BLE address') + '\nExample 4: %(prog)s -i ble -a 12:34:56:78:9A:BC -p ninebot extbms bms107.bin - flash bms107.bin to Ninebot\'s external BMS via BLE, use specified BLE address') -devices = {'ble' : BT.BLE, 'esc' : BT.ESC, 'bms' : BT.BMS} # TODO: add extbms +devices = {'ble' : BT.BLE, 'esc' : BT.ESC, 'bms' : BT.BMS, 'extbms' : BT.EXTBMS } parser.add_argument('device', help='target device', type=str.lower, choices=devices) parser.add_argument('file', type=argparse.FileType('rb'), help='firmware file') @@ -99,6 +99,9 @@ if len(argv)==1: exit() args = parser.parse_args() +if args.device=='extbms' and args.protocol!='ninebot': + exit('Only Ninebot supports External BMS !') + dev = devices.get(args.device) if args.interface=='ble': diff --git a/sniffer.py b/sniffer.py index 942f174..949df89 100644 --- a/sniffer.py +++ b/sniffer.py @@ -7,6 +7,7 @@ from py9b.link.serial import SerialLink from py9b.transport.base import BaseTransport as BT from py9b.transport.packet import BasePacket as PKT from py9b.transport.xiaomi import XiaomiTransport +from py9b.transport.ninebot import NinebotTransport link = SerialLink() #link = TCPLink() @@ -17,7 +18,8 @@ with link: ports = link.scan() print ports - tran = XiaomiTransport(link) + #tran = XiaomiTransport(link) + tran = NinebotTransport(link) #link.open(("192.168.1.45", 6000)) link.open(ports[0][1])