mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
slop
This commit is contained in:
+28
-45
@@ -204,51 +204,38 @@ if [[ ! -f "$CONFIG_PATH" ]]; then
|
||||
echo "Copied config.example.yaml to config.yaml; edit it before exposing the service."
|
||||
fi
|
||||
|
||||
# Use the same YAML library as the server instead of approximating nested YAML
|
||||
# with grep. This makes system configuration follow the exact explicit boolean
|
||||
# feature flag that the running Node service will use.
|
||||
BALANCE_BOARD_ENABLED=$(SERVER_DIR="$SERVER_DIR" CONFIG_PATH="$CONFIG_PATH" "$NODE_BIN" <<'NODE'
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const yaml = require(path.join(process.env.SERVER_DIR, 'node_modules', 'js-yaml'));
|
||||
const config = yaml.load(fs.readFileSync(process.env.CONFIG_PATH, 'utf8')) || {};
|
||||
process.stdout.write(config.balanceBoard?.enabled === true ? 'true' : 'false');
|
||||
NODE
|
||||
)
|
||||
echo " Configuring BlueZ for the Wii Balance Board"
|
||||
if ! modinfo hid-wiimote >/dev/null 2>&1; then
|
||||
echo "The running kernel does not provide hid-wiimote; install a Fedora kernel with that module." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$BALANCE_BOARD_ENABLED" == "true" ]]; then
|
||||
echo " Configuring BlueZ for the Wii Balance Board"
|
||||
if ! modinfo hid-wiimote >/dev/null 2>&1; then
|
||||
echo "The running kernel does not provide hid-wiimote; install a Fedora kernel with that module before enabling balanceBoard." >&2
|
||||
exit 1
|
||||
fi
|
||||
install -d -m 0755 /etc/bluetooth /etc/modules-load.d
|
||||
touch "$BLUEZ_INPUT_CONFIG"
|
||||
chmod 0644 "$BLUEZ_INPUT_CONFIG"
|
||||
# Balance Board support is a server hardware prerequisite, just like the native
|
||||
# worker and udev rule above. Install it every time instead of coupling machine
|
||||
# setup to an application setting in config.yaml; that keeps the installer
|
||||
# deterministic and lets the feature flag remain a simple runtime UI switch.
|
||||
# crudini changes only the two Wii compatibility keys and preserves every other
|
||||
# Bluetooth input option already configured by the operator.
|
||||
crudini --set "$BLUEZ_INPUT_CONFIG" General UserspaceHID false
|
||||
crudini --set "$BLUEZ_INPUT_CONFIG" General ClassicBondedOnly false
|
||||
|
||||
install -d -m 0755 /etc/bluetooth /etc/modules-load.d
|
||||
touch "$BLUEZ_INPUT_CONFIG"
|
||||
chmod 0644 "$BLUEZ_INPUT_CONFIG"
|
||||
# Modern BlueZ defaults Classic HID devices to userspace UHID and enforces a
|
||||
# security mode that breaks the Wii family's unusual legacy HID handshake.
|
||||
# crudini changes only these two keys, preserving every unrelated Bluetooth
|
||||
# input option an operator may already have configured on the server.
|
||||
crudini --set "$BLUEZ_INPUT_CONFIG" General UserspaceHID false
|
||||
crudini --set "$BLUEZ_INPUT_CONFIG" General ClassicBondedOnly false
|
||||
|
||||
# The service consumes the calibrated evdev axes created specifically by the
|
||||
# kernel hid-wiimote driver. Load it now and on every future boot so the brief
|
||||
# board wake window is never lost waiting for manual module setup.
|
||||
cat > "$BALANCE_BOARD_MODULES_LOAD" <<'EOF'
|
||||
# The service consumes calibrated evdev axes from the kernel driver. Load the
|
||||
# driver now and at every boot so a short board wake is never lost while an
|
||||
# operator manually prepares the server.
|
||||
cat > "$BALANCE_BOARD_MODULES_LOAD" <<'EOF'
|
||||
# MultiRoombaRover Wii Balance Board support.
|
||||
hid-wiimote
|
||||
EOF
|
||||
chmod 0644 "$BALANCE_BOARD_MODULES_LOAD"
|
||||
modprobe hid-wiimote
|
||||
chmod 0644 "$BALANCE_BOARD_MODULES_LOAD"
|
||||
modprobe hid-wiimote
|
||||
|
||||
# BlueZ reads input.conf only at daemon startup. Restart it during the
|
||||
# installer, before multirover is restarted below, so the new HID mode is
|
||||
# guaranteed to be active without requiring a reboot or another command.
|
||||
systemctl enable --now bluetooth.service
|
||||
systemctl restart bluetooth.service
|
||||
fi
|
||||
# BlueZ reads input.conf only at daemon startup. Restart it before the rover
|
||||
# service so the required HID mode is active immediately without a reboot.
|
||||
systemctl enable --now bluetooth.service
|
||||
systemctl restart bluetooth.service
|
||||
|
||||
tmpdir=$(mktemp -d)
|
||||
trap 'rm -rf "$tmpdir"' EXIT
|
||||
@@ -382,9 +369,5 @@ echo
|
||||
echo "Update $CONFIG_PATH to set admins, lockdown settings, and media parameters."
|
||||
echo "Kinect/libfreenect packages and udev permissions were installed."
|
||||
echo "If a Kinect is already plugged in, unplug/replug its USB/power before testing so the new udev rule applies."
|
||||
if [[ "$BALANCE_BOARD_ENABLED" == "true" ]]; then
|
||||
echo "Wii Balance Board BlueZ compatibility, kernel driver, bridge, and restricted input rule were installed."
|
||||
echo "Press the red Sync button once to commission it; later wakes use the front power button."
|
||||
else
|
||||
echo "Wii Balance Board bridge and restricted input rule were installed but system Bluetooth compatibility was left unchanged because balanceBoard is disabled."
|
||||
fi
|
||||
echo "Wii Balance Board Bluetooth support, kernel driver, bridge, and restricted input rule were installed."
|
||||
echo "Enable balanceBoard in config.yaml, press red Sync once, then use the front button for later wakes."
|
||||
|
||||
Reference in New Issue
Block a user