IBM-Cloud / node-mqtt-for-anki-overdrive

Node.js Controller and MQTT API for Anki Overdrive
Apache License 2.0
56 stars 31 forks source link

controller.js error connecting #3

Open ChronoGit opened 6 years ago

ChronoGit commented 6 years ago

Hello!

I am having a problem with the controller program. Up until then, everything worked, and I could find the two IDs of my cars (Although they were a lot shorter than the ones in the screenshot).

If I now try to start the controller.js however, nothing happens on screen. The "help" command works, but every other command throws this error:

Command: s <Buffer 06 24 f4 01 d4 30 00>
Error sending command

My config file looks like this:

# Bluetooth config: mandatory

# BLE Peripheral/Car ID
# - GroundShock
carid=f0f42007e011
# - Skull
#carid=yourperipheralid

# Start lane: optional (1/right - 4/left, clockwise, default: 1)
# - GroundShock
startlane=4
# - Skull
#startlane=1

# MQTT config: optional
# Comment out the properties below if you don't want to connect to Bluemix

# Device ID you use when you register with the IoT foundation
# - GroundShock
#deviceid=da353e8ed420
# - Skull
#deviceid=yourdeviceid
# For controller (device)
# - GroundShock
authtoken=yourauthtoken
# - Skull
#authtoken=yourauthtoken

# Application key
apikey=yourapikey
apitoken=yourapitoken

Could it be a problem that I am running the program in a Linux VM?

Thanks for any help you can provide!

Sincerely, Chrono

kwiatks commented 6 years ago

Can you confirm you get connectivity to IBM Cloud/Bluemix MQTT ? you get a line saying connectivity has been made at the start of the App on the Mac. I have got the system working but have a real Mac where everything is running (i.e. bluetooth and connectivity to the Cloud).

Did the system ever work with your current setup ?

ChronoGit commented 6 years ago

This was the first time I tried this application, so the System has not worked before.

I was also trying the Controller without Bluemix, as the instructions stated that as optional, as long as you comment the last lines out. Now in the version I posted that is not the case, however I also tried it with everything below the MQTT commented out.

BenDuan commented 6 years ago

Hello, I am having the same problem with the controller programm. Have you solved this problem?

pleribus commented 6 years ago

After much hair pulling and logging to console, I was able to get this working by:

Using following to scan correctly with noble (replacing the startScanning section):

noble.on('stateChange', function(state) { if (state === 'poweredOn') { console.log('start scanning'); noble.startScanning(); } else { noble.stopScanning(); } });

and then also stepping through the services array until I found the matching characteristic.uuid's

peripheral.connect(function(error) {
peripheral.discoverServices([], function(error, services) {
var service = services[2];

(was 0, and only worked after setting to 2)

honsa commented 5 years ago

Thanks for pulling your hair. This was the solution.

The problem are multiple Bluetooth devices so you have to select the correct from the service object.