Help with developing a beacon service extension

Oh great ! Thanks for your work !
How can I get this extension ?

OK flyingPencil.
If you give an email address I will send you the instructions and files as attach.

Dear @Piero_Della_Romanesc
I am also working on iBeacon using MIT app inventor and I realized that BLE Extension can't help me.
Can you share your extension with me, I would like to try it. Thanks.

Hello F pencil I am also very interested in this can you please share more info?

Thanks Sander

Hello Flying Pencil How did you managed to read data from eddystone?
Very curious how you did I search allready weeks for it

Thanks Sander

dear Piero_Della_Romanesc,

  • I want to ask if you can send me your iBeacon extension for APP Inventor, please. Thank you very much in advance.

  • I think the following way should work with Beacons directly, only with the BLE library. Unfortunately, I can't program such an extension :frowning:

BLE Scan returns ScanResult, which contains ScanRecord:

public ScanResult (BluetoothDevice device,
int eventType,
int primaryPhy,
int secondaryPhy,
int advertisingSid,
int txPower,
int rssi,
int periodicAdvertisingInterval,
ScanRecord scanRecord,
long timestampNanos)

Raw Beacon data are returned by the getBytes () method from ScanResult.ScanRecord.getBytes ()
The input of the function will be DeviceAdress.

https://developer.android.com/reference/android/bluetooth/le/ScanRecord 1

I greet everyone,
please is there somewhere to download the iBeacon extension for APP Inventor, or can someone send it to me? Much thanks you

I give you the following links for downloading:

  1. the extension for MIT Appinventor (edu.mit.appinventor.blebeacons.aix
    file) =>
    https://drive.google.com/file/d/1AOTuc9uNSfs_GRZ9y9UW73SCkKqPHvSY/view?usp=sharing

  2. a very basic test app for showing the list of detected beacons and
    the closest one (BeaconscanMIT.apk) =>
    https://drive.google.com/file/d/1GDvgO1xVmJNcIdb_mcfFvyTNxWHmMJQk/view?usp=sharing


Please note that:

  1. In the test app you can leave blank the parameter "N cicli" as it defaults to 1 (seconds). You can use this parameter just for increasing the interval of time over which the "closest beacon" is evaluated, because the distance of a transmitting beacon is derived from the signal intensity which is not very steady.

  2. I'm sorry but I didn't completed yet a documentation, although the usage i very simple:

  • a block (StartScansione) allows you to start detecting beacons (so far only iBeacons and AltBeacons, not Eddystone)
  • an event occurs when a new beacon is detected or when a previously detected beacon disappears: the corresponding "when" block (ListaBeaconsChange) returns the list of all the beacons detected (each element is a beacon and is identified by UUID, Major, Minor and estimated distance)
  • an event occurs when a detected beacon becomes the closest beacon: the corresponding "when" block (ClosestBeaconChange) returns UUID, Major and Minor of that beacon

