Tuesday, December 26, 2017

Developing Eddystones App In Android

Eddystone beacons is google's answer to Apple's Ibeacon. Both devices use BLE technology but differ in advertising protocols.

Ibeacons transmit a single frame wherein the Ibeacon identifier bytes is at the 8th and 9th byte of the frame. See picture below as seen on Ibeacon Detector app on android:

And a more detailed data structure of the frame is below:


In comparison, Eddystones transmit 3 frames which is like below:
As an evidence, if you use Ibeacon Detector App to detect the Eddystones, you will notice that the data packets received always changes that is because eddystones transmit 3 frames.

I have previously developed an android app to scan ibeacons (A Simple Ibeacon Scanner App in Android) and this app can be slightly modified to scan for eddystones as well by removing the validation that look for "0215" pattern in the frame and look for valid values to identify the frame type as described in the last picture.

A lot of people ask, why do we need eddystones since we already have ibeacons? The answer is obvious, eddystones is able to transmit more data than ibeacons. Ibeacon frame contain only the RSSI, UUID, Majo and Minor. The latter 3 is used to identify the ibeacon, while the eddystones frames contain the TX power, Temperature, URL, Battery Charge Level, Instance Id, Namespace Id, and many more.

Changing URL in Eddystone using LighBlue App

1. Carefully remove the battery of the eddystone to hard reset.
2. Download the LightBlue app from apple app store.
3. After installing the app scan for the eddystone. Once detected, just tap on the eddystone to connect.
4. If connected successfully, search for 0xBEE2. Tap on it to change the value.
5. Then enter your URL in ASCII code. The url must start with 00 for http:// and ends with 07 for .com

6. Save the new value.

7. Search for 0xFFFF, this is located at the bottom of the service(UUID:FFF0).
8. Enter "minew123" and save.
9. You may check with your favorite sample eddystone detector app which can be download for free in the app store.

The url can also be changed in Android using Nrf Connect app. The Android version must be at least 6.0

Sunday, December 24, 2017

Eddystone Beacon The Thin Device

The Apps Factory Beacons just arrived and I am so excited to introduce them here. These beacons are world class and are equipped with the most advanced hardware and firmware which include Nordic's nRF51822 microchip which is equipped with proprietary power management circuit that should make our Beacons' power consumption more efficient enabling batteries to discharge slower by as much as 100% slower than its competitors.



In terms of form factor and appearance, the beacons are so thin and light and the white plastic casing has smooth surface ideal for display in any location whether at the counter or gallery where every object should appear and be seen as a work of art. Changing the color or adding more designs to the surface of the casing is not issue because it can be easily accomplished by using silkscreen printing or creating design on stickers.

The beacons broadcast temperature, its battery charge level and of course the eddystone and ibeacon data packets.  The eddystone data packets consists of 3 frames(UID, TLM and URL) which makes it really high tech because the beacons can be customized to add external hardware like arduino and its famous peripherals. To achieve this, one needs expertise in reprogramming the firmaware of the beacons through the exposed serial or jtag port of the beacon as shown in the picture below.

Just like its older version, the apps that was used to calibrate and configure the ibeacons is still useable(check my blog post in my other blog Ibeacon with thin form factor and that really works!). To configure the eddystone, the lighblue app for IOS or the nRF Master Control Panel app for Android is used.

The new beacons were also designed to comply with Google's Security guidelines which means the device must have configuration mode which can be activated just after turning the device on. And it resumes into broadcast-only mode after a few seconds of inactivity. During the broadcast-only mode, no other device can connect and modify the eddystone and ibeacon configuration.

Google Nearby Troubleshooting Guide and the Minew Eddystones

This serves as a continuation of my post Google Nearby 101. As I have mentioned in my previous post, there are a bunch of cons that a developer should be aware of using Google Nearby. In summary, here are the cons:

  1. smartphone has to be connected to the internet
  2. the screen must be opened to receive the notification
  3. bluetooth and location services must also be turned on
  4. notification had no sound
  5. the notification disappears all by itself after 10 to 20 minutes(sometimes less than 2 minutes)
  6. once the notification is deleted, it will not reappear too soon because of google's standard notification backoff policy

