當前位置: 首頁>>代碼示例>>Java>>正文


Java BluetoothGattCharacteristic.getStringValue方法代碼示例

本文整理匯總了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);
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:27,代碼來源:DfuBaseService.java

示例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);
}
 
開發者ID:MB3hel,項目名稱:Quick-Bluetooth-LE,代碼行數:10,代碼來源:BLEServer.java

示例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);
}
 
開發者ID:MB3hel,項目名稱:Quick-Bluetooth-LE,代碼行數:10,代碼來源:BLEClient.java

示例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);
}
 
開發者ID:runtimeco,項目名稱:Android-DFU-App,代碼行數:6,代碼來源:UARTManager.java

示例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;
}
 
開發者ID:Samsung,項目名稱:microbit,代碼行數:49,代碼來源:BLEService.java


注:本文中的android.bluetooth.BluetoothGattCharacteristic.getStringValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。