2016-12-05 2 views
0

アプリとのペアリング時にBluetoothタグをフィルタする方法たとえば、「タイル」は、許可されたタグ以外のタグと接続しません。私の質問は、どのようにしてアプリケーションから承認されたタグを認識するのですか?アンドロイドアプリからBluetoothタグをフィルタリングする方法

+0

あなたは、 'デバイス名' を意味しますか? –

+0

詳しくは、私のブルートゥースの範囲にたくさんのタグがある場合、私は自分の会社のタグだけをアプリに表示したいと思います。他のタグはアプリに表示されません。 –

答えて

1

単純な解決策は、信頼できないデバイスに接続し、特定の結果が期待される信号を送信し、正常に受信した場合はそのデバイスを「信頼する」ことです。次の負荷に続いて

、と対にMACアドレス..似

何かを確認してください。

private BluetoothDevice mDevice = null; 
if (mDevice == null) { 
     BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
     if (mBluetoothAdapter != null) { 
      if (mBluetoothAdapter.isEnabled()) { 
       Set<BluetoothDevice> bluetoothDevices = mBluetoothAdapter 
         .getBondedDevices(); 
       if (bluetoothDevices != null && bluetoothDevices.size() > 0) { 
        String bondedID = SharedPreferences.getInstance(
          getApplicationContext() 
        ).getPairedAddress(); 
        if (bondedID != null) { 
         for (final BluetoothDevice device : bluetoothDevices) { 
          if (device != null 
            && device.getAddress().equals(bondedID)) { 
           mDevice = device; 
           break; 
          } 
         } 
        } 
       } else { 
        Logger.v(TAG, "There are no Bluetooth Paired devices"); 
       } 
      } 
     } 
    } 
+0

Bluetoothタグに信号を送信することを意味しますか?アプリが期待した結果を受け取った場合、そのタグを信頼して応答しますか? –

+0

はい、それはうまく動作しますが、 'mDevice.getName()'など)を使って特定のデバイス名だけを信頼するなど、他の方法も一般的です。 – Bonatti

+0

私の考えはセキュリティ上の問題です。誰かが自分のアプリを使って自分のタグを販売している場合、私のアプリがそれらのタグを信用できないようにするにはどうすればいいですか? –