本文整理汇总了Java中com.neovisionaries.bluetooth.ble.advertising.ADStructure类的典型用法代码示例。如果您正苦于以下问题:Java ADStructure类的具体用法?Java ADStructure怎么用?Java ADStructure使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ADStructure类属于com.neovisionaries.bluetooth.ble.advertising包,在下文中一共展示了ADStructure类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchRFdroid
import com.neovisionaries.bluetooth.ble.advertising.ADStructure; //导入依赖的package包/类
private void dispatchRFdroid(BluetoothDevice device, int rssi, final byte[] scanRecord) {
if (scanningList.containsKey(device.getAddress())) {
if (adListener != null && measurement.getBtDevice() != null && measurement.getBtDevice().getDeviceAddress().equals(device.getAddress())) {
long ts = new Date().getTime();
measurement.getHistoryList().add(ts);
adListener.onADframeReceived(ts, measurement.getHistoryList());
}
} else {
Log.i(TAG, "found a RFdroid");
List<ADStructure> structures = ADPayloadParser.getInstance().parse(scanRecord);
int advInterval = -1;
for (ADStructure structure : structures) {
if (structure instanceof ADManufacturerSpecific) {
ADManufacturerSpecific data = (ADManufacturerSpecific) structure;
if (data.getData().length == 9) {
byte[] name = new byte[7];
System.arraycopy(data.getData(), 0, name, 0, 7);
String nameStr = new String(name);
if (nameStr.equals("RFdroid")) {
advInterval = (data.getData()[7] << 8) + (data.getData()[8] & 0xFF);
Log.i(TAG, "current scan interval : " + advInterval);
}
}
}
}
if (advInterval != -1) {
scanningList.put(device.getAddress(), device);
if (!measurement.isSelectionningDevice())
measurement.setBtDevice(new BluetoothObject(device.getAddress(), device.getName(), (int) (advInterval * 0.625)));
try {
JSONObject object = new JSONObject();
object.put(JsonConstants.BT_ADDRESS, device.getAddress());
object.put(JsonConstants.BT_DEVICE_NAME, device.getName());
object.put(JsonConstants.BT_ADVERTISING_INTERVAL, (int) (advInterval * 0.625));
ArrayList<String> deviceInfo = new ArrayList<>();
deviceInfo.add(object.toString());
broadcastUpdateStringList(BluetoothEvents.BT_EVENT_DEVICE_DISCOVERED, deviceInfo);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}