2
  • test connection from device (android, iphone, wp10)
  • Send advertisment
enzo
  • 21

1 Answers1

3

linux-ibeacon is a Python script that creates an Apple iBeacon-compatible Bluetooth LE beacon using a computer running Linux and a Bluetooth LE adapter. You need to install either Python 2.6 or Python 2.7 and version 5.0 or greater of BlueZ, the Linux Bluetooth stack and associated tools.

In Ubuntu 15.10 and later (required for bluez>=5.0), open the terminal and type:

sudo apt install python2.7 bluetooth bluez-tools blueman

Your computer must also have a Bluetooth adapter (either built-in or USB) that is compatible with the Bluetooth 4.0 LE standard. To test whether your adapter is LE-compatible, run the following command:

sudo hcitool lescan ## Start LE scan

If you see either nothing, or a list of MAC addresses (aa:bb:cc:dd:ee:ff) then your adapter supports Bluetooth LE. If, on the other hand, you see any error messages in the output, then your adapter does not support LE. (This command will continuously scan for devices, so to exit it press Ctrl+C.)

How to use it

The command ibeacon works if:

  • ibeacon is in $PATH
  • ibeacon needs to be executable

    sudo chmod a+x ibeacon
    
  • filename should have no extension (i.e. ibeacon)

  • shebang in the first line of script is needed(#!/usr/bin/python)

Usage: sudo ibeacon [-u|--uuid=UUID or `random' (default=Beacon Toolkit app)] [-M|--major=major (0-65535, default=0)] [-m|--minor=minor (0-65535, default=0)] [-p|--power=power (0-255, default=200)] [-d|--device=BLE device to use (default=hci0)] [-z|--down] [-v|--verbose] [-n|--simulate (implies -v)] [-h|--help]

This script must be run with root privileges in order to configure Bluetooth adapters. It is most convenient to run it using sudo.

By default, the script creates an iBeacon whose UUID matches that which is used by the Beacon Toolkit iOS app, with major and minor both set to 0. These can be changed using the -u, -M and -m flags respectively. When specifying the UUID, you can specify an explicit UUID, or by specifying random the script will randomly generate a UUID.

UUID, major and minor may also be specified by setting the IBEACON_UUID, IBEACON_MAJOR and IBEACON_MINOR environment variables, respectively. If a value(s) is specified both in the environment as well as a command line option, the command line option takes precedence.

To test, you will need a device compatible with Bluetooth. In the Apple universe, that means the iPhone 4S or later, iPad 3rd gen or later (including Mini and Air), and the iPod touch. For Android, most phones made within the last 2 years or so should be BLE-compatible.) Then download either Beacon Toolkit (https://itunes.apple.com/us/app/beacon-toolkit/id728479775?mt=8) (for iOS) or iBeacon Scanner (for Android.) Fire up the app and begin scanning. Your newly-created iBeacon should appear in the list. If not, check to make sure that you specified the correct UUID, major and minor numbers. (For iOS devices, if you used a non-default UUID, you will have to enter it in the Beacon Toolkit app's settings screen.)

karel
  • 114,770