This commit is contained in:
Harald Hoyer 2017-04-21 16:12:57 +02:00
parent 75c8241f1b
commit c8f51ead7e
8 changed files with 35 additions and 13 deletions

View file

@ -1,7 +1,7 @@
from ant.core import message
from ant.core.constants import *
from ant.core.exceptions import ChannelError
from const import *
from iConst import *
import thread
from binascii import hexlify
import struct

View file

@ -1,2 +1,18 @@
# iconsole
reverse engineering of the iconsole+ bike computer serial protocol
Reverse engineering of the iconsole+ bike computer serial protocol.
Broadcasts the power and speed on the ANT network.
## Requirements
```
$ pip install --user requirements.txt
```
## Usage
```
$ python iConsole.py <ANT Network Key in ASCII Hex>
```
Use the ANT+ network key to record the data with ANT+ compatible devices, such as a bike computer or fitness watch.

View file

@ -1,7 +1,7 @@
from ant.core import message
from ant.core.constants import *
from ant.core.exceptions import ChannelError
from const import *
from iConst import *
import thread
from binascii import hexlify
import struct

9
iconsole.py → iConsole.py Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/env python
# f0:b2 01:01:04:06 03:11 01:3b 01:07 01:0d 01:01 0f:33 09 02
# T: 3:05 21.0km/h RPM58 D:0.6 cal 12 HF 0 W:1450 LVL8
#
@ -42,13 +44,13 @@
import serial, struct, sys, hashlib, curses
from time import sleep
from binascii import hexlify
from binascii import hexlify,unhexlify
from ant.core import driver
from ant.core import node
from bluetooth import *
from PowerMeterTx import PowerMeterTx
from SpeedTx import SpeedTx
from const import *
from iConst import *
INIT_A0 = struct.pack('BBBBB', 0xf0, 0xa0, 0x02, 0x02, 0x94)
PING = struct.pack('BBBBB', 0xf0, 0xa0, 0x01, 0x01, 0x92)
@ -232,9 +234,10 @@ def main(win):
win.refresh()
if __name__ =='__main__':
NETKEY = unhexlify(sys.argv[1])
stick = driver.USB1Driver(device="/dev/ttyANT", log=LOG, debug=DEBUG)
antnode = node.Node(stick)
print("Starting ANT node")
print("Starting ANT node on network %s" % sys.argv[1])
antnode.start()
key = node.NetworkKey('N:ANT+', NETKEY)
antnode.setNetworkKey(0, key)

View file

@ -1,4 +1,3 @@
NETKEY = '\xB9\xA5\x21\xFB\xBD\x72\xC3\x45'
CADENCE_DEVICE_TYPE = 0x7A
SPEED_DEVICE_TYPE = 0x7B
SPEED_CADENCE_DEVICE_TYPE = 0x79

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
git+https://github.com/baderj/python-ant.git
pybluez

View file

@ -1,20 +1,21 @@
import serial, struct, sys, hashlib, curses
from time import sleep
from binascii import hexlify
from binascii import hexlify,unhexlify
from ant.core import driver
from ant.core import node
from bluetooth import *
from PowerMeterTx import PowerMeterTx
from const import *
from iConst import *
power_meter = None
POWER_SENSOR_ID = int(int(hashlib.md5(getserial()).hexdigest(), 16) & 0xfffe) + 1
if __name__ =='__main__':
NETKEY = unhexlify(sys.argv[1])
stick = driver.USB1Driver(device="/dev/ttyANT", log=None, debug=True)
antnode = node.Node(stick)
print("Starting ANT node")
print("Starting ANT node on network %s" % sys.argv[1])
antnode.start()
key = node.NetworkKey('N:ANT+', NETKEY)
antnode.setNetworkKey(0, key)

View file

@ -1,20 +1,21 @@
import serial, struct, sys, hashlib, curses
from time import sleep
from binascii import hexlify
from binascii import hexlify,unhexlify
from ant.core import driver
from ant.core import node
from bluetooth import *
from SpeedTx import SpeedTx
from const import *
from iConst import *
speed = None
SPEED_SENSOR_ID = int(int(hashlib.md5(getserial()).hexdigest(), 16) & 0xfffe) + 2
if __name__ =='__main__':
NETKEY = unhexlify(sys.argv[1])
stick = driver.USB1Driver(device="/dev/ttyANT", log=None, debug=True)
antnode = node.Node(stick)
print("Starting ANT node")
print("Starting ANT node on network %s" % sys.argv[1])
antnode.start()
key = node.NetworkKey('N:ANT+', NETKEY)
antnode.setNetworkKey(0, key)