Reputation: 138
I have developed a mobile application using Ionic 4, the main functionality of my application is to scan, connect and receive data from a medical hardware using the BLE protocole.
Now, our client want to have the same working version on OSx and to do that we have implement the BLE part using electron alongside ionic 4 and it works fine but we can't find a solution to detect the status of bluetooth: (active or not).
I really appreciate any kind of help, i can't figure it out and i feel really stuck :/
Since the code is basically typescript and javascript any solution with one of these technologies will work.
We are using the Bluetooth web API to make the BLE part work for OSX app.
the function:
navigator.bluetooth.requestDevice()
show an alert in case bluetooth is not active or no device is detected if there is a way i can overwrite this alert in case bluetooth is inactive, i think it's solution right?
BTW, the function:
navigator.bluetooth.getAvailability()
just give me if the current device (Mac) have bluetooth or not, it doesn't return the status of the bluetooth.
Guys i really appreciate your help and thanks in advance.
Upvotes: 2
Views: 645
Reputation: 641
Few years ago I have tried making a prototype Electron app that communicates to bluetooth medical devices(glucometer, blood pressure monitor, weight scale, etc). I was surprised that my codebase in Ionic 1 for the mobile app works in Electron with just minimal adjustments. The app works and was tested on 32bit/64bit WinXP, Win7, Win8 and Win10, MacOSX Mavericks and Ubuntu Linux. It's just not good that they did not pursue that project. I was using the same ionic plugin for bluetooth low energy.
https://github.com/randdusing/cordova-plugin-bluetoothle
I did not find issues on the bluetooth control and operation. My main coding was more focused on Electron and nodejs stuffs.
As for WEB API for Bluetooth, I also studied on that before but I never find a way to make it work.
Since you mention that you have already developed an ionic app with BLE functionality. I was wondering if you have also tried the same code based to the electron app and also use the same BLE plugin. I think that would work also.
Upvotes: 2