> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.android-kiosk.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# JS: EddyStone Beacon Support

||| Deprecated in v2.8.8 or higher.

A dedicated beacon monitoring test page can be found here: http://www.android-kiosk.com/beacontest.htm

Version 2.6.6 (build 230) or higher is required for beacon support.

###### What is Eddystone?
Eddystone is a BLE format developed by Google. It’s open and multiplatform, so you can use it with both Android and iOS. There are four types of data a beacon can broadcast with Eddystone, described by three frames:

* Eddystone-URL for broadcasting URL addresses
* Eddystone-UID for broadcasting beacons IDs
* Eddystone-TLM for beacon telemetry
* Eddystone-EID for security


###### Monitoring Beacons
Using the powerful JavaScript interface in Kiosk Browser you can register to monitor beacons, once registered Kiosk Browser automatically returns results of nearby beacons to a JavaScript function on your page (detailed below). To start monitoring beacons you must call monitorBeacons(bool monitor, int scanIntervalMilliseconds).  Once monitorBeacons has been called it will continue running regardless of whether you have browsed to another page. To stop monitoring call monitorBeacons(false,0).


|| Bluetooth must be enabled on the device, it's possible to enable bluetooth via KBBluetooth.setBluetoothEnabled(bool enable). Location permissions must be granted for beacon monitoring.

```
<script type='text/javascript'>
	function monitorBeacons(monitor, interval) {
		Android.monitorBeacons(monitor, interval);
		showAndroidToast("Monitor Beacons: " + monitor);
	}

	function showAndroidToast(toast) {
		Android.showToast(toast);
	}
	
	//SHOWS MESSAGE IN SNACKBAR
	function showSnackbar(message) {
		Android.showSnackbar(message);
	}
</script>
<a href="javascript:monitorBeacons(true, 1000)">Start Monitoring Beacons</a>
<a href="javascript:monitorBeacons(false, 0)">Stop Monitoring Beacons</a>
```

###### Results Function
To receive results you must implement the following function on your page. Data returned is JSON and must be parsed using JSON.parse.
```
<script>	
	function eddyStoneBeaconMonitor(data) {
		var jsonData = JSON.parse(data);
		console.log(jsonData);
	}	
</script>
```


###### Sample JSON data from eddyStoneBeaconMonitor(data) function (Eddystone-URL)
Depending on the type of EddyStone beacons in range, the data will differ, for example there will be no url the beacon is of type Eddystone-UID. The url property will still exist in the JSON data.
```
{  
   "beacontype":16,
   "bluetoothaddress":"XX:QZ:ZX:XX:X0:FF",
   "bluetoothname":"BeaconName",
   "distance":0.03429382,
   "lastseen":"2018-11-15 15:37:51",
   "namespaceid":"03616363-656e-742d-7379-7374656d7307",
   "rssi":-45,
   "txpower":-62,
   "url":"https://www.android-kiosk.com"
}
```