顯示具有 Beacon 標籤的文章。 顯示所有文章
顯示具有 Beacon 標籤的文章。 顯示所有文章

2016年7月20日 星期三

Estimote SDK: Building a beacon Android app ---- 3/3

since: 2016/07/20
update: 2016/07/20

reference:
1. Beacon Tech Overview - Estimote Developer

 Part 3: Ranging beacons

A. Start ranging
    1. 開啟 MainActivity.java 修改如下:
package myhome.airport;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.estimote.sdk.Beacon;

import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;

import com.estimote.sdk.SystemRequirementsChecker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import java.util.UUID;

public class MainActivity extends AppCompatActivity {

    private BeaconManager beaconManager;
    private Region region;

    private static final Map<String, List<String>> PLACES_BY_BEACONS;

    // TODO: replace "<major>:<minor>" strings to match your own beacons.
    static {
        Map<String, List<String>> placesByBeacons = new HashMap<>();
        placesByBeacons.put("0:5", new ArrayList<String>() {{
            add("Heavenly Sandwiches");
            // read as: "Heavenly Sandwiches" is closest
            // to the beacon with major 0 and minor 5

            add("Green & Green Salads");
            // "Green & Green Salads" is the next closest
            add("Mini Panini");
            // "Mini Panini" is the furthest away
        }});
        placesByBeacons.put("0:7", new ArrayList<String>() {{
            add("Mini Panini");
            add("Green & Green Salads");
            add("Heavenly Sandwiches");
        }});
        PLACES_BY_BEACONS = Collections.unmodifiableMap(placesByBeacons);
    }


    private List<String> placesNearBeacon(Beacon beacon) {
        String beaconKey = String.format("%d:%d", beacon.getMajor(), beacon.getMinor());
        if (PLACES_BY_BEACONS.containsKey(beaconKey)) {
            return PLACES_BY_BEACONS.get(beaconKey);
        }
        return Collections.emptyList();
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        beaconManager = new BeaconManager(this);
        region = new Region("ranged region",
                UUID.fromString("FDA50693-A4E2-4FB1-AFCF-C6EB07647825"), null, null);

        // add Ranging listener
        beaconManager.setRangingListener(new BeaconManager.RangingListener() {
            @Override
            public void onBeaconsDiscovered(Region region, List<Beacon> list) {
                if (!list.isEmpty()) {
                    Beacon nearestBeacon = list.get(0);
                    List<String> places = placesNearBeacon(nearestBeacon);
                    // TODO: update the UI here
                    Log.d("Airport", "Nearest places: " + places);
                    Log.d("Major: ", ""+nearestBeacon.getMajor());
                    Log.d("Minor: ", ""+nearestBeacon.getMinor());
                    Log.d("UUID: ", ""+ nearestBeacon.getProximityUUID());
                    Log.d("MeasuredPower: ", ""+ nearestBeacon.getMeasuredPower());
                    Log.d("Rssi: ", ""+ nearestBeacon.getRssi());
                }
            }
        });

    }

    //@add ########################
    @Override
    protected void onResume() {
        super.onResume();

        //@add ########################
        // Runtime permissions (Android 6.0)
        SystemRequirementsChecker.checkWithDefaultDialogs(this);

        // start Ranging
        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            @Override
            public void onServiceReady() {
                beaconManager.startRanging(region);
            }
        });

    }

    //@add ########################
    @Override
    protected void onPause() {

        // stop Ranging
        beaconManager.stopRanging(region);

        super.onPause();
    }


}


    2. 結果:

Estimote SDK: Building a beacon Android app ---- 2/3

since: 2016/07/20
update: 2016/07/20

reference:
1. Beacon Tech Overview - Estimote Developer

Part 2: Background monitoring
 

A. Add a beacon manager
    1. 新增一個 MyApplication Java Class:
        > 點選 MainActivity class 所屬的套件 > 滑鼠右鍵 > New
        > Java Class

      > Name: MyApplication
      > Kind: Class
      > OK

     > 結果:

    2. 開啟 MyApplication.java 修改如下:
package myhome.airport;

import android.app.Application;
import com.estimote.sdk.BeaconManager;


//public class MyApplication {
public class MyApplication extends Application {

    private BeaconManager beaconManager;

    @Override
    public void onCreate() {
        super.onCreate();

        beaconManager = new BeaconManager(getApplicationContext());
    }

}


    3. 在 AndroidManifest.xml 裡, 宣告此類別:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="myhome.airport">

    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


-----------------------------------------------------------------------------------------------

