use of nodomain.freeyourgadget.gadgetbridge.model.DeviceType in project Gadgetbridge by Freeyourgadget.
the class DiscoveryActivity method handleDeviceFound.
private void handleDeviceFound(BluetoothDevice device, short rssi, ParcelUuid[] uuids) {
LOG.debug("found device: " + device.getName() + ", " + device.getAddress());
if (LOG.isDebugEnabled()) {
if (uuids != null && uuids.length > 0) {
for (ParcelUuid uuid : uuids) {
LOG.debug(" supports uuid: " + uuid.toString());
}
}
}
if (device.getBondState() == BluetoothDevice.BOND_BONDED) {
// ignore already bonded devices
return;
}
GBDeviceCandidate candidate = new GBDeviceCandidate(device, rssi, uuids);
DeviceType deviceType = DeviceHelper.getInstance().getSupportedType(candidate);
if (deviceType.isSupported()) {
candidate.setDeviceType(deviceType);
LOG.info("Recognized supported device: " + candidate);
int index = deviceCandidates.indexOf(candidate);
if (index >= 0) {
// replace
deviceCandidates.set(index, candidate);
} else {
deviceCandidates.add(candidate);
}
cadidateListAdapter.notifyDataSetChanged();
}
}
use of nodomain.freeyourgadget.gadgetbridge.model.DeviceType in project Gadgetbridge by Freeyourgadget.
the class DeviceHelper method toGBDevice.
/**
* Converts a known device from the database to a GBDevice.
* Note: The device might not be supported anymore, so callers should verify that.
* @param dbDevice
* @return
*/
public GBDevice toGBDevice(Device dbDevice) {
DeviceType deviceType = DeviceType.fromKey(dbDevice.getType());
GBDevice gbDevice = new GBDevice(dbDevice.getIdentifier(), dbDevice.getName(), deviceType);
List<DeviceAttributes> deviceAttributesList = dbDevice.getDeviceAttributesList();
if (deviceAttributesList.size() > 0) {
gbDevice.setModel(dbDevice.getModel());
DeviceAttributes attrs = deviceAttributesList.get(0);
gbDevice.setFirmwareVersion(attrs.getFirmwareVersion1());
gbDevice.setFirmwareVersion2(attrs.getFirmwareVersion2());
gbDevice.setVolatileAddress(attrs.getVolatileIdentifier());
}
return gbDevice;
}
Aggregations