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!
Trouble getting BLE to work with Cordova app
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
Hi!
Before you build the app, you need to add the BLE cordova plugin using the CLI
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."
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."
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
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
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
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
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
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'
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
You run your app in xcode, right? Please check the console output (lower middle right in the xcode window) for error messages.
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
I am running it in PhoneGap
Re: Trouble getting BLE to work with Cordova app
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
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
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
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
Where do I punch in the URL to index.html? I am using the latest version of EvoThings Workbench and viewer
-
- Posts: 7
- Joined: 12:49, 19 Nov 2015
Re: Trouble getting BLE to work with Cordova app
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: Google [Bot] and 12 guests