本文整理汇总了Java中no.nordicsemi.android.log.Logger.v方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.v方法的具体用法?Java Logger.v怎么用?Java Logger.v使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.nordicsemi.android.log.Logger
的用法示例。
在下文中一共展示了Logger.v方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readCharacteristic
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Sends the read request to the given characteristic.
*
* @param characteristic the characteristic to read
* @return true if request has been sent
*/
protected final boolean readCharacteristic(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null)
return false;
// Check characteristic property
final int properties = characteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) == 0)
return false;
Logger.v(mLogSession, "Reading characteristic " + characteristic.getUuid());
Logger.d(mLogSession, "gatt.readCharacteristic(" + characteristic.getUuid() + ")");
return gatt.readCharacteristic(characteristic);
}
示例2: connect
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Connects to the Bluetooth Smart device
*
* @param device a device to connect to
*/
public void connect(final BluetoothDevice device) {
if (mConnected)
return;
if (mBluetoothGatt != null) {
Logger.d(mLogSession, "gatt.close()");
mBluetoothGatt.close();
mBluetoothGatt = null;
}
final boolean autoConnect = shouldAutoConnect();
mUserDisconnected = !autoConnect; // We will receive Linkloss events only when the device is connected with autoConnect=true
Logger.v(mLogSession, "Connecting...");
Logger.d(mLogSession, "gatt = device.connectGatt(autoConnect = " + autoConnect + ")");
mBluetoothGatt = device.connectGatt(mContext, autoConnect, getGattCallback());
}
示例3: enableNotifications
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Enables notifications on given characteristic
*
* @return true is the request has been sent, false if one of the arguments was <code>null</code> or the characteristic does not have the CCCD.
*/
protected final boolean enableNotifications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null)
return false;
// Check characteristic property
final int properties = characteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0)
return false;
Logger.d(mLogSession, "gatt.setCharacteristicNotification(" + characteristic.getUuid() + ", true)");
gatt.setCharacteristicNotification(characteristic, true);
final BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID);
if (descriptor != null) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
Logger.v(mLogSession, "Enabling notifications for " + characteristic.getUuid());
Logger.d(mLogSession, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x01-00)");
return gatt.writeDescriptor(descriptor);
}
return false;
}
示例4: enableIndications
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Enables indications on given characteristic
*
* @return true is the request has been sent, false if one of the arguments was <code>null</code> or the characteristic does not have the CCCD.
*/
protected final boolean enableIndications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null)
return false;
// Check characteristic property
final int properties = characteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == 0)
return false;
Logger.d(mLogSession, "gatt.setCharacteristicNotification(" + characteristic.getUuid() + ", true)");
gatt.setCharacteristicNotification(characteristic, true);
final BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID);
if (descriptor != null) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
Logger.v(mLogSession, "Enabling indications for " + characteristic.getUuid());
Logger.d(mLogSession, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x02-00)");
return gatt.writeDescriptor(descriptor);
}
return false;
}
示例5: onServiceAdded
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onServiceAdded(final int status, final BluetoothGattService service) {
Logger.v(mLogSession, "[Server] Service " + service.getUuid() + " added");
mHandler.post(new Runnable() {
@Override
public void run() {
// Adding another service from callback thread fails on Samsung S4 with Android 4.3
if (IMMEDIATE_ALERT_SERVICE_UUID.equals(service.getUuid()))
addLinklossService();
else {
Logger.i(mLogSession, "[Server] Gatt server started");
ProximityManager.super.connect(mDeviceToConnect);
mDeviceToConnect = null;
}
}
});
}
示例6: onCharacteristicReadRequest
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onCharacteristicReadRequest(final BluetoothDevice device, final int requestId, final int offset, final BluetoothGattCharacteristic characteristic) {
Logger.d(mLogSession, "[Server callback] Read request for characteristic " + characteristic.getUuid() + " (requestId=" + requestId + ", offset=" + offset + ")");
Logger.i(mLogSession, "[Server] READ request for characteristic " + characteristic.getUuid() + " received");
byte[] value = characteristic.getValue();
if (value != null && offset > 0) {
byte[] offsetValue = new byte[value.length - offset];
System.arraycopy(value, offset, offsetValue, 0, offsetValue.length);
value = offsetValue;
}
if (value != null)
Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, value=" + ParserUtils.parse(value) + ")");
else
Logger.d(mLogSession, "server.sendResponse(GATT_SUCCESS, value=null)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
Logger.v(mLogSession, "[Server] Response sent");
}
示例7: connect
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void connect(final BluetoothDevice device) {
// Should we use the GATT Server?
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
final boolean useGattServer = preferences.getBoolean(ProximityActivity.PREFS_GATT_SERVER_ENABLED, true);
if (useGattServer) {
// Save the device that we want to connect to. First we will create a GATT Server
mDeviceToConnect = device;
final BluetoothManager bluetoothManager = (BluetoothManager) getContext().getSystemService(Context.BLUETOOTH_SERVICE);
try {
DebugLogger.d(TAG, "[Server] Starting Gatt server...");
Logger.v(mLogSession, "[Server] Starting Gatt server...");
openGattServer(getContext(), bluetoothManager);
addImmediateAlertService();
// the BluetoothGattServerCallback#onServiceAdded callback will proceed further operations
} catch (final Exception e) {
// On Nexus 4&7 with Android 4.4 (build KRT16S) sometimes creating Gatt Server fails. There is a Null Pointer Exception thrown from addCharacteristic method.
Logger.e(mLogSession, "[Server] Gatt server failed to start");
Log.e(TAG, "Creating Gatt Server failed", e);
}
} else {
super.connect(device);
}
}
示例8: onServiceAdded
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onServiceAdded(final int status, final BluetoothGattService service) {
Logger.v(mLogSession, "[Server] Service " + service.getUuid() + " added");
mHandler.post(new Runnable() {
@Override
public void run() {
// Adding another service from callback thread fails on Samsung S4 with Android 4.3
if (IMMEDIATE_ALERT_SERVICE_UUID.equals(service.getUuid()))
addLinklossService();
else {
Logger.i(mLogSession, "[Proximity Server] Gatt server started");
ProximityManager.super.connect(mDeviceToConnect);
mDeviceToConnect = null;
}
}
});
}
示例9: enableNotifications
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Enables notifications on given characteristic
*
* @return true is the request has been sent, false if one of the arguments was <code>null</code> or the characteristic does not have the CCCD.
*/
protected final boolean enableNotifications(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null)
return false;
// Check characteristic property
final int properties = characteristic.getProperties();
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == 0)
return false;
gatt.setCharacteristicNotification(characteristic, true);
final BluetoothGattDescriptor descriptor = characteristic.getDescriptor(CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID);
if (descriptor != null) {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
Logger.v(mLogSession, "Enabling notifications for " + characteristic.getUuid());
Logger.d(mLogSession, "gatt.writeDescriptor(" + CLIENT_CHARACTERISTIC_CONFIG_DESCRIPTOR_UUID + ", value=0x01-00)");
return gatt.writeDescriptor(descriptor);
}
return false;
}
示例10: disconnect
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Disconnects from the device. Does nothing if not connected.
* @return true if device is to be disconnected. False if it was already disconnected.
*/
public boolean disconnect() {
mUserDisconnected = true;
if (mConnected && mBluetoothGatt != null) {
Logger.v(mLogSession, "Disconnecting...");
mCallbacks.onDeviceDisconnecting();
Logger.d(mLogSession, "gatt.disconnect()");
mBluetoothGatt.disconnect();
return true;
}
return false;
}
示例11: writeCharacteristic
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Writes the characteristic value to the given characteristic.
*
* @param characteristic the characteristic to write to
* @return true if request has been sent
*/
protected final boolean writeCharacteristic(final BluetoothGattCharacteristic characteristic) {
final BluetoothGatt gatt = mBluetoothGatt;
if (gatt == null || characteristic == null)
return false;
// Check characteristic property
final int properties = characteristic.getProperties();
if ((properties & (BluetoothGattCharacteristic.PROPERTY_WRITE | BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE)) == 0)
return false;
Logger.v(mLogSession, "Writing characteristic " + characteristic.getUuid() + " (" + getWriteType(characteristic.getWriteType()) + ")");
Logger.d(mLogSession, "gatt.writeCharacteristic(" + characteristic.getUuid() + ")");
return gatt.writeCharacteristic(characteristic);
}
示例12: 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;
}
示例13: onServicesDiscovered
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onServicesDiscovered(final BluetoothGatt gatt, final int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
Logger.i(mLogSession, "Services Discovered");
if (isRequiredServiceSupported(gatt)) {
Logger.v(mLogSession, "Primary service found");
final boolean optionalServicesFound = isOptionalServiceSupported(gatt);
if (optionalServicesFound)
Logger.v(mLogSession, "Secondary service found");
// Notify the parent activity
mCallbacks.onServicesDiscovered(optionalServicesFound);
// Obtain the queue of initialization requests
mInitInProgress = true;
mInitQueue = initGatt(gatt);
// When the device is bonded and has Service Changed characteristic, the indications must be enabled first.
// In case this method returns true we have to continue in the onDescriptorWrite callback
if (ensureServiceChangedEnabled(gatt))
return;
// We have discovered services, let's start by reading the battery level value. If the characteristic is not readable, try to enable notifications.
// If there is no Battery service, proceed with the initialization queue.
if (!readBatteryLevel())
nextRequest();
} else {
Logger.w(mLogSession, "Device is not supported");
mCallbacks.onDeviceNotSupported();
disconnect();
}
} else {
DebugLogger.e(TAG, "onServicesDiscovered error " + status);
onError(ERROR_DISCOVERY_SERVICE, status);
}
}
示例14: onConnectClicked
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Called when user press CONNECT or DISCONNECT button. See layout files -> onClick attribute.
*/
public void onConnectClicked(final View view) {
if (isBLEEnabled()) {
if (mService == null) {
setDefaultUI();
showDeviceScanningDialog(getFilterUUID());
} else {
Logger.v(mLogSession, "Disconnecting...");
mService.disconnect();
}
} else {
showBLEDialog();
}
}
示例15: 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");
}