@Test public void secureRfcomm_notNull() throws Exception { assertThat( bluetoothAdapter.listenUsingRfcommWithServiceRecord( "serviceName", UUID.randomUUID())) .isNotNull(); }
public AcceptThread(BluetoothAdapter adapter) { BluetoothServerSocket temp = null; try { temp = adapter.listenUsingRfcommWithServiceRecord("BT", UUID.fromString(Constants.STR_UUID)); } catch (IOException e) { e.printStackTrace(); } mServerSocket = temp; }
public AcceptThread() { BluetoothServerSocket temp = null; try { temp = Bluetooth.mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME, Bluetooth.MY_UUID); } catch (IOException e) { } bluetoothServerSocket = temp; }
public AcceptThread(boolean isAndroid) { BluetoothServerSocket tmp = null; // Create a new listening server socket try { if(isAndroid) tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE); else tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE); } catch (IOException e) { } mmServerSocket = tmp; }
public AcceptThread() { BluetoothServerSocket tmp = null; try { tmp = mAdapter.listenUsingRfcommWithServiceRecord(TAG, mAppUuid); } catch (IOException e) {} mmServerSocket = tmp; }
public AcceptThread(BluetoothAdapter bluetoothAdapter, OnAcceptListener onAcceptListener) { this.onAcceptListener = onAcceptListener; BluetoothServerSocket tmp = null; try { tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(Constants.NAME, UUID.fromString(Constants.NEED_UUID)); } catch (IOException e) { } mmServerSocket = tmp; }
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket try { tmp = mAdapter .listenUsingRfcommWithServiceRecord(NAME, MY_UUID); } catch (Exception e) { Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e); } mmServerSocket = tmp; }
public ServerThread(BluetoothAdapter bluetoothAdapter, Handler handler) { this.bluetoothAdapter = bluetoothAdapter; this.uiHandler = handler; BluetoothServerSocket tmp = null; try { tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(Params.NAME, UUID.fromString(Params.UUID)); } catch (IOException e) { e.printStackTrace(); } serverSocket = tmp; Log.e(TAG, "-------------- do new()"); }
public ServerThread() { Log.d(LOG_TAG, "Initializing ServerThread"); try { Log.d(LOG_TAG, "try ServerThread with UUID: "+MY_UUID_SECURE); mBluetoothServerSocket = mBluetoothAdapter.listenUsingRfcommWithServiceRecord("SessionManagerSecure", MY_UUID_SECURE); } catch (IOException e1) { Log.e(LOG_TAG, "Error listenUsingRfcommWithServiceRecord"); e1.printStackTrace(); } }
public BluetoothServerSocket listen() { BluetoothServerSocket tmp = null; try { // TODO use an OpenXC-specific UUID tmp = getDefaultAdapter().listenUsingRfcommWithServiceRecord( "TODO", DeviceManager.RFCOMM_UUID); } catch (IOException e) { } return tmp; }
public AcceptThread(boolean secure) { BluetoothServerSocket tmp = null; mSocketType = secure ? "Secure" : "Insecure"; // Create a new listening server socket try { if (secure) { tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, MY_UUID_SECURE); } else { tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord( NAME_INSECURE, MY_UUID_INSECURE); } } catch (IOException e) { Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e); } mmServerSocket = tmp; }
public void run() { try { serverSocket = mAdaptadorBluetooth. listenUsingRfcommWithServiceRecord(SERVICO, MEU_UUID); clientSocket = serverSocket.accept(); trataSocket(clientSocket); } catch (IOException e) { mTelaHandler.obtainMessage(MSG_DESCONECTOU, e.getMessage() + "[1]").sendToTarget(); e.printStackTrace(); } } public void iniciar() {
/** * コンストラクタ * @param secure セキュア接続を待機するならtrue */ public ListeningThread(final boolean secure) { super("ListeningThread:" + mName); // Create a new listening server socket BluetoothServerSocket tmp = null; try { if (secure) { // セキュアな接続を行うためのBluetoothServerSocketを生成 tmp = mAdapter.listenUsingRfcommWithServiceRecord(mName, mSecureProfileUUID); } else { tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(mName, mInSecureProfileUUID); } } catch (final IOException e) { Log.w(TAG, e); } mmServerSocket = tmp; }
private UUID startServerSocket() { UUID uuid = UUID.randomUUID(); // Listener socket must know this value. String name = "bluetoothserver"; mBluetooth = BluetoothAdapter.getDefaultAdapter(); try { final BluetoothServerSocket btserver = mBluetooth.listenUsingRfcommWithServiceRecord(name, uuid); Thread acceptThread = new Thread(new Runnable() { public void run() { try { // Block until client connection established. mBluetoothSocket = btserver.accept(); // Start listening for messages. listenForMessages(); } catch (IOException e) { Log.e(TAG, "Server connection IO Exception", e); } } }); acceptThread.start(); } catch (IOException e) { Log.e(TAG, "Socket listener IO Exception", e); } return uuid; }
@SuppressLint("NewApi") public AcceptThread(boolean secure) { synchronized(THREAD_LOCK){ //Log.d(TAG, "Creating an Accept Thread"); BluetoothServerSocket tmp = null; mSocketType = secure ? "Secure":"Insecure"; // Create a new listening server socket try { if (secure) { tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, SERVER_UUID); } } catch (IOException e) { //Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e); //Let's try to shut down this thead }catch(SecurityException e2){ //Log.e(TAG, "<LIVIO> Security Exception in Accept Thread - "+e2.toString()); interrupt(); } mmServerSocket = tmp; //Should only log on debug //BluetoothSocket mySock = getBTSocket(mmServerSocket); //Log.d(TAG, "Accepting Connections on SDP Server Port Number: " + getChannel(mySock) + "\r\n"); } }
/** * Initialize the thread. * * @param adapter The bluetooth adapter */ public AcceptThread(BluetoothAdapter adapter, OnSocketEstablishedListener onSocketEstablishedListener, OnStateChangedListener stateListener, OnErrorListener errorListener) { super(TAG); this.onSocketEstablishedListener = onSocketEstablishedListener; this.stateListener = stateListener; this.errorListener = errorListener; BluetoothServerSocket tmp = null; try { tmp = adapter.listenUsingRfcommWithServiceRecord( Config.BLUETOOTH_SERVICE_NAME, UUID.fromString(Config.BLUETOOTH_UUID_STR)); } catch (IOException e) { Log.e(TAG, "Error:", e); errorListener.onError(OnErrorListener.ERR_SOCKET_CREATE, e); } serverSocket = tmp; }
@Override public void run() { try { serverSocket = bluetoothAdapter .listenUsingRfcommWithServiceRecord("KDE Connect", SERVICE_UUID); } catch (IOException e) { e.printStackTrace(); return; } if (continueProcessing) { try { BluetoothSocket socket = serverSocket.accept(); connect(socket); } catch (Exception ignored) { } } }
public void run() { Log.i(TAG, "Listen server started"); BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter(); try { serverSocket = btAdapter.listenUsingRfcommWithServiceRecord(PROTOCOL_SCHEME_RFCOMM, uuidSpp); Log.d(TAG, "Server socket created"); while (serverSocket != null && btAdapter.isEnabled()) { try { BluetoothSocket bluetoothSocket = serverSocket.accept(); Socket socket = new BluetoothSocketAdapter(bluetoothSocket); Log.i(TAG, ">>Connection opened (" + socket.getDestination() + ")"); BluetoothConnectionProvider.this.connectionManager.newConnection(socket); } catch (IOException e) { Log.e(TAG, "Error during accept", e); Log.i(TAG, "Waiting 5 seconds before accepting again..."); try { Thread.sleep(5000); } catch (InterruptedException e1) { } } } } catch (IOException e) { Log.e(TAG, "Error in listenUsingRfcommWithServiceRecord", e); } Log.i(TAG, "Listen server stopped"); } };
btfAdapter.listenUsingRfcommWithServiceRecord("LivroAndroid", uuid); Log.d(TAG, "Servidor aguardando conexão...");
@Override public void subscribe(@NonNull SingleEmitter<BluetoothSocket> emitter) { try { BluetoothServerSocket bluetoothServerSocket = bluetoothAdapter.listenUsingRfcommWithServiceRecord(name, uuid); try { emitter.onSuccess(bluetoothServerSocket.accept()); } finally { bluetoothServerSocket.close(); } } catch(IOException e) { emitter.onError(e); } } });