Skip to content

Commit

Permalink
Merge pull request JunTingLin#30 from bosh-wang/master
Browse files Browse the repository at this point in the history
fixed: app crashing due to not enabling bluetooth
  • Loading branch information
JunTingLin authored Aug 24, 2023
2 parents 7358f2b + 0893ab5 commit c543c8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package com.junting.drug_android_frontend.services.BTServices;


import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.util.Log;


import java.io.IOException;
import java.io.OutputStream;

public class BluetoothSocket{

SerialSocket ss = new SerialSocket();
public SerialSocket ss = new SerialSocket();

// calling this function to send the message to the device
public void openPillbox(String cellPosition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
public class SerialSocket{

private static final UUID BLUETOOTH_SPP = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
private BluetoothSocket socket;
public BluetoothSocket socket;

public SerialSocket() {
run();
}
void write(byte[] data) throws IOException {
socket.getOutputStream().write(data);
if (socket != null){
socket.getOutputStream().write(data);
}
}
public void close(){
try {
Expand All @@ -35,6 +37,7 @@ public void run() {
socket.connect();
}
catch (Exception e) {
socket = null;
e.printStackTrace();
}
}
Expand Down

0 comments on commit c543c8a

Please sign in to comment.