本文整理匯總了Java中android.bluetooth.BluetoothGattDescriptor.getPermissions方法的典型用法代碼示例。如果您正苦於以下問題:Java BluetoothGattDescriptor.getPermissions方法的具體用法?Java BluetoothGattDescriptor.getPermissions怎麽用?Java BluetoothGattDescriptor.getPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.bluetooth.BluetoothGattDescriptor
的用法示例。
在下文中一共展示了BluetoothGattDescriptor.getPermissions方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decodePermissions
import android.bluetooth.BluetoothGattDescriptor; //導入方法依賴的package包/類
public static WritableMap decodePermissions(BluetoothGattDescriptor descriptor) {
// NOTE: props strings need to be consistent across iOS and Android
WritableMap props = Arguments.createMap();
int permissions = descriptor.getPermissions();
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ) != 0x0 ) {
props.putString("Read", "Read");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE) != 0x0 ) {
props.putString("Write", "Write");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED) != 0x0 ) {
props.putString("ReadEncrypted", "ReadEncrypted");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED) != 0x0 ) {
props.putString("WriteEncrypted", "WriteEncrypted");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM) != 0x0 ) {
props.putString("ReadEncryptedMITM", "ReadEncryptedMITM");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED_MITM) != 0x0 ) {
props.putString("WriteEncryptedMITM", "WriteEncryptedMITM");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED) != 0x0 ) {
props.putString("WriteSigned", "WriteSigned");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED_MITM) != 0x0 ) {
props.putString("WriteSignedMITM", "WriteSignedMITM");
}
return props;
}
示例2: decodePermissions
import android.bluetooth.BluetoothGattDescriptor; //導入方法依賴的package包/類
public static JSONArray decodePermissions(BluetoothGattDescriptor descriptor) {
// NOTE: props strings need to be consistent across iOS and Android
JSONArray props = new JSONArray();
int permissions = descriptor.getPermissions();
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ) != 0x0 ) {
props.put("Read");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE) != 0x0 ) {
props.put("Write");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED) != 0x0 ) {
props.put("ReadEncrypted");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED) != 0x0 ) {
props.put("WriteEncrypted");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_READ_ENCRYPTED_MITM) != 0x0 ) {
props.put("ReadEncryptedMITM");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_ENCRYPTED_MITM) != 0x0 ) {
props.put("WriteEncryptedMITM");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED) != 0x0 ) {
props.put("WriteSigned");
}
if ((permissions & BluetoothGattDescriptor.PERMISSION_WRITE_SIGNED_MITM) != 0x0 ) {
props.put("WriteSignedMITM");
}
return props;
}
示例3: asWritableMap
import android.bluetooth.BluetoothGattDescriptor; //導入方法依賴的package包/類
public WritableMap asWritableMap(BluetoothGatt gatt) {
WritableMap map = asWritableMap();
WritableArray servicesArray = Arguments.createArray();
WritableArray characteristicsArray = Arguments.createArray();
if (connected && gatt != null) {
for (BluetoothGattService service : gatt.getServices()) {
WritableMap serviceMap = Arguments.createMap();
serviceMap.putString("uuid", UUIDHelper.uuidToString(service.getUuid()));
for (BluetoothGattCharacteristic characteristic : service.getCharacteristics()) {
WritableMap characteristicsMap = Arguments.createMap();
characteristicsMap.putString("service", UUIDHelper.uuidToString(service.getUuid()));
characteristicsMap.putString("characteristic", UUIDHelper.uuidToString(characteristic.getUuid()));
characteristicsMap.putMap("properties", Helper.decodeProperties(characteristic));
if (characteristic.getPermissions() > 0) {
characteristicsMap.putMap("permissions", Helper.decodePermissions(characteristic));
}
WritableArray descriptorsArray = Arguments.createArray();
for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
WritableMap descriptorMap = Arguments.createMap();
descriptorMap.putString("uuid", UUIDHelper.uuidToString(descriptor.getUuid()));
if (descriptor.getValue() != null)
descriptorMap.putString("value", Base64.encodeToString(descriptor.getValue(), Base64.NO_WRAP));
else
descriptorMap.putString("value", null);
if (descriptor.getPermissions() > 0) {
descriptorMap.putMap("permissions", Helper.decodePermissions(descriptor));
}
descriptorsArray.pushMap(descriptorMap);
}
if (descriptorsArray.size() > 0) {
characteristicsMap.putArray("descriptors", descriptorsArray);
}
characteristicsArray.pushMap(characteristicsMap);
}
servicesArray.pushMap(serviceMap);
}
map.putArray("services", servicesArray);
map.putArray("characteristics", characteristicsArray);
}
return map;
}
示例4: displayGattServices
import android.bluetooth.BluetoothGattDescriptor; //導入方法依賴的package包/類
private void displayGattServices(List<BluetoothGattService> gattServices) {
if (gattServices == null) return;
for (BluetoothGattService gattService : gattServices) {
//-----Service的字段信息-----//
int type = gattService.getType();
Log.e(TAG,"-->service type:"+Utils.getServiceType(type));
Log.e(TAG,"-->includedServices size:"+gattService.getIncludedServices().size());
Log.e(TAG,"-->service uuid:"+gattService.getUuid());
//-----Characteristics的字段信息-----//
List<BluetoothGattCharacteristic> gattCharacteristics =gattService.getCharacteristics();
for (final BluetoothGattCharacteristic gattCharacteristic: gattCharacteristics) {
Log.e(TAG,"---->char uuid:"+gattCharacteristic.getUuid());
int permission = gattCharacteristic.getPermissions();
Log.e(TAG,"---->char permission:"+Utils.getCharPermission(permission));
int property = gattCharacteristic.getProperties();
Log.e(TAG,"---->char property:"+Utils.getCharPropertie(property));
byte[] data = gattCharacteristic.getValue();
if (data != null && data.length > 0) {
Log.e(TAG,"---->char value:"+new String(data));
}
if(gattCharacteristic.getUuid().toString().equals(UUID_RESPONSE)) {
ResponseCharac = gattCharacteristic;
}
//UUID_KEY_DATA是可以跟藍牙模塊串口通信的Characteristic
if(gattCharacteristic.getUuid().toString().equals(UUID_REQUEST)){
//測試讀取當前Characteristic數據,會觸發mOnDataAvailable.onCharacteristicRead()
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mBLE.readCharacteristic(gattCharacteristic);
mHandler.postDelayed(this, 500);
mBLE.readRemoteRssi();
//BluetoothGattDescriptor descriptor = gattCharacteristic.getDescriptor(HD_Profile.UUID_CHAR_NOTIFY_DIS)
}
}, 500);
//接受Characteristic被寫的通知,收到藍牙模塊的數據後會觸發mOnDataAvailable.onCharacteristicWrite()
mBLE.setCharacteristicNotification(gattCharacteristic, true);
//設置數據內容
//gattCharacteristic.setValue("hi");
//往藍牙模塊寫入數據
// mBLE.writeCharacteristic(gattCharacteristic);
}
//-----Descriptors的字段信息-----//
List<BluetoothGattDescriptor> gattDescriptors = gattCharacteristic.getDescriptors();
for (BluetoothGattDescriptor gattDescriptor : gattDescriptors) {
Log.e(TAG, "-------->desc uuid:" + gattDescriptor.getUuid());
int descPermission = gattDescriptor.getPermissions();
Log.e(TAG,"-------->desc permission:"+ Utils.getDescPermission(descPermission));
byte[] desData = gattDescriptor.getValue();
if (desData != null && desData.length > 0) {
Log.e(TAG, "-------->desc value:"+ new String(desData));
}
}
}
}//
}