我正在使用字节数组和strings.my BLE不对固件有价值。我正在发送bytE数组来写入值。我的代码显示如下: -
private boolean writeCharacteristic(String password,String title){
Log.w("writing log",title);
if (mGatt == null) {
Log.e("Connection status", "lost connection");
return false;
}
BluetoothGattService Service = mGatt.getService(UUID.fromString("f9519c06-99ab-4277-83d8-d934fff00000"));
if (Service == null) {
Log.e("Service status", "service not found!");
return false;
}
BluetoothGattCharacteristic charac = Service.getCharacteristic(UUID.fromString("f9519c06-99ab-4277-83d8-d934fff10000"));
boolean status ;
byte[] read=charac.getValue();
for (int i=0;i<5;i++)
{
char[] x = password.toCharArray();
String hex= String.format("%s3", x[i]);
Integer resuInteger=Integer.parseInt(hex,16);
read[i+4]=resuInteger.byteValue();
}
try {
charac.setValue(URLEncoder.encode(Arrays.toString(read), "utf-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
charac.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
status = mGatt.writeCharacteristic(charac);
mGatt.setCharacteristicNotification(charac,true);
Log.w("status",String.valueOf(status));
dialog_change.dismiss();
return status;
}
答案 0 :(得分:1)
尝试将写入类型更改为defuault
我对cysmart使用无响应 Psoc始终无法读取 当我使用其他类型时,它可以读取我的写作
所以你可以试试改变类型