即使存在WRITE属性,Android也不允许写入BLE

时间:2019-02-09 20:25:09

标签: android bluetooth-lowenergy

我将BLE字符设置为读取,通知和写入:

char_props.broadcast      = 0;
char_props.read           = 1;
char_props.write_wo_resp  = 0;
char_props.write          = 1;
char_props.notify         = 1;
char_props.indicate       = 0;
char_props.auth_signed_wr = 0;

和:

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
cccd_md.vloc = BLE_GATTS_VLOC_STACK;

我检查了Android字符的属性,它是26,所以我认为是正确的。

I/System.out: mLockCharacteristic.getProperties(): 26

Android具有以下定义:

public static final int PERMISSION_WRITE = 16;
public static final int PERMISSION_WRITE_ENCRYPTED = 32;
public static final int PERMISSION_WRITE_ENCRYPTED_MITM = 64;
public static final int PERMISSION_WRITE_SIGNED = 128;
public static final int PERMISSION_WRITE_SIGNED_MITM = 256;
public static final int PROPERTY_BROADCAST = 1;
public static final int PROPERTY_EXTENDED_PROPS = 128;
public static final int PROPERTY_INDICATE = 32;
public static final int PROPERTY_NOTIFY = 16;
public static final int PROPERTY_READ = 2;
public static final int PROPERTY_SIGNED_WRITE = 64;
public static final int PROPERTY_WRITE = 8;

但是当我写的时候,我得到了错误:

E/BleManager: onCharacteristicWrite error 3

public static final int GATT_WRITE_NOT_PERMITTED = 3;

有人有什么主意吗?

0 个答案:

没有答案