Issue #33 resolved

Add a pair mode

Benoît Allard
repo owner created an issue

This shouldn't be too difficult (on the technical side), once we have a UI component working (#31) ...

This is a formatted log of the pairing process: http://pastebin.com/kQLQqSzn (Kindly donated by https://github.com/iluetkeb). The network part has no secret either, it's just about coupling the two together ...

Comments (21)

  1. Anonymous

    I just bought a Fitbit One before I realized there is no Linux support, so I am VERY interested in this project. I can possibly work on the pairing issue, because I still need to pair my device.

  2. Benoît Allard reporter

    Actually the biggest challenge there is to answer the questions from the server, as the server sends them as HTML pages. I have a proof of concept where I detect the question being asked, and answer from a list of hard-coded answers (like login: username/password, profile:weight/height/...). It's not easy to do it right as the HTML are full of JavaScript, and we don't know how strict the server is in accepting the answers.

    What I am saying is that while I want to release this code, it will probably not leave an experimental stage, so if you want to go for security, you're better off trying to perform the process from a smartphone or a friend's computer.

    Now if you're still following me, and are still there, I highly appreciate your testing offer. I'll try to push some early version this week-end.

    Which tracker type do you have actually ?

  3. Anonymous

    I have the Fitbit One tracker. I used the Android app to pair my device. I assume that it is possible to remove and re-add a device. I am more than happy to assist with testing or coding.

  4. Benoît Allard reporter

    I greatly appreciate your offer for help !

    I just pushed my experimental code.

    As I said, the answer values are taken from the configuration file, my one includes the following snippet:

    hardcoded-ui:
      login:
        choice: 'login'
        username: MyFitbitUserName
        password: MyPassword
    

    Looks like the server doesn't accepts my 'profile' as I forget to parse the "select" HTML elements. As I said, highly experimental, there is still a lot to do there ...

    Feel free to work on whatever please you !

  5. Benoît Allard reporter

    The select case is now fixed, I won't have much time to work on this over the weekend. So enjoy ! And don't feel obliged to deliver anything, it's free software, it's meant to be fun at first !

  6. Benoît Allard reporter

    Making some progress there ...

    Main blocker at the moment is that the server does not accept the 'code' we enter. I would believe we do everything according to the rules, so I don't understand why, but it is probably something small ...

  7. adolson

    Hi Ben, does your last comment indicate that a brand new Fitbit can now be paired with Galileo alone? I only run Linux and don't have ready access to a Windows PC in my immediate neighborhood.

    I had ordered a Fitbit a couple days ago, thinking that the experimental pair option was already merged into a released version of the script. But, as you know, the version installed using pip was missing it. Is there any way for pip to update to the 0.5dev version, or is it a manual process?

  8. Benoît Allard reporter

    Honestly, I believe it could work. I've not been able to finalize the process with my tracker, but I think the "pairing" in itself is done. The remaining issue is just with synchronization of the greeting message (and what might come after that).

    Be warned however that it is still in an experimental state, and not very user friendly ... At least you should already have an account with username/password (I don't believe it works if you login via Facebook or Google)

    For pip to use the dev version, you need to point him to a link of the tarball of that version. Something like:

    pip install https://bitbucket.org/benallard/galileo/get/default.tar.gz

    During the pairing, the server is sending us a few questions via HTML form. The answer to those questions is taken from galileo configuration file. In most of the cases, if you already configured your account (age, gender, height, ...), the default values are correct.

    I guess the best would be for me to publish that part of my configuration file. I can do that when I'll come back home ...

  9. adolson

    OK, cool. I've got the dev version installed now. I'm expecting the Fitbit to arrive sometime this week and already set up an account on the site, so I will give this a shot.

    You posted a snippet of your config file above nearly 2 months ago; is there more to it now?

    Thanks for your work on this tool!

  10. adolson

    Hi Ben, my Fitbit One arrived today.

    I tried making a config file but the only stuff I put in it was login info from the snippet above, and of course it doesn't work:

    \nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_NAME\', \'Please enter a valid name\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_HEIGHT\', \'Invalid height\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_WEIGHT\', \'Invalid weight\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_GENDER\', \'Please specify a gender\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_BIRTHDAY\', \'Invalid birthday\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_UNDER13\', \'You have to be at least 13 years old to use Fitbit.\');\nfitbit.i18n.setResource(\'com.fitbit.app.device.galileo.client.PROFILE_INVALID_TOOEARLY\', \'Invalid birthday\');\n</script>

    Can you post a complete sample config file example for me, pretty please?

    Edit: after poking around into it a bit, the above block I pasted is probably not helpful at all. Maybe this is?

    /usr/local/bin/galileo: 0.5dev
    Python: 2.7.7 (default, Jun 3 2014, 16:16:56) [GCC 4.8.3]
    Platform: Linux digory 3.14-1-amd64 #1 SMP Debian 3.14.7-1 (2014-06-16) x86_64 
    pyusb: 1.0.0b1
    requests: 2.3.0
    yaml: own version
    Last communications:
    > 02 02
    < 20 01 43 61 6E 63 65 6C 44 69 73 63 6F 76 65 72 79 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    < 20 01 54 65 72 6D 69 6E 61 74 65 4C 69 6E 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    < 
    > 02 01
    < 15 08 01 06 6D C5 AB 72 39 D0 74 04 00 20 00 00 FF E7 01 00 02 00 00 00 00 00 00 00 00 00 00 00
    
  11. Benoît Allard reporter

    This is the content of my config file:

    hardcoded-ui:
      login:
        choice: login
        username: xxxxx
        password: yyyyy
      profile:
        heightUnit: METRIC
        gender: MALE
        weightUnit: METRIC
      chooseDeviceType:
        chosenDevice: hadron
      greeting:
        greeting: GREET
    
  12. Benoît Allard reporter

    'hadron' here is the codename for 'One'. Run the pairing process with --debug, and look at the html from the server to try to find the fitting one for you. it can be a bit tricky, maybe we can setup a chat session if you need more assistance ... the other values, 'METRIC', and 'MALE', have been extracted the same way from the answer from the server ...

  13. adolson

    Thank you! I ran it and the Fitbit One shows up in my account now, saying it sync'd.

    Also, it spit this out right after I entered the number that showed up on the device. Not sure if you need/want it:

    # /usr/local/bin/galileo: 0.5dev
    # Python: 2.7.7 (default, Jun 3 2014, 16:16:56) [GCC 4.8.3]
    # Platform: Linux digory 3.14-1-amd64 #1 SMP Debian 3.14.7-1 (2014-06-16) x86_64 
    # pyusb: 1.0.0b1
    # requests: 2.3.0
    # yaml: own version
    # Last communications:
    # > 53 02 66 2F AB 53 01 92 2F AB 53 9F 51 00 00 00 00 00 00 F1 00 00 00 00 00 00 00 00 00 00 00 14
    # < C0 13 D4 00 00 70 01 00 00 00 00 00 C0 DB DC DD C0 06 EC 00 00 00 00 00 00 00 00 00 00 00 00 05
    # > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02
    # < C0 13 E4 00 00 70 01 00 00 00 00 00 C0 DB DC DD C0 06 EC 00 00 00 00 00 00 00 00 00 00 00 00 05
    # > C0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02
    # < C0 02 E4 00 00 70 01 00 00 00 00 00 C0 DB DC DD C0 06 EC 00 00 00 00 00 00 00 00 00 00 00 00 02
    # > C0 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02
    # < C0 01 E4 00 00 70 01 00 00 00 00 00 C0 DB DC DD C0 06 EC 00 00 00 00 00 00 00 00 00 00 00 00 02
    # > C0 10 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03
    Traceback (most recent call last):
      File "/usr/local/bin/galileo", line 9, in <module>
        load_entry_point('galileo==0.5dev', 'console_scripts', 'galileo')()
      File "/usr/local/lib/python2.7/dist-packages/galileo/main.py", line 263, in main
        }[config.mode](config)
      File "/usr/local/lib/python2.7/dist-packages/galileo/conversation.py", line 79, in __call__
        r = self.do_command(command)
      File "/usr/local/lib/python2.7/dist-packages/galileo/conversation.py", line 97, in do_command
        return f(*childs, **elems)
      File "/usr/local/lib/python2.7/dist-packages/galileo/conversation.py", line 139, in _connect
        [('data', {}, [], dump.toBase64())])
    AttributeError: 'NoneType' object has no attribute 'toBase64'
    
  14. Benoît Allard reporter

    Congrats ! you're the first to setup a tracker entirely using galileo ! I'm a bit proud of myself ! Time to party !

    The information you pasted isn't enough for me to debug anything, I need the lines after that also ...

  15. adolson

    Yes, you should be proud! Thank you so much for this.. I'd been writing Fitbit for like 2-3 years now, asking about Linux support. It was that time of year again, so I checked back in here and saw the experimental sync, figured now is the time. :)

    And whoops! I added the missing info above.

  16. Benoît Allard reporter

    Thank you very much, such feedback helps a lot !

    That issue you experienced is the same I have, and the one I mentioned in the first paragraph of that comment.

    As I thought, and as you just confirmed, it is not mandatory in order to successfully pair a tracker.

  17. Benoît Allard reporter

    This is the final content of my config file:

    hardcoded-ui:
      login:
        choice: login
        username: xxx
        password: yyy
      profile:
        heightUnit: METRIC
        gender: MALE
        weightUnit: METRIC
      chooseDeviceType:
        chosenDevice: hadron
      greeting:
        greeting: GREET
      done: {} 
    
  18. Log in to comment