Pixelspark Wireless Led Protocol (PWLP) server

Building

Regular build

sh cargo build

For Raspberry Pi

sh cargo build --target=arm-unknown-linux-musleabi --features=raspberrypi

To streamline building and uploading to a Raspberry Pi, use build_pi.sh. Add the following to your SSH config file (~/.ssh/config):

Host rpi HostName raspberrypi.local User pi IdentityFile ~/.ssh/id_rsa StrictHostKeyChecking no UserKnownHostsFile /dev/null

After adding your SSH public key (~/.ssh/id_rsa.pub) to ~/.ssh/authorized_keys on the Pi, you will be able to upload without using a password. If you don't have an SSH key yet, run ssh-keygen.

WASM

sh cargo install wasm-pack wasm-pack build --target=web --release -- --no-default-features --features=wasm

See index.html for a usage example. To test:

sh npm install -g http-server http-server

Programs

The binaries will include several default programs as binaries; these are in the src/programs folder and can be rebuilt using ./generate_programs.sh:

Usage

````

Compile a script

cargo run -- compile test/random.txt test/random.bin

Test run a script

cat test/random.txt | cargo run -- run

Serve programs to devices (configure using config.toml)

cargo run -- serve

Run a client (configure using config.toml)

cargo run -- client

Run a program

cargo run -- run --binary test/clock.bin

Run a program on an actual strip with 100 LEDs (SPI bus 0 SS 0) on a Raspberry

cargo run -- run --binary --hardware -l 100 test/clock.bin

Run a program on an actual strip with 100 LEDs connected to SPI bus 1 slave select 1 on a Raspberry

cargo run -- run --binary --hardware --bus 1 --ss 1 -l 100 test/clock.bin ````

Protocol

The PLWP protocol devices a message format as well as an instruction architecture. Scripts are compiled to this architecture and transmitted using the message format to the devices, who will execute them.

For more information see protocol.md.

Script language

Example scripts can be found in the test folder.

Statements

Consecutive statements are separated by ";". Supported constructs:

Expressions

Supported operators:

API

GET /

Get server status. Can be used for health checking.

json {}

GET /devices

Returns a list of devices currently or previously connected.

json { "devices": { "aa-bb-cc-dd-ee-ff": { "address": "1.2.3.4:5678", "program": [10, 11, 12, ...] } } }

GET /devices/<mac>

Returns information on a specific device

json { "address": "1.2.3.4:5678", "program": [10, 11, 12, ...] }

GET /devices/<mac>/<program_name>

Send a built-in program to the device. Built-in program names:

json {}

License

MIT