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


Java BluetoothGatt.getDevice方法代码示例

本文整理汇总了Java中android.bluetooth.BluetoothGatt.getDevice方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothGatt.getDevice方法的具体用法?Java BluetoothGatt.getDevice怎么用?Java BluetoothGatt.getDevice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.BluetoothGatt的用法示例。


在下文中一共展示了BluetoothGatt.getDevice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureServiceChangedEnabled

import android.bluetooth.BluetoothGatt; //导入方法依赖的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;

	return enableIndications(scCharacteristic);
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:28,代码来源:BleManager.java

示例2: ensureServiceChangedEnabled

import android.bluetooth.BluetoothGatt; //导入方法依赖的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

示例3: onServicesDiscovered

import android.bluetooth.BluetoothGatt; //导入方法依赖的package包/类
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
	Log.i(TAG, "onServicesDiscovered called...");
	BluetoothDevice device = gatt.getDevice();
	int discoveredServices = gatt.getServices().size();
	if(discoveredServices == 0 && isConnected(device)) {
		Log.i(TAG, "Re-discovering services. No previous services and is connected");
		gatt.discoverServices();
		return;
	}
	broadcastUpdate(ACTION_GATT_CLIENT_SERVICES_DISCOVERED);
}
 
开发者ID:masterjc,项目名称:bluewatcher,代码行数:13,代码来源:BluetoothClientService.java


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