GitHub logo Build Status Version badge

OLED menu microservice module for PeachCloud. A state machine which listens for GPIO events (button presses) by subscribing to peach-buttons over websockets and makes JSON-RPC calls to relevant PeachCloud microservices (peach-network, peach-oled, peach-stats).

Note: This module is a work-in-progress.

Directory Tree

├── Cargo.lock
├── Cargo.toml
├── src
│   ├──          // JSON-RPC WebSocket client for peach-buttons
│   ├──            // custom MenuError type & From implementations
│   ├──              // launch state machine & RPC client for buttons
│   ├──             // init logger, call run() & catch application errors
│   ├──          // JSON-RPC HTTP client for peach-network
│   ├──             // JSON-RPC HTTP client for peach-oled
│   ├──    // state machine & state_changer()
│   ├──           // state-specific logic called by state machine
│   ├──            // JSON-RPC HTTP client for peach-stats
│   └──          // data types used by RPC clients

Button Code Mappings

0 => Center,  
1 => Left,  
2 => Right,  
3 => Up,  
4 => Down,  
5 => A,  
6 => B


Home(0),        // home menu
Home(1),        // networking selected
Home(2),        // system stats selected
Home(3),        // display off selected
Home(4),        // shutdown selected 
Logo,           // logo splash screen
Network,        // network device view
NetworkConf(0), // network configuration menu
NetworkConf(1), // client mode selected
NetworkConf(2), // access point mode selected
NetworkMode(0), // client mode activated
NetworkMode(1), // access point mode activated
OledPower(0),   // oled display off
OledPower(1),   // oled display on
Reboot,         // rebooting
Shutdown,       // shutting down
Stats,          // system statistics view


Clone this repo:

git clone

Move into the repo and compile:

cd peach-menu
cargo build --release

Run the binary:


Note: Will currently panic if peach_buttons is not running (connection to ws server fails).


The JSON-RPC HTTP server address and port for the OLED microservice can be configured with the PEACH_OLED_SERVER environment variable:


When not set, the value defaults to

Logging is made available with env_logger:

export RUST_LOG=info

Other logging levels include debug, warn and error.


This work was made much, much easier by the awesome blog post titled Pretty State Machine Patterns in Rust by hoverbear. Thanks hoverbear!