當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。