B. Start monitoring
     1. 開啟 MyApplication.java 修改如下:

package myhome.airport;

import android.app.Application;
import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;

import java.util.UUID;


//public class MyApplication {
public class MyApplication extends Application {

    private BeaconManager beaconManager;

    @Override
    public void onCreate() {
        super.onCreate();

        beaconManager = new BeaconManager(getApplicationContext());

        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {


            @Override
            public void onServiceReady() {


                // Monitor: UUID, major, minor
                /*
                beaconManager.startMonitoring(new Region(
                        "monitored region",
                        UUID.fromString("FDA50693-A4E2-4FB1-AFCF-C6EB07647825"),
                        0, 5));
                */

                // Monitor: UUID, major
                /*
                beaconManager.startMonitoring(new Region(
                        "monitored region",
                        UUID.fromString("FDA50693-A4E2-4FB1-AFCF-C6EB07647825"),
                        0, null));
                */

                // Monitor: UUID
                beaconManager.startMonitoring(new Region(
                        "monitored region",
                        UUID.fromString("FDA50693-A4E2-4FB1-AFCF-C6EB07647825"),
                        null, null));

            }
        });

    }
}


-----------------------------------------------------------------------------------------------

C. Show an "enter / exit" notification

     1. add a helper method to the MyApplication class:
         // 開啟 MyApplication.java 修改如下:

package myhome.airport;

import android.app.Application;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;


import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;

import java.util.UUID;

//public class MyApplication {
public class MyApplication extends Application {
....


    // show Notification
    public void showNotification(String title, String message) {

        Intent notifyIntent = new Intent(this, MainActivity.class);
        notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivities(this, 0,
                new Intent[] { notifyIntent }, PendingIntent.FLAG_UPDATE_CURRENT);

        Notification notification = new Notification.Builder(this)
                .setSmallIcon(android.R.drawable.ic_dialog_info)
                .setContentTitle(title)
                .setContentText(message)
                .setAutoCancel(true)
                .setContentIntent(pendingIntent)
                .build();
        notification.defaults |= Notification.DEFAULT_SOUND;
       
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, notification);
    }


}

     2. 開啟 MyApplication.java 修改如下:
package myhome.airport;

import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

import com.estimote.sdk.Beacon;
import com.estimote.sdk.BeaconManager;
import com.estimote.sdk.Region;


import java.util.List;
import java.util.UUID;


//public class MyApplication {
public class MyApplication extends Application {

    private BeaconManager beaconManager;

    @Override
    public void onCreate() {
        super.onCreate();

        beaconManager = new BeaconManager(getApplicationContext());

        beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {

            // on Entered Region
            @Override
            public void onEnteredRegion(Region region, List<Beacon> list) {

                showNotification(
                        "Notification",
                        "You Entered Region!");
            }

            // on Exited Region
            @Override
            public void onExitedRegion(Region region) {
                showNotification(
                        "Notification",
                        "You Exited Region!");
            }
        });

  }
....
}


     3. 結果:


Estimote SDK: Building a beacon Android app ---- 1/3

since: 2016/07/20
update: 2016/07/20

reference:
1. Beacon Tech Overview - Estimote Developer

Part 1: Setting up

A. Create a beacon project
    1. Start a new Android Studio project

    2. 設定好專案相關資料後 > Next

    3. Minimum SDK 選擇 API 18: Android 4.3 (Jelly Bean)
        > Next

    4. 選擇 Empty Activity > Next

    5. Customize the Activity: 使用預設即可 > Finish

-----------------------------------------------------------------------------------------------

B. Add Estimote SDK
    1. 查詢 Estimote Android SDK 最新的版本:
        Releases · Estimote/Android-SDK
        目前:  
dependencies {
    compile 'com.estimote:sdk:0.10.8@aar'
}

    2. 加入 Estimote SDK:
        > 開啟 Gradle Script > build.gradle (Module: app), 修改如下:
....
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.0'

    //@add ########################
    // add the following line, and replace "0.10.4" with the latest version
    // of Estimote Android SDK; you'll find the latest version number on:
    //   https://github.com/Estimote/Android-SDK/releases

    compile 'com.estimote:sdk:0.10.8@aar'
}


    3. 接著右上方出現訊息: Gradle files have changed since last project sync
        > 按下 Sync Now

-----------------------------------------------------------------------------------------------

C. Runtime permissions (Android 6.0)
    1. 開啟 MainActivity.java 修改如下:
