本文整理匯總了Java中android.bluetooth.BluetoothGattCharacteristic.getStringValue方法的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothGattCharacteristic.getStringValue方法的具體用法?Java BluetoothGattCharacteristic.getStringValue怎麽用?Java BluetoothGattCharacteristic.getStringValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.bluetooth.BluetoothGattCharacteristic
的用法示例。
在下文中一共展示了BluetoothGattCharacteristic.getStringValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readCharacteristicNoFailure
import android.bluetooth.BluetoothGattCharacteristic; //導入方法依賴的package包/類
private String readCharacteristicNoFailure(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
if (mConnectionState != STATE_CONNECTED_AND_READY)
return "not_ready";
if (characteristic == null)
return "unknown";
logi("readCharacteristicNoFailure");
gatt.readCharacteristic(characteristic);
try {
synchronized (mLock) {
while ((!mRequestCompleted && mConnectionState == STATE_CONNECTED_AND_READY && mError == 0 && !mAborted) || mPaused)
mLock.wait();
}
} catch (final InterruptedException e) {
loge("Sleeping interrupted", e);
}
if (mAborted)
return "unknown";
if (mError != 0)
return "unknown";
if (mConnectionState != STATE_CONNECTED_AND_READY)
return "unknown";
return characteristic.getStringValue(0);
}
示例2: getCharacteristicValueString
import android.bluetooth.BluetoothGattCharacteristic; //導入方法依賴的package包/類
public String getCharacteristicValueString(UUID serviceUuid, UUID characteristicUuid, int ofst){
BluetoothGattService service = gattServer.getService(serviceUuid);
if(service == null)
return null;
BluetoothGattCharacteristic ch = service.getCharacteristic(characteristicUuid);
if(ch == null)
return null;
return ch.getStringValue(ofst);
}
示例3: getCharacteristicValueString
import android.bluetooth.BluetoothGattCharacteristic; //導入方法依賴的package包/類
public String getCharacteristicValueString(UUID serviceUuid, UUID characteristicUuid, int ofst){
BluetoothGattService service = gattConnection.getService(serviceUuid);
if(service == null)
return null;
BluetoothGattCharacteristic ch = service.getCharacteristic(characteristicUuid);
if(ch == null)
return null;
return ch.getStringValue(ofst);
}
示例4: onCharacteristicNotified
import android.bluetooth.BluetoothGattCharacteristic; //導入方法依賴的package包/類
@Override
public void onCharacteristicNotified(final BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
final String data = characteristic.getStringValue(0);
mCallbacks.onDataReceived(data);
}
示例5: registerNotifications
import android.bluetooth.BluetoothGattCharacteristic; //導入方法依賴的package包/類
private boolean registerNotifications(boolean enable) {
logi("registerNotifications() : " + enable);
//Read micro:bit firmware version
BluetoothGattService deviceInfoService = getService(GattServiceUUIDs.DEVICE_INFORMATION_SERVICE);
if(deviceInfoService != null) {
BluetoothGattCharacteristic firmwareCharacteristic = deviceInfoService.getCharacteristic
(CharacteristicUUIDs.FIRMWARE_REVISION_UUID);
if(firmwareCharacteristic != null) {
String firmware = "";
BluetoothGattCharacteristic characteristic = readCharacteristic(firmwareCharacteristic);
if(characteristic != null && characteristic.getValue() != null && characteristic.getValue().length != 0) {
firmware = firmwareCharacteristic.getStringValue(0);
}
sendMicrobitFirmware(firmware);
logi("Micro:bit firmware version String = " + firmware);
}
} else {
Log.e(TAG, "Not found DeviceInformationService");
}
BluetoothGattService eventService = getService(GattServiceUUIDs.EVENT_SERVICE);
if(eventService == null) {
Log.e(TAG, "Not found EventService");
logi("registerNotifications() :: not found service : Constants.EVENT_SERVICE");
return false;
}
logi("Constants.EVENT_SERVICE = " + GattServiceUUIDs.EVENT_SERVICE.toString());
logi("Constants.ES_MICROBIT_REQUIREMENTS = " + CharacteristicUUIDs.ES_MICROBIT_REQUIREMENTS.toString());
logi("Constants.ES_CLIENT_EVENT = " + CharacteristicUUIDs.ES_CLIENT_EVENT.toString());
logi("Constants.ES_MICROBIT_EVENT = " + CharacteristicUUIDs.ES_MICROBIT_EVENT.toString());
logi("Constants.ES_CLIENT_REQUIREMENTS = " + CharacteristicUUIDs.ES_CLIENT_REQUIREMENTS.toString());
if(!registerMicrobitRequirements(eventService, enable)) {
if(DEBUG) {
logi("***************** Cannot Register Microbit Requirements.. Will continue ************** ");
}
}
register_AppRequirement(eventService, enable);
if(!registerMicroBitEvents(eventService, enable)) {
logi("Failed to registerMicroBitEvents");
return false;
}
logi("registerNotifications() : done");
return true;
}