Standalone Cordova BLE scanner

Ask, and ye shall receive.
andersjj
Posts: 7
Joined: 20:17, 31 Oct 2015

Standalone Cordova BLE scanner

Postby andersjj » 14:49, 09 Nov 2015

I was working with the BLE scanner sample in the EVO Workbench samples. I modified it a bit to do what I wanted, which was reading the advertisement data from a RAD Dot beacon transmitting in AltBeacon mode on iOS. I wanted to make a standalone version of this not using the workbench in Cordova so as not to have any external dependencies. It seemed to be working pretty well, but I noticed that my code to read the Alt Beacon advertisement data wasn't running.

After looking more closely, I noticed that the device data had the "scanRecord" attribute, which would normally only show up on Android. After debugging a little, there was only basic information coming back from the device data, including Name, Address, rssi, etc. Weird thing is, this attribute normally only shows up on Android, not on iOS, which is the platform I was running on when I saw the issue.

So, I'm thinking that I'm missing a plugin or something. The only BLE plugin I installed was "com.evothings.ble" which is listed on the API page. To try to debug a bit, I un-installed the com.evothings.ble plugin and installed the cordova-ble plugin from git. When I tried to generate the Xcode project from the command line, I got some compile errors. What are the plugins required for BLE to work in a standalone Cordova App?

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: Standalone Cordova BLE scanner

Postby micke » 15:16, 09 Nov 2015

Hi Anders,

The only plugin needed should be com.evothings.ble.

To get the advertisement data in a consistent way on Android an iOS you can use the "Easy BLE" library. (https://github.com/evothings/evothings- ... easyble.js)

There is code in the Eddystone library that uses this data, for example. (https://github.com/evothings/evothings- ... dystone.js)

The scanRecord field should contain info on Android, but in iOS is should not contain anything useful at least. I thought it would be null/undefined, it is not set in the native iOS code in the BLE plugin.

Let me know how it goes.

Mikael

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

Re: Standalone Cordova BLE scanner

Postby Fredrik » 15:17, 09 Nov 2015

"cordova-ble" and "com.evothings.ble" should be the same plugin. It does not depend on any other plugins. Recommended Cordova version is currently 5.4.0.

"advertisementData" should be available natively on iOS, if you're using a sufficiently recent version of the plugin (version 1.0.0 will do). It is available on Android if you use the wrapper library "easyble". "scanRecord" is perhaps less useful in comparison.

andersjj
Posts: 7
Joined: 20:17, 31 Oct 2015

Re: Standalone Cordova BLE scanner

Postby andersjj » 16:20, 09 Nov 2015

Thanks for the quick reply.

When I installed the plugin, I did a "cordova plugin add com.evothings.ble".

I started digging around in the source code for Obj-C and it doesn't seem to be doing anything with the advertisement data. I added some debug code and was able to verify the info I was expecting was coming through as follows:

2015-11-09 10:14:14.840 DemoApp3[637:227679] key = kCBAdvDataIsConnectable
2015-11-09 10:14:14.840 DemoApp3[637:227679] 0
2015-11-09 10:14:14.840 DemoApp3[637:227679] key = kCBAdvDataManufacturerData
2015-11-09 10:14:14.841 DemoApp3[637:227679] <1801beac 11111111 22223333 44445555 55555555 00010014 c564>

But I'm not seeing this data in the javascript call back.

Is there a different package name, etc on the cordova plugin add that I should be using?

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

Re: Standalone Cordova BLE scanner

Postby Fredrik » 16:28, 09 Nov 2015

The latest version of the plugin is here. You may run "cordova plugin add https://github.com/evothings/cordova-ble".

The Objective-C code which sends advertiesementData is here.

andersjj
Posts: 7
Joined: 20:17, 31 Oct 2015

Re: Standalone Cordova BLE scanner

Postby andersjj » 16:46, 09 Nov 2015

OK, that did it. I was having some trouble with it before, but I had been installing/un-installing plugins to see what's going on. I started a fresh project and installed from git and now it's working just like it was in the viewer.

Thanks!


Return to “Questions and answers”

Who is online

Users browsing this forum: MSN [Bot] and 7 guests