package myhome.airport;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.estimote.sdk.SystemRequirementsChecker;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    //@add ########################
    @Override
    protected void onResume() {
        super.onResume();

        //@add ########################
        // Runtime permissions (Android 6.0)

        SystemRequirementsChecker.checkWithDefaultDialogs(this);
    }

}


    2. 執行:


2016年7月19日 星期二

Estimote SDK: Building a beacon iOS app ---- 3/3

since: 2016/07/30
update: 2016/07/30

reference:
1. Beacon Tech Overview - Estimote Developer

Part 3: Ranging beacons

A. 開啟 ViewController.swift 修改如下:
import UIKit

//@update ################################
// 1. Add the ESTBeaconManagerDelegate protocol

//class ViewController: UIViewController {
class ViewController: UIViewController, ESTBeaconManagerDelegate {
   
    //@add ################################
    // Add the property holding the data.
    // TODO: replace "<major>:<minor>" strings to match your own beacons

    let placesByBeacons = [
        "0:5": [
            "Heavenly Sandwiches": 50, // read as: it's 50 meters from
            // "Heavenly Sandwiches" to the beacon with
            // major 0 and minor 5

            "Green & Green Salads": 150,
            "Mini Panini": 325
        ],
        "0:7": [
            "Heavenly Sandwiches": 250,
            "Green & Green Salads": 100,
            "Mini Panini": 20
        ]
    ]


    //@add ################################
    // 2. Add the beacon manager and the beacon region

    let beaconManager = ESTBeaconManager()
    let beaconRegion = CLBeaconRegion(
        proximityUUID: NSUUID(UUIDString: "FDA50693-A4E2-4FB1-AFCF-C6EB07647825")!,
        identifier: "ranged region")

   
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
       
        //@add ################################
        // 3. Set the beacon manager's delegate

        self.beaconManager.delegate = self
       
        //@add ################################
        // 4. We need to request this authorization for every beacon manager

        // self.beaconManager.requestAlwaysAuthorization()
        self.beaconManager.requestWhenInUseAuthorization()

    }

    //@add ################################
    // start ranging as the view controller appears on screen

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.beaconManager.startRangingBeaconsInRegion(self.beaconRegion)
    }

   
    //@add ################################
    // stop ranging as the view controller disappears on screen

    override func viewDidDisappear(animated: Bool) {
        super.viewDidDisappear(animated)
        self.beaconManager.stopRangingBeaconsInRegion(self.beaconRegion)
    }

   
    //@add ################################
    // places Near Beacon

    func placesNearBeacon(beacon: CLBeacon) -> [String]? {
        let beaconKey = "\(beacon.major):\(beacon.minor)"
        if let places = self.placesByBeacons[beaconKey] {
            //let sortedPlaces = Array(places).sorted { $0.1 < $1.1 }.map { $0.0 }
            let sortedPlaces = Array(places).sort { $0.1 < $1.1 }.map { $0.0 }
            return sortedPlaces
        }
        return nil
    }

   
    //@add ################################
    // didRangeBeacons delegate

    func beaconManager(manager: AnyObject, didRangeBeacons beacons: [CLBeacon],
                       inRegion region: CLBeaconRegion) {
        if let nearestBeacon = beacons.first, places = placesNearBeacon(nearestBeacon) {
            // TODO: update the UI here
            print("************************")
            print("UUID:" + region.proximityUUID.UUIDString + "; identifier: " + region.identifier)
            print("major: " + nearestBeacon.major.stringValue + "; minor: " + nearestBeacon.minor.stringValue)
           
            print(places) // TODO: remove after implementing the UI
            print("")
        }
    }

   
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}


-----------------------------------------------------------------------------------------------

B. 結果:


Estimote SDK: Building a beacon iOS app ---- 2/3

since: 2016/07/19
update: 2016/07/30

reference:
1. Beacon Tech Overview - Estimote Developer

Part 2: Background monitoring

A. Start beacon monitoring
    1. 開啟 AppDelegate.swift 修改如下:
....
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
       
        //@add ################################
        // 3. Set the beacon manager's delegate
        self.beaconManager.delegate = self
       
        //@add ################################
        // request the authorization:
        self.beaconManager.requestAlwaysAuthorization()
       
        //@add ################################
        // case 1: Start monitoring for UUID & major & minor
        /*
        self.beaconManager.startMonitoringForRegion(CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "FDA50693-A4E2-4FB1-AFCF-C6EB07647825")!,
            major: 0, minor: 5, identifier: "UUID, major, minor: monitored region"))
        */
       
        //
