android.bluetooth.BluetoothServerSocket Java Examples
The following examples show how to use
android.bluetooth.BluetoothServerSocket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: connectivity-samples Author: android File: BluetoothChatService.java License: Apache License 2.0 | 6 votes |
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; mState = STATE_LISTEN; }
Example #2
Source Project: ClassicBluetooth Author: sdwfqin File: CbtServiceListener.java License: Apache License 2.0 | 6 votes |
/** * 初始化 * * @return */ public void init(BluetoothAdapter bluetoothAdapter, ServiceListenerCallback callback) { mListenerCallback = callback; if (mBluetoothAdapter != null || mBluetoothServerSocket != null) { return; } mBluetoothAdapter = bluetoothAdapter; BluetoothServerSocket tmp = null; try { // 明文传输,无需配对 // adapter.listenUsingInsecureRfcommWithServiceRecord(TAG, SPP_UUID); // 加密传输,会自动执行配对 tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord(CbtConstant.CBT_NAME, CbtConstant.CBT_UUID); } catch (IOException e) { mListenerCallback.onStartError(e); CbtLogs.e(e.getMessage()); return; } mBluetoothServerSocket = tmp; listener(); }
Example #3
Source Project: grblcontroller Author: zeevy File: GrblBluetoothSerialService.java License: GNU General Public License v3.0 | 6 votes |
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 | NullPointerException e) { Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e); } mmServerSocket = tmp; mState = STATE_LISTEN; }
Example #4
Source Project: libcommon Author: saki4510t File: BluetoothManager.java License: Apache License 2.0 | 6 votes |
/** * コンストラクタ * @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; }
Example #5
Source Project: secureit Author: mziccard File: BluetoothServerTask.java License: MIT License | 6 votes |
public BluetoothServerTask(Context context) throws NoBluetoothException { Log.i("BluetoothServerTask", "Created"); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { // Device does not support Bluetooth throw new NoBluetoothException(); } this.context = context; Log.i("BluetoothServerTask", "Got adapter"); // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord( Remote.BLUETOOTH_NAME, Remote.BLUETOOTH_UUID); Log.i("BluetoothServerTask", "Created insecure server socket"); } catch (IOException e) { throw new NoBluetoothException(); } mmServerSocket = tmp; }
Example #6
Source Project: ELM327 Author: Hesamedin File: BluetoothIOGateway.java License: Apache License 2.0 | 6 votes |
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) { MyLog.e(TAG, "Listen to " + mSocketType + " socket type failed. More: ", e); } mmServerSocket = tmp; }
Example #7
Source Project: tilt-game-android Author: mediamonks File: BluetoothServerService.java License: MIT License | 6 votes |
public AcceptThread(boolean secure) { _socketType = secure ? "Secure" : "Insecure"; // Create a new listening server socket BluetoothServerSocket serverSocket = null; try { if (secure) { if (_debug) Log.d(TAG, "AcceptThread: started listening secure, uuid = " + _secureUuid + ", spd name = " + _secureSPDName); serverSocket = _adapter.listenUsingRfcommWithServiceRecord(_secureSPDName, _secureUuid); } else { if (_debug) Log.d(TAG, "AcceptThread: started listening insecure, uuid = " + _insecureUuid + ", spd name = " + _insecureSPDName); serverSocket = _adapter.listenUsingInsecureRfcommWithServiceRecord(_insecureSPDName, _insecureUuid); } } catch (IOException e) { Log.e(TAG, "AcceptThread: listen failed"); e.printStackTrace(); } _serverSocket = serverSocket; _isListening = true; }
Example #8
Source Project: PodEmu Author: xtensa File: SerialInterface_BT.java License: GNU General Public License v3.0 | 6 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket try { PodEmuLog.debug("SIBT: AcceptThread connecting with btdev_uuid_idx=" + btdev_uuid_idx); tmp = btAdapter.listenUsingRfcommWithServiceRecord(getName(), BTDEV_UUID[btdev_uuid_idx]); } catch (IOException e) { PodEmuLog.debug("SIBT: AcceptThread listen() failed"); PodEmuLog.printStackTrace(e); } mmServerSocket = tmp; }
Example #9
Source Project: AndroidSmoothBluetooth Author: palaima File: BluetoothService.java License: Apache License 2.0 | 6 votes |
public AcceptThread(boolean isAndroid, boolean secure) { BluetoothServerSocket tmp = null; // Create a new listening server socket try { if (secure) { if(isAndroid) tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE); else tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE); } else { if(isAndroid) tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_ANDROID_DEVICE); else tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(NAME_SECURE, UUID_OTHER_DEVICE); } } catch (IOException e) { } mmServerSocket = tmp; }
Example #10
Source Project: SimpleBluetoothLibrary Author: DeveloperPaul123 File: BluetoothUtility.java License: Apache License 2.0 | 6 votes |
public AcceptThread() { // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(SERVER_NAME, SERVER_UUID); } catch (IOException e) { } mmServerSocket = tmp; if(bluetoothHandler != null) { bluetoothHandler .obtainMessage(BluetoothHandler.MESSAGE_WAIT_FOR_CONNECTION) .sendToTarget(); } }
Example #11
Source Project: android-BluetoothChat Author: googlearchive File: BluetoothChatService.java License: Apache License 2.0 | 6 votes |
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; mState = STATE_LISTEN; }
Example #12
Source Project: sdl_java_suite Author: smartdevicelink File: MultiplexBluetoothTransport.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@SuppressLint("NewApi") @RequiresPermission(Manifest.permission.BLUETOOTH) 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"); } }
Example #13
Source Project: gilgamesh Author: n8fr8 File: DirectMessageSession.java License: GNU General Public License v3.0 | 6 votes |
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; }
Example #14
Source Project: NovarumBluetooth Author: halilkabaca File: NovarumbluetoothModule.java License: MIT License | 6 votes |
public AcceptThread() { // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(SERVERNAME, UUID.fromString(DEFAULT_UUID)); } catch (IOException e) { postError(e.getMessage()); } mmServerSocket = tmp; }
Example #15
Source Project: NovarumBluetooth Author: halilkabaca File: BluetoothService.java License: MIT License | 6 votes |
public AcceptThread() { // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(SERVERNAME, UUID.fromString(DEFAULT_UUID)); } catch (IOException e) { postError(e.getMessage()); } mmServerSocket = tmp; }
Example #16
Source Project: DataLogger Author: STRCWearlab File: BluetoothConnectionHelper.java License: MIT License | 5 votes |
public AcceptThread(int index) { mIndex = index; BluetoothServerSocket tmp = null; // Create a new listening server socket try { tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord( NAME, UUID.fromString(mUUIDs[mIndex])); } catch (IOException e) { Log.e(TAG, "::AcceptThread Socket listen() at "+ mIndex + " failed.", e); } mmServerSocket = tmp; }
Example #17
Source Project: EFRConnect-android Author: SiliconLabs File: BluetoothServer.java License: Apache License 2.0 | 5 votes |
public BluetoothServer(BluetoothAdapter bluetoothAdapter, String serviceName, UUID serviceUUID) { // Use a temporary object that is later assigned to mmServerSocket, // because mmServerSocket is final BluetoothServerSocket tmp = null; try { // MY_UUID is the app's UUID string, also used by the client code tmp = bluetoothAdapter.listenUsingRfcommWithServiceRecord(serviceName, serviceUUID); } catch (IOException ignored) { } serverSocket = tmp; }
Example #18
Source Project: Chorus-RF-Laptimer Author: voroshkov File: BluetoothService.java License: MIT License | 5 votes |
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; }
Example #19
Source Project: BluetoothStudy Author: QiaoJim File: ServerThread.java License: Apache License 2.0 | 5 votes |
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()"); }
Example #20
Source Project: UnityBluetoothPlugin Author: rlatkdgus500 File: BluetoothService.java License: Apache License 2.0 | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; try { tmp = BluetoothService.this.mBtAdapter.listenUsingRfcommWithServiceRecord("BluetoothPlugin", BluetoothService.MY_UUID); } catch (IOException e) { Log.e(TAG, "listen() failed", e); } this.mmServerSocket = tmp; }
Example #21
Source Project: SmartOrnament Author: fergus825 File: AcceptThread.java License: Apache License 2.0 | 5 votes |
public AcceptThread(BluetoothAdapter bluetoothAdapter, Handler handler) { mBluetoothAdapter=bluetoothAdapter; BluetoothServerSocket tmp = null; mHandler=handler; try { //监听RFCOMM tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord( "Bluetooth_Chat_Room", UUID.fromString(UUID_STR)); } catch (IOException e) { } mServerSocket = tmp; }
Example #22
Source Project: unity-bluetooth Author: seiji File: BCLServiceServer.java License: MIT License | 5 votes |
private AcceptThread() { BluetoothServerSocket tmp = null; try { tmp = mBtAdapter.listenUsingRfcommWithServiceRecord("_", UUID.fromString(CHARACTERISTIC_UUID)); } catch (IOException e) { Log.e(TAG, e.getMessage()); } mmServerSocket = tmp; }
Example #23
Source Project: Droid2JoyStick Author: akexorcist File: BluetoothService.java License: Apache License 2.0 | 5 votes |
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; }
Example #24
Source Project: Car_remote_control Author: hongfeiyucode File: BluetoothChatService.java License: GNU General Public License v3.0 | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; try { tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID); } catch (IOException e) { Log.e(TAG, "listen() failed", e); } mmServerSocket = tmp; }
Example #25
Source Project: Android-Bluetooth-Fingerprint Author: lethalskillzz File: BluetoothService.java License: Apache License 2.0 | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket try { tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID); } catch (IOException e) { Log.e(TAG, "listen() failed", e); } mmServerSocket = tmp; }
Example #26
Source Project: Arduino-Android-Bluetooth Author: coconauts File: Bluetooth.java License: GNU General Public License v2.0 | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket try { tmp = mAdapter .listenUsingRfcommWithServiceRecord(NAME, MY_UUID); } catch (IOException e) { Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e); } mmServerSocket = tmp; }
Example #27
Source Project: esc-pos-android Author: iYaroslav File: BTService.java License: Apache License 2.0 | 5 votes |
public MainThread() { Log.d(TAG, "Main thread created"); BluetoothServerSocket tmp = null; try { tmp = adapter.listenUsingRfcommWithServiceRecord(BT_NAME, BT_UUID); } catch (IOException ignored) { } serverSocket = tmp; }
Example #28
Source Project: PodEmu Author: xtensa File: SerialInterface_BT.java License: GNU General Public License v3.0 | 5 votes |
public SerialInterface_BT () { btAdapter = BluetoothAdapter.getDefaultAdapter(); if (btAdapter == null) { // Device does not support Bluetooth PodEmuLog.debug("SIBT: device does not support Bluetooth."); btServerSocket = null; return; } if (!btAdapter.isEnabled()) { // Bluetooth is still disabled :( PodEmuLog.debug("SIBT: Bluetooth is disabled. Not trying to turn it on though..."); btServerSocket = null; return; } // Use a temporary object that is later assigned to mmServerSocket // because mmServerSocket is final. BluetoothServerSocket tmp = null; try { PodEmuLog.debug("SIBT: SerialInterface_BT connecting with btdev_uuid_idx=0"); tmp = btAdapter.listenUsingRfcommWithServiceRecord(getName(), BTDEV_UUID[0]); } catch (IOException e) { PodEmuLog.debug("SIBT: Socket's listen() method failed"); PodEmuLog.printStackTrace(e); } btServerSocket = tmp; btState = STATE_NONE; }
Example #29
Source Project: BTChat Author: godstale File: BluetoothManager.java License: GNU General Public License v3.0 | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket try { tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME, MY_UUID); } catch (IOException e) { Log.e(TAG, "listen() failed" + e.toString()); } mmServerSocket = tmp; }
Example #30
Source Project: boogie-board-sync-sdk-android Author: kent-displays File: SyncStreamingService.java License: MIT License | 5 votes |
public AcceptThread() { BluetoothServerSocket tmp = null; // Create a new listening server socket. try { tmp = mBluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord("Sync Streaming Profile", LISTEN_UUID); } catch (IOException e) { Log.e(TAG, "listen() failed", e); } mServerSocket = tmp; }