mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-22 16:14:23 +01:00
Log level -> priority
This commit is contained in:
@@ -6,6 +6,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -52,7 +53,7 @@ public abstract class BatteryManager<T extends BatteryManagerCallbacks> extends
|
||||
|
||||
@Override
|
||||
public void onInvalidDataReceived(@NonNull final BluetoothDevice device, final @NonNull Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Invalid Battery Level data received: " + data);
|
||||
log(Log.WARN, "Invalid Battery Level data received: " + data);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +61,7 @@ public abstract class BatteryManager<T extends BatteryManagerCallbacks> extends
|
||||
if (isConnected()) {
|
||||
readCharacteristic(mBatteryLevelCharacteristic)
|
||||
.with(mBatteryLevelDataCallback)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING,"Battery Level characteristic not found"))
|
||||
.fail((device, status) -> log(Log.WARN,"Battery Level characteristic not found"))
|
||||
.enqueue();
|
||||
}
|
||||
}
|
||||
@@ -71,8 +72,8 @@ public abstract class BatteryManager<T extends BatteryManagerCallbacks> extends
|
||||
setNotificationCallback(mBatteryLevelCharacteristic)
|
||||
.with(mBatteryLevelDataCallback);
|
||||
enableNotifications(mBatteryLevelCharacteristic)
|
||||
.done(device -> log(LogContract.Log.Level.INFO, "Battery Level notifications enabled"))
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Battery Level characteristic not found"))
|
||||
.done(device -> log(Log.INFO, "Battery Level notifications enabled"))
|
||||
.fail((device, status) -> log(Log.WARN, "Battery Level characteristic not found"))
|
||||
.enqueue();
|
||||
}
|
||||
}
|
||||
@@ -83,7 +84,7 @@ public abstract class BatteryManager<T extends BatteryManagerCallbacks> extends
|
||||
public void disableBatteryLevelCharacteristicNotifications() {
|
||||
if (isConnected()) {
|
||||
disableNotifications(mBatteryLevelCharacteristic)
|
||||
.done(device -> log(LogContract.Log.Level.INFO, "Battery Level notifications disabled"))
|
||||
.done(device -> log(Log.INFO, "Battery Level notifications disabled"))
|
||||
.enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
@@ -103,7 +104,7 @@ public class BPMManager extends BatteryManager<BPMManagerCallbacks> {
|
||||
|
||||
@Override
|
||||
public void onInvalidDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Invalid ICP data received: " + data);
|
||||
log(Log.WARN, "Invalid ICP data received: " + data);
|
||||
}
|
||||
});
|
||||
setIndicationCallback(mBPMCharacteristic)
|
||||
@@ -128,12 +129,12 @@ public class BPMManager extends BatteryManager<BPMManagerCallbacks> {
|
||||
|
||||
@Override
|
||||
public void onInvalidDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Invalid BPM data received: " + data);
|
||||
log(Log.WARN, "Invalid BPM data received: " + data);
|
||||
}
|
||||
});
|
||||
|
||||
enableNotifications(mICPCharacteristic)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING,
|
||||
.fail((device, status) -> log(Log.WARN,
|
||||
"Intermediate Cuff Pressure characteristic not found"))
|
||||
.enqueue();
|
||||
enableIndications(mBPMCharacteristic).enqueue();
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -110,7 +111,7 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
log(LogContract.Log.Level.APPLICATION, "E2E CRC feature " + (mSecured ? "supported" : "not supported"));
|
||||
}
|
||||
})
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Could not read CGM Feature characteristic"))
|
||||
.fail((device, status) -> log(Log.WARN, "Could not read CGM Feature characteristic"))
|
||||
.enqueue();
|
||||
|
||||
// Check if the session is already started. This is not supported in the experimental CGMS from the SDK.
|
||||
@@ -124,7 +125,7 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Could not read CGM Status characteristic"))
|
||||
.fail((device, status) -> log(Log.WARN, "Could not read CGM Status characteristic"))
|
||||
.enqueue();
|
||||
|
||||
// Set notification and indication callbacks
|
||||
@@ -161,7 +162,7 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
@Override
|
||||
public void onContinuousGlucoseMeasurementReceivedWithCrcError(@NonNull final BluetoothDevice device,
|
||||
@NonNull final Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Continuous Glucose Measurement record received with CRC error");
|
||||
log(Log.WARN, "Continuous Glucose Measurement record received with CRC error");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -209,7 +210,7 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
@Override
|
||||
public void onCGMSpecificOpsResponseReceivedWithCrcError(@NonNull final BluetoothDevice device,
|
||||
@NonNull final Data data) {
|
||||
log(LogContract.Log.Level.ERROR, "Request failed: CRC error");
|
||||
log(Log.ERROR, "Request failed: CRC error");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -264,7 +265,7 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
@Override
|
||||
public void onRecordAccessOperationError(@NonNull final BluetoothDevice device,
|
||||
final int requestCode, final int errorCode) {
|
||||
log(LogContract.Log.Level.WARNING, "Record Access operation failed (error " + errorCode + ")");
|
||||
log(Log.WARN, "Record Access operation failed (error " + errorCode + ")");
|
||||
if (errorCode == RACP_ERROR_OP_CODE_NOT_SUPPORTED) {
|
||||
mCallbacks.onOperationNotSupported(device);
|
||||
} else {
|
||||
@@ -275,13 +276,13 @@ public class CGMSManager extends BatteryManager<CGMSManagerCallbacks> {
|
||||
|
||||
// Enable notifications and indications
|
||||
enableNotifications(mCGMMeasurementCharacteristic)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to enable Continuous Glucose Measurement notifications (" + status + ")"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to enable Continuous Glucose Measurement notifications (" + status + ")"))
|
||||
.enqueue();
|
||||
enableIndications(mCGMSpecificOpsControlPointCharacteristic)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to enable CGM Specific Ops Control Point indications notifications (" + status + ")"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to enable CGM Specific Ops Control Point indications notifications (" + status + ")"))
|
||||
.enqueue();
|
||||
enableIndications(mRecordAccessControlPointCharacteristic)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to enabled Record Access Control Point indications (error " + status + ")"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to enabled Record Access Control Point indications (error " + status + ")"))
|
||||
.enqueue();
|
||||
|
||||
// Start Continuous Glucose session if hasn't been started before
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -102,7 +103,7 @@ public class CSCManager extends BatteryManager<CSCManagerCallbacks> {
|
||||
@Override
|
||||
public void onInvalidDataReceived(@NonNull final BluetoothDevice device,
|
||||
final @NonNull Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Invalid CSC Measurement data received: " + data);
|
||||
log(Log.WARN, "Invalid CSC Measurement data received: " + data);
|
||||
}
|
||||
});
|
||||
enableNotifications(mCSCMeasurementCharacteristic).enqueue();
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -241,7 +242,7 @@ public class GlucoseManager extends BatteryManager<GlucoseManagerCallbacks> {
|
||||
@Override
|
||||
public void onRecordAccessOperationError(@NonNull final BluetoothDevice device,
|
||||
final int requestCode, final int errorCode) {
|
||||
log(LogContract.Log.Level.WARNING, "Record Access operation failed (error " + errorCode + ")");
|
||||
log(Log.WARN, "Record Access operation failed (error " + errorCode + ")");
|
||||
if (errorCode == RACP_ERROR_OP_CODE_NOT_SUPPORTED) {
|
||||
mCallbacks.onOperationNotSupported(device);
|
||||
} else {
|
||||
@@ -253,7 +254,7 @@ public class GlucoseManager extends BatteryManager<GlucoseManagerCallbacks> {
|
||||
enableNotifications(mGlucoseMeasurementCharacteristic).enqueue();
|
||||
enableNotifications(mGlucoseMeasurementContextCharacteristic).enqueue();
|
||||
enableIndications(mRecordAccessControlPointCharacteristic)
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to enabled Record Access Control Point indications (error " + status + ")"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to enabled Record Access Control Point indications (error " + status + ")"))
|
||||
.enqueue();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -98,7 +99,7 @@ public class HRSManager extends BatteryManager<HRSManagerCallbacks> {
|
||||
mCallbacks.onBodySensorLocationReceived(device, sensorLocation);
|
||||
}
|
||||
})
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Body Sensor Location characteristic not found"))
|
||||
.fail((device, status) -> log(Log.WARN, "Body Sensor Location characteristic not found"))
|
||||
.enqueue();
|
||||
setNotificationCallback(mHeartRateCharacteristic)
|
||||
.with(new HeartRateMeasurementDataCallback() {
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.os.IBinder;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import no.nordicsemi.android.ble.BleManager;
|
||||
@@ -95,7 +96,7 @@ public abstract class BleProfileService extends Service implements BleManagerCal
|
||||
final ILogger logger = getBinder();
|
||||
|
||||
final String stateString = "[Broadcast] Action received: " + BluetoothAdapter.ACTION_STATE_CHANGED + ", state changed to " + state2String(state);
|
||||
logger.log(LogContract.Log.Level.DEBUG, stateString);
|
||||
logger.log(Log.DEBUG, stateString);
|
||||
|
||||
switch (state) {
|
||||
case BluetoothAdapter.STATE_ON:
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.os.IBinder;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -395,7 +396,7 @@ public abstract class BleMulticonnectProfileService extends Service implements B
|
||||
for (final BleManager<BleManagerCallbacks> manager : mBleManagers.values()) {
|
||||
// Service is being destroyed, no need to disconnect manually.
|
||||
manager.close();
|
||||
manager.log(LogContract.Log.Level.INFO, "Service destroyed");
|
||||
manager.log(Log.INFO, "Service destroyed");
|
||||
}
|
||||
mBleManagers.clear();
|
||||
mManagedDevices.clear();
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.os.IBinder;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
@@ -164,7 +165,7 @@ public abstract class BleMulticonnectProfileServiceReadyActivity<E extends BleMu
|
||||
@Override
|
||||
public void onServiceConnected(final ComponentName name, final IBinder service) {
|
||||
final E bleService = mService = (E) service;
|
||||
bleService.log(LogContract.Log.Level.DEBUG, "Activity bound to the service");
|
||||
bleService.log(Log.DEBUG, "Activity bound to the service");
|
||||
mManagedDevices.addAll(bleService.getManagedDevices());
|
||||
onServiceBound(bleService);
|
||||
|
||||
@@ -232,7 +233,7 @@ public abstract class BleMulticonnectProfileServiceReadyActivity<E extends BleMu
|
||||
mService.setActivityIsChangingConfiguration(isChangingConfigurations());
|
||||
// Log it here as there is no callback when the service gets unbound
|
||||
// and the mService will not be available later (the activity doesn't keep log sessions)
|
||||
mService.log(LogContract.Log.Level.DEBUG, "Activity unbound from the service");
|
||||
mService.log(Log.DEBUG, "Activity unbound from the service");
|
||||
}
|
||||
|
||||
unbindService(mServiceConnection);
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -73,8 +74,8 @@ class ProximityManager extends BatteryManager<ProximityManagerCallbacks> {
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
writeCharacteristic(mLinkLossCharacteristic, AlertLevelData.highAlert())
|
||||
.done(device -> log(LogContract.Log.Level.INFO, "Link loss alert level set"))
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to set link loss level: " + status))
|
||||
.done(device -> log(Log.INFO, "Link loss alert level set"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to set link loss level: " + status))
|
||||
.enqueue();
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ class ProximityManager extends BatteryManager<ProximityManagerCallbacks> {
|
||||
return;
|
||||
|
||||
writeCharacteristic(mAlertLevelCharacteristic, on ? AlertLevelData.highAlert() : AlertLevelData.noAlert())
|
||||
.before(device -> log(LogContract.Log.Level.VERBOSE,
|
||||
.before(device -> log(Log.VERBOSE,
|
||||
on ? "Setting alarm to HIGH..." : "Disabling alarm..."))
|
||||
.with((device, data) -> log(LogContract.Log.Level.APPLICATION,
|
||||
"\"" + AlertLevelParser.parse(data) + "\" sent"))
|
||||
@@ -132,7 +133,7 @@ class ProximityManager extends BatteryManager<ProximityManagerCallbacks> {
|
||||
mAlertOn = on;
|
||||
mCallbacks.onRemoteAlarmSwitched(device, on);
|
||||
})
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING,
|
||||
.fail((device, status) -> log(Log.WARN,
|
||||
status == FailCallback.REASON_NULL_ATTRIBUTE ?
|
||||
"Alert Level characteristic not found" :
|
||||
GattError.parse(status)))
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -106,7 +107,7 @@ public class TemplateManager extends BatteryManager<TemplateManagerCallbacks> {
|
||||
// In case of MTU this method is called also when the MTU hasn't changed, or has changed
|
||||
// to a different (lower) value. Use .with(...) to get the MTU value.
|
||||
})
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "MTU change not supported"))
|
||||
.fail((device, status) -> log(Log.WARN, "MTU change not supported"))
|
||||
.enqueue();
|
||||
|
||||
// Set notification callback
|
||||
@@ -127,18 +128,18 @@ public class TemplateManager extends BatteryManager<TemplateManagerCallbacks> {
|
||||
|
||||
@Override
|
||||
public void onInvalidDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) {
|
||||
log(LogContract.Log.Level.WARNING, "Invalid data received: " + data);
|
||||
log(Log.WARN, "Invalid data received: " + data);
|
||||
}
|
||||
});
|
||||
|
||||
// Enable notifications
|
||||
enableNotifications(mRequiredCharacteristic)
|
||||
// Method called after the data were sent (data will contain 0x0100 in this case)
|
||||
.with((device, data) -> log(LogContract.Log.Level.DEBUG, "Data sent: " + data))
|
||||
.with((device, data) -> log(Log.DEBUG, "Data sent: " + data))
|
||||
// Method called when the request finished successfully. This will be called after .with(..) callback
|
||||
.done(device -> log(LogContract.Log.Level.APPLICATION, "Notifications enabled successfully"))
|
||||
// Methods called in case of an error, for example when the characteristic does not have Notify property
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to enable notifications"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to enable notifications"))
|
||||
.enqueue();
|
||||
}
|
||||
|
||||
@@ -199,7 +200,7 @@ public class TemplateManager extends BatteryManager<TemplateManagerCallbacks> {
|
||||
final Integer value = data.getIntValue(Data.FORMAT_UINT8, 0);
|
||||
log(LogContract.Log.Level.APPLICATION, "Value '" + value + "' has been read!");
|
||||
} else {
|
||||
log(LogContract.Log.Level.WARNING, "Value is empty!");
|
||||
log(Log.WARN, "Value is empty!");
|
||||
}
|
||||
})
|
||||
.enqueue();
|
||||
@@ -214,7 +215,7 @@ public class TemplateManager extends BatteryManager<TemplateManagerCallbacks> {
|
||||
* @param parameter parameter to be written.
|
||||
*/
|
||||
void performAction(final String parameter) {
|
||||
log(LogContract.Log.Level.VERBOSE, "Changing device name to \"" + parameter + "\"");
|
||||
log(Log.VERBOSE, "Changing device name to \"" + parameter + "\"");
|
||||
// Write some data to the characteristic.
|
||||
writeCharacteristic(mDeviceNameCharacteristic, Data.from(parameter))
|
||||
// If data are longer than MTU-3, they will be chunked into multiple packets.
|
||||
@@ -222,12 +223,12 @@ public class TemplateManager extends BatteryManager<TemplateManagerCallbacks> {
|
||||
.split()
|
||||
// Callback called when data were sent, or added to outgoing queue in case
|
||||
// Write Without Request type was used.
|
||||
.with((device, data) -> log(LogContract.Log.Level.DEBUG, data.size() + " bytes were sent"))
|
||||
.with((device, data) -> log(Log.DEBUG, data.size() + " bytes were sent"))
|
||||
// Callback called when data were sent, or added to outgoing queue in case
|
||||
// Write Without Request type was used. This is called after .with(...) callback.
|
||||
.done(device -> log(LogContract.Log.Level.APPLICATION, "Device name set to \"" + parameter + "\""))
|
||||
// Callback called when write has failed.
|
||||
.fail((device, status) -> log(LogContract.Log.Level.WARNING, "Failed to change device name"))
|
||||
.fail((device, status) -> log(Log.WARN, "Failed to change device name"))
|
||||
.enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user