Gaiger Chen
Gaiger Chen

Reputation: 300

Broadcasting message in Bluetooth low energy mode

Your Honor:

I would like to know how to broadcast message in BLE(bluetooth low energy mode).

That behavior is just like iBeacon in Macintosh.

As my know, windows(7 or 8) do not support this function.

But linux does.

Anyone could guide/cue me a way to achieve this in linux ?

By command line or code are ok , good in both.

That is like, x86-linux boardcasting a message , like: "I am laptop"

And I could use another device(phone/computer..etc) to receiver this message.

Thank your help.

Upvotes: 1

Views: 5688

Answers (3)

Carl Binding
Carl Binding

Reputation: 69

export IBEACONPROFIX="02 01 1A 1A FF 4C 00 02 15"

is correct but can be further divided into Bluetooth HCI data plus Apple proprietary data:

3 bytes of Flags as per Supplement to the Bluetooth Core Specification

02 : length (1)

01 : type "Flag"

1A : value of flags

followed by vendor proprietary data

1A : length of proprietary payload (1), here 0x1A == 26: 5 bytes iBeacon header + 21 iBeacon payload data

FF : indicator of proprietary data (1)

4C 00: company ID (2), Apple

02 : iBeacon type

15 : iBeacon data length (1) 0x15 == 21: 16 bytes UUID, 2 bytes major, 2 bytes minor, 1 byte TX Power

https://www.bluetooth.com/specifications/assigned-numbers/company-identifiers/

https://www.bluetooth.com/specifications/bluetooth-core-specification/

Upvotes: 0

Gaiger Chen
Gaiger Chen

Reputation: 300

Step 0:

(if you have mac, download mactsAsBeacon for verify)

Download iBeacon scanner in you android/iOS mobile phone.

Step 1:

It is my shell script:

#!/bin/bash
set -x

export BLUETOOTH_DEVICE=hci0
#sudo hcitool -i hcix cmd <OGF> <OCF> <No. Significant Data Octets> <iBeacon Prefix>    <UUID> <Major> <Minor> <Tx Power> <Placeholder Octets>

#OGF = Operation Group Field = Bluetooth Command Group = 0x08
#OCF = Operation Command Field = HCI_LE_Set_Advertising_Data = 0x0008
#No. Significant Data Octets (Max of 31) = 1E (Decimal 30)
#iBeacon Prefix (Always Fixed) = 02 01 1A 1A FF 4C 00 02 15

export OGF="0x08"
export OCF="0x0008"
export IBEACONPROFIX="02 01 1A 1A FF 4C 00 02 15"
#export UUID="92 77 83 0A B2 EB 49 0F A1 DD 7F E3 8C 49 2E DE"
export UUID="B9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D"
export MAJOR="01 02"
export MINOR="03 04"
export POWER="C5 00"

sudo hciconfig $BLUETOOTH_DEVICE up
sudo hciconfig $BLUETOOTH_DEVICE noleadv
sudo hciconfig $BLUETOOTH_DEVICE noscan
sudo hciconfig $BLUETOOTH_DEVICE leadv 3
sudo hcitool -i $BLUETOOTH_DEVICE cmd 0x08 0x0008 $IBEACONPROFIX $UUID $MAJOR $MINOR $POWER

#sudo hciconfig $BLUETOOTH_DEVICE leadv 3

Step 2:

Run this script, you will find the iBeacon scanner on your mobile has found the linux ibeacon transmitter.

If you want to turn off the boardcasting:

sudo hciconfig hci0 noleadv

Upvotes: 1

davidgyoung
davidgyoung

Reputation: 64926

You can use the BlueZ stack to advertise a BLE device in Linux. See this question for the basics of how to do this:

Use BlueZ Stack As A Peripheral (Advertiser)

Depending on what you want to advertise, you need to figure out the format of the bytes in the advertisement. Here is an example of how you can use BlueZ to transmit the open-source AltBeacon advertisement format: https://github.com/RadiusNetworks/altbeacon-reference/blob/master/altbeacon_transmit

Upvotes: 1

Related Questions