示例#1
0
def main():
    #base = DynastreamANT(True)
    base = FitBitANT(debug=True)
    if not base.open():
        print "No devices connected!"
        return 1

    device = FitBit(base)

    device.init_tracker_for_transfer()

    device.get_tracker_info()
    # print device.tracker

    device.parse_bank2_data(device.run_data_bank_opcode(0x02))
    print "---"
    device.parse_bank0_data(device.run_data_bank_opcode(0x00))
    device.run_data_bank_opcode(0x04)
    d = device.run_data_bank_opcode(0x02)  # 13
    for i in range(0, len(d), 13):
        print["%02x" % x for x in d[i:i + 13]]
    d = device.run_data_bank_opcode(0x00)  # 7
    print["%02x" % x for x in d[0:7]]
    print["%02x" % x for x in d[7:14]]
    j = 0
    for i in range(14, len(d), 3):
        print d[i:i + 3]
        j += 1
    print "Records: %d" % (j)
    device.parse_bank1_data(device.run_data_bank_opcode(0x01))

    # for i in range(0, len(d), 14):
    #     print ["%02x" % x for x in d[i:i+14]]
    base.close()
    return 0
示例#2
0
class FitBitClient(object):
    CLIENT_UUID = "2ea32002-a079-48f4-8020-0badd22939e3"
    #FITBIT_HOST = "http://client.fitbit.com:80"
    FITBIT_HOST = "https://client.fitbit.com"  # only used for initial request
    START_PATH = "/device/tracker/uploadData"

    def __init__(self):
        self.info_dict = {}
        base = FitBitANT(debug=True)

        for retries in (2, 1, 0):
            try:
                if not base.open():
                    print "No devices connected!"
                    return
            except Exception, e:
                print e
                if retries:
                    print "retrying"
                    time.sleep(5)
                else:
                    raise

        self.fitbit = FitBit(base)
        self.remote_info = None
示例#3
0
    def __init__(self):
        self.info_dict = {}
        base = FitBitANT(debug=True)
        if not base.open():
            print "No devices connected!"
            return 1

        self.fitbit = FitBit(base)
        self.remote_info = None
示例#4
0
 def __init__(self):
     self.info_dict = {}
     base = FitBitANT(debug=True)
     self.fitbit = FitBit(base)
     self.remote_info = None
     for retries in (2, 1, 0):
         try:
             if not base.open():
                 print "No devices connected!"
                 exit(1)
         except Exception, e:
             print e
             if retries:
                 print "retrying"
                 time.sleep(5)
             else:
                 raise
示例#5
0
 def __init__(self):
     self.info_dict = {}
     self.fitbit = None
     for base in [bc(debug=self.DEBUG) for bc in self.BASES]:
         for retries in (2, 1, 0):
             try:
                 if base.open():
                     print "Found %s base" % (base.NAME, )
                     self.fitbit = FitBit(base)
                     self.remote_info = None
                     break
                 else:
                     break
             except Exception, e:
                 print e
                 if retries:
                     print "retrying"
                     time.sleep(5)
         else:
             raise
         if self.fitbit:
             break