case 2: Start monitoring for UUID & major
        /*
        self.beaconManager.startMonitoringForRegion(CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "FDA50693-A4E2-4FB1-AFCF-C6EB07647825")!,
            major: 0, identifier: "UUID, major: monitored region"))
        */
       
        //
case 3: Start monitoring for UUID
        self.beaconManager.startMonitoringForRegion(CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "FDA50693-A4E2-4FB1-AFCF-C6EB07647825")!, identifier: "UUID: monitored region"))

       
        // stop Monitoring For Region
        /*
        self.beaconManager.stopMonitoringForRegion(CLBeaconRegion(
            proximityUUID: NSUUID(UUIDString: "FDA50693-A4E2-4FB1-AFCF-C6EB07647825")!, identifier: "UUID: monitored region"))
        */


        // check
regionsCount       
        /*
        let
regionsCount = self.beaconManager.monitoredRegions.count
        print("
regionsCount = \(regionsCount)")
        */

        return true
    }
....


    2. 結果:
        執行 app 並 Lock 住, 當 Unlock 時, 左下角會出現: Suggested apps,
        將其往上滑(swiped up), 就可以開啟此 app.
        說明: 必須配合 self.beaconManager.requestAlwaysAuthorization() 才有效

-----------------------------------------------------------------------------------------------

B. Show an "enter / exit" region notification
    1. 開啟 AppDelegate.swift 修改如下:
....
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        ....
        //@add ################################
        // to show notifications
        UIApplication.sharedApplication().registerUserNotificationSettings(
            UIUserNotificationSettings(forTypes: .Alert, categories: nil))

       
        return true
    }

    //@add ################################
    // Show an "enter" notification
    func beaconManager(manager: AnyObject, didEnterRegion region: CLBeaconRegion) {
        let notification = UILocalNotification()
        notification.alertBody =
            "You enter the region!"
        UIApplication.sharedApplication().presentLocalNotificationNow(notification)
       
        print("You enter the region! identifier: \(region.identifier)")

    }
   
    //@add ################################
    // Show an "exit" notification
    func beaconManager(manager: AnyObject, didExitRegion region: CLBeaconRegion) {
        let notification = UILocalNotification()
        notification.alertBody =
            "You exit the region!"
        UIApplication.sharedApplication().presentLocalNotificationNow(notification)
       
        print("You exit the region! identifier: \(region.identifier)")

    }
....


    2. 結果:
        說明: 必須配合 self.beaconManager.requestAlwaysAuthorization() 才有效


2016年7月18日 星期一

Estimote SDK: Building a beacon iOS app ---- 1/3

since: 2016/07/18
update: 2016/07/30

reference:
1. Beacon Tech Overview - Estimote Developer

Part 1: Setting up

A. Create a beacon project
    1. iOS > Application > Single View Application > Next

    2. Language: Swift > Next

    3. 設定 iOS 的版本需求: (至少 8.0 以上)
        Airport(Project) > General > Deployment Target: 8.0

-----------------------------------------------------------------------------------------------

B. Add Estimote SDK
    1. 下載: Estimote iOS SDK
         將下載的 iOS-SDK-master.zip 解壓縮後, 在 EstimoteSDK 目錄下可以看到:
         EstimoteSDK.framework 檔案.

    2. 直接將 EstimoteSDK.framework 檔案, 拖拉到專案裡, 並勾選: Copy items if needed

    3. 完成後, 可以看到  EstimoteSDK.framework 已加到專案裡  

-----------------------------------------------------------------------------------------------

C. Add an Objective-C bridging header
     1. Airport(專案目錄) > New File...  

     2. iOS > Source > Header File > Next

     3. Save As: ObjCBridge.h
         > 勾選 Target: Airport(專案目錄)
         > Create

     4. 開啟 ObjCBridge.h 檔案, 修改如下:
#ifndef ObjCBridge_h
#define ObjCBridge_h

//@add ###########################
#import <EstimoteSDK/EstimoteSDK.h>

#endif /* ObjCBridge_h */ 


     5. 設定: Objective-C Bridging Header:
          Airport(Project) > Build Settings >
          Swift Compiler - Code Generation (蠻下面的) > Objective-C Bridging Header
          輸入: ${PROJECT_NAME}/ObjCBridge.h
          備註: 如果
專案名稱更改為中文, 在此要輸入: Airport/ObjCBridge.h

     6. 結果:

-----------------------------------------------------------------------------------------------

D. Add a beacon manager
   1. 開啟 AppDelegate.swift 檔案, 修改如下:
