Implement cross-platform Bluetooth module #299

Closed
valentinstoychev opened this Issue Jun 9, 2015 · 22 comments

Projects

None yet
@valentinstoychev
Contributor

to support the Bluetooth APIs in a cross-platform manner.

@valentinstoychev valentinstoychev modified the milestone: 1.2.0 Jun 9, 2015
@alejonext

+1

@NathanaelA
Contributor

@valentinstoychev - Is this actually going to be released in v1.2 which from what I understand is coming in the next week or so?

@valentinstoychev
Contributor

No, this is not planned for 1.2. It is still in unplanned state.

@N3ll
Contributor
N3ll commented Oct 7, 2015

You can vote in our voting-ideas-site here: https://nativescript.ideas.aha.io/ideas/NS-I-61.

@codeowl1
codeowl1 commented Dec 2, 2015

Our first project will in Native Script will require Bluetooth communication with a micro controller so this would be fantastic for us!!

@sitefinitysteve
Contributor

+1

@codeowl1

I would also add that as the IoT (Internet of Things) is exploding now in popularity and platforms like arduino make it so easy... a cross platform Bluetooth module would really add value to Native Script developers, and could mean the difference between choosing one platform or another for a project requiring Bluetooth ....

@lhitc
lhitc commented Dec 27, 2015

Any news on a Bluetooth module?
Bluetooth would be a mandatory feature for some upcoming project which I would love to implement in NativeScript. Also I support @codeowl1 concerning the importance of Bluetooth.
@valentinstoychev I'm willing to help regarding the Android part (having some still limited knowledge there), but I have not much of a clue on iOS.

@valentinstoychev valentinstoychev added this to the 1.6.0 (Under Review) milestone Jan 4, 2016
@hshristov hshristov modified the milestone: 1.7.0 (Under Review), 1.6.0 Jan 6, 2016
@sixman9
sixman9 commented Jan 12, 2016

Porting from PhoneGap/Cordova-based Bluetooth mobile plugin APIs to NativeScript

With regard to developing this further, I'm hoping the following PhoneGap/Cordova-based plugin APIs may offer a good starting point for porting a cross-platform Bluetooth API over to NativeScript.

Generally, these potential 'donor' projects contain both a cross-platform Javascript API and platform-specific code (usually for IOS and Android), which should serve as a great code porting resource, to NativeScript.

'Standard' Bluetooth profile donor projects

Superficially, the following project looks most promising, given its support of both Bluetooth 4.0/2.1 _and_ Bluetooth Low Engery (BLE)

See BCSphere's bc.js and its various Bluetooth profiles JavaScript files for further ideas regarding integration of a cross-platform API.

BluetoothSerial by Don Coleman (499 Github stars), is also an interesting looking project, although, I'm unsure whether its Bluetooth profile coverage is as comprehensive as BCSsphere's.

Bluetooth Low Energy (BLE) donor projects

If only the newer Bluetooth Low Energy (BLE) compatibility we're required, especially considering some Apple-controlled connection restrictions it alleviates on IOS (see Apple's MFI Program FAQ), then the follow project seems most appropriate to work from:

  • BluetoothLE by Rand Dussing - 336 Github stars (Jan 2016)

Admittedly, this project is geared towards Bluetooth Low Energy, but it's reasonably comprehensive and may offer API design ideas. Again, with honourable mention for Bluetooth Low Energy on PhoneGap/Cordova:

Finally, as far I'm aware, generally all the above projects are permissively licensed (e.g. commercial friendly) and are, usually, Apache licensed.

I'm hoping someone within the NativeScript community can make good use of these resources.

@lhitc
lhitc commented Jan 14, 2016

In the meantime, I built a plugin (the native side being Android only due to my lack of iOS knowledge and hardware).

It is very crude, since it is:

  • built the "learning by doing" way and as such
  • far from complete or clean
  • focused on BLE
  • not derived from the Cordova APIs

What it currently does/has:

  • major BT Adapter methods
  • major Device methods
  • BT assigned numbers
  • scan for classic BT and BLE devices
  • connect to GATT servers
  • GATT services and characteristics (descriptors being currently used only from within the module, natively)
  • workarounds for Android specific BT/BLE caveats
  • a module for the blood pressure profile (as an idea how to implement profiles)

So at least I was able to build a playground app onto it that reads blood pressure data from a BLE device and contains absolutely no native code/objects/constants/whatever.

As I stated above, I'm willing to share and help.
Still, it would require someone with deeper NativeScript experience to define the API and someone with iOS knowledge. Is there anybody (from core team or other) to fill these roles?

@bradmartin
Contributor

@EddyVerbruggen - are you still working on this one?

@EddyVerbruggen
Member

Yeah. Waiting for a few devices to test with though.

@lhitc
lhitc commented Feb 9, 2016

@EddyVerbruggen I can't contribute devices but I can contribute testing with a few devices. If you're interested in assistance, let me know.

@valentinstoychev @bradmartin Also, if a contribution from a "distant user" like me is considered non-valuable, let me know, then I'll just sit and wait until 1.7.0 comes out ;-)

@EddyVerbruggen
Member

@lhitc Much appreciated, thanks!

@valentinstoychev
Contributor

@lhitc Each and every contribution counts! :) Thanks for offering your help. I'm sure Eddy will contact you once the bits are available.

@lhitc
lhitc commented Feb 9, 2016

@EddyVerbruggen @valentinstoychev Thanks; eagerly awaiting any Bluetooth bits ;-)

@dkallkro

Hi Eddy,

The BT module will be shipped to you today or tomorrow,
Sorry for the delay.

Allan Krøyer
CIM Mobility

@EddyVerbruggen
Member

Hi @lhitc, if you're still up for it I'd like you to play with the plugin a bit. Can you (and other folks that may be interested) send me an email at eddyverbruggen at gmail dot com so I can send some instructions and not bother the other repo subscribers with it?

@EddyVerbruggen
Member

Hey all, I just added the capability to write to peripherals to the Bluetooth plugin. And with that I consider the plugin feature complete and only need to test with a few more devices.

It's a matter of days before I publish it on npm, but if you feel like kicking its tires please go ahead and clone the demo app and open issues on the repo if you think anything is misbehaving.

@EddyVerbruggen
Member

Hey @valentinstoychev this one is ready for review. I just pushed 1.0.0 to npm.

To help testing and verification I created a demo app which shows how to perform (start/stop)scanning and (dis)connecting. It also shows how to interact with characteristics: read, write, and notify are support at this time.

@valentinstoychev
Contributor

The plugin is now live @ https://plugins.telerik.com/nativescript/plugin/bluetooth. Big thanks to Eddy for this contribution! @EddyVerbruggen

@alejonext

Thanks!! Valentin!! @valentinstoychev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment