Kaydet (Commit) 2244bb14 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Add comments, logging, empty lines

Change-Id: Ife81ec74b36f71782997219e36ac926ea429c297
üst b3729421
...@@ -183,6 +183,8 @@ public class SelectorActivity extends SherlockActivity { ...@@ -183,6 +183,8 @@ public class SelectorActivity extends SherlockActivity {
} }
void doBindService() { void doBindService() {
// This is what creates the first (only?) CommunicationService instance
// and calls its run() method (in another thread).
Intent aIntent = new Intent(this, CommunicationService.class); Intent aIntent = new Intent(this, CommunicationService.class);
startService(aIntent); startService(aIntent);
bindService(aIntent, mConnection, Context.BIND_IMPORTANT); bindService(aIntent, mConnection, Context.BIND_IMPORTANT);
......
...@@ -36,6 +36,9 @@ public class BluetoothClient extends Client { ...@@ -36,6 +36,9 @@ public class BluetoothClient extends Client {
Receiver aReceiver, boolean aBluetoothWasEnabled) Receiver aReceiver, boolean aBluetoothWasEnabled)
throws IOException { throws IOException {
super(aServer, aCommunicationService, aReceiver); super(aServer, aCommunicationService, aReceiver);
Log.i(Globals.TAG, "BluetoothClient(" + aServer + ")");
mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothWasEnabled = aBluetoothWasEnabled; mBluetoothWasEnabled = aBluetoothWasEnabled;
if (!mBluetoothWasEnabled) { if (!mBluetoothWasEnabled) {
...@@ -45,18 +48,21 @@ public class BluetoothClient extends Client { ...@@ -45,18 +48,21 @@ public class BluetoothClient extends Client {
BluetoothDevice aDevice = mAdapter BluetoothDevice aDevice = mAdapter
.getRemoteDevice(aServer.getAddress()); .getRemoteDevice(aServer.getAddress());
mAdapter.cancelDiscovery(); mAdapter.cancelDiscovery();
// This is the "standard UUID for the Serial Port Profile". // This is the "standard UUID for the Serial Port Profile".
// I.e. the 16-bit SerialPort UUID 0x1101 inserted into the // I.e. the 16-bit SerialPort UUID 0x1101 inserted into the
// Bluetooth BASE_UUID. See // Bluetooth BASE_UUID. See
// https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm // https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm
mSocket = aDevice.createRfcommSocketToServiceRecord(UUID mSocket = aDevice.createRfcommSocketToServiceRecord(UUID
.fromString("00001101-0000-1000-8000-00805F9B34FB")); .fromString("00001101-0000-1000-8000-00805F9B34FB"));
mSocket.connect(); mSocket.connect();
Log.i(Globals.TAG, "BluetoothClient: connected"); Log.i(Globals.TAG, "BluetoothClient: connected");
mInputStream = mSocket.getInputStream(); mInputStream = mSocket.getInputStream();
mReader = new BufferedReader(new InputStreamReader(mInputStream, mReader = new BufferedReader(new InputStreamReader(mInputStream,
CHARSET)); CHARSET));
mOutputStream = mSocket.getOutputStream(); mOutputStream = mSocket.getOutputStream();
String aTemp = mReader.readLine(); String aTemp = mReader.readLine();
......
...@@ -53,6 +53,9 @@ public class Server { ...@@ -53,6 +53,9 @@ public class Server {
return mTimeDiscovered; return mTimeDiscovered;
} }
public String toString() {
return getClass().getName() + '@' + Integer.toHexString(hashCode()) + ":{" + mAddress + "," + mName + "}";
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment