Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change: Retrieve beacon name for beacon monitor sensor #2941

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -15,6 +15,7 @@ data class IBeacon(
var distance: Double,
var rssi: Double,
var skippedUpdated: Int,
var name: String?,
)

class IBeaconMonitor {
Expand All @@ -38,10 +39,11 @@ class IBeaconMonitor {
val minor = newBeacon.id3.toString()
val distance = round(newBeacon.distance * 100) / 100
val rssi = newBeacon.runningAverageRssi
val name = newBeacon.bluetoothName
if (!tmp.contains(name(uuid, major, minor))) { // we found a new beacon
requireUpdate = true
}
tmp += Pair(name(uuid, major, minor), IBeacon(uuid, major, minor, distance, rssi, 0))
tmp += Pair(name(uuid, major, minor), IBeacon(uuid, major, minor, distance, rssi, 0, name))
}
val sorted = sort(tmp.values).toMutableList()
if (requireUpdate) {
Expand Down
Expand Up @@ -359,7 +359,15 @@ class BluetoothSensorManager : SensorManager {
val attr = mutableMapOf<String, Any?>()
if (BluetoothUtils.isOn(context) && monitoringManager.isMonitoring()) {
for (beacon: IBeacon in beaconMonitoringDevice.beacons) {
attr += Pair(name(beacon.uuid, beacon.major, beacon.minor), beacon.distance)
attr += listOf(
name(beacon.uuid, beacon.major, beacon.minor) to mapOf(
"distance" to beacon.distance,
"name" to beacon.name,
"uuid" to beacon.uuid,
"major" to beacon.major,
"minor" to beacon.minor
)
)
}
}

Expand Down