As stated in the title, the my bluetooth socket will only make a connection if it is ran in the debugger. When i put a breakpoint on the connect()
, it connects when i step over taking about a second to connect. When I try running in release it immediately throws an IOexception stating that read from the socket failed. I am running on android 5.1.1
Code that attempts connection
BtCommThread(BluetoothDevice btDevice, BluetoothInterface btInterface) throws IOException {//let caller handle Exception with constructor
callbacks = btInterface;
device = btDevice;
socket = device.createRfcommSocketToServiceRecord(BluetoothService.uuid);
socket.connect();//attempt connection
input = new BufferedReader(new InputStreamReader(socket.getInputStream()));//get input
output = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));//get output
}
What could cause the bluetooth socket to work in only the debugger? I have implemented a service that retries constructing my BtCommThread and connecting the socket if it fails up to ten times. I have also tried adding a simple thread sleep before the connect thinking it could possibly be a timing issue. I am really at a loss.
Does anyone have an idea what might help?
Hardware Information
Android Phone: Google Nexus 5
Linux System: Udoo MCU running debian armhf