当前位置: 首页>>代码示例>>Java>>正文


Java Logger类代码示例

本文整理汇总了Java中no.nordicsemi.android.log.Logger的典型用法代码示例。如果您正苦于以下问题:Java Logger类的具体用法?Java Logger怎么用?Java Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Logger类属于no.nordicsemi.android.log包,在下文中一共展示了Logger类的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);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:21,代码来源:BleManager.java

示例2: 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;
	mBleManager.setLogger(mLogSession);
	mDeviceNameView.setText(name != null ? name : getString(R.string.not_available));
	mConnectButton.setText(R.string.action_disconnect);
	mBleManager.connect(device);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:17,代码来源:BleProfileExpandableListActivity.java

示例3: 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());
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:22,代码来源:BleManager.java

示例4: ensureServiceChangedEnabled

import no.nordicsemi.android.log.Logger; //导入依赖的package包/类
/**
 * When the device is bonded and has the Generic Attribute service and the Service Changed characteristic this method enables indications on this characteristic.
 * In case one of the requirements is not fulfilled this method returns <code>false</code>.
 *
 * @param gatt the gatt device with services discovered
 * @return <code>true</code> when the request has been sent, <code>false</code> when the device is not bonded, does not have the Generic Attribute service, the GA service does not have
 * the Service Changed characteristic or this characteristic does not have the CCCD.
 */
private boolean ensureServiceChangedEnabled(final BluetoothGatt gatt) {
	if (gatt == null)
		return false;

	// The Service Changed indications have sense only on bonded devices
	final BluetoothDevice device = gatt.getDevice();
	if (device.getBondState() != BluetoothDevice.BOND_BONDED)
		return false;

	final BluetoothGattService gaService = gatt.getService(GENERIC_ATTRIBUTE_SERVICE);
	if (gaService == null)
		return false;

	final BluetoothGattCharacteristic scCharacteristic = gaService.getCharacteristic(SERVICE_CHANGED_CHARACTERISTIC);
	if (scCharacteristic == null)
		return false;

	Logger.i(mLogSession, "Service Changed characteristic found on a bonded device");
	return enableIndications(scCharacteristic);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:29,代码来源:BleManager.java

示例5: 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;
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:27,代码来源:BleManager.java

示例6: 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;
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:27,代码来源:BleManager.java

示例7: 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);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:28,代码来源:BleManager.java

示例8: onCharacteristicWrite

import no.nordicsemi.android.log.Logger; //导入依赖的package包/类
@Override
public void onCharacteristicWrite(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic, final int status) {
	if (status == BluetoothGatt.GATT_SUCCESS) {
		Logger.i(mLogSession, "Data written to " + characteristic.getUuid() + ", value: " + ParserUtils.parse(characteristic.getValue()));
		// The value has been written. Notify the manager and proceed with the initialization queue.
		onCharacteristicWrite(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);
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:18,代码来源:BleManager.java

示例9: 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);
		}
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:23,代码来源:BleManager.java

示例10: onStartCommand

import no.nordicsemi.android.log.Logger; //导入依赖的package包/类
@Override
public int onStartCommand(final Intent intent, final int flags, final int startId) {
	if (intent == null || !intent.hasExtra(EXTRA_DEVICE_ADDRESS))
		throw new UnsupportedOperationException("No device address at EXTRA_DEVICE_ADDRESS key");

	final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI);
	mLogSession = Logger.openSession(getApplicationContext(), logUri);
	mDeviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);

	Logger.i(mLogSession, "Service started");

	// notify user about changing the state to CONNECTING
	final Intent broadcast = new Intent(BROADCAST_CONNECTION_STATE);
	broadcast.putExtra(EXTRA_CONNECTION_STATE, STATE_CONNECTING);
	LocalBroadcastManager.getInstance(BleProfileService.this).sendBroadcast(broadcast);

	final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
	final BluetoothAdapter adapter = bluetoothManager.getAdapter();
	final BluetoothDevice device = adapter.getRemoteDevice(mDeviceAddress);
	mDeviceName = device.getName();
	onServiceStarted();

	mBleManager.connect(device);
	return START_REDELIVER_INTENT;
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:26,代码来源:BleProfileService.java

示例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;
	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();
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:18,代码来源:BleProfileServiceReadyActivity.java

示例12: 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.
	 */
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:18,代码来源:BleProfileServiceReadyActivity.java

示例13: 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
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:23,代码来源:BleProfileServiceReadyActivity.java

示例14: 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...
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:24,代码来源:BleProfileServiceReadyActivity.java

示例15: 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;
			}
		}
	});
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:19,代码来源:ProximityManager.java


注:本文中的no.nordicsemi.android.log.Logger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。