0

I am working with byte arrays and strings.my BLE not wrtie value to the firmware.i am sending bytE Array to write value. there are show the my code as below :-

  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;
        }

1 Answer 1

1

Try change write type to defuault

I use the No response to cysmart Psoc always can't read When I use other type it can read my write

So you can try change type

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.