tanelih / phonegap-bluetooth-plugin

Bluetooth plugin for PhoneGap version 2.6.0+
MIT License
57 stars 50 forks source link

bt socket connect failed, code:9 #30

Open CosminPOP opened 9 years ago

CosminPOP commented 9 years ago

Hi

I'm getting this error whenever I try to 'connect' to any device: "bt socket connect failed" error code: 9

I added an 'error' parameter to the onFail function :

... var onFail = function (error) { ...

to see this error response that gets called from

... window.bluetooth.connect(onConnection, onFail, { uuid: device.uuids[0], address: self.model.get('address') }); ...

tanelih commented 9 years ago

Have you enabled Bluetooth on both devices? Are you sure the device address is set correctly?

There could be many reasons for this error, the code you are receiving (9), refers to this error. And it seems like the error happens somewhere around here.

Try adding some logging somewhere in the area I pointed out in order to pinpoint the actual error, or failure that is happening. Good luck!

MalikDrako commented 9 years ago

I'm getting this same error. I can get UUIDs and pair the devices, but when I try to connect with any of the retrieved UUIDs I get:

Connect error:  Object {message: "read failed, socket might closed or timeout, read ret: -1", code: 9}

I am running the app on a Nexus 9, trying to connect to a Nexus 7 and a Windows 8 PC. I can connect to the PC through the bluetooth settings, it appears on the PC as a stereo audio service. The example app does the same as my app, although I had to add extra logging in the JS to verify this.

Edit: I found a bluetooth speaker and can connect to that, but I dont think I'm sending data in the right format for it.