Skip to content

Commit

Permalink
add bluetooth control - support turn off/on (and get state)
Browse files Browse the repository at this point in the history
  • Loading branch information
BarVaserman committed Feb 14, 2022
1 parent d7feadc commit d922119
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
Empty file added src/__init__.py
Empty file.
Empty file added src/rpcclient/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions src/rpcclient/rpcclient/macos/bluetooth.py
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'}>"
7 changes: 6 additions & 1 deletion src/rpcclient/rpcclient/macos/client.py
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)

0 comments on commit d922119

Please sign in to comment.