Skip to content

Commit 40d71d3

Browse files
committed
some adjusts
1 parent 928ff57 commit 40d71d3

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
# linux-bluetooth-connection-fix
22
Tries to connect bluetooth devices on Linux despite error `hci0: command 0x0c24 tx timeout`
33

4+
# Running it
5+
6+
Download the [latest release][1] then run the command below:
7+
8+
```bash
9+
$ java -jar linux-bluetooth-connection-fix.jar 94:CC:56:E5:72:85
10+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - found=false, code=0, out=null
11+
[main] WARN com.mageddo.linux.bluetoothfix.BluetoothConnector - systemctl will ask you for root password to restart bluetooth service ...
12+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - status=restarted, code=0, out=null
13+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - status=tryConnecting, device=94:DB:56:F5:78:41
14+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - found=true, code=0, out=null
15+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - status=done, occurrence=CONNECTED
16+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - status=tried, occurrence=CONNECTED, time=18218
17+
[main] INFO com.mageddo.linux.bluetoothfix.BluetoothConnector - status=successfullyConnected!, device=94:CC:56:E5:72:85, totalTime=19218
18+
```
19+
20+
# Requirements
21+
22+
* Linux
23+
* JRE 8+
24+
425
# Compiling from source
526

627
```bash
7-
$ ./gradlew build shadowJar
28+
$ ./gradlew build shadowJar
829
```
30+
31+
[1]: https://github.com/mageddo-projects/linux-bluetooth-connection-fix/releases

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=0.1.0

src/main/java/com/mageddo/linux/bluetoothfix/BluetoothConnector.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public void connect(String deviceId) {
3939
this.restartService();
4040
status = this.connect0(deviceId);
4141

42-
log.debug(
42+
log.info(
4343
"status=tried, occurrence={}, time={}",
4444
status, stopWatch.getTime() - stopWatch.getSplitTime()
4545
);
4646
Threads.sleep(1000);
4747

4848
} while (status != Occurrence.CONNECTED);
49-
log.debug(
49+
log.info(
5050
"status=successfullyConnected!, device={}, totalTime={}",
5151
deviceId, stopWatch.getTime()
5252
);
@@ -58,10 +58,10 @@ boolean disconnect(String deviceId) {
5858
"bluetoothctl --timeout %d disconnect %s", timeoutSecs, deviceId
5959
)
6060
.checkExecution();
61-
log.debug("status=disconnected, {}", result.toString(PRINT_OUT));
61+
log.info("status=disconnected, {}", result.toString(PRINT_OUT));
6262
return true;
6363
} catch (ExecutionValidationFailedException e) {
64-
log.debug("status=failedToDisconnect, {}", e.result()
64+
log.info("status=failedToDisconnect, {}", e.result()
6565
.toString(PRINT_OUT));
6666
return false;
6767
}
@@ -78,7 +78,7 @@ CommandLines.Result restartService() {
7878
}, false);
7979
final CommandLines.Result result = CommandLines.exec(cmd)
8080
.checkExecution();
81-
log.debug("status=restarted, {}", result.toString(PRINT_OUT));
81+
log.info("status=restarted, {}", result.toString(PRINT_OUT));
8282
Threads.sleep(BLUETOOTH_POWER_ON_DELAY); // wait some time to bluetooth power on
8383
return result;
8484
}
@@ -100,7 +100,7 @@ boolean isConnected(String deviceId) {
100100

101101
Occurrence connect0(String deviceId) {
102102
try {
103-
log.debug("status=tryConnecting, device={}", deviceId);
103+
log.info("status=tryConnecting, device={}", deviceId);
104104
final CommandLines.Result result = CommandLines
105105
.exec(
106106
"bluetoothctl --timeout %d connect %s", timeoutSecs, deviceId
@@ -111,7 +111,7 @@ Occurrence connect0(String deviceId) {
111111
return occurrence;
112112
}
113113
final Occurrence occur = this.connectionOccurrenceCheck(deviceId);
114-
log.debug("status=done, occurrence={}", occur);
114+
log.info("status=done, occurrence={}", occur);
115115
return occur;
116116
} catch (ExecutionValidationFailedException e) {
117117
return OccurrenceParser.parse(e.result());
@@ -148,7 +148,7 @@ boolean isSoundDeviceConfigured(String deviceId) {
148148
.getOutAsString()
149149
.contains(audioSinkId);
150150

151-
log.debug("found={}, {}", found, result.toString(PRINT_OUT));
151+
log.info("found={}, {}", found, result.toString(PRINT_OUT));
152152
return found;
153153

154154
}

0 commit comments

Comments
 (0)