###前提・実現したいこと
現在AndroidアプリとGenuino101をBLE通信で繋ぎ、データの送受信を行っています。
Characteristicの値を変更することによってデータの送受信を行うことには成功しています。
Android側で要素数8のbyte型配列を用意し、byte[0]、byte[1]、byte[2]、…にそれぞれ異なる値を格納し、Characteristicsにこの値を乗せ送信しようとしています。
Genuino側では Serial.println(Characteristic.value()); とし、シリアルモニタで表示・確認をしていますが、送信Characteristicの先頭配列の値しか表示されません。
Android側で送信したCharacteristicの全要素(値)を、Genuino側のシリアルモニタで確認したいです。
そのため配列の格納場所?を変更する方法、もしくは全要素の一斉表示の方法を教えていただきたいです。
###該当のソースコード
java
1/* 接続部分は省略させていただきます */ 2/* データ送信部 */ 3public void sendData(byte[] bytes){ 4 BluetoothGattService myService = mBluetoothGatt.getService(UUID.fromString(Genuino_UUID)); 5 BluetoothGattCharacteristic characteristic = myService.getCharacteristic(UUID.fromString(Genuino_Write)); 6 characteristic.setValue(bytes); 7 mBluetoothGatt.writeCharacteristic(characteristic); 8}
java
1/* クリックイベント時にsendData */ 2public void onClick(View v) { 3 byte[] test = new byte[8]; 4 test[0] = 0; 5 test[1] = 1; 6 test[2] = 2; 7 mBluetoothLeService.sendData(test); 8}
###補足情報(言語/FW/ツール等のバージョンなど)
Android Studio,ArduinoIDE
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/21 12:23 編集
2017/12/22 06:31
2017/12/22 06:39
2017/12/22 07:18 編集
2017/12/22 08:30
2017/12/22 08:32