Java Code Examples for android.bluetooth.BluetoothSocket#getOutputStream()
The following examples show how to use
android.bluetooth.BluetoothSocket#getOutputStream() .
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 File: Bluetooth.java From Arduino-Android-Bluetooth with GNU General Public License v2.0 | 6 votes |
public ConnectedThread(BluetoothSocket socket, String socketType) { Log.d(TAG, "create ConnectedThread: " + socketType); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 2
Source File: BluetoothManager.java From libcommon with Apache License 2.0 | 6 votes |
public ReceiverThread(final BluetoothSocket socket) { super("ReceiverThread:" + mName, socket); // if (DEBUG) Log.d(TAG, "create ReceiverThread:"); InputStream tmpIn = null; OutputStream tmpOut = null; // 受信待ち用のInputStreamと送信用のOutputStreamを取得する // 普通のInputStreamはBufferedInputStreamで、OutputStreamは // BufferedOutputStreamでラップするけどここで取得されるStreamを // ラップすると上手く動かないみたい try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (final IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 3
Source File: ConnectedThread.java From Android-Simple-Bluetooth-Example with MIT License | 6 votes |
public ConnectedThread(BluetoothSocket socket, Handler handler) { mmSocket = socket; mHandler = handler; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the input and output streams, using temp objects because // member streams are final try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 4
Source File: BluetoothClient.java From EFRConnect-android with Apache License 2.0 | 6 votes |
private void manageConnectedSocket(BluetoothSocket socket) throws IOException { synchronized (this) { os = socket.getOutputStream(); } is = socket.getInputStream(); //noinspection InfiniteLoopStatement while (true) { // While loop will terminate only upon an actual IOException // or upon a close of the socket that will also cause an IOException. int didRead = is.read(buffer); //noinspection StatementWithEmptyBody if (didRead > 0) { // TODO } } }
Example 5
Source File: BluetoothService.java From Android-Bluetooth-Fingerprint with Apache License 2.0 | 6 votes |
public ConnectedThread(BluetoothSocket socket) { Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; mInStream = tmpIn; mOutStream = tmpOut; }
Example 6
Source File: GrblBluetoothSerialService.java From grblcontroller with GNU General Public License v3.0 | 6 votes |
public ConnectedThread(BluetoothSocket socket, String socketType) { Log.d(TAG, "create ConnectedThread: " + socketType); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException | NullPointerException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; mState = STATE_CONNECTED; }
Example 7
Source File: NTRIPService.java From api-ntrip-java-client with MIT License | 6 votes |
public BTConnectedThread(BluetoothSocket socket, String autoconfigmodel) { mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; autoconfig = autoconfigmodel; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { //Log.e(BTAG, "temp sockets not created", e); handler.sendMessage(handler.obtainMessage(MSG_BT_LOG_MESSAGE, "Could not create Streams")); handler.sendMessage(handler.obtainMessage(MSG_BT_FINISHED)); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 8
Source File: BluetoothUtility.java From SimpleBluetoothLibrary with Apache License 2.0 | 6 votes |
public ConnectedThread(BluetoothSocket socket) { mmSocket = socket; bluetoothSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the input and output streams, using temp objects because // member streams are final try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { // Log.d("ConnectedThread", e.getMessage()); } mInputStream = tmpIn; mOutputStream = tmpOut; }
Example 9
Source File: BtCommService.java From AndrOBD with GNU General Public License v3.0 | 6 votes |
BtWorkerThread(BluetoothSocket socket, String socketType) { log.log(Level.FINE, "create BtWorkerThread: " + socketType); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { log.log(Level.SEVERE, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; // set streams ser.setStreams(mmInStream, mmOutStream); }
Example 10
Source File: DeviceConnector.java From bluetooth-spp-terminal with Apache License 2.0 | 6 votes |
public ConnectedThread(BluetoothSocket socket) { if (D) Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { if (D) Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 11
Source File: MainActivity.java From rubik-robot with MIT License | 5 votes |
public void connectBluetooth() { mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!mBluetoothAdapter.isEnabled()) { Toast.makeText(this, "Enable Bluetooth and pair", Toast.LENGTH_LONG).show(); return; } BluetoothDevice device = mBluetoothAdapter.getRemoteDevice("98:D3:31:30:3B:D8"); for (BluetoothDevice x : mBluetoothAdapter.getBondedDevices()) { Log.d("Main", "Address: " + x.getAddress()); for (ParcelUuid uuid : x.getUuids()) { Log.d("Main", "parceluuid:" + uuid.toString()); } } try { mBluetoothAdapter.cancelDiscovery(); BluetoothSocket socket = device.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805f9b34fb")); socket.connect(); mRobotScheduler = new RobotScheduler(socket.getInputStream(), socket.getOutputStream(), 10); Toast.makeText(this, "Connected to arduino", Toast.LENGTH_SHORT).show(); mMapper = new SlightlyMoreAdvancedMapper(); } catch (IOException e) { Log.d("Main", "Exception connecting to bluetooth: ", e); } }
Example 12
Source File: BluetoothManager.java From BTChat with GNU General Public License v3.0 | 5 votes |
public ConnectedThread(BluetoothSocket socket) { Log.d(TAG, "create ConnectedThread"); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "temp sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 13
Source File: BCLServiceBase.java From unity-bluetooth with MIT License | 5 votes |
public ConnectedThread(BluetoothSocket socket) { mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, e.getMessage()); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 14
Source File: GodotBluetooth.java From GodotBluetooth with MIT License | 5 votes |
public ConnectedThread(BluetoothSocket newSocket) { InputStream tmpIn = null; OutputStream tmpOut = null; try { tmpIn = newSocket.getInputStream(); tmpOut = newSocket.getOutputStream(); } catch (IOException e) { } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 15
Source File: Bluetooth.java From Makeblock-App-For-Android with MIT License | 5 votes |
public ConnectedThread(BluetoothSocket socket){ mmSocket = socket; mRx = new ArrayList<Byte>(); InputStream tmpIn = null; OutputStream tmpOut = null; try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 16
Source File: BluetoothService.java From Chorus-RF-Laptimer with MIT License | 5 votes |
public ConnectedThread(BluetoothSocket socket, String socketType) { mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 17
Source File: BluetoothConnectionHelper.java From DataLogger with MIT License | 5 votes |
public ConnectedThread(BluetoothSocket socket, int index) { // Log.d(TAG, "create ConnectedThread"); mmSocket = socket; mIndex = index; InputStream tmpIn = null; OutputStream tmpOut = null; // Get the BluetoothSocket input and output streams try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { Log.e(TAG, "::ConnectedThread Input/Output stream sockets not created", e); } mmInStream = tmpIn; mmOutStream = tmpOut; }
Example 18
Source File: BluetoothActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
private void sendMessage(BluetoothSocket socket, String message) { OutputStream outputStream; try { outputStream = socket.getOutputStream(); // Add a stop character. byte[] byteArray = (message + " ").getBytes(); byteArray[byteArray.length-1] = 0; outputStream.write(byteArray); } catch (IOException e) { Log.e(TAG, "Failed to send message: " + message, e); } }
Example 19
Source File: TaskerFireReceiver.java From sony-headphones-control with GNU General Public License v3.0 | 5 votes |
static void sendPacket(BluetoothSocket socket, byte[] data) throws IOException, InterruptedException { OutputStream o = socket.getOutputStream(); InputStream i = socket.getInputStream(); byte[] packet = new byte[data.length + 3]; packet[0] = 0x3e; packet[packet.length - 1] = 0x3c; byte crc = 0; for (int j = 0; j < data.length; j++) { crc += data[j]; packet[j + 1] = data[j]; } packet[packet.length - 2] = crc; o.write(packet); byte[] buffer = new byte[256]; Date date = new Date(); while (new Date().getTime() - date.getTime() < 200) { if (i.available() > 0) { int r = i.read(buffer); StringBuilder sb = new StringBuilder(); for (int j = 0; j < r; j++) { sb.append(String.format(" %02x", buffer[j])); } // Log.i(TAG, "Read: " + r + " bytes:" + sb); break; } Thread.sleep(50); } }
Example 20
Source File: ConnectedThread.java From EasyBluetoothFrame with Apache License 2.0 | 5 votes |
private void init(BluetoothSocket socket, int mode) { handler = new Handler(Looper.getMainLooper()); mmSocket = socket; InputStream tmpIn = null; OutputStream tmpOut = null; try { tmpIn = socket.getInputStream(); tmpOut = socket.getOutputStream(); } catch (IOException e) { e.printStackTrace(); } mmInStream = tmpIn; mmOutStream = tmpOut; this.mode = mode; }