One important information that I have not mentioned in my previous post although it is not con but it is very important is that the URL must be "https" other than this, the configuration will not work.

Knowing the cons can help in speeding up the development of Apps. Another important aspect to take note of is that the Nearby Service is not in the hands of developers and there are occasions when Google shuts down the service which may trick other developers which will make them think that Google NearBy is not stable. Based on my personal experience this is how I was able to determine that when my smartphone is not able to get the notification and the cause is that the Google Nearby Service is not running is as follows:

I used several apps to check if my eddystones are working like the following: 
  1.  Ibeacon Detector. This app when run in Android 6.0 shows the different frames coming from the eddystones by refreshing the screen each time it receives the new frame. If there is no new frame received, the screen does not refresh so I know when the eddystones is not working.
  2.  nRf Connect App. This app does the same thing as the Ibeacon Detector app but it identifies the frame type and shows each values it receives with proper labeling like the temperature, uuid, instance id, etc. so this is better the Ibeacon Detector App.
  3. BeaconSet+. This app shows all the frames it received and it does not refresh the screen. It will not be able to detect the eddystones if the datat it receives is incomplete.
 I use these 3 apps to confirm if the source of error is coming from the Google Nearby Service using the logic: "My eddystones are working but I am not able to receive the notification but I confirm that a few minutes ago, it was working fine."


The Hardware
For some other reasons, knowing better the Eddystone being used can also be very important. As a developer, your knowledge of how the eddystones work should be at leas above average or at least know more than the end-user. You should be very familiar how it operates and know when the battery is still fully charged.

The eddystones I am using(Minew I6 models) operates this way:

  1. Upon insertion of the battery, it goes to connectible mode for 1 minute. During this mode, it will not transmit the URL and UID frames. 
  2. You can use the nRF Connect to configure the eddystones while in connectible mode.
  3. Google Nearby will not work during this 1 minute period.
  4. I determine if the battery charge is weak when I put 2 beacons in close range which will make them compete to get their signals be received by other devices, and the ones that loose is the one with weak battery charge. Although the measured battery charge level shown in nRF Connect can also be accurate.
For now, all of this information is based on my personal experiences which I am so willing to share.

Locating a Point Using 3 Beacons

Beacons can be used to track the movement of object on a given space like in our example, is perhaps a Fashion Store with a regular  rectangular shape. Assuming the object is a smartphone with a beacon app installed and has stable internet connection to transmit data back to the shop owner's back end app. These data will be the rssi(received signal strength) of each beacons received every 1 second.

The back end app by default, knows exactly the position of the three beacons.

So with these sets of data available, the location of the smartphone can be traced every second using trilateration algorithm which is a process of finding the location of the point using the geometry of circles, spheres and triangle. More information about trilateration is in wikipedia.

Using the rssi transmitted by the smartphone, and since we know the distance of each beacon from each other(d and e), we have a lot of data to use in determining the exact location of the point. We will also assume that all points of interest in the scenario lie on the same plane. The formula for computing distance in meters from  rssi is as follows:

RSSI = -20 * log10(distance in meters) + RssiAtOneMeter
distance in meters = pow(10, (RssiAtOneMeter - ReceivedRSSI) / 20)

source: Evaluation of the Reliability of RSSI for Indoor Localization

In the above picture, we can easily determine the value of x and y by Trigonometry's Pythagorian Theorem:


Using the eaquation:

x2+y2=b2

Google Nearby 101

It has been a huge challenge for business owners how to get people download their apps so that they can send notifications containing rich information about their products, services and promotions. One of the best idea how to get people's attention is to send them notifications even if they have not downloaded the app. This is a good idea aside from hiring somebody to be stationed in front of the store to convince people download the app and giving away flyers. The advantage of the electronic form is that it can be done 24/7 all year round.

