Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean open (int inputPipe, int channel, boolean secure) {
- Log.d(LOG_TAG, "AJ: Inside open, channel:"+channel+", secure:"+secure);
- if (channel == 0) {
- try {
- bluetoothSocket = secure? bluetoothDevice.createRfcommSocketToServiceRecord(SERIAL_PROFILE_UUID):
- bluetoothDevice.createInsecureRfcommSocketToServiceRecord(SERIAL_PROFILE_UUID);
- } catch (IOException exception) {
- Log.e(LOG_TAG, "Bluetooth UUID resolution failed: " + bluetoothAddress + ": " + exception.getMessage());
- bluetoothSocket = null;
- }
- } else {
- Log.d(LOG_TAG, "AJ: createRfcommSocket");
- bluetoothSocket = createRfcommSocket(bluetoothDevice, channel);
- }
- if (bluetoothSocket != null) {
- try {
- Log.d(LOG_TAG, "AJ: before connect()");
- bluetoothSocket.connect();
- inputStream = bluetoothSocket.getInputStream();
- outputStream = bluetoothSocket.getOutputStream();
- Log.d(LOG_TAG, "AJ: before pipe creation");
- {
- File pipeFile = new File("/proc/self/fd/" + inputPipe);
- pipeStream = new FileOutputStream(pipeFile);
- }
- Log.d(LOG_TAG, "AJ: before inputThread.start()");
- inputThread = new InputThread();
- inputThread.start();
- Log.d(LOG_TAG, "AJ: Ok, return");
- return true;
- } catch (IOException openException) {
- Log.e(LOG_TAG, "Bluetooth connect failed: " + bluetoothAddress + ": " + openException.getMessage());
- }
- }
- close();
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement