本文整理汇总了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));
}
}
}
}//
}