Hi folks, I’ve been working for a bit on this, a Kotlin client for the Websocket API. (Before anyone asks, I’m not planning on writing any apps). I originally wrote a client in C++ for the arduino, but went through absolute hell debugging it (embedded programming is fun). After some tearing my hair out I decided to move away from learning a new API in an uncomfortable language on a difficult to debug platform and write something in a more comfortable environment for me. I’m glad I did, because in the end I completely scrapped the interface and interaction model I’d planned out and I’m very happy with the result.
The API doesn’t really favor request-response interaction, so this library discourages it. Instead it favors outbound messages as fire-and-forget and allows the configuration of watcher methods to receive inbound messages. It only implements the core everyday usage API right now, but I did my best to make it easy to extend, even without changes to the client library.
Other than the pretty standard “Send a message” functionality, also offerred:
- Send a message every $interval
- Send a message and await a response (Though this is discouraged)
- Expose a channel for writes to a control or something else that allows saving to flash, with handling of how often to save.
- An optional cache that keeps up to date on the current state of the connected Pixelblaze
- A client for the discovery service
- Defaults for everything, but everything configurable
In progress:
- Handling of image data received from the Pixelblaze
- Client for the sensor data protocol
I’ve worked with a lot of bad API clients, and I tried to put together something worthwhile here. I’d love thoughts or help testing things, and especially the addition of more aspects of the API. It’s very much still a work in progress and not yet published to a repository, but some other eyes on it would help a great deal.
Enjoy!
Edit: Forgot, here’s a few examples of usage: kotlin-pixelblaze-client/core/src/main/kotlin/industries/hannah/pixelblaze/examples at main · hkolbeck/kotlin-pixelblaze-client · GitHub