The emergence of iBeacons as a micro location provider has created a number of solutions provided by different vendors in this space. Given the quantity of beacons involved in each implementation, monitoring and maintaining the beacons have become time consuming and effort intensive increasing the maintenance & operational costs. This paper discusses about IGATE’s solution to detect the iBeacon failure using Raspberry Pi and the probable challenges that could be faced during the implementation.
2. Problem Statement
Recent trends show that iBeacons, small battery powered Bluetooth Low Energy (BLE) devices, are being extensively used in retail stores for pushing promotions and Indoor Positioning. Each of these beacons has a typical battery life of 6-8 months depending on the type of battery used. With a relatively huge setup that needs managing at least 500-600 beacons, manually monitoring the health of each beacon is time consuming and increases maintenance costs significantly. Also if any one of the beacons has malfunctioned, detecting it might take more time which can result in loss of revenue to the retailer.
3. About Raspberry Pi
The Raspberry Pi is a credit card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.
Figure 1: Raspberry Pi
In 2014, the Raspberry Pi Foundation launched the Compute Module, which packages a Raspberry Pi Model B into module for use as a part of embedded systems, to encourage their use.
The Raspberry Pi is based on the Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded (Model B & Model B+) to 512 MB. The system has Secure Digital (SD) or MicroSD (Model A+ and B+) sockets for boot media and persistent storage.
The Foundation provides Debian and Arch Linux ARM distributions for download. Tools available are Python as the main programming language, with support for BBC BASIC , C, C++, Java, Perl and Ruby.
5.Components of the system
Figure 2: Components of the system
6.1 Preparing the Raspberry Pi
Installing the Bluez SDK, will add Bluetooth capability to the pi.
Once the USB Bluetooth adapter is connected to the Pi, the device status can be checked using the shell command
sudo hciconfig hci0 status
if the status shows “down”, the device has to be started using the command
sudo hciconfig hci0 up
Once the device is up and running the shell script to detect the beacons can be run through command line or added as a cron-job that will run continuously for every 10 minutes
iBeacons are placed around the Raspberry Pi for it to be detected
6.2 Shell Script:
The shell script uses the hcitool to read the bluetooth packets near its vicinity and the script is used to filter the iBeacon packets in the list.
sudo hcitool lescan –duplicates &
The shell script, in turn, processes the iBeacon packets to retrieve the UUID, Major ID, Minor ID, RSSI, and Power which will be uploaded using cURL to the server using a web service.
One major challenge was that the hcitool scan sniffed the packets at a higher rate than the script could process, which resulted in the readings getting processed very slowly. As the script runs continuously to scan bluetooth packets, there was a major delay in processing by the script which will led to delayed messages sent to server. To avoid this the script is run as a cron-job every 5 minutes and will last for 20 seconds every time.
timeout 20 ./ibeacon_scan.sh
This will make sure that there would be minimal delay in sending the bluetooth scan readings to the server for processing, and the server can, in turn, detect the iBeacon failure with a maximum delay of 10 minutes.
6.3 Server application:
The server application consists of a web service and also a web based front end to show the beacon status on a store layout. The web service gets the data from the Raspberry such as the iBeacon’s UUID, Major ID, Minor ID, RSSI, and also the time stamp of the iBeacon packet reading. This data is updated on the database for the beacon table with the last updated time stamp for the beacon. A cron scheduler will check the current server time with the last updated timestamp for the beacon, and if this difference is more than 10 minutes, the beacon status will be updated as not working. The web based front end that shows the beacon status as red/ green will get updated accordingly.
7.Challenges in implementation
Some of the challenges faced during the implementation is listed below
The Raspberry Pi itself can fail for multiple reasons like power failure or some other reasons. This can be taken care by maintaining the last updated date of the Raspberry Pi.
Detecting multiple beacons with the same UUID on the Raspberry Pi will fail as the iBeacon packet read by the Raspberry Pi will not have the Mac Address of the beacon
Absence of any HTTP framework on Raspberry Pi for handling Web service calls to server for data exchange ended up in using a lot of low level functions on the Raspberry Pi.
As 500-600 beacons are involved in an implementation, beacon failure detection will be time consuming and expensive, if done manually. A Raspberry Pi combined with a Bluetooth adapter and a server application can be used to detect iBeacon failure with a maximum delay of 10 minutes as given by the solution given in this paper. This solution eliminates the need for manual checking of the beacons failures.