2017-05-24 9 views
0

バイト配列とstrings.myで作業しています。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; 
     } 

答えて

0

をdefuaultしようとする変更のライトタイプは、私は私がそれを読むことができる他のタイプを使用する場合は、必ず を読み取ることができません PSOCをcysmartに対する応答を使用していません私の書き込み

あなたはタイプ変更を試すことができます

関連する問題