Skip to content

Commit e1ac8f1

Browse files
authored
Exit with error code if connect/disconnect fails
1 parent 173686a commit e1ac8f1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

BluetoothConnector.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@ if !bluetoothDevice.isPaired() {
5151
exit(-4)
5252
}
5353

54+
var error : IOReturn = -1
55+
5456
if bluetoothDevice.isConnected() {
5557
if (action == "disconnect" || action == nil) {
56-
bluetoothDevice.closeConnection()
58+
error = bluetoothDevice.closeConnection()
5759
}
5860
}
5961
else {
6062
if (action == "connect" || action == nil) {
61-
bluetoothDevice.openConnection()
63+
error = bluetoothDevice.openConnection()
6264
}
6365
}
66+
67+
if error > 0 {
68+
print("\(action ?? "toggle") failed")
69+
exit(-1)
70+
}

0 commit comments

Comments
 (0)