blackberry / WebWorks-Community-APIs

Community owned repository containing JavaScript Extensions for BlackBerry WebWorks
Apache License 2.0
140 stars 204 forks source link

Extend BT plugin to support non-SPP connections (e.g., HRM / Cadence) #371

Closed rtholmes closed 9 years ago

rtholmes commented 9 years ago

The SimpleBtSppPlugin is a great proof of concept for working with bluetooth from Webworks. Is there any chance it could be extended to support GATT for non-chat applications, or would it be better to start from scratch?. For example, something that would work for the HR / Cadence scenarios here would be fantastic:

http://devblog.blackberry.com/2013/04/bluetooth-low-energy-and-the-internet-of-things/

http://devblog.blackberry.com/2013/05/nfc-cadence-cascades/

timwindsor commented 9 years ago

@jcmurray Were you planning to extend the plugin more with some of your work with GATT?

jcmurray commented 9 years ago

It's a good question. This plugin originally stemmed from some work that I had done connecting Bluetooth Medical devices to BlackBerry 10 Cordova apps and I had implemented both SPP/RFCOMM legacy profiles as well as some Bluetooth LE profiles that some medical devices exposed via the GATT ( heart rate measurements, BP, and Oximeter etc. ). So, I have the code and the model works very nicely ... my dilemma was whether to include this in the existing plugin. BTLE has a large number of GATT profiles and I felt that adding these to the existing plugin would make it overly complex (the purpose of this is to help people learn how to use these technologies ) and become a bit of a Swiss Army knife which becomes unwieldy and difficult to use and maintain.

I suspect that it would be better to have another plugin that perhaps did HR, another for cycling cadence etc. -- I'll put it in my list of things to produce.

timwindsor commented 9 years ago

Yeah, I think it's better in the long run to separate plugins into separate groups. Perhaps based on major profile area - ie: we have simple SPP, maybe one focused on various GATT profiles that health and wearables might use?

timwindsor commented 9 years ago

@rtholmes Take a look at https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10-Cordova/SimpleBtLeHrPlugin added by #379. Does it do what you need?

rtholmes commented 9 years ago

Wow, works great @timwindsor ; thanks so much @jcmurray! This is awesome! Just a quick question: to add cadence, would you recommend just modifying the plugin and adding support for the additional profile, or would you recommend copying and adding the profile to a new plugin?

jcmurray commented 9 years ago

For the Cycling Speed and Cadence profile and for a code sample I'd probably clone the HRM plugin and replace the HRM specific parts by the Cadence parts -- 80-90%% of the plugin will be the same since it's really only the format of the characteristics and notification that will carry a different payload that would be different. You should be able to cookie-cutter it. Check out this earlier post on Cadence here: http://devblog.blackberry.com/2013/05/nfc-cadence-cascades/ -- you'll find all the necessary Cadence logic here as well https://github.com/blackberry/Cascades-Community-Samples/tree/master/CscMonitor .