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:

  1. 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

    ReplyDelete
  2. 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!

    ReplyDelete
  3. @Unknown

    I have no plans to do one right now.

    ReplyDelete
  4. @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

    ReplyDelete
  5. Nice! works very well!! thanks!!

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

    ReplyDelete
  7. @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.

    ReplyDelete
  8. Is it compatible with Bluetooth Smart?

    ReplyDelete
  9. hi simon


    i m not able to download the GIT repo

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

    ReplyDelete
  10. @yoga surya

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

    ReplyDelete