Monday, March 4, 2013

PhoneGap Bluetooth Plugin Updated

So the Bluetooth plugin was horribly out of date so I took some time to update it to work with PhoneGap 2.2.0 and higher. As well as the usual updates to the JS and Java code I fixed an instance in the "listDevices" call which would block code execution for 10 seconds while it scanned for devices.

Anyway, if you need Bluetooth functionality the plugin provides the following method:

  • listDevices
  • isBTEnabled
  • enableBT
  • disableBT
  • pairBT
  • unPairBT
  • listBoundDevices
  • stopDiscovering
  • isBound
Enjoy!

Update: Oh by the Hoary Hosts of Hogarth! I should mention that I didn't originate this plugin, I just saw the need for it to be updated. All credit should go the original authors: Daniel Tizón, Idoia Olalde and Iñigo González

12 comments:

Naga Harish Movva said...

Nice plugin..

Abulafia said...

Hi Simon,
great job.
Do you have a shot example, how to send/receive data to a (paired) bluetooth device?

I'm using cordova 2.3.0 w/ android

thx

Unknown said...

Hi Simon! Do you think that a serial port plugin to read data off USB is on the horizon?

I've looked into it and it seems complex.

Thakns!

Simon MacDonald said...

@Unknown

I have no plans to do one right now.

Simon MacDonald said...

@Abulafia

Hopefully the device you are pairing with has an SDK but if not:

http://manojprasaddevelopers.blogspot.com/2012/02/bluetooth-data-transfer-example.html

bedorlan said...

Nice! works very well!! thanks!!

blogger for study said...

Sir i want ask you , how can make widget with phonegap ?

Simon MacDonald said...

@blogger for study

You would have to write it in native Android code. PhoneGap is a cross platform framework for creating apps and Widgets are pretty specific to Android.

Adrien Giboire said...

Is it compatible with Bluetooth Smart?

Simon MacDonald said...

@Adrien Giboire

Don't see why not.

yoga surya said...

hi simon


i m not able to download the GIT repo

https://github.com/phonegap/phonegap-plugins/archive/master.zip

Simon MacDonald said...

@yoga surya

Okay, not sure what to tell you. The file downloads fine for me.