writecharacteristic android不使用字节数组

writecharacteristic android不使用字节数组,android,bluetooth-lowenergy,Android,Bluetooth Lowenergy,我正在使用字节数组和字符串。我的BLE未将值写入固件。我正在发送字节数组以写入值。我的代码如下所示: private boolean writeCharacteristic(String password,String title){ Log.w("writing log",title); if (mGatt == null) { Log.e("Connection status", "lost connecti

我正在使用字节数组和字符串。我的BLE未将值写入固件。我正在发送字节数组以写入值。我的代码如下所示:

  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;
        }
private boolean writeCharacteristic(字符串密码、字符串标题){
Log.w(“书写日志”,标题);
如果(mGatt==null){
日志e(“连接状态”、“断开连接”);
返回false;
}
BluetoothGattService服务=mGatt.getService(UUID.fromString(“f9519c06-99ab-4277-83d8-d934fff00000”);
if(服务==null){
Log.e(“服务状态”,“未找到服务!”);
返回false;
}
BluetoothGattCharacteristic charac=Service.getCharacteristic(UUID.fromString(“f9519c06-99ab-4277-83d8-d934fff10000”);
布尔状态;
字节[]读取=charac.getValue();

对于(int i=0;i尝试将写入类型更改为defuult

我对cysmart使用无响应 Psoc总是无法阅读 当我使用其他类型时,它可以读取我的文字

所以你可以尝试改变类型