Google introduced sometime in 2016 the Physical Web integrated with Chrome Internet Browser and using Eddystones. But the transmission and detection is intermitent and unreliable so it did not became very popular. About 7 months ago(not so sure) Google introduced the Nearby Messaging Service to replace the Physical Web and I only got to know about this 3 days ago and since then, I had been experimenting with it. Based on my tests, this is more stable and reliable even though the greatest setback is that the smartphone has to be connected to the internet to retrieve information about the beacon and in order to receive the notification, the screen must be opened and bluetooth and location services must also be turned on. But at least the service is consistent and stable. I also noticed that the notification had no sound at least on my cherry mobile flare xl 2 and the samsung s8 which I experimented with at the concept store and the notification disappears all by itself after 10 to 20 minutes. I wonder why google did not made the notification the same as receiving an sms message. The aliexpress app had the same notification characteristics as the sms messaging. Or at least google provided a way to let users configure it that way. And lastly, do take note that once the notification is deleted, it will not reappear too soon because of google's standard notification backoff policy. I figured a way to make the notification reappear quickly by disabling - enabling the bluetooth service.

All android smartphones with at least KitKat(4.43) version had this Google Nearby. And are ready to receive the Eddystone signal. The photo below is the screenshot of my SKK Android Kitkat showing the notification from google nearby and the physical web software. Both notifications came from the same eddystone beacon. In this device, both google nearby and physical web are not reliable. I just forced both software to detect the beacon signal.


Here is how I made the google nearby worked:

1. I created a Google Cloud Platform Project. This should be easy because if you are in the Beacon Dashboard which can be found here link, The first screen will abvice you to create a project.:
And here is the project I created:

2. After you created the project, it will take you back to the first screen and click your project to select it.

3. Download the Beacon Tools app in Play Store to register the beacon. Open the app and it will ask you to choose your project. Just select your project and the next screen will detect your beacon unregistered. The screen shot below shows the Eddystone URL frame. This frame cant be registered in Google Nearby. Only the UID or EID frames are allowed which I already did. Just make sure that the eddystone is in connectible mode.


And here is the registered UID Frame:
And here is the registration screen:

I only populated the Description field and saved the registration on this android app.

4. I went back to the Beacon Dashboard and clicked on the project and it has taken me to the screen that lists all active beacons on that project.


5. I clicked the active beacon I registered in the Beacon Tools app, and has taken me to a screen that allows me to further configure the beacon:

In this screen, I populated all the fields and added just one property and went to the second tab(create attachment).



 Even though I had no idea what it is for, I just created a dummy data:

And here is the attachment I created:


And lastly, I created the Nearby Notification:


I saved the data I entered. My main objective here is to just send a notification message which when clicked, will open my blog to an internet browser on the smartphone.

And here is the final result showing the Eddystone URL link:



I have not explained in detail what each fields are for because I am also a beginner trying to make the Google Nearby work and so that I can check if it is stable and yes it was! There are other message types that will allow the user to open the app of the eddystone owner if it was already installed or will open the google play store which displays the app and the user will have to click the download button and install the app.

To complete my experiment, I went to a nearest Samsung Concept store and brought along my Eddystone to check if other android smartphones can detect the signal without doing any configuration and it was a success, I did not took any picture because I did not bring along my phone so that I can fully test it. Bringing along my phone could influence the result.

Conclusion:
I still see a lot cons than pros but the best part of it is that the service is very stable and reliable and google has solved the huge problem how to get people' attention to get them download the business owner's app.

Ways Eddystones can help boost sales of Businesses

With the Philippines' growing economy, big retailers keeps on investing in huge malls all over the country leaving small players struggling to boost sales. This holiday season, employees has received their 13th to 14th month pay plus Christmas bonuses and have a lot of money to spend.

With this huge potential customers, capturing a small portion can make retailers earn more profits. Beacon technologies is new and most likely very few developers and business owners are aware of its existence. And because of this, if early adapters use the technology to attract more customers is one great advantage because of the following reasons:

1 Beacon Technology can deliver relevant information to potential customers at the right place and the right time.
2. Traditional Marketing tool have smaller conversion rate than Beacon Marketing Technologies.
3. Beacon Marketing Technology enhance customers shopping experience by introducing new payment methods and helping them get the information they need with incredibly rich content and carefully designed website and video.
4. It can prevent customers frustrations when they cant find the products they need by sending them forms that will enable them to list those products and retailers can inform when the product is already in stock in invite them to come back.

I end this post with a sample news report featuring the beacon technology: