- changes to OL module
This commit is contained in:
parent
57c5401243
commit
63a78a35ca
6 changed files with 52 additions and 36 deletions
|
@ -109,7 +109,7 @@ android {
|
|||
defaultConfig {
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "2.8.2.5-dev_mdt2"
|
||||
version "2.8.2.5-dev_mdt3"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||
|
|
|
@ -69,7 +69,7 @@ public class RileyLinkBLE {
|
|||
this.context = context;
|
||||
this.bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||
|
||||
orangeLink.rileyLinkBLE = this;
|
||||
//orangeLink.rileyLinkBLE = this;
|
||||
|
||||
bluetoothGattCallback = new BluetoothGattCallback() {
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class RileyLinkBLE {
|
|||
radioResponseCountNotified.run();
|
||||
}
|
||||
|
||||
orangeLink.onCharacteristicChanged(gatt, characteristic);
|
||||
orangeLink.onCharacteristicChanged(characteristic);
|
||||
}
|
||||
|
||||
|
||||
|
@ -229,6 +229,9 @@ public class RileyLinkBLE {
|
|||
final List<BluetoothGattService> services = gatt.getServices();
|
||||
|
||||
boolean rileyLinkFound = false;
|
||||
orangeLink.resetOrangeLinkData();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder("RileyLink Device Debug\n");
|
||||
|
||||
for (BluetoothGattService service : services) {
|
||||
final UUID uuidService = service.getUuid();
|
||||
|
@ -238,13 +241,14 @@ public class RileyLinkBLE {
|
|||
}
|
||||
|
||||
if (gattDebugEnabled) {
|
||||
debugService(service, 0);
|
||||
debugService(service, 0, stringBuilder);
|
||||
}
|
||||
|
||||
orangeLink.checkIsOrange(uuidService);
|
||||
}
|
||||
|
||||
if (gattDebugEnabled) {
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, stringBuilder.toString());
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, "onServicesDiscovered " + getGattStatusMessage(status));
|
||||
}
|
||||
|
||||
|
@ -270,6 +274,7 @@ public class RileyLinkBLE {
|
|||
@Inject
|
||||
public void onInit() {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "BT Adapter: " + this.bluetoothAdapter);
|
||||
this.orangeLink.rileyLinkBLE = this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,7 +304,7 @@ public class RileyLinkBLE {
|
|||
}
|
||||
|
||||
|
||||
public void debugService(BluetoothGattService service, int indentCount) {
|
||||
public void debugService(BluetoothGattService service, int indentCount, StringBuilder stringBuilder) {
|
||||
|
||||
String indentString = StringUtils.repeat(' ', indentCount);
|
||||
|
||||
|
@ -308,7 +313,7 @@ public class RileyLinkBLE {
|
|||
if (gattDebugEnabled) {
|
||||
final String uuidServiceString = uuidService.toString();
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
//StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.append(indentString);
|
||||
stringBuilder.append(GattAttributes.lookup(uuidServiceString, "Unknown service"));
|
||||
|
@ -325,12 +330,12 @@ public class RileyLinkBLE {
|
|||
|
||||
stringBuilder.append("\n\n");
|
||||
|
||||
aapsLogger.warn(LTag.PUMPBTCOMM, stringBuilder.toString());
|
||||
//aapsLogger.warn(LTag.PUMPBTCOMM, stringBuilder.toString());
|
||||
|
||||
List<BluetoothGattService> includedServices = service.getIncludedServices();
|
||||
|
||||
for (BluetoothGattService serviceI : includedServices) {
|
||||
debugService(serviceI, indentCount + 4);
|
||||
debugService(serviceI, indentCount + 4, stringBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,20 +382,22 @@ public class RileyLinkBLE {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void findRileyLink(String RileyLinkAddress) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RileyLink address: " + RileyLinkAddress);
|
||||
|
||||
public void findRileyLink(String rileyLinkAddress) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RileyLink address: " + rileyLinkAddress);
|
||||
// Must verify that this is a valid MAC, or crash.
|
||||
//macAddress = RileyLinkAddress;
|
||||
boolean useScanning = sp.getBoolean(RileyLinkConst.Prefs.OrangeUseScanning, false);
|
||||
if (useScanning) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Start scan for OrangeLink device.");
|
||||
orangeLink.startScan();
|
||||
} else {
|
||||
rileyLinkDevice = bluetoothAdapter.getRemoteDevice(RileyLinkAddress);
|
||||
rileyLinkDevice = bluetoothAdapter.getRemoteDevice(rileyLinkAddress);
|
||||
// if this succeeds, we get a connection state change callback?
|
||||
if (rileyLinkDevice != null) {
|
||||
connectGattInternal();
|
||||
} else {
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "RileyLink device not found with address: " + RileyLinkAddress);
|
||||
aapsLogger.error(LTag.PUMPBTCOMM, "RileyLink device not found with address: " + rileyLinkAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -398,6 +405,7 @@ public class RileyLinkBLE {
|
|||
public void connectGatt() {
|
||||
boolean useScanning = sp.getBoolean(RileyLinkConst.Prefs.OrangeUseScanning, false);
|
||||
if (useScanning) {
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Start scan for OrangeLink device.");
|
||||
orangeLink.startScan();
|
||||
} else {
|
||||
connectGattInternal();
|
||||
|
|
|
@ -30,7 +30,7 @@ public class GattAttributes {
|
|||
public static String CHARA_RADIO_VERSION = "30d99dc9-7c91-4295-a051-0a104d238cf2";
|
||||
public static String CHARA_RADIO_LED_MODE = "c6d84241-f1a7-4f9c-a25f-fce16732f14e";
|
||||
|
||||
//Orange Radio Service
|
||||
// Orange Radio Service
|
||||
public static String SERVICE_RADIO_ORANGE = "6e400001-b5a3-f393-e0a9-e50e24dcca9e";
|
||||
public static String CHARA_NOTIFICATION_ORANGE = "6e400003-b5a3-f393-e0a9-e50e24dcca9e";
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.device
|
|||
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.bluetooth.BluetoothAdapter.LeScanCallback
|
||||
import android.bluetooth.BluetoothGatt
|
||||
import android.bluetooth.BluetoothGattCharacteristic
|
||||
import android.bluetooth.le.BluetoothLeScanner
|
||||
import android.bluetooth.le.ScanCallback
|
||||
|
@ -34,7 +33,7 @@ class OrangeLinkImpl @Inject constructor(
|
|||
|
||||
lateinit var rileyLinkBLE: RileyLinkBLE
|
||||
|
||||
fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) {
|
||||
fun onCharacteristicChanged(characteristic: BluetoothGattCharacteristic) {
|
||||
if (characteristic.uuid.toString().equals(GattAttributes.CHARA_NOTIFICATION_ORANGE)) {
|
||||
val data = characteristic.value
|
||||
val first = 0xff and data[0].toInt()
|
||||
|
@ -50,6 +49,15 @@ class OrangeLinkImpl @Inject constructor(
|
|||
}
|
||||
|
||||
|
||||
fun resetOrangeLinkData() {
|
||||
rileyLinkServiceData.isOrange = false
|
||||
rileyLinkServiceData.versionOrangeFirmware = null
|
||||
rileyLinkServiceData.versionOrangeHardware = null
|
||||
}
|
||||
|
||||
/**
|
||||
* We are checking if this is special Orange (with ORANGE_NOTIFICTION_SERVICE)
|
||||
*/
|
||||
fun checkIsOrange(uuidService: UUID) {
|
||||
if (GattAttributes.isOrange(uuidService)) {
|
||||
rileyLinkServiceData.isOrange = true
|
||||
|
@ -94,7 +102,7 @@ class OrangeLinkImpl @Inject constructor(
|
|||
val bluetoothAdapter = rileyLinkBLE.getBluetoothAdapter()
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "startScan")
|
||||
handler.sendEmptyMessageDelayed(TIME_OUT_WHAT, TIME_OUT.toLong())
|
||||
val bluetoothLeScanner: BluetoothLeScanner = bluetoothAdapter.getBluetoothLeScanner()
|
||||
val bluetoothLeScanner: BluetoothLeScanner = bluetoothAdapter.bluetoothLeScanner
|
||||
// if (bluetoothLeScanner == null) {
|
||||
// bluetoothAdapter.startLeScan(mLeScanCallback)
|
||||
// return
|
||||
|
|
|
@ -91,30 +91,29 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
|||
|
||||
this.connectionStatus.setText(resourceHelper.gs(rileyLinkServiceData.rileyLinkServiceState.getResourceId()));
|
||||
|
||||
// BS FIXME rileyLinkServiceData is injected so I suppose it cannot be null?
|
||||
if (rileyLinkServiceData != null) {
|
||||
this.configuredRileyLinkAddress.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkAddress).orElse(PLACEHOLDER));
|
||||
this.configuredRileyLinkName.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkName).orElse(PLACEHOLDER));
|
||||
this.configuredRileyLinkAddress.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkAddress).orElse(PLACEHOLDER));
|
||||
this.configuredRileyLinkName.setText(Optional.ofNullable(rileyLinkServiceData.rileyLinkName).orElse(PLACEHOLDER));
|
||||
|
||||
if (sp.getBoolean(resourceHelper.gs(R.string.key_riley_link_show_battery_level), false)) {
|
||||
batteryLevelRow.setVisibility(View.VISIBLE);
|
||||
Integer batteryLevel = rileyLinkServiceData.batteryLevel;
|
||||
this.batteryLevel.setText(batteryLevel == null ? PLACEHOLDER : resourceHelper.gs(R.string.rileylink_battery_level_value, batteryLevel));
|
||||
} else {
|
||||
batteryLevelRow.setVisibility(View.GONE);
|
||||
}
|
||||
if (sp.getBoolean(resourceHelper.gs(R.string.key_riley_link_show_battery_level), false)) {
|
||||
batteryLevelRow.setVisibility(View.VISIBLE);
|
||||
Integer batteryLevel = rileyLinkServiceData.batteryLevel;
|
||||
this.batteryLevel.setText(batteryLevel == null ? PLACEHOLDER : resourceHelper.gs(R.string.rileylink_battery_level_value, batteryLevel));
|
||||
} else {
|
||||
batteryLevelRow.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
RileyLinkError rileyLinkError = rileyLinkServiceData.rileyLinkError;
|
||||
this.connectionError.setText(rileyLinkError == null ? PLACEHOLDER : resourceHelper.gs(rileyLinkError.getResourceId(targetDevice)));
|
||||
RileyLinkError rileyLinkError = rileyLinkServiceData.rileyLinkError;
|
||||
this.connectionError.setText(rileyLinkError == null ? PLACEHOLDER : resourceHelper.gs(rileyLinkError.getResourceId(targetDevice)));
|
||||
|
||||
|
||||
if(rileyLinkServiceData.isOrange){
|
||||
this.firmwareVersion.setText("FV:"+Optional.ofNullable(rileyLinkServiceData.versionOrangeFirmware).orElse(PLACEHOLDER)+"\nHV:"+Optional.ofNullable(rileyLinkServiceData.versionOrangeHardware).orElse(PLACEHOLDER));
|
||||
}else{
|
||||
this.firmwareVersion.setText(resourceHelper.gs(R.string.rileylink_firmware_version_value,
|
||||
Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER), Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER)));
|
||||
|
||||
}
|
||||
if (rileyLinkServiceData.isOrange) {
|
||||
this.firmwareVersion.setText(resourceHelper.gs(R.string.rileylink_firmware_version_value_orange,
|
||||
Optional.ofNullable(rileyLinkServiceData.versionOrangeFirmware).orElse(PLACEHOLDER),
|
||||
Optional.ofNullable(rileyLinkServiceData.versionOrangeHardware).orElse(PLACEHOLDER)));
|
||||
} else {
|
||||
this.firmwareVersion.setText(resourceHelper.gs(R.string.rileylink_firmware_version_value,
|
||||
Optional.ofNullable(rileyLinkServiceData.versionBLE113).orElse(PLACEHOLDER),
|
||||
Optional.ofNullable(rileyLinkServiceData.versionCC110).orElse(PLACEHOLDER)));
|
||||
}
|
||||
|
||||
RileyLinkPumpDevice rileyLinkPumpDevice = (RileyLinkPumpDevice) activePlugin.getActivePump();
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<string name="rileylink_last_device_contact">Last Device Contact:</string>
|
||||
<string name="rileylink_firmware_version">Firmware Version:</string>
|
||||
<string name="rileylink_firmware_version_value">BLE113: %1$s\nCC110: %2$s</string>
|
||||
<string name="rileylink_firmware_version_value_orange">FW: %1$s\nHW: %2$s</string>
|
||||
<string name="rileylink_pump_serial_number">Pump Serial Number:</string>
|
||||
<string name="rileylink_pump_frequency">Pump Frequency:</string>
|
||||
<string name="rileylink_pump_frequency_value">%1$.2f MHz</string>
|
||||
|
|
Loading…
Reference in a new issue