Skip to content

Commit

Permalink
make bluetooth init more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
b3nn0 committed Sep 22, 2024
1 parent 4812d1e commit ff1f01d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __lib__systemd__system__stratux.service
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=Stratux
After=network.target
After=network.target bluetooth.target

[Service]
ExecStartPre=/opt/stratux/bin/stratux-pre-start.sh
Expand Down
10 changes: 7 additions & 3 deletions main/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,13 @@ func initBluetooth() {
if len(globalSettings.BleOutputs) == 0 {
return
}
if err := bleAdapter.Enable(); err != nil {
addSingleSystemErrorf("BLE", "Failed to init BLE adapter: %s", err.Error())
return
for {
if err := bleAdapter.Enable(); err != nil {
log.Printf("Failed to init BLE adapter: %s", err.Error())
time.Sleep(5 * time.Second)
} else {
break
}
}
services := []bluetooth.UUID{}
for _, conn := range globalSettings.BleOutputs {
Expand Down

0 comments on commit ff1f01d

Please sign in to comment.