Page 1 of 2
Trouble getting BLE to work with Cordova app
Posted: 12:55, 19 Nov 2015
by josephclawrence
I am trying to create Cordova app, using PhoneGap, and initially using one of the RedBearLabs examples from EvoThingsWorkbench. I have followed all the instructions as far as I can see, and tried multiple different ways, also with Cordova CLI. I have added the Evothings BLE Cordova plugin, but it doesn't work.
I have added in some debugging code, and I can see that 'evothings.ble' is undefined. So it is at the point that evothings.ble.stopScan() is called that the app fails.
I have tried to find where this evothings.ble object should be coming from but I can't find it - I'm not well versed enough in Objective C to dive in deeper, but according to the documentation I should be able to get this EvoThings Workbench example working as a Cordova app, with the correct plugins installed.
Thanks in advance for any help!
Re: Trouble getting BLE to work with Cordova app
Posted: 13:09, 19 Nov 2015
by alex
Hi!
Before you build the app, you need to add the BLE cordova plugin using the CLI
Code: Select all
cordova plugin add https://github.com/evothings/cordova-ble
And just like my colleague Fredrik mentioned in a recent post
http://evothings.com/forum/viewtopic.php?f=8&t=1846, is the following
"Also worth checking is that your app's AndroidManifest.xml file contains "android.permission.BLUETOOTH" and "android.permission.BLUETOOTH_ADMIN". Without those permissions, Bluetooth will fail even if the plugin is installed."
Re: Trouble getting BLE to work with Cordova app
Posted: 13:13, 19 Nov 2015
by josephclawrence
Thanks for the reply. I have installed the plugin, and I am developing for iOS, so those Android permissions should not be relevant. But yes, I had already installed that plugin before posting here the first time...
Re: Trouble getting BLE to work with Cordova app
Posted: 13:19, 19 Nov 2015
by alex
Aha, I was reading too fast, I see that you've added it, sorry about that.
What happens if you try to building one of our examples, like
https://evothings.com/doc/examples/ble-scan.htmlthat also rely on the BLE plugin? Then you can try start & stop scan in an easy way.
best
Alex
Re: Trouble getting BLE to work with Cordova app
Posted: 13:34, 19 Nov 2015
by josephclawrence
Have just tried this, and it's the same issue - it fails as soon as it tries to run evothings.ble.stopScan()
I dug a bit further, and whilst 'evothings' is a valid object, it seems the only property it has is 'os' - it does not have the property 'ble'
Re: Trouble getting BLE to work with Cordova app
Posted: 14:15, 19 Nov 2015
by Fredrik
You run your app in xcode, right? Please check the console output (lower middle right in the xcode window) for error messages.
Re: Trouble getting BLE to work with Cordova app
Posted: 14:16, 19 Nov 2015
by josephclawrence
I am running it in PhoneGap
Re: Trouble getting BLE to work with Cordova app
Posted: 16:42, 19 Nov 2015
by alex
And if you run your own code in Evothings Viewer, does it work then ?
Either use the Workbench, or punch in the URL to index.html, including the
http://,
to where your code is stored.
If you use the Workbench, you can see what's going on inside the app using hyper.log() under the Tools tab!
best
Alex
Re: Trouble getting BLE to work with Cordova app
Posted: 07:35, 20 Nov 2015
by josephclawrence
Hi Alex...well it works fine when I run it as an EvoThings example, within Workbench, but let me try hooking up this Cordova project.
Where do I punch in the URL to index.html? I am using the latest version of EvoThings Workbench and viewer
Re: Trouble getting BLE to work with Cordova app
Posted: 08:11, 20 Nov 2015
by josephclawrence
I tried just dragging my project into Workbench, and then viewing it in the viewer, and interestingly it doesn't load. The screen on my iPhone just goes white and I have to quit the viewer app. Nothing is displayed in the Worbench Tools log, I assume because the app fails before anything gets started...