本文整理汇总了Java中no.nordicsemi.android.log.Logger.d方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.d方法的具体用法?Java Logger.d怎么用?Java Logger.d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类no.nordicsemi.android.log.Logger
的用法示例。
在下文中一共展示了Logger.d方法的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: onServiceConnected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) {
final E bleService = mService = (E) service;
mLogSession = mService.getLogSession();
Logger.d(mLogSession, "Activity binded to the service");
onServiceBinded(bleService);
// update UI
mDeviceName = bleService.getDeviceName();
mDeviceNameView.setText(mDeviceName);
mConnectButton.setText(R.string.action_disconnect);
// and notify user if device is connected
if (bleService.isConnected())
onDeviceConnected();
}
示例6: onStart
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
protected void onStart() {
super.onStart();
/*
* If the service has not been started before, the following lines will not start it. However, if it's running, the Activity will be binded to it and
* notified via mServiceConnection.
*/
final Intent service = new Intent(this, getServiceClass());
if (bindService(service, mServiceConnection, 0)) // we pass 0 as a flag so the service will not be created if not exists
Logger.d(mLogSession, "Binding to the service..."); // (* - see the comment below)
/*
* * - When user exited the UARTActivity while being connected, the log session is kept in the service. We may not get it before binding to it so in this
* case this event will not be logged (mLogSession is null until onServiceConnected(..) is called). It will, however, be logged after the orientation changes.
*/
}
示例7: onStop
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
protected void onStop() {
super.onStop();
try {
// We don't want to perform some operations (e.g. disable Battery Level notifications) in the service if we are just rotating the screen.
// However, when the activity is finishing, we may want to disable some device features to reduce the battery consumption.
if (mService != null)
mService.setActivityIsFinishing(isFinishing());
Logger.d(mLogSession, "Unbinding from the service...");
unbindService(mServiceConnection);
mService = null;
Logger.d(mLogSession, "Activity unbinded from the service");
onServiceUnbinded();
mDeviceName = null;
mLogSession = null;
} catch (final IllegalArgumentException e) {
// do nothing, we were not connected to the sensor
}
}
示例8: onDeviceDisconnected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
/**
* Called when the device has disconnected (when the callback returned
* {@link BluetoothGattCallback#onConnectionStateChange(android.bluetooth.BluetoothGatt, int, int)} with state DISCONNECTED.
*/
public void onDeviceDisconnected() {
mConnectButton.setText(R.string.action_connect);
mDeviceNameView.setText(getDefaultDeviceName());
if (mBatteryLevelView != null)
mBatteryLevelView.setText(R.string.not_available);
try {
Logger.d(mLogSession, "Unbinding from the service...");
unbindService(mServiceConnection);
mService = null;
Logger.d(mLogSession, "Activity unbinded from the service");
onServiceUnbinded();
mDeviceName = null;
mLogSession = null;
} catch (final IllegalArgumentException e) {
// do nothing. This should never happen but does...
}
}
示例9: 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");
}
示例10: onDeviceSelected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onDeviceSelected(final BluetoothDevice device, final String name) {
final int titleId = getLoggerProfileTitle();
if (titleId > 0) {
mLogSession = Logger.newSession(getApplicationContext(), getString(titleId), device.getAddress(), name);
// If nRF Logger is not installed we may want to use local logger
if (mLogSession == null && getLocalAuthorityLogger() != null) {
mLogSession = LocalLogSession.newSession(getApplicationContext(), getLocalAuthorityLogger(), device.getAddress(), name);
}
}
mDeviceName = name;
mDeviceNameView.setText(name != null ? name : getString(R.string.not_available));
mConnectButton.setText(R.string.action_disconnect);
// The device may not be in the range but the service will try to connect to it if it reach it
Logger.d(mLogSession, "Creating service...");
final Intent service = new Intent(this, getServiceClass());
service.putExtra(BleProfileService.EXTRA_DEVICE_ADDRESS, device.getAddress());
if (mLogSession != null)
service.putExtra(BleProfileService.EXTRA_LOG_URI, mLogSession.getSessionUri());
startService(service);
Logger.d(mLogSession, "Binding to the service...");
bindService(service, mServiceConnection, 0);
}
示例11: onServiceConnected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) {
final E bleService = mService = (E) service;
mBluetoothDevice = bleService.getBluetoothDevice();
mLogSession = mService.getLogSession();
Logger.d(mLogSession, "Activity bound to the service");
onServiceBinded(bleService);
// Update UI
mDeviceName = bleService.getDeviceName();
mDeviceNameView.setText(mDeviceName);
mConnectButton.setText(R.string.action_disconnect);
// And notify user if device is connected
if (bleService.isConnected()) {
onDeviceConnected(mBluetoothDevice);
} else {
// If the device is not connected it means that either it is still connecting,
// or the link was lost and service is trying to connect to it (autoConnect=true).
onDeviceConnecting(mBluetoothDevice);
}
}
示例12: onPause
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
protected void onPause() {
super.onPause();
try {
// We don't want to perform some operations (e.g. disable Battery Level notifications) in the service if we are just rotating the screen.
// However, when the activity will disappear, we may want to disable some device features to reduce the battery consumption.
if (mService != null)
mService.setActivityIsChangingConfiguration(isChangingConfigurations());
unbindService(mServiceConnection);
mService = null;
Logger.d(mLogSession, "Activity unbound from the service");
onServiceUnbinded();
mDeviceName = null;
mBluetoothDevice = null;
mLogSession = null;
} catch (final IllegalArgumentException e) {
// do nothing, we were not connected to the sensor
}
}
示例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.i(mLogSession, "[Server] Write request to characteristic " + characteristic.getUuid() + " (requestId = " + requestId + ", value = " + ParserUtils.parse(value) + ", offset = " + offset + ")");
characteristic.setValue(value);
if (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();
}
}
if (responseNeeded) {
Logger.v(mLogSession, "[Server] Sending response: SUCCESS");
Logger.d(mLogSession, "[Server] sendResponse(GATT_SUCCESS)");
mBluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
}
}
示例14: onServiceConnected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) {
final E bleService = mService = (E) service;
mLogSession = mService.getLogSession();
Logger.d(mLogSession, "Activity binded to the service");
onServiceBinded(bleService);
// update UI
//TODO 初始化控件
mDeviceName = bleService.getDeviceName();
// and notify user if device is connected
if (bleService.isConnected())
onDeviceConnected();
}
示例15: onDeviceSelected
import no.nordicsemi.android.log.Logger; //导入方法依赖的package包/类
@Override
public void onDeviceSelected(final BluetoothDevice device, final String name) {
final int titleId = getLoggerProfileTitle();
if (titleId > 0) {
mLogSession = Logger.newSession(getApplicationContext(), getString(titleId), device.getAddress(), name);
// If nRF Logger is not installed we may want to use local logger
if (mLogSession == null && getLocalAuthorityLogger() != null) {
mLogSession = LocalLogSession.newSession(getApplicationContext(), getLocalAuthorityLogger(), device.getAddress(), name);
}
}
mDeviceNameView.setText(mDeviceName = name);
mConnectButton.setText(R.string.action_disconnect);
// The device may not be in the range but the service will try to connect to it if it reach it
Logger.d(mLogSession, "Creating service...");
final Intent service = new Intent(this, getServiceClass());
service.putExtra(BleProfileService.EXTRA_DEVICE_ADDRESS, device.getAddress());
if (mLogSession != null)
service.putExtra(BleProfileService.EXTRA_LOG_URI, mLogSession.getSessionUri());
startService(service);
Logger.d(mLogSession, "Binding to the service...");
bindService(service, mServiceConnection, 0);
}