You also have a block (StopScansione) for stopping the detection and you can set the following parameters:

  • NCicli (I explained it before)
  • ListaUUIDs (for filtering the detection and limiting to some specific UUIDs you can provide as a list item)
  • DistanzaMinima (for filtering the detection just to beacons whose estimated distance is <= DistanzaMinima // DistanzaMinima defaults to 1000mt)
  1. If you are using an Android version greater then 9 you must MANUALLY grant the location permissions to the test app (and any other app making use of blebeacons extension) OTHERWISE NO BEACON WILL BE DETECTED !

dear Piero_Della_Romanesc,
thank you very much for the extension.
Have you solved the "manifest problem" in any way to be able to develop the application using MIT AI2 companion? I ended up with "Error from Companion: The BeaconService is not properly declared in AndroidManifest.xml. If using Eclipse, please verify that your project.properties has manifestmerger.enabled = true". Sorry, I'm not an Android player and I don't know what to do with this :frowning:

Great job, the features seem clear and fully usable, I just miss the ability to display RSSI (TX-power). This value is also part of the iBeacon BLE packet and you can read it because you offer a function that filters according to it. Would it be possible to get RSSI in addition to UUID, Major and Minor? Thanks

Dear John,
MIT AI2 companion is very useful for testing an app, but it has some compatibility flaws when using some extensions. Unfortunately, the "BLEbeacons" extension is one of them.
Therefore you will have to generate the .apk file of your app (AndroidManifest.xml in this case will be generated correctly) and install it on a physical Android device with a physical bluetooth interface.
As for the missing fields (rssi etc.) in a future version of the extension they will be added to the content of the "ClosestBeacon" and "ListaBeacons" fields.

don't forget to MANUALLY grant the location permissions to your app just after installed on your test device

Thank you very much, Piero_Della_Romanesc. It already works for me, but the response is too slow. Even a change in "N cicli" will not solve it. My iBeacon broadcasts with a period of 400ms. Can you think of a way to get an "immediate response"?

hi John
the extension uses the altbeacon library which provides the following methods:
-setForegroundScanPeriod
-setForegroundBetweenScanPeriod
-setBackgroundScanPeriod
-setBackgroundBetweenScanPeriod
However the current version of the extension does not allow to modify these parameters which are fixed to:
-setForegroundScanPeriod = 5000ms
-setForegroundBetweenScanPeriod = 0ms
-setBackgroundScanPeriod = 25000ms
-setBackgroundBetweenScanPeriod = 30000ms
If you shorten ScanPeriod too much you risk missing some brodcasts.
I don't know the needs of your application but in a future version of the extension I might add the ability to change the defaults.
Alternatively I could send you the Java code of the extension so that you can create your own version.
Let me know

Buonasera John,
buone notizie !
ho aggiornato l'estensione BleBeacons all'ultima versione (2.19.3) della libreria Altbeacon.
Ho colto l'occasione di aggiungere le modifiche che mi chiedevi:

  1. possibilità di ottenere i valori TxPower e RSSI per i beacon rilevati
  2. possibilità di impostare i valori di
    -ForegroundScanPeriod
    -ForegroundBetweenScanPeriod
    ood evening John,
    Good news !
    I updated the BleBeacons extension to the latest version (2.19.3) of the Altbeacon library.
    I took the opportunity to add the changes you asked me:
  3. possibility to obtain the TxPower and RSSI values for the detected beacons
  4. possibility to set the values of
    -ForegroundScanPeriod
    -ForegroundBetweenScanPeriod
    -BackgroundScanPeriod
    -BackgroundBetweenScanPeriod
  5. the ForegroundScanPeriod default value is now 1100 milliseconds, but it can be changed, although a lower value is not recommended.
    Please note that the RSSI value is actually calculated as a running average of RSSI within the scan cycle.
    Here is the link to download the .aix file of the extension:
    https://drive.google.com/file/d/10F_-BOy_xNo_wNuSbxGmFVQAdmxb6Rzh/view?usp=sharing
    here is the link to download the BeaconScan test app .apk file:
    https://drive.google.com/file/d/1v744LK5rxrD5Tpy-B47AOZy7LQQhAQ6V/view?usp=sharing
    Let me know if the extension is ok for you
    Regards

Dear Piero_Della_Romanesc,
I haven't thoroughly tested all the features yet, but at first glance it works well. Nice job, one more thanks!

Does the "Ncicli" property still matter? It seems to me that it has no effect on the result.

Dear John,
Actually, the NCicli parameter only affects the frequency of the ClosestBeaconChange event, in the sense that ClosestBeacon is the beacon that has the shortest distance in a period of time equal to NCicli * ForegroundScanPeriod among all the detected beacons.
While ClosestBeaconParm is the beacon that has the shortest distance among all the beacons detected in the ForegroundScanPeriod time period.
If NCicli> 1 the ClosestBeaconChange event will occur less frequently than the ClosestBeaconParmChange event.
Depending on the purpose of your app you will be able to use either of the two events.

Hello Piero_Della_Romanesc,

First of all, thank you very much for sharing your extension. I was wondering, is there is a way to extract the raw data that the beacon is broadcasting?

Thanks again,
Daniela

Hi Daniela,
the extension is based on the Altbeacon library (Android Beacon Library 2.19.3) of which only some of the available fields are used.
However, it does not seem to me that the aforementioned library provides the data you request.
You can check for yourself the fields and methods available for the "beacon" class on this link:
https://altbeacon.github.io/android-beacon-library/javadoc/org/altbeacon/beacon/Beacon.html

Pierluigi

Thank you for the information!

I will check it out.

Hi DanielaAH,
Were you able to figure out how to extract raw data from the beacon ? I am a newbie and will much appreciate help in form of .aia/.apk/ block diagrams.
Thanks in advance.