2

Bluetooth をテストするために、新しい nexus 7 (4.3 JSS15R) で bluetoothle サンプル (android-sdks/samples/android-18/legacy/BluetoothLeGatt/) を使用します。そして、 readCharacteristic があまりにも多くの時間を費やしていることがわかりました (読み取りごとに約 1 ~ 3 秒)。

まず、サービス項目がクリックされたときに readCharacteristic をトリガーします。

    DeviceControlActivity.java
    ....
    private final ExpandableListView.OnChildClickListener servicesListClickListner = 
    ....
    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
    ....
         mBluetoothLeService.readCharacteristic(characteristic);

次に、特性が読み取られるときに readCharacteristic を繰り返します。

    BluetoothLeService.java
    ....
    private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    ....
    @Override
    public void onCharacteristicRead(BluetoothGatt gatt,
                                     BluetoothGattCharacteristic characteristic,
                                     int status) {
        if(TEST_COUNT < 20) {
            Log.d(TAG,"onCharacteristicRead");
            readCharacteristic(characteristic);
            TEST_COUNT ++; 
        } else {
            TEST_COUNT = 0;
        }   

        /*  
        if (status == BluetoothGatt.GATT_SUCCESS) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }
        */
    } 

ログは次のように表示されます:

10-29 11:16:37.360: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:39.362: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:41.364: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:43.356: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:45.358: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:47.340: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:49.342: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:51.334: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:53.336: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:55.328: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:57.319: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:16:59.311: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:01.313: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:03.305: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:05.297: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:07.289: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:09.291: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:11.283: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:13.285: DEBUG/MyTest(9554): onCharacteristicRead
10-29 11:17:15.277: DEBUG/MyTest(9554): onCharacteristicRead

すべての特性読み取りを受信するのに 2 秒かかります。本当に奇妙です。

samsung ble sdkともちろん同じbleデバイスを使用して、galaxy s4で同じ動作をテストします。しかし、ログは、読み取りに費やす時間が少ないことを示しています。

10-29 11:51:19.393  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.493  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.588  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.688  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.783  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.878  I/MyTest﹕  onCharacteristicRead
10-29 11:51:19.978  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.078  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.183  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.323  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.418  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.518  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.613  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.713  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.808  I/MyTest﹕  onCharacteristicRead
10-29 11:51:20.908  I/MyTest﹕  onCharacteristicRead
10-29 11:51:21.003  I/MyTest﹕  onCharacteristicRead
10-29 11:51:21.103  I/MyTest﹕  onCharacteristicRead
10-29 11:51:21.248  I/MyTest﹕  onCharacteristicRead
10-29 11:51:21.343  I/MyTest﹕  onCharacteristicRead
10-29 11:51:21.443  I/MyTest﹕  onCharacteristicRead

誰も同じ問題を抱えていますか? 新しい nexus 7 ハードウェアが原因ですか? またはアンドロイド4.3 SDK?

readCharacteristic に費やす時間を短縮するにはどうすればよいですか?

4

0 に答える 0