https://github.com/buckley-w-david/smart-device-client
https://github.com/buckley-w-david/smart-device-client
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/buckley-w-david/smart-device-client
- Owner: buckley-w-david
- License: mit
- Created: 2021-11-24T03:33:39.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-24T20:50:57.000Z (almost 4 years ago)
- Last Synced: 2025-01-28T02:11:46.238Z (9 months ago)
- Language: Python
- Size: 27.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Smart Device Client
This is a package meant to facilitate writing clients for the calibre wireless device connection. It is also mostly a learning excercise on my part to get my head around the protocol to talk to calibre as a wireless device.
Implementation heavily inspired by the `calibre.koplugin` plugin in [koreader](https://github.com/koreader/koreader).
## Usage
```python
from smart_device_client import SmartDeviceClient, SmartDeviceOpcode
import shutilimport logging
logging.basicConfig(level=logging.DEBUG)# Inherit from SmartDeviceClient
class MySmartDeviceClient(SmartDeviceClient):
# Implement methods according to your environment
def on_free_space(self, message):
_, _, free = shutil.disk_usage("/")
# Return the mesages that should be sent
return (SmartDeviceOpcode.OK, {"free_space_on_device": free})...
# Init the client (or do it manually providing a host and port)
client = MySmartDeviceClient.find_calibre_server()
# And serve
client.serve()
```