本文整理汇总了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();
}
}
}
}
开发者ID:bertrandmartel,项目名称:rfdroid-scanparam,代码行数:63,代码来源:BluetoothCustomManager.java
注:本文中的com.neovisionaries.bluetooth.ble.advertising.ADStructure类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论