我正在使用 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;
我需要为这个特定的制造商获取附近位置的所有信标。
安卓代码是:
beaconManager.getBeaconParsers().add(new 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();
}
}
但找不到任何信标,请建议我该怎么做或者是他们的任何其他图书馆