Skip to content
This repository has been archived by the owner on Apr 14, 2018. It is now read-only.

Two small fixes, plus a little cleanup. #42

Merged
merged 3 commits into from
Aug 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/linux/11-fitbit_base.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="84c4", MODE="0666", SYMLINK+="fitbit", GROUP="video"
1 change: 0 additions & 1 deletion platform/linux/51-fitbit_base.rules

This file was deleted.

12 changes: 6 additions & 6 deletions python/fitbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def gen_packet_id(self):

def parse_info_packet(self, data):
"""Parses the information gotten from the 0x24 retrieval command"""

self.serial = data[0:5]
self.firmware_version = data[5]
self.bsl_major_version = data[6]
Expand Down Expand Up @@ -278,7 +278,7 @@ def erase_data_bank(self, index, tstamp=None):
def get_data_bank(self):
data = []
cmd = 0x70 # Send 0x70 on first burst
for parts in range(20):
for parts in range(2000):
bank = self.check_tracker_data_bank(self.current_bank_id, cmd)
self.current_bank_id += 1
cmd = 0x60 # Send 0x60 on subsequent bursts
Expand Down Expand Up @@ -310,7 +310,7 @@ def parse_bank0_data(self, data):
else:
record_date = (datetime.datetime.fromtimestamp(last_date_time + 60 * time_index))
# steps are easy. It's just the last byte
steps = data[i+2]
steps = data[i+2]
# active score: second byte, subtract 10 (because METs
# start at 1 but 1 is subtracted per minute, see
# asterisk note on fitbit website, divide by 10.
Expand All @@ -319,15 +319,15 @@ def parse_bank0_data(self, data):
not_sure = data[i] - 0x81
print "%s: ???: %d Active Score: %f Steps: %d" % (record_date, not_sure, active_score, steps)
i = i + 3
time_index = time_index + 1
time_index = time_index + 1

def parse_bank1_data(self, data):
for i in range(0, len(data), 14):
print ["0x%.02x" % x for x in data[i:i+13]]
# First 4 bytes are seconds from Jan 1, 1970
daily_steps = data[i+7] << 8 | data[i+6]
record_date = datetime.datetime.fromtimestamp(data[i] | data[i + 1] << 8 | data[i + 2] << 16 | data[i + 3] << 24)
print "Time: %s Daily Steps: %d" % (record_date, daily_steps)
print "Time: %s Daily Steps: %d" % (record_date, daily_steps)

def parse_bank6_data(self, data):
i = 0
Expand All @@ -342,7 +342,7 @@ def parse_bank6_data(self, data):
d = data[i:i+4]
tstamp = d[3] | d[2] << 8 | d[1] << 16 | d[0] << 24
i += 4

def main():
#base = DynastreamANT(True)
base = FitBitANT(debug=True)
Expand Down