Physical Web Scanner for FxOS (using native implementation) and Cordova (using evothings plugin)
The idea is having an app that can work in any mobile device that scans BLE Physical Web Devices and that can be used in different ways:
-
As a device scanner in which the devices are listed (parameter
showClosestDevice
configured tofalse
in index.js) -
As an URL opener, that opens the URL of the closest Physical Web Device (parameter
showClosestDevice
configured totrue
in index.js)
The URL to be used for every Physical Web Device again can be of 2 types:
- The URL directly stored in the device. (parameter
showDeviceUrl
in index.js is configured totrue
) - A URL stored in Firebase (together with some extra information), the URL in the device is just a pointer to the Firebase URL (kind of proxy). This is the configuration used when parameter
showDeviceUrl
in index.js isfalse
.
For doing so, you need to generate a build with the patches available in Bug 933357
Once you have a build with the proper BLE support you can just install the app available at the www folder that already includes everything that is required: manifest, icons, code, etc...
The code of the WebApp is exactly the same, but it relies in Cordova in order to make it a native app (this is required until Android or iPHone include a WebAPI for Bluetooth). Apart from Cordova a BLE pluging is required as well as some other plugins describe below.
Clone the repo and install the target platform(s)
$ cordova platform add ios
$ cordova platform add android
After that you need to install the required plugins:
$ cordova plugin add org.apache.cordova.inappbrowser
$ cordova plugin add https://github.com/evothings/cordova-ble.git
$ cordova plugin add org.apache.cordova.console
And build it for the target platforms:
$ cordova build ios
$ cordova build android
After that you can install the apps in your Android or iOS devices.
For instance, in the case of Android:
$ adb install platforms/android/ant-build/CordovaApp-debug.apk