I have some custom beacons for communicating via Bluetooth LE. Currently I am performing an LE-scan and check if the MAC-address of any found BLE-device is one of mine.
I would like to use Google Awareness Fence API to get triggered, if one of my beacons is in range instead of implementing the whole stuff by myself. But, if I want to create such a AwarenessFence
, I only can define the attributes
when using the 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);
}
}
});
Questions:
What does namespace and type mean? Are these attributes given to all BLE devices and can I read them somehow from my beacons? Or is this eg something Eddystone specific?
Can I use the Awareness API with MAC addresses of my beacons?
1) Had the same problem and solved it.
From https://developers.google.com/beacons/proximity/attachments you get a attachment context with a field "namespaceType". All you have to to is splitt up the hole String from "namespace/type" to "namespace" and "type" for your FenceState.TypeFilter. The namespace should be your project-id form the GoogleDevConsole.
To setup your beacon get the "Beacon Tools"(Google Inc.) from GooglePlayStore and find your beacon, there you can add an attachment.
2) As far as I can see: When a fence is triggered, you only get the fence key. So the answere is NO. But you could make a getBeaconState()-request, to see which beacons are near to you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.