2011-08-13 13 views
3

Androidタブレットに2つの同時ブルートゥースSPPデバイス(ブルートゥース経由のシリアルポート)を接続するように求められました。アンドロイド上のデュアルSPPブルートゥース接続

私は、ブルートゥースチャットをベースとして接続しましたが、同時に2つのデバイスに接続すると失われます。

目的は、2つのリモートデバイスからデータを収集し、データを比較することです。

タブレットはサーバーとして動作することはできません。タブレットは、これらのデバイスのクライアントでなければなりません。

私は見回しましたが、ソースの例は見つかりませんでした。

誰かが助けることができれば...

おかげ セドリック

+0

[リンク] http://code.google.com/p/apps-for-android/source/browse/#svn%2Ftrunk%2FBTClickLinkCompete [/リンク] しかし、それは、サーバー部分のみです複数のクライアントを許可します。 複数のサーバーに接続するクライアントの部分が必要です。 – Cedric

答えて

2

は最後に、私は、接続スレッドを含むクラスをクローン化し、主な活動でハンドラを倍増しました。 私は2台のデバイスに接続するためにメニューを2倍にし、数回微調整した後、魅力的なように機能します!

+0

GitHubであなたのコードをオープンソースにすることができれば驚くべきことです。 –

0

本当に簡単です。ただ2回すべてをやりなさい。私が見つけた

bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 

    bluetoothDevice = bluetoothAdapter.getRemoteDevice(btAddress1); 
    UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); 
    bluetoothSocket = bluetoothDevice.createInsecureRfcommSocketToServiceRecord(uuid); 

    Log.d(TAG, "start connect."); 
    bluetoothSocket.connect(); 
    Log.d(TAG, "finished connect."); 

    Log.d(TAG, "getting second adapter"); 
    bluetoothAdapter2 = BluetoothAdapter.getDefaultAdapter(); 
    Log.d(TAG, "getting second adapter success, getting device 2"); 
    bluetoothDevice2 = bluetoothAdapter2.getRemoteDevice(btAddress2); 
    Log.d(TAG, "getting second device success"); 
    UUID uuid2 = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); 
    bluetoothSocket2 = bluetoothDevice2.createInsecureRfcommSocketToServiceRecord(uuid2); 

    Log.d(TAG, "start connect 2."); 
    bluetoothSocket2.connect(); 
    Log.d(TAG, "finished connect 2."); 
関連する問題