aelveborn / Wii-Scale

Turns your Wii Balance Board into a scale and presents your weight on a responsive website. Runs Linux and works on your Raspberry Pi.
http://aelveborn.github.io/Wii-Scale/
GNU General Public License v2.0
116 stars 27 forks source link

Wii-Scale only connects to a board that is in pairing mode, even if it's paired and trusted #11

Closed dm8tbr closed 7 years ago

dm8tbr commented 8 years ago

I was under the impression, that pairing the board and making it trusted would get rid of the need to put the board into pairing mode. After some fumbling I finally settled for using bluetoothctl, a nice CLI tool for bluez, and got the board paired and set to trusted. I can also use it to connect to the board after pressing the power button on the board and while its LED is blinking. When connected the power LED turns solid until disconnected I've set the board address in the settings: npm config set wii-scale:address 00:25:A0:38:12:34

However, Wii-Scale will always terminate with a python backtrace - unless the board has been put into pairing mode.

Listening on 0.0.0.0:8080

/home/dm8tbr/src/wii-scale/scripts/start-python.js:42
                if (error) throw error;
                                 ^
Error: bluetooth.btcommon.BluetoothError: (112, 'Host is down')
    at PythonShell.parseError (/home/dm8tbr/src/wii-scale/node_modules/python-shell/index.js:131:17)
    at ChildProcess.<anonymous> (/home/dm8tbr/src/wii-scale/node_modules/python-shell/index.js:67:28)
    at ChildProcess.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:820:12)
    ----- Python Traceback -----
    File "wii-scale/wii-scale.py", line 222, in <module>
      main(sys.argv[1:])
    File "wii-scale/wii-scale.py", line 184, in main
      board.connect(address)
    File "/home/dm8tbr/src/wii-scale/wii-scale/wiiboard.py", line 87, in connect
      self.receivesocket.connect((address, 0x13))
    File "<string>", line 5, in connect

Running the python script manually and then starting Wii-Scale produces similar backtraces while connecting:

$ wii-scale/wii-scale.py -a 00:25:A0:38:12:34
Wii-Scale started
Traceback (most recent call last):
  File "wii-scale/wii-scale.py", line 222, in <module>
    main(sys.argv[1:])
  File "wii-scale/wii-scale.py", line 184, in main
    board.connect(address)
  File "/home/dm8tbr/src/wii-scale/wii-scale/wiiboard.py", line 87, in connect
    self.receivesocket.connect((address, 0x13))
  File "<string>", line 5, in connect
bluetooth.btcommon.BluetoothError: (111, 'Connection refused')

Both errors 111 and 112 will happen, depending on if the board turned off before being connected.

This is on: Ubuntu 16.04; kernel 4.4.0-24-generic i386; bluez 5.37-0ubuntu5

I'd try to debug this further, but I'm not well versed in node.js and python interaction.

aelveborn commented 7 years ago

I will try this myself with a paired board. The problem is probably within the wiiboard.py code that handles the bluetooth connection. I don't think Wiiboard.py is not maintained anymore but I'll look in to it.

adrianmihalko commented 7 years ago

//off: -> any chance for export function to CSV, FitBit, or more?

aelveborn commented 7 years ago

@adrianmihalko yes, see #12

aelveborn commented 7 years ago

Closing this issue, @ribbons is rewriting the backend to better handle paired devices.