-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add bluetooth control - support turn off/on (and get state)
- Loading branch information
1 parent
d7feadc
commit d922119
Showing
4 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
|
||
class Bluetooth: | ||
|
||
def __init__(self, client): | ||
self._client = client | ||
|
||
def _set(self, is_on): | ||
self._client.symbols.IOBluetoothPreferenceSetControllerPowerState(is_on) | ||
|
||
def is_on(self): | ||
return 1 == self._client.symbols.IOBluetoothPreferenceGetControllerPowerState().c_int64 | ||
|
||
def turn_on(self): | ||
self._set(is_on=1) | ||
|
||
def turn_off(self): | ||
self._set(is_on=0) | ||
|
||
def __repr__(self): | ||
return f"<Bluetooth state:{'ON' if self.is_on() else 'OFF'}>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
from rpcclient.darwin.client import DarwinClient | ||
from rpcclient.macos.bluetooth import Bluetooth | ||
|
||
|
||
class MacosClient(DarwinClient): | ||
pass | ||
|
||
def __init__(self, sock, sysname: str, hostname: str, port: int = None): | ||
super().__init__(sock, sysname, hostname, port) | ||
|
||
self.bluetooth = Bluetooth(self) |