import UIKit

@UIApplicationMain

//@update ################################
//1. Add the ESTBeaconManagerDelegate protocol
//class AppDelegate: UIResponder, UIApplicationDelegate {
class AppDelegate: UIResponder, UIApplicationDelegate, ESTBeaconManagerDelegate {

    var window: UIWindow?
   
    //@add ################################
    // 2. Add a property to hold the beacon manager and instantiate it
    let beaconManager = ESTBeaconManager()

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
       
        //@add ################################
        // 3. Set the beacon manager's delegate
        self.beaconManager.delegate = self
       
        return true
    }


....

-----------------------------------------------------------------------------------------------

E. Authorization to use Location Services
    1. 點選 Info.plist 檔案
       > Add Row:
      Key: NSLocationAlwaysUsageDescription
      Type: String
      Value: (for example:)
      We use low-energy Bluetooth and iBeacon devices installed at the airport to find you inside the hall, and provide relevant information. You don’t need to know security wait times when you’re already at the gate, do you?

    或:
        Key: NSLocationWhenInUsageDescription
        Type: String
        Value: (for example:)
      We use low-energy Bluetooth and iBeacon devices installed at the airport to find you inside the hall, and provide relevant information. You don’t need to know security wait times when you’re already at the gate, do you?

    2. 開啟 AppDelegate.swift 檔案, 修改如下:
....
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
       
        //@add ################################
        // 3. Set the beacon manager's delegate
        self.beaconManager.delegate = self
       
        //@add ################################
        // request the authorization:
        // self.beaconManager.requestWhenInUseAuthorization()

        self.beaconManager.requestAlwaysAuthorization()
       
        return true
    }
....


    3. 第一次執行結果:

2016年3月29日 星期二

Raspberry Pi: Turn It Into An Beacon Node

since: 2016/03/29
update: 2016/04/01

reference:
1. Raspberry Pi應用 - Bluetooth 4.0 使用 iBeacon 
2. Overview | piBeacon - DIY Beacon with a Raspberry Pi 
3. Raspberry Pi 3 as an Eddystone URL beacon 


A. Install Required Libraries
    $ sudo apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev

-----------------------------------------------------------------------------------------------

B. Download Bluez

    $ sudo mkdir bluez
    $ cd bluez
    $ sudo wget www.kernel.org/pub/linux/bluetooth/bluez-5.38.tar.xz

-----------------------------------------------------------------------------------------------

C. Unzip and Compile Bluez

    $ sudo unxz bluez-5.38.tar.xz
    $ sudo tar xvf bluez-5.38.tar
    $ cd bluez-5.38
    $ sudo ./configure --disable-systemd
   
    $ sudo make
    $ sudo make install
-----------------------------------------------------------------------------------------------

D. Check for your USB Module

    $ cd /home/pi/bluez/bluez-5.38
    $ tools/hciconfig

    hci0:    Type: BR/EDR  Bus: USB
    BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING
    RX bytes:652 acl:0 sco:0 events:43 errors:0
    TX bytes:1533 acl:0 sco:0 commands:43 errors:0


-----------------------------------------------------------------------------------------------

E. Enable the USB Device
    $ sudo tools/hciconfig hci0 up
    $ sudo tools/hciconfig hci0 leadv 3

      LE set advertise enable on hci0 returned status 12

    $ sudo tools/hciconfig hci0 noscan

-----------------------------------------------------------------------------------------------

F. Enter the Beacon Advertising Data
   $ sudo tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00

< HCI Command: ogf 0x08, ocf 0x0008, plen 32
  1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F
  17 D1 AD 07 A9 61 00 00 00 00 C8 00
> HCI Event: 0x0e plen 4
  01 08 20 00


-----------------------------------------------------------------------------------------------

G. 測試軟體
     1. Mac: Beacon Scan

     2. iOS: Locate Beacon

     3. Android: Locate Beacon

-----------------------------------------------------------------------------------------------

H. 簡易開機自動啟動

     $ sudo nano /home/pi/iBeacon.sh
#!/bin/bash
sleep 5
cd /home/pi/bluez/bluez-5.38/
tools/hciconfig hci0 leadv 3
tools/hciconfig hci0 noscan
tools/hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 E2 0A 39 F4 73 F5 4B C4 A1 2F 17 D1 AD 07 A9 61 00 00 00 00 C8 00


     $ sudo crontab -e
        ....
        @reboot /home/pi/iBeacon.sh

-----------------------------------------------------------------------------------------------
I. 測試結果:(iOS)