You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 24, 2021. It is now read-only.
Hi.
I try the SPPServerActivity for a SPP Server Mode.
This works fine... The PC open the SPP port, and I can send and receive messages in App.
The problem is when el Client close the connection.
A Exception occurs on SPPServerController, and I don't receive "onBluetoothDeviceDisconnected" Callback, to bind a new connection.
java.io.IOException: bt socket closed, read return: -1
at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:558)
at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:88)
at java.io.InputStream.read(InputStream.java:101)
at me.kudryavka.bluecon.SPPServer.SPPServerController$CommunicationThread$ReadThread.run(SPPServerController.java:423)
The Exception is generate here. In SPPServerController.java, when try to read a closed socket.
@Override
public void run() {
byte[] data = new byte[buffSize];
int len;
while (true) {
try {
len = inputStream.read(data);
byte[] read = new byte[len];
System.arraycopy(data, 0, read, 0, len);
for (SPPListener sppListener : sppListeners) {
sppListener.onPacketReceived(socket.getRemoteDevice().getAddress(), read);
}
} catch (IOException e) {
Log.e(TAG, "CONNECTION CLOSED BY PEER", e);
disconnected(socket, this);
break;
}
}
}