Raspberry Pi Zero WHは、Bluetooth4.0/BLE(Bluetooth Low Energy)が使えるので、Beaconの送信をしてみた
Bluez
LinuxオフィシャルなBluetoothスタックのBluezを使います
Bluez-ibeaconのインストール
手っ取り早くBluez-iBeacon github.com
cd /usr/local/src sudo git clone https://github.com/carsonmcdonald/bluez-ibeacon.git cd bluez-ibeacon/bluez-beacon/ sudo make
Usage
cd bluez-ibeacon/bluez-beacon/ ./ibeacon Usage: ./ibeacon <advertisement time in ms> <UUID> <major number> <minor number> <RSSI calibration amount>
Beaconの送信
sudo ./ibeacon 200 67567567567567567567567567567567 1 1 -29
param | value |
---|---|
advertisement time in ms | 200 |
UUID | 67567567567567567567567567567567 |
majer number | 1 |
minor number | 1 |
RSSI calibration amount | -29 |
※ パラメータはこれを参考に設定
Beaconの受信
BLEスキャナー
今回はこのアプリを使用 play.google.com
受信できました
距離もImmediate(至近距離)と出てます
Bluetoothデバイス名の変更
Beaconを受信できたけど、デバイス名が機械的で認識しずらいので、名前を変更する
/etc/machine-info
/etc/machine-info
を作成し、以下の内容を記述する
PRETTY_HOSTNAME=device-name
Bluetooth serviceのrestart
sudo invoke-rc.d bluetooth restart
確認
再度beaconを送信して確認
デバイス名が任意の名前に変更できた