gpt4 book ai didi

android - 带有 Beacons MAC 的 Google Awareness API

转载 作者:太空宇宙 更新时间:2023-11-03 13:14:32 25 4
gpt4 key购买 nike

我有一些自定义信标,用于通过蓝牙 LE 进行通信。目前我正在执行 LE 扫描并检查任何找到的 BLE 设备的 MAC 地址是否是我的。

如果我的一个信标在范围内,我想使用 Google Awareness Fence API 来触发,而不是我自己实现整个东西。但是,如果我想创建这样一个AwarenessFence,我只能定义属性

  • 命名空间,
  • 类型

当使用 TypeFilters 时:

final BeaconState.TypeFilter typeFilter = BeaconState.TypeFilter.with("abc", "def");
final AwarenessFence beaconFence = BeaconFence.found(typeFilter);
Awareness.FenceApi.updateFences(
client,
new FenceUpdateRequest.Builder()
.addFence(BEACON_FENCE, beaconFence, pi)
.build())
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Fence was successfully registered.");
} else {
Log.e(TAG, "Fence could not be registered: " + status);
}
}
});

问题:

  1. namespace 和类型是什么意思?这些属性是否已赋予所有 BLE 设备,我能否以某种方式从我的信标中读取它们?或者这是例如Eddystone 特定的东西?

  2. 我可以将 Awareness API 与我的信标的 MAC 地址一起使用吗?

最佳答案

1) 遇到了同样的问题,解决了。

来自 https://developers.google.com/beacons/proximity/attachments你得到一个带有字段“namespaceType”的附件上下文。您所要做的就是为您的 FenceState.TypeFilter 将孔字符串从“ namespace /类型”拆分为“ namespace ”和“类型”。命名空间应该是您在 GoogleDevConsole 中的项目 ID。

要设置您的信标,请从 GooglePlayStore 获取“信标工具”(Google Inc.) 并找到您的信标,您可以在其中添加附件。


2)据我所知:触发围栏时,您只能获得围栏键。所以答案是否定的。但是您可以发出 getBeaconState() 请求,以查看附近有哪些信标。

关于android - 带有 Beacons MAC 的 Google Awareness API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38436723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com