Android で近くのビーコンを検索/検索しようとしており、Altbeacon Android ライブラリを使用しています。
ビーコンはカスタムで、メーカー固有のものは次のとおりです。
//---------------flags data type------------------------------------------------
// FLAGS data type
typedef PACKED_STRUCT
{
uint8_t len; // # bytes for data type (but not including len field)
uint8_t type; // 0x01
uint8_t attrib; // 0x06
} flags_data_t;
//---------------manufacturer specific data ------------------------------------
#define BLE_MFG_SPECIFIC_DATA_TYPE 0xff
// company identifiers of interest
#define BLE_COMPANY_ID_SOMECOMPANY 0x0312
// Manufacturer specific data (msd) header
typedef PACKED_STRUCT
{
uint8_t len; // # bytes for data type (but not including len field)
uint8_t type; // 0xff for manufacturer specific
uint16_t company_id; // Bluetooth org registered company id, use Enlighted
} msd_data_header_t;
この特定のメーカーの近くの場所のすべてのビーコンを取得する必要があります.
Android コードは次のとおりです。
beaconManager.getBeaconParsers().add(新しい BeaconParser() .setBeaconLayout("m:2-3=0312,i:4-19,i:20-21,i:22-23,p:24-24,d: 25-25"));
@Override
public void onBeaconServiceConnect() {
final Region region = new Region("myBeaons", Identifier.parse(UUID), null, null);
beaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
try {
Log.d(TAG, "didEnterRegion");
beaconManager.startRangingBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
}
@Override
public void didExitRegion(Region region) {
try{
Log.d(TAG, "didExitRegion");
beaconManager.stopRangingBeaconsInRegion(region);
} catch (RemoteException e) {
}}
@Override
public void didDetermineStateForRegion(int i, Region region)
{
Log.d(TAG, "didDetermineStateForRegion");
}
});
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
for (Beacon oneBeacon : beacons) {
Log.d(TAG, "distance: " + oneBeacon.getDistance() + " id:" + oneBeacon.getId1() + "/" + oneBeacon.getId2() + "/" + oneBeacon.getId3());
}
}
});
try {
beaconManager.startMonitoringBeaconsInRegion(region);
} catch (RemoteException e) {
e.printStackTrace();
}
}
しかし、ビーコンを見つけることができません。どうすればこれを行うことができるか、または他のライブラリを提案してください