Page 1 of 2

Phonegap help needed

Posted: 17:19, 13 Feb 2015
by Uli
Hi!
I hope I'm posting in the right forum :)

Code: Select all

function onDeviceReady(){               
   estimote.beacons.startEstimoteBeaconsDiscoveryForRegion({}, onScan, onError);                  
}

function onError(__info){
       $('#debug').append('<p>Error:'+__info+'</p>');
}   


I always get Error: INVALID ACTION
How can I debug this?
Cheers

Re: Phonegap help needed

Posted: 17:39, 13 Feb 2015
by Fredrik
That function is implemented on iOS, but not on Android.

On Android, only these functions are currently implemented: startRangingBeaconsInRegion, startMonitoringForRegion and their associated stop functions.

If you're running your program on an Android device, that would explain the error you're getting.

Re: Phonegap help needed

Posted: 18:10, 13 Feb 2015
by Uli
Yes indeed, I'm developing for Android. Thanks for the reply.

Re: Phonegap help needed

Posted: 18:40, 13 Feb 2015
by Uli
Well, nothing works here

Code: Select all

window.EstimoteBeacons.startMonitoringForRegion(function () {
               //every now and then get the list of beacons in range
               setInterval(function () {
                  window.EstimoteBeacons.getBeacons(function (data) {
                     $('#debug').append('<p>Monitor:'+data+'</p>');
                  });
               }, 1000);
            });               
               
            
            window.EstimoteBeacons.startRangingBeaconsInRegion(function () {
               //every now and then get the list of beacons in range
               setInterval(function () {
                  window.EstimoteBeacons.getBeacons(function (data) {
                     $('#debug').append('<p>Ranging:'+data+'</p>');
                  });
               }, 1000);
            });      


Anything I'm doing wrong? Any working example for phongap for Android? Cheers..

Re: Phonegap help needed

Posted: 18:49, 13 Feb 2015
by Fredrik
Yes, there is an example, called "estimote-scan". It's distributed as part of Evothings Studio. The source code is here.

Re: Phonegap help needed

Posted: 19:06, 13 Feb 2015
by Uli
Thanks again... This is what I've tried:

Code: Select all

estimote.beacons.startMonitoringForRegion({}, onMonitoringSuccess, onError);

function onMonitoringSuccess(regionState){            
            $('#debug').append('<p>State:'+regionState.state+'</p>');
         }
function onError(__error){
            $('#debug').append('<p>Error:'+__error+'</p>');
         }      



And the app is crashing instantly upon start now....
Android 5.0.1, Phonegap 4.2.0, pl.makingwaves.estimotebeacons 0.6.0
Any idea?

Re: Phonegap help needed

Posted: 19:21, 13 Feb 2015
by Uli
Updated plugin to version 0.7.0 from master found here : https://github.com/evothings/phonegap-estimotebeacons
Same issue..

Re: Phonegap help needed

Posted: 19:54, 13 Feb 2015
by Fredrik
Well, we're still running on Cordova 3.6. It might be prudent to update the plugin to indicate it doesn't support PhoneGap 4 yet. Or, if possible, test/fix it.

I'll need to bring in a colleague.

In the meantime, you might try the Evothings Client, which is what we've tested the plugin with.

Re: Phonegap help needed

Posted: 18:03, 18 Feb 2015
by Uli
Confirmed, 3.6 works, 4.2 doesn't ...
But now beacon.uuid is undefined, but Major and Minor work.

Code: Select all

function onBeaconsRanged(beaconInfo){            
            for (var i in beaconInfo.beacons){            
               var beacon = beaconInfo.beacons[i];            
               html += '<li>UUID:'+beacon.uuid+'<br>MAJOR:'+beacon.major+'<br>MINOR:'+beacon.minor+'</li>';                  
            }
            $('#beacons').html(html);
         }

Is there any alternative to get UUID ?
Also it only finds 2 out of 3 beacons?

Cheers

Re: Phonegap help needed

Posted: 21:00, 18 Feb 2015
by micke
Hi Uli,

I noticed that the UUID field is named proximityUUID (not uuid), this is probably why you don't see the UUID.

Just tested to build the latest version of the example app Beacon Finder in the plugin repository for Android with Cordova 4.2.0. The app works for me, I get all beacons when ranging. Is your app still crashing on Cordova 4.2.0?

Also tested the following code for ranging, which prints all beacons ranged to the debug console (logcat when running on Android, and the Tools log window if using Evothings Workbench). This is a handy way to actually see the data sent to the ranging callback function:

Code: Select all

 estimote.beacons.startRangingBeaconsInRegion(
    {}, // Empty region matches all beacons.
    function(info) {
      console.log('Beacons ranged:')
      estimote.printObject(info) },
    function(errorMessage) {
      console.log('Ranging error: ' + errorMessage) })


And to stop ranging:

Code: Select all

estimote.beacons.stopRangingBeaconsInRegion({})


There are some things to be aware of that may be a potential source of confusion.

The Evothings Client app is not updated as fast as the Estimote plugin is updated, and this means that not everything listed in the documentation will work in Evothings Client.

Testing of the plugin is done using the Beacon Finder example app. This app can be used in place of Evothings Client, to connect to Evothings Workbench and get live reload and log output in the Tools window. This is very handy when developing. And you can also use this with your own Cordova app.

Instructions are available here:

https://github.com/evothings/phonegap-e ... ive-reload

Here is information for how to setup a Cordova app for use with Evothings Workbench:

http://evothings.com/doc/build/cordova- ... rEvothings

And here is a page with useful information about Cordova and Evothings:

http://evothings.com/cordova-starter-kit/

Also want to clarify that setInterval should not be used since the callback for ranging is called repeatedly, getBeacons was used with the old plugin API and has been removed.

Version 0.7.1 of the Estimote plugin was pushed to GitHub yesterday, this is the version I just tested now with Cordova 4.2.0.

Best regards, Mikael