ペリフェラルおよびセントラル、どちらもAndroid端末でConnectioを張ってWriteを行おうとしたのですがうまくいきませんでした。
端末は2つともZenPad7.0のOSは5.1.1です。
以下のようにセントラル側でwriteCharacteristicを呼び出すと返却値はtrueを返してきたので一見うまくいったように感じたのですが、ペリフェラル側ではコールバックであるonCharacteristicWriteRequestが実行されませんでした。
boolean result = this.bluetoothGatt.writeCharacteristic(write); Log.d("bluetooth", "writeCharacteristic: " + result);
セントラル側のonCharacteristicWriteは実行されてstatusが3でした。3はGATT_WRITE_NOT_PERMITTEDのようなのでパーミッションが問題かと思ったのですが、もしパーミッションが許可されていなかったとしたらwrtieCharacteristicでfalseが帰ってくるようです。
@Override public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { Log.d("bluetooth", "onCharacteristicWrite: " + status); }
サービスのcharacteristicは以下のように設定しています。
private void setServices() { BluetoothGattService service = new BluetoothGattService( this.SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY); BluetoothGattCharacteristic charWrite = new BluetoothGattCharacteristic( this.CHAR_WRITE_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE, BluetoothGattCharacteristic.PERMISSION_WRITE); service.addCharacteristic(charWrite); this.mGattServer.addService(service); }
原因は何でしょうか。端末依存の問題なんでしょうか。
ちなみにReadはうまくいきました。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/04/20 10:13
2017/04/20 10:20
2017/04/20 10:26
2017/04/21 00:05