本文整理汇总了Java中no.nordicsemi.android.log.Logger.a方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.a方法的具体用法?Java Logger.a怎么用?Java Logger.a使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.nordicsemi.android.log.Logger
的用法示例。
在下文中一共展示了Logger.a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readBatteryLevel
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Reads the battery level from the device.
*
* @return true if request has been sent
*/
public final boolean readBatteryLevel() {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null)
return false;
final BluetoothGattService batteryService = gatt.getService(BATTERY_SERVICE);
if (batteryService == null)
return false;
final BluetoothGattCharacteristic batteryLevelCharacteristic = batteryService.getCharacteristic(BATTERY_LEVEL_CHARACTERISTIC);
if (batteryLevelCharacteristic == null)
return false;
// Check characteristic property
final int properties = batteryLevelCharacteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) == 0) {
return setBatteryNotifications(true);
}
Logger.a(mLogSession, "Reading battery level...");
return readCharacteristic(batteryLevelCharacteristic);
}
示例2: onCharacteristicChanged
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onCharacteristicChanged(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
final String data = ParserUtils.parse(characteristic);
if (isBatteryLevelCharacteristic(characteristic)) {
Logger.i(mLogSession, "Notification received from " + characteristic.getUuid() + ", value: " + data);
final int batteryValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);
Logger.a(mLogSession, "Battery level received: " + batteryValue + "%");
mCallbacks.onBatteryValueReceived(batteryValue);
} else {
final BluetoothGattDescriptor cccd = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID);
final boolean notifications = cccd == null || cccd.getValue() == null || cccd.getValue().length != 2 || cccd.getValue()[0] == 0x01;
if (notifications) {
Logger.i(mLogSession, "Notification received from " + characteristic.getUuid() + ", value: " + data);
onCharacteristicNotified(gatt, characteristic);
} else { // indications
Logger.i(mLogSession, "Indication received from " + characteristic.getUuid() + ", value: " + data);
onCharacteristicIndicated(gatt, characteristic);
}
}
}
示例3: onCharacteristicNotified
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicNotified(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
Logger.a(mLogSession, "\"" + CGMMeasurementParser.parse(characteristic) + "\" received");
// CGM Measurement characteristic may have one or more CGM records
int totalSize = characteristic.getValue().length;
int offset = 0;
while (offset < totalSize) {
final int cgmSize = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset);
final float cgmValue = characteristic.getFloatValue(BluetoothGattCharacteristic.FORMAT_SFLOAT, offset + 2);
final int sequenceNumber = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset + 4);
final long timestamp = mSessionStartTime + (sequenceNumber * 60000L); // Sequence number is in minutes since Start Session
//This will send callback to CGMSActivity when new concentration value is received from CGMS device
final CGMSRecord cgmsRecord = new CGMSRecord(sequenceNumber, cgmValue, timestamp);
mRecords.put(cgmsRecord.sequenceNumber, cgmsRecord);
mCallbacks.onCGMValueReceived(gatt.getDevice(), cgmsRecord);
offset += cgmSize;
}
}
示例4: onCharacteristicNotified
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
protected void onCharacteristicNotified(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
// Intermediate Cuff Pressure characteristic read
if (mLogSession != null)
Logger.a(mLogSession, IntermediateCuffPressureParser.parse(characteristic));
parseBPMValue(characteristic);
}
示例5: onCharacteristicIndicated
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
protected void onCharacteristicIndicated(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
// Blood Pressure Measurement characteristic read
if (mLogSession != null)
Logger.a(mLogSession, BloodPressureMeasurementParser.parse(characteristic));
parseBPMValue(characteristic);
}
示例6: onCharacteristicIndicated
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicIndicated(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (mLogSession != null)
Logger.a(mLogSession, TemperatureMeasurementParser.parse(characteristic));
try {
final double tempValue = decodeTemperature(characteristic.getValue());
mCallbacks.onHTValueReceived(tempValue);
} catch (Exception e) {
DebugLogger.e(TAG, "Invalid temperature value", e);
}
}
示例7: onCharacteristicNotified
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicNotified(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (mLogSession != null)
Logger.a(mLogSession, RSCMeasurementParser.parse(characteristic));
// Decode the new data
int offset = 0;
final int flags = characteristic.getValue()[offset]; // 1 byte
offset += 1;
final boolean islmPresent = (flags & INSTANTANEOUS_STRIDE_LENGTH_PRESENT) > 0;
final boolean tdPreset = (flags & TOTAL_DISTANCE_PRESENT) > 0;
final boolean running = (flags & WALKING_OR_RUNNING_STATUS_BITS) > 0;
final float instantaneousSpeed = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset) / 256.0f; // 1/256 m/s in [m/s]
offset += 2;
final int instantaneousCadence = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, offset); // [SPM]
offset += 1;
float instantaneousStrideLength = RSCManagerCallbacks.NOT_AVAILABLE;
if (islmPresent) {
instantaneousStrideLength = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset); // [cm]
offset += 2;
}
float totalDistance = RSCManagerCallbacks.NOT_AVAILABLE;
if (tdPreset) {
totalDistance = (float) characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, offset) / 10.0f; // 1/10 m in [m]
//offset += 4;
}
// Notify listener about the new measurement
mCallbacks.onMeasurementReceived(instantaneousSpeed, instantaneousCadence, totalDistance, instantaneousStrideLength, running ? RSCManagerCallbacks.ACTIVITY_RUNNING
: RSCManagerCallbacks.ACTIVITY_WALKING);
}
示例8: setBatteryNotifications
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* This method tries to enable notifications on the Battery Level characteristic.
*
* @param enable <code>true</code> to enable battery notifications, false to disable
* @return true if request has been sent
*/
public boolean setBatteryNotifications(final boolean enable) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null) {
return false;
}
final BluetoothGattService batteryService = gatt.getService(BATTERY_SERVICE);
if (batteryService == null)
return false;
final BluetoothGattCharacteristic batteryLevelCharacteristic = batteryService.getCharacteristic(BATTERY_LEVEL_CHARACTERISTIC);
if (batteryLevelCharacteristic == null)
return false;
// Check characteristic property
final int properties = batteryLevelCharacteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0)
return false;
gatt.setCharacteristicNotification(batteryLevelCharacteristic, enable);
final BluetoothGattDescriptor descriptor = batteryLevelCharacteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID);
if (descriptor != null) {
if (enable) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
Logger.a(mLogSession, "Enabling battery level notifications...");
Logger.v(mLogSession, "Enabling notifications for " + BATTERY_LEVEL_CHARACTERISTIC);
Logger.d(mLogSession, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x01-00)");
} else {
descriptor.setValue(BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE);
Logger.a(mLogSession, "Disabling battery level notifications...");
Logger.v(mLogSession, "Disabling notifications for " + BATTERY_LEVEL_CHARACTERISTIC);
Logger.d(mLogSession, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x00-00)");
}
return gatt.writeDescriptor(descriptor);
}
return false;
}
示例9: onCharacteristicRead
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Read Response received from " + characteristic.getUuid() + ", value: " + ParserUtils.parse(characteristic));
if (isBatteryLevelCharacteristic(characteristic)) {
final int batteryValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);
Logger.a(mLogSession, "Battery level received: " + batteryValue + "%");
mCallbacks.onBatteryValueReceived(batteryValue);
// The Battery Level value has been read. Let's try to enable Battery Level notifications.
// If the Battery Level characteristic does not have the NOTIFY property, proceed with the initialization queue.
if (!setBatteryNotifications(true))
nextRequest();
} else {
// The value has been read. Notify the manager and proceed with the initialization queue.
onCharacteristicRead(gatt, characteristic);
nextRequest();
}
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
DebugLogger.w(TAG, ERROR_AUTH_ERROR_WHILE_BONDED);
mCallbacks.onError(ERROR_AUTH_ERROR_WHILE_BONDED, status);
}
} else {
DebugLogger.e(TAG, "onCharacteristicRead error " + status);
onError(ERROR_READ_CHARACTERISTIC, status);
}
}
示例10: onDescriptorWrite
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onDescriptorWrite(final BluetoothGatt gatt, final BluetoothGattDescriptor descriptor, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Data written to descr. " + descriptor.getUuid() + ", value: " + ParserUtils.parse(descriptor));
if (isServiceChangedCCCD(descriptor)) {
Logger.a(mLogSession, "Service Changed notifications enabled");
if (!readBatteryLevel())
nextRequest();
} else if (isBatteryLevelCCCD(descriptor)) {
final byte[] value = descriptor.getValue();
if (value != null && value.length > 0 && value[0] == 0x01) {
Logger.a(mLogSession, "Battery Level notifications enabled");
nextRequest();
} else
Logger.a(mLogSession, "Battery Level notifications disabled");
} else {
nextRequest();
}
} else if (status == BluetoothGatt.GATT_INSUFFICIENT_AUTHENTICATION) {
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_NONE) {
DebugLogger.w(TAG, ERROR_AUTH_ERROR_WHILE_BONDED);
mCallbacks.onError(ERROR_AUTH_ERROR_WHILE_BONDED, status);
}
} else {
DebugLogger.e(TAG, "onDescriptorWrite error " + status);
onError(ERROR_WRITE_DESCRIPTOR, status);
}
}
示例11: onCharacteristicRead
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicRead(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (mLogSession != null)
Logger.a(mLogSession, BodySensorLocationParser.parse(characteristic));
final String sensorPosition = getBodySensorPosition(characteristic.getValue()[0]);
//This will send callback to HRSActivity when HR sensor position on body is found in HR device
mCallbacks.onHRSensorPositionFound(sensorPosition);
}
示例12: onCharacteristicNotified
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicNotified(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (mLogSession != null)
Logger.a(mLogSession, HeartRateMeasurementParser.parse(characteristic));
int hrValue;
if (isHeartRateInUINT16(characteristic.getValue()[0])) {
hrValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 1);
} else {
hrValue = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 1);
}
//This will send callback to HRSActivity when new HR value is received from HR device
mCallbacks.onHRValueReceived(hrValue);
}
示例13: onCharacteristicWriteRequest
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattCharacteristic characteristic, final boolean preparedWrite,
final boolean responseNeeded, final int offset, final byte[] value) {
Logger.d(mLogSession, "[Server callback] Write request to characteristic " + characteristic.getUuid()
+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
final String writeType = !responseNeeded ? "WRITE NO RESPONSE" : "WRITE COMMAND";
Logger.i(mLogSession, "[Server] " + writeType + " request for characteristic " + characteristic.getUuid() + " received, value: " + ParserUtils.parse(value));
if (offset == 0) {
characteristic.setValue(value);
} else {
final byte[] currentValue = characteristic.getValue();
final byte[] newValue = new byte[currentValue.length + value.length];
System.arraycopy(currentValue, 0, newValue, 0, currentValue.length);
System.arraycopy(value, 0, newValue, offset, value.length);
characteristic.setValue(newValue);
}
if (!preparedWrite && value != null && value.length == 1) { // small validation
if (value[0] != NO_ALERT[0]) {
Logger.a(mLogSession, "[Server] Immediate alarm request received: " + AlertLevelParser.parse(characteristic));
mCallbacks.onAlarmTriggered();
} else {
Logger.a(mLogSession, "[Server] Immediate alarm request received: OFF");
mCallbacks.onAlarmStopped();
}
}
Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}
示例14: writeImmediateAlertOn
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
public void writeImmediateAlertOn() {
Logger.a(mLogSession, "Immediate alarm request: ON");
if (mAlertLevelCharacteristic != null) {
mAlertLevelCharacteristic.setValue(HIGH_ALERT);
writeCharacteristic(mAlertLevelCharacteristic);
} else {
DebugLogger.w(TAG, "Immediate Alert Level Characteristic is not found");
}
}
示例15: writeImmediateAlertOff
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
public void writeImmediateAlertOff() {
Logger.a(mLogSession, "Immediate alarm request: OFF");
if (mAlertLevelCharacteristic != null) {
mAlertLevelCharacteristic.setValue(NO_ALERT);
writeCharacteristic(mAlertLevelCharacteristic);
} else {
DebugLogger.w(TAG, "Immediate Alert Level Characteristic is not found");
}
}