Creating a USB-to-LAN bridge for a Spark 3
To bypass the Spark Wifi, without having to connect your Brewblox server to your Spark over USB, you can use a second Pi as a bridge. This Pi will be discovered as a Wifi Spark, and can be used as such by Spark services.
Required:
Installation
First, install the Raspberry Pi OS on your Pi.
After this is done, run:
sudo apt update
sudo apt install -y avahi-daemon socat
You do not need to install Brewblox on this Pi.
Preparation
First, we need to get the Spark device ID. To get this, run brewblox-ctl discover-spark
on your Brewblox server, and copy the Device ID value.
Example device ID for a Spark 3: 400032001047383531363134
.
Now stop your Brewblox services with brewblox-ctl down
.
We want the Spark to no longer connect to Wifi. To clear Wifi credentials, hold the SETUP button until it first blinks dark blue, and then rapidly blinks light blue.
Configuration
We’re creating two configuration files:
- a systemd service to start the bridge when the Pi starts.
- an Avahi service to let the Pi be discovered as a Spark.
Create the systemd service file at /etc/systemd/system/spark-bridge.service
[Unit]
Description=Brewblox Spark Bridge
Wants=network.target
After=syslog.target network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/socat tcp-listen:8332,reuseaddr,fork file:/dev/ttyACM0,raw,echo=0,b115200
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
To load and start the systemd service, run
sudo chmod 640 /etc/systemd/system/spark-bridge.service
sudo systemctl daemon-reload
sudo systemctl enable spark-bridge
sudo systemctl start spark-bridge
sudo systemctl status spark-bridge
Create the Avahi service configuration at /etc/avahi/services/spark-bridge.service
<?xml version="1.0" standalone="no"?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h Spark Bridge</name>
<service>
<type>_brewblox._tcp</type>
<port>8332</port>
<txt-record>ID=${DEVICE_ID}</txt-record>
<txt-record>HW=Spark 3</txt-record>
</service>
</service-group>
Replace ${DEVICE_ID}
with the device ID you copied in the Preparation step.
To load and start the service, run
sudo systemctl restart avahi-daemon
sudo systemctl status avahi-daemon
Startup
Now if you run brewblox-ctl discover-spark
on your Brewblox server, it should show a LAN Spark 3 with the IP address of your bridge Pi.
Start Brewblox with brewblox-ctl up
, and your service should connect as normal.