Trouble getting BLE to work with Cordova app

Ask, and ye shall receive.
josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Trouble getting BLE to work with Cordova app

Postby josephclawrence » 12:55, 19 Nov 2015

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!

alex
Posts: 92
Joined: 00:59, 19 Nov 2013

Re: Trouble getting BLE to work with Cordova app

Postby alex » 13:09, 19 Nov 2015

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."

josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Re: Trouble getting BLE to work with Cordova app

Postby josephclawrence » 13:13, 19 Nov 2015

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...

alex
Posts: 92
Joined: 00:59, 19 Nov 2013

Re: Trouble getting BLE to work with Cordova app

Postby alex » 13:19, 19 Nov 2015

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.html
that also rely on the BLE plugin? Then you can try start & stop scan in an easy way.

best

Alex

josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Re: Trouble getting BLE to work with Cordova app

Postby josephclawrence » 13:34, 19 Nov 2015

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'

Fredrik
Site Admin
Posts: 196
Joined: 15:00, 18 Nov 2013

Re: Trouble getting BLE to work with Cordova app

Postby Fredrik » 14:15, 19 Nov 2015

You run your app in xcode, right? Please check the console output (lower middle right in the xcode window) for error messages.

josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Re: Trouble getting BLE to work with Cordova app

Postby josephclawrence » 14:16, 19 Nov 2015

I am running it in PhoneGap

alex
Posts: 92
Joined: 00:59, 19 Nov 2013

Re: Trouble getting BLE to work with Cordova app

Postby alex » 16:42, 19 Nov 2015

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

josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Re: Trouble getting BLE to work with Cordova app

Postby josephclawrence » 07:35, 20 Nov 2015

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

josephclawrence
Posts: 7
Joined: 12:49, 19 Nov 2015

Re: Trouble getting BLE to work with Cordova app

Postby josephclawrence » 08:11, 20 Nov 2015

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...


Return to “Questions and answers”

Who is online

Users browsing this forum: No registered users and 17 guests