2017-08-15 13 views
0

私は現在、LilyPad Simblee BLEボード(RFD77101)を所有しています。これは、arduino 1.6.5 IDEで定義しているカスタムサービスとの接続を確立しようとしています。Simblee.customUUIDコマンド。カスタムサービスとの接続を確立できません

私は以前に確立したUUIDを使用してBluetoothleGattサンプルコードのAndroidスタジオでサービスと特性を取得しようとしました。

私がSimbleeに接続すると、アプリケーションがサービスを認識できず、次のエラーが記録されるという問題があります。

カスタムBLEサービスは、コードがちょっと長いので、私は直接のすべてを掲示していないされて

が見つかりません。誰かが私の問題と必要性とコードの一部を解決するというアイデアを持っているなら、私はそれを投稿することが明らかに嬉しいです。

前もって誰にも感謝します。

これは私が特性を取得しようとします。public voidです:あなたが提供するUUIDが正しい形式ではありません

public void readCustomCharacteristic() { 
    if (mBluetoothAdapter == null || mBluetoothGatt == null) { 
    Log.w(TAG, "BluetoothAdapter not initialized"); 
    return; 
    } 
    /*check if the service is available on the device*/ 
    BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("fe84-0000-1000-8000-00805f9b34fb")); 
    if(mCustomService == null) { 
    Log.w(TAG, "Custom BLE Service not found"); 
    return; 
    } 
    /*get the read characteristic from the service*/ 
    BluetoothGattCharacteristic mReadCharacteristic = mCustomService.getCharacteristic(UUID.fromString("2d30c083-f39f-4ce6-923f-3484ea480596")); 
    if(!mBluetoothGatt.readCharacteristic(mReadCharacteristic)) { 
    Log.w(TAG, "Failed to read characteristic"); 
    } 
} 

答えて

0
BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("fe84-0000-1000-8000-00805f9b34fb")); 

。ドキュメントによると、最初のハイフンの前の部分は、4つの16進オクテットで構成されていなければなりませんが、ここでは2つしかありません。あなたは

BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("0000fe84-0000-1000-8000-00805f9b34fb")); 

編集のように前にパディング0を追加する必要があります。ここでのポイントがありません。 mBluetoothGatt.discoverServices()に電話しましたか?

+0

"0000"のパディングを追加して特性uuidを "2d30c08 ** 2 ** ..."(Simbleeモジュールの読み込み特性)に変更すると、今すぐ正常に動作しました。ありがとう –

関連する問題