In July 2016, examining the articles on “Habrahabr”, I learned about
the Google Device Lab contest , which offered to try the BLE-beacons with Eddystone technology and describe in the article my solution based on them.

Article author Pavel Valentov, in the framework of the competition "Device Lab from Google . "
We already knew about BLE beacons from discussions on the
FireMonkey Developers Forum ,
Google’s developer portal , from
Maxim Kulgin ’s
video blog , and we’ve already
figured out how to use them in our mobile apps.
BLE devices (Bluetooth Low Energy, English) are devices that have an extremely low level of energy consumption when transmitting data via Bluetooth. Beacons also belong to BLE-devices, created to communicate software developers with real-world objects. I propose to read about the beacons
article on Habrahabr .
And I want to talk about our experience of using beacons. SoftInterGroup (
www.singro.ru ) creates mobile applications. In our portfolio there is an Android
application "Control of electricity metering devices" , developed for
JSC "Oreloblenergo" . This application was created for the work of supervisors, who daily receive tasks from the enterprise server, bypass certain subscriber addresses, check the integrity of electricity meters, record readings in the application and transfer the results of work to the enterprise server.
')
We had an idea to offer the customer a revision of the application, including interaction with beacons, simplify the detection of electricity metering devices for supervisors, facilitate searching the list of meters, get the geo-coordinates of inputting device readings where there is no satellite signal (in hangars, basements, rooms ).
For these purposes, it was decided to take part in the competition and test the work of the beacons.
Got beacons
After registering on
the contest website , I applied for beacons, talked about our mobile application and plans for using Eddystone technology. I wanted to deploy a network of beacons, so in the application I requested to test thirty beacons at once. In response, a Google employee told me that you can only get two.
- Well, two so two. - I answered, and the next time I went to the Google office at Baltschug, where the promised beacons were waiting for me at the reception.
How was it tested?
The resulting beacons are called iBKS 105A.

To test their performance on your HTC One with Android 6.0, it was enough to turn on Bluetooth on your smartphone, and pull out a plastic jumper from the beacon that opens contact with the battery.
After a couple of seconds, a notification with the icon “Physical Web” and the header of the site “Github” appeared on the smartphone in the notification curtain.
Clicking on this notification, in Chrome, the Eddystone page on Github opened with a description of the technology and the Eddystone API. I already knew that we followed the link that was originally sewn into the beacon.
For programming the beacon, the iBKS Config Tool application was installed from Google Play.
This application allows you to completely reconfigure beacons, set unique identifiers and data that the beacon sends, change the packet sending technology, for example, replace the Eddystone technology with iBeacon.
Eddystone mobile application
We develop mobile applications in the Embarcadero RAD Studio environment. This is very convenient, because all the necessary components and libraries for working with beacons are already included in the delivery of the development environment, creating an application for debugging beacons took 15 minutes:
- I threw the button “Turn on Bluetooth” on the form, the “Beacon” component and a text field for debug information;

- included a couple of Android permissions for working with Bluetooth;

- connected the event logic of components;
procedure TForm2.BeaconBeaconEnter(const Sender: TObject; const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList); begin case ABeacon.KindofBeacon of iBeacons: m.Lines.Add('Enter iBeacons: ' + ABeacon.DeviceIdentifier); AltBeacons: m.Lines.Add('Enter AltBeacons: ' + ABeacon.DeviceIdentifier); Eddystones: m.Lines.Add('Enter Eddystones: ' + ABeacon.DeviceIdentifier); iBAltBeacons: m.Lines.Add('Enter iBAltBeacons: ' + ABeacon.DeviceIdentifier); end; end; procedure TForm2.BeaconBeaconError(const Sender: TObject; AError: TBeaconError; const ErrorMsg: string; const ABeacon: TBeaconInfo); begin m.Lines.Add('Error: ' + ErrorMsg); end; procedure TForm2.BeaconBeaconExit(const Sender: TObject; const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList); begin m.Lines.Add('Exit: ' + ABeacon.DeviceIdentifier); end; procedure TForm2.BeaconCalculateDistances(const Sender: TObject; const ABeacon: IBeacon; ATxPower, ARssi: Integer; var NewDistance: Double); begin m.Lines.Add('Distanced: ABeacon: ' + ABeacon.DeviceIdentifier + ', Distance: ' + NewDistance.ToString); end; procedure TForm2.BeaconEnterRegion(const Sender: TObject; const UUID: TGUID; AMajor, AMinor: Integer); begin m.Lines.Add('Enter region: UUID:' + UUID.ToString); end; procedure TForm2.BeaconExitRegion(const Sender: TObject; const UUID: TGUID; AMajor, AMinor: Integer); begin m.Lines.Add('Exit region: UUID:' + UUID.ToString); end; procedure TForm2.BeaconNewEddystoneTLM(const Sender: TObject; const ABeacon: IBeacon; const AEddystoneTLM: TEddystoneTLM); begin m.Lines.Add('EddystoneTLM: ID:' + ABeacon.DeviceIdentifier); end; procedure TForm2.BeaconNewEddystoneURL(const Sender: TObject; const ABeacon: IBeacon; const AEddystoneURL: TEddystoneURL); begin m.Lines.Add('URL: ' + ABeacon.DeviceIdentifier + ' - ' + AEddystoneURL.URL); end; procedure TForm2.Button1Click(Sender: TObject); begin Beacon1.Enabled := not Beacon1.Enabled; if not Beacon1.Enabled then m.Lines.Clear; end;
- clicked the "Run project" button, the project was assembled and started on the device connected to the computer.
After launching the application, the information from the beacons “flowed”: links, identifiers, entry and exit from configured zones, distance to sensors, battery charge level, temperature on board the sensor.

Started to arrange the sensors, and began to walk with a smartphone and track changes in parameters that will be useful in further development.

What technology beacons apply Eddystone or iBeacon?
Features of our application that is designed to work on tablets without the Internet. The data gets into it from GPS sensors and is entered with stylus of controllers. Therefore, the use of the Eddystone-URL advertising link was not relevant for us, because the link will not be available for this link to the Internet. However, all those who have the Internet will be able to go, they will catch a beacon signal on their smartphones and, out of curiosity, will want to open the link. Therefore, as a URL, a link to the OryloblEnergo website was sewn into beacons.
An interesting feature. During testing, it turned out that Physical Web shows advertising links in the notification area (in the blind) only when the link points to a site protected with an SSL certificate, that is, the site address begins with HTTPS. Eddystone developers explain why this is done. Redirection via Google URL Shortener does not resolve the issue, you need the final resource opened via the HTTPS protocol. The customer's site works without SSL, so Physical Web does not display it in a blind. Well, okay, now we have another task.
For our task, we used the Eddystone-UID beacon parameter. We needed a unique beacon identifier that is tied to the identifiers in the enterprise meter database, and to which the geo-coordinates of the metering device location are tied. The application has developed a service that polls beacons. If Eddystone beacon is detected, with reference to the OryolOblEnergo website, information about this will appear in the notification area of the tablet or smartphone.
Click on the notification, a form opens with a list of detected beacons and information about the meters linked to them in the database.
On this screen, you must select the metering device with which you plan to work.

If one beacon is found, a form immediately opens to view information about the metering device and enter the meter readings.
To date, testing applications for working with beacons completed. We have reached our goal and are preparing a release for trial operation.
Thus Eddystone beacons entered the service of controlling energy consumption.
And we have already begun to design a positioning system.