Skip to content

Commit

Permalink
bugfix for manufacturer data: subscibing for the event (missing updates)
Browse files Browse the repository at this point in the history
  • Loading branch information
vkolotov committed Dec 3, 2018
1 parent 8bff492 commit 6417a58
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* A multi-channel bluetooth device handler which represents a parsable advertising service data
Expand Down Expand Up @@ -46,6 +47,19 @@ public void serviceDataChanged(Map<URL, byte[]> serviceData) {
}
}

@Override
public void manufacturerDataChanged(Map<Short, byte[]> manufacturerData) {
Map<URL, byte[]> virtualServiceData = manufacturerData.entrySet().stream()
.collect(Collectors.toMap(
entry -> getURL().copyWithService(
String.format("%08X-0000-0000-0000-000000000000", entry.getKey() & 0xFFFF)),
Map.Entry::getValue));
if (virtualServiceData.containsKey(url.getServiceURL())) {
byte[] data = virtualServiceData.get(url.getServiceURL());
dataChanged(data, true);
}
}

private DeviceGovernor getGovernor() {
return handler.getBluetoothContext().getManager().getDeviceGovernor(url);
}
Expand Down

0 comments on commit 6417a58

Please sign in to comment.