本文整理汇总了Java中no.nordicsemi.android.log.Logger.w方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.w方法的具体用法?Java Logger.w怎么用?Java Logger.w使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.nordicsemi.android.log.Logger
的用法示例。
在下文中一共展示了Logger.w方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: onDescriptorReadRequest
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onDescriptorReadRequest(final BluetoothDevice device, final int requestId, final int offset, final BluetoothGattDescriptor descriptor) {
Logger.d(mLogSession, "[Server callback] Write request to descriptor " + descriptor.getUuid() + " (requestId=" + requestId + ", offset=" + offset + ")");
Logger.i(mLogSession, "[Server] READ request for descriptor " + descriptor.getUuid() + " received");
// This method is not supported
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}
示例3: onDescriptorWriteRequest
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onDescriptorWriteRequest(final BluetoothDevice device, final int requestId, final BluetoothGattDescriptor descriptor, final boolean preparedWrite,
final boolean responseNeeded, final int offset, final byte[] value) {
Logger.d(mLogSession, "[Server callback] Write request to descriptor " + descriptor.getUuid()
+ " (requestId=" + requestId + ", prepareWrite=" + preparedWrite + ", responseNeeded=" + responseNeeded + ", offset=" + offset + ", value=" + ParserUtils.parse(value) + ")");
Logger.i(mLogSession, "[Server] READ request for descriptor " + descriptor.getUuid() + " received");
// This method is not supported
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, offset, null);
Logger.v(mLogSession, "[Server] Response sent");
}
示例4: onExecuteWrite
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onExecuteWrite(final BluetoothDevice device, final int requestId, final boolean execute) {
Logger.d(mLogSession, "[Server callback] Execute write request (requestId=" + requestId + ", execute=" + execute + ")");
// This method is not supported
Logger.w(mLogSession, "[Server] Operation not supported");
Logger.d(mLogSession, "[Server] server.sendResponse(GATT_REQUEST_NOT_SUPPORTED)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED, 0, null);
Logger.v(mLogSession, "[Server] Response sent");
}
示例5: onConnectionStateChange
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onConnectionStateChange(final BluetoothGatt gatt, final int status, final int newState) {
Logger.d(mLogSession, "[Callback] Connection state changed with status: " + status + " and new state: " + newState + " (" + stateToString(newState) + ")");
if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) {
// Notify the parent activity/service
Logger.i(mLogSession, "Connected to " + gatt.getDevice().getAddress());
mConnected = true;
mCallbacks.onDeviceConnected();
/*
* The onConnectionStateChange event is triggered just after the Android connects to a device.
* In case of bonded devices, the encryption is reestablished AFTER this callback is called.
* Moreover, when the device has Service Changed indication enabled, and the list of services has changed (e.g. using the DFU),
* the indication is received few milliseconds later, depending on the connection interval.
* When received, Android will start performing a service discovery operation itself, internally.
*
* If the mBluetoothGatt.discoverServices() method would be invoked here, if would returned cached services,
* as the SC indication wouldn't be received yet.
* Therefore we have to postpone the service discovery operation until we are (almost, as there is no such callback) sure, that it had to be handled.
* Our tests has shown that 600 ms is enough. It is important to call it AFTER receiving the SC indication, but not necessarily
* after Android finishes the internal service discovery.
*
* NOTE: This applies only for bonded devices with Service Changed characteristic, but to be sure we will postpone
* service discovery for all devices.
*/
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// Some proximity tags (e.g. nRF PROXIMITY) initialize bonding automatically when connected.
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_BONDING) {
Logger.v(mLogSession, "Discovering Services...");
Logger.d(mLogSession, "gatt.discoverServices()");
gatt.discoverServices();
}
}
}, 600);
} else {
if (newState == BluetoothProfile.STATE_DISCONNECTED) {
if (status != BluetoothGatt.GATT_SUCCESS)
Logger.w(mLogSession, "Error: (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status));
onDeviceDisconnected();
mConnected = false;
if (mUserDisconnected) {
Logger.i(mLogSession, "Disconnected");
mCallbacks.onDeviceDisconnected();
close();
} else {
Logger.w(mLogSession, "Connection lost");
mCallbacks.onLinklossOccur();
// We are not closing the connection here as the device should try to reconnect automatically.
// This may be only called when the shouldAutoConnect() method returned true.
}
return;
}
// TODO Should the disconnect method be called or the connection is still valid? Does this ever happen?
Logger.e(mLogSession, "Error (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status));
mCallbacks.onError(ERROR_CONNECTION_STATE_CHANGE, status);
}
}
示例6: onConnectionStateChange
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public final void onConnectionStateChange(final BluetoothGatt gatt, final int status, final int newState) {
Logger.v(mLogSession, "[Callback] Connection state changed with status: " + status + " and new state: " + newState + " (" + stateToString(newState) + ")");
if (status == BluetoothGatt.GATT_SUCCESS && newState == BluetoothProfile.STATE_CONNECTED) {
// Notify the parent activity/service
Logger.i(mLogSession, "Connected to " + gatt.getDevice().getAddress());
mConnected = true;
mCallbacks.onDeviceConnected();
/*
* The onConnectionStateChange event is triggered just after the Android connects to a device.
* In case of bonded devices, the encryption is reestablished AFTER this callback is called.
* Moreover, when the device has Service Changed indication enabled, and the list of services has changed (e.g. using the DFU),
* the indication is received few milliseconds later, depending on the connection interval.
* When received, Android will start performing a service discovery operation itself, internally.
*
* If the mBluetoothGatt.discoverServices() method would be invoked here, if would returned cached services,
* as the SC indication wouldn't be received yet.
* Therefore we have to postpone the service discovery operation until we are (almost, as there is no such callback) sure, that it had to be handled.
* Our tests has shown that 600 ms is enough. It is important to call it AFTER receiving the SC indication, but not necessarily
* after Android finishes the internal service discovery.
*
* NOTE: This applies only for bonded devices with Service Changed characteristic, but to be sure we will postpone
* service discovery for all devices.
*/
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// Some proximity tags (e.g. nRF PROXIMITY) initialize bonding automatically when connected.
if (gatt.getDevice().getBondState() != BluetoothDevice.BOND_BONDING) {
Logger.v(mLogSession, "Discovering Services...");
Logger.d(mLogSession, "gatt.discoverServices()");
gatt.discoverServices();
}
}
}, 600);
} else {
if (newState == BluetoothProfile.STATE_DISCONNECTED) {
if (status != BluetoothGatt.GATT_SUCCESS)
Logger.w(mLogSession, "Error: (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status));
onDeviceDisconnected();
mConnected = false;
if (mUserDisconnected) {
Logger.i(mLogSession, "Disconnected");
mCallbacks.onDeviceDisconnected();
close();
} else {
Logger.w(mLogSession, "Connection lost");
mCallbacks.onLinklossOccur();
// We are not closing the connection here as the device should try to reconnect automatically.
// This may be only called when the shouldAutoConnect() method returned true.
}
return;
}
// TODO Should the disconnect method be called or the connection is still valid? Does this ever happen?
Logger.e(mLogSession, "Error (0x" + Integer.toHexString(status) + "): " + GattError.parseConnectionError(status));
mCallbacks.onError(ERROR_CONNECTION_STATE_CHANGE, status);
}
}