Crate ebyte_e32_ui

source ·
Expand description

Ebyte module control.

ebyte-e32-ui

Ebyte E32 Command Line Interface + minimal GUI.

Works with Ebyte-E32 LoRa modules with configurable pin assignment. The Linux sysfs interface is used to interact with GPIO and the serial port.

Uses ebyte-e32-rs as a driver, plus some traits from embedded-hal and their implementations from linux-embedded-hal.

For the CLI, clap is used.

For the GUI, on top of clap, klask is used.

Example Pinout

Configurable with Config.toml in the same directory as the binary:

serial_path = "/dev/ttyAMA0"
baudrate = 9600
parity = "None"
data_bits = 8
stop_bits = 1
aux_pin = 18
m0_pin = 23
m1_pin = 24
Ebyte PinRaspberry Pi Pin (BCM pin number)
VCC3v3
GNDGND
AUX18
M023
M124
TX15 (RX)
RX14 (TX)

A Note about SYSFS GPIO Pins

To have access to the configured sysfs gpio pins, you may need to enable them first. This can be done by:

echo 18 > /sys/class/gpio/export
echo 23 > /sys/class/gpio/export
echo 24 > /sys/class/gpio/export

This way, the settings will not persist over reboots, but it’s good for experimentation.

To re-apply the settings on each boot,

  • install sysfsutils,
  • check its status with systemctl status sysfsutils
  • create a file /etc/sysfs.d/local-gpio.conf:
  • reboot, then check with ls /sys/class/gpio that the expected pin directories have been created.
class/gpio/export = 18
class/gpio/export = 23
class/gpio/export = 24

Usage

  • CLI: cargo run --bin ebyte-e32-cli -- [OPTIONS] --address <ADDRESS> --channel <CHANNEL> {listen|send|read-model-data}. For send mode, enter your messages in the prompt or pipe them in via stdin.
  • GUI: cargo run or cargo run --bin ebyte-e32-gui. For send mode, the input provided in the Input tab is sent (there, you can also open a file to read the input from).

Persistence

With the persistence argument, the settings can be saved temporary or permanent. In permanent mode, the settings will be persisted onto the LoRa module.

Screenshots

You can run the GUI on your normal OS for testing.

Portability

This program requires only the sysfs interface. It used to only run on Raspberry Pis, but this limitation has been dropped.

Of course, the underlying driver (ebyte-e32-rs) is platform-agnostic (doesn’t require linux, just implementations of embedded-hal).

CLI Help

ebyte-e32-ui 0.2.0
CLI interface definition

USAGE:
    ebyte-e32-cli [OPTIONS] --address <ADDRESS> --channel <CHANNEL> <SUBCOMMAND>

OPTIONS:
    -a, --address <ADDRESS>
            Module Address (16 Bit)

        --air-rate <AIR_RATE>
            Air Baudrate [default: bps2400] [possible values: bps300, bps1200, bps2400, bps4800,
            bps9600, bps19200]

    -c, --channel <CHANNEL>
            Channel (8 Bit)

        --fec <FEC>
            Forward Error Correction Mode [default: on] [possible values: on, off]

    -h, --help
            Print help information

        --io-drive-mode <IO_DRIVE_MODE>
            IO drive Mode for AUX pin [default: push-pull] [possible values: push-pull,
            open-collector]

        --persistence <PERSISTENCE>
            Whether settings should be saved persistently on the module [default: temporary]
            [possible values: temporary, permanent]

        --transmission-mode <TRANSMISSION_MODE>
            Transmission Mode [default: transparent] [possible values: transparent, fixed]

        --transmission-power <TRANSMISSION_POWER>
            Transmission Power [default: dbm30] [possible values: dbm30, dbm27, dbm24, dbm21]

        --uart-parity <UART_PARITY>
            UART Parity [default: none] [possible values: none, odd, even]

        --uart-rate <UART_RATE>
            UART Baudrate [default: bps9600] [possible values: bps1200, bps2400, bps4800, bps9600,
            bps19200, bps38400, bps57600, bps115200]

    -V, --version
            Print version information

        --wakeup-time <WAKEUP_TIME>
            Wireless Wakeup Time [default: ms250] [possible values: ms250, ms500, ms750, ms1000,
            ms1250, ms1500, ms1750, ms2000]

SUBCOMMANDS:
    help               Print this message or the help of the given subcommand(s)
    listen             Listen for incoming data on the Ebyte module
    read-model-data    Read Ebyte module data and print to stdout
    send               Send data from stdin over the Ebyte module

Raspberry Pi Serial Port Setup

The serial port hardware peripheral must be enabled (but without login shell).

Simplified Dependency Graph

graph

Modules

Command line interface. A CLI interface with configuration data for running an Ebyte module.
Configuration from Config.toml.

Functions

Load a configuration from Config.toml, returning an error if something goes wrong.
Setup the hardware, then load some parameters, update them if needed, then listen, send, or read model data.