Compare commits

...

15 Commits

Author SHA1 Message Date
261359f973 fix: improve error handling in NetworkManager hotspot configuration 2026-03-16 09:05:48 +01:00
63a33f4deb fix: enhance NetworkManager hotspot configuration and cleanup process 2026-03-16 08:58:36 +01:00
12ff47207e fix: enhance AP and client mode switching with NetworkManager support 2026-03-16 08:50:26 +01:00
4ad82a1a66 fix: refactor networking scripts for improved robustness and clarity 2026-03-16 08:42:26 +01:00
855339ef42 fix: harden NetworkManager hotspot creation to prevent supplicant-timeout errors on Pi 3B 2026-03-16 08:26:41 +01:00
4e1858de61 fix: make setup script WiFi-safe by removing instant network activation 2026-03-16 00:10:50 +01:00
6fea68f903 fix: force NetworkManager hotspot priority and disconnect active client wifi to ensure AP activation 2026-03-15 23:56:38 +01:00
237ff76670 fix: implement NetworkManager (nmcli) hotspot support for modern Debian/Trixie systems 2026-03-15 23:49:10 +01:00
1aa5717891 fix: enforce absolute unmasking and disable default wifi networking to ensure AP mode success 2026-03-15 23:41:12 +01:00
46b5361ef7 feat: skip compilation and use pre-compiled ofxPiMapper binary for instant setup 2026-03-15 23:20:15 +01:00
778f31a8e7 ci: add pre-built artifacts (frontend/dist + bin/ofxPiMapper) 2026-03-15 22:01:21 +00:00
260a8f16cb fix: implement lightning-fast engine setup by utilizing pre-compiled OpenFrameworks correctly and avoiding core re-compilation 2026-03-15 16:41:53 +01:00
82813baa58 fix: implement path-agnostic source patching and refine global compatibility header logic 2026-03-15 15:56:17 +01:00
705b698b1d fix: enforce -O0 optimization and VRP disable to bypass compiler crashes on Pi 3B 2026-03-15 09:16:35 +01:00
e0e06978b2 fix: enforce clean ofxPiMapper addon state and implement high-powered global compatibility header to resolve syntax and namespace errors 2026-03-15 09:04:01 +01:00
6 changed files with 319 additions and 147 deletions

8
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"chat.tools.terminal.autoApprove": {
"/^bash -n scripts/setup\\.sh && bash -n scripts/switch-to-ap\\.sh && bash -n scripts/switch-to-client\\.sh$/": {
"approve": true,
"matchCommandLine": true
}
}
}

View File

@ -9,6 +9,8 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const multer = require('multer'); const multer = require('multer');
const scriptsDir = path.join(__dirname, '../scripts');
const app = express(); const app = express();
app.use(express.json()); app.use(express.json());
app.use(express.static(path.join(__dirname, '../frontend/dist'))); app.use(express.static(path.join(__dirname, '../frontend/dist')));
@ -120,14 +122,14 @@ app.post('/media/assign', (req, res) => {
// Networking API // Networking API
app.post('/network/ap', (req, res) => { app.post('/network/ap', (req, res) => {
exec('bash scripts/switch-to-ap.sh', (err, stdout) => { exec(`bash "${path.join(scriptsDir, 'switch-to-ap.sh')}"`, (err, stdout) => {
if (err) return res.status(500).json({ error: err.message }); if (err) return res.status(500).json({ error: err.message });
res.json({ status: 'switching to ap', output: stdout }); res.json({ status: 'switching to ap', output: stdout });
}); });
}); });
app.post('/network/client', (req, res) => { app.post('/network/client', (req, res) => {
exec('bash scripts/switch-to-client.sh', (err, stdout) => { exec(`bash "${path.join(scriptsDir, 'switch-to-client.sh')}"`, (err, stdout) => {
if (err) return res.status(500).json({ error: err.message }); if (err) return res.status(500).json({ error: err.message });
res.json({ status: 'switching to client', output: stdout }); res.json({ status: 'switching to client', output: stdout });
}); });

BIN
bin/ofxPiMapper Executable file

Binary file not shown.

View File

@ -3,9 +3,249 @@
# MPVJ Headless Setup Script (Final Polish & Robustness) # MPVJ Headless Setup Script (Final Polish & Robustness)
# Usage: curl -sSL <URL>/setup.sh | sudo bash -s -- <REPO_URL> # Usage: curl -sSL <URL>/setup.sh | sudo bash -s -- <REPO_URL>
set -e set -euo pipefail
REPO_URL=$1 REPO_URL=${1:-}
AP_ADDRESS="192.168.4.1/24"
AP_GATEWAY="192.168.4.1"
AP_DHCP_RANGE_START="192.168.4.20"
AP_DHCP_RANGE_END="192.168.4.150"
AP_CONNECTION_NAME="MPVJ-AP"
set_wifi_country() {
if command -v raspi-config > /dev/null 2>&1; then
raspi-config nonint do_wifi_country "$WIFI_COUNTRY" || true
fi
mkdir -p /etc/wpa_supplicant
if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ]; then
if grep -q '^country=' /etc/wpa_supplicant/wpa_supplicant.conf; then
sed -i "s/^country=.*/country=$WIFI_COUNTRY/" /etc/wpa_supplicant/wpa_supplicant.conf
else
sed -i "1icountry=$WIFI_COUNTRY" /etc/wpa_supplicant/wpa_supplicant.conf
fi
else
cat <<EOF > /etc/wpa_supplicant/wpa_supplicant.conf
country=$WIFI_COUNTRY
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
EOF
fi
if [ -f /etc/default/crda ]; then
if grep -q '^REGDOMAIN=' /etc/default/crda; then
sed -i "s/^REGDOMAIN=.*/REGDOMAIN=$WIFI_COUNTRY/" /etc/default/crda
else
echo "REGDOMAIN=$WIFI_COUNTRY" >> /etc/default/crda
fi
fi
if command -v iw > /dev/null 2>&1; then
iw reg set "$WIFI_COUNTRY" || true
fi
}
configure_wlan0_static_profile() {
if [ -f /etc/dhcpcd.conf ]; then
sed -i '/# BEGIN MPVJ AP/,/# END MPVJ AP/d' /etc/dhcpcd.conf
cat <<EOF >> /etc/dhcpcd.conf
# BEGIN MPVJ AP
interface wlan0
static ip_address=$AP_ADDRESS
nohook wpa_supplicant
# END MPVJ AP
EOF
fi
}
cleanup_legacy_access_point_stack() {
rm -f /etc/NetworkManager/conf.d/99-mpvj-unmanage-wlan0.conf
rm -f /etc/systemd/system/mpvj-ap-mode.service
systemctl disable mpvj-ap-mode.service hostapd.service dnsmasq.service 2>/dev/null || true
systemctl stop mpvj-ap-mode.service hostapd.service dnsmasq.service 2>/dev/null || true
if [ -f /etc/dhcpcd.conf ]; then
sed -i '/# BEGIN MPVJ AP/,/# END MPVJ AP/d' /etc/dhcpcd.conf
fi
}
cleanup_networkmanager_access_point_stack() {
rm -f /etc/systemd/system/mpvj-nm-ap.service
systemctl disable mpvj-nm-ap.service 2>/dev/null || true
systemctl stop mpvj-nm-ap.service 2>/dev/null || true
nmcli connection down "$AP_CONNECTION_NAME" 2>/dev/null || true
}
configure_networkmanager_access_point() {
mkdir -p /etc/systemd/system /etc/NetworkManager/conf.d
cleanup_legacy_access_point_stack
cleanup_networkmanager_access_point_stack
cat <<EOF > /etc/NetworkManager/conf.d/90-mpvj-wifi-powersave.conf
[connection]
wifi.powersave = 2
EOF
cat <<EOF > /etc/sysctl.d/90-mpvj-ap.conf
net.ipv4.ip_forward=1
EOF
systemctl enable NetworkManager.service
systemctl restart NetworkManager.service
nmcli radio wifi on || true
nmcli connection delete "$AP_CONNECTION_NAME" 2>/dev/null || true
nmcli device set wlan0 managed yes || true
nmcli device set wlan0 autoconnect yes || true
nmcli device disconnect wlan0 2>/dev/null || true
if ! nmcli --wait 30 device wifi hotspot ifname wlan0 con-name "$AP_CONNECTION_NAME" ssid "$WIFI_SSID" band bg password "$WIFI_PASS"; then
echo "NetworkManager hotspot creation failed."
return 1
fi
if ! nmcli connection modify "$AP_CONNECTION_NAME" connection.interface-name wlan0; then
echo "NetworkManager hotspot tuning failed (interface-name)."
return 1
fi
if ! nmcli connection modify "$AP_CONNECTION_NAME" connection.autoconnect yes connection.autoconnect-priority 100 connection.wait-device-timeout 30000; then
echo "NetworkManager hotspot tuning failed (autoconnect)."
return 1
fi
if ! nmcli connection modify "$AP_CONNECTION_NAME" 802-11-wireless.mode ap 802-11-wireless.band bg 802-11-wireless.channel 7 802-11-wireless.powersave 2 802-11-wireless.cloned-mac-address permanent; then
echo "NetworkManager hotspot tuning failed (wireless)."
return 1
fi
if ! nmcli connection modify "$AP_CONNECTION_NAME" ipv4.method shared ipv4.addresses "$AP_ADDRESS" ipv4.shared-dhcp-range "$AP_DHCP_RANGE_START,$AP_DHCP_RANGE_END" ipv6.method disabled; then
echo "NetworkManager hotspot tuning failed (IP settings)."
return 1
fi
if ! nmcli connection modify "$AP_CONNECTION_NAME" 802-11-wireless-security.key-mgmt wpa-psk 802-11-wireless-security.psk "$WIFI_PASS" 802-11-wireless-security.proto rsn 802-11-wireless-security.pairwise ccmp 802-11-wireless-security.group ccmp 802-11-wireless-security.pmf 1; then
echo "NetworkManager hotspot tuning failed (security)."
return 1
fi
nmcli connection modify "$AP_CONNECTION_NAME" remove 802-1x || true
nmcli connection down "$AP_CONNECTION_NAME" 2>/dev/null || true
cat <<EOF > /etc/systemd/system/mpvj-nm-ap.service
[Unit]
Description=Bring up MPVJ NetworkManager hotspot on boot
After=NetworkManager.service
Wants=NetworkManager.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bash -lc 'nmcli radio wifi on || true; nmcli device set wlan0 managed yes || true; nmcli device set wlan0 autoconnect yes || true; nmcli connection reload; nmcli --wait 30 connection up "$AP_CONNECTION_NAME" ifname wlan0'
ExecStop=/usr/bin/bash -lc 'nmcli connection down "$AP_CONNECTION_NAME" 2>/dev/null || true'
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable mpvj-nm-ap.service avahi-daemon.service
if ! systemctl restart mpvj-nm-ap.service; then
echo "NetworkManager hotspot activation failed."
return 1
fi
echo "NetworkManager hotspot configured successfully."
return 0
}
configure_legacy_access_point_stack() {
mkdir -p /etc/hostapd /etc/systemd/system /etc/NetworkManager/conf.d
cleanup_networkmanager_access_point_stack
cat <<EOF > /etc/hostapd/hostapd.conf
country_code=$WIFI_COUNTRY
interface=wlan0
driver=nl80211
ssid=$WIFI_SSID
hw_mode=g
channel=7
ieee80211n=1
wmm_enabled=1
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=$WIFI_PASS
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
EOF
cat <<EOF > /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
if [ -f /etc/dnsmasq.conf ] && [ ! -f /etc/dnsmasq.conf.mpvj-backup ]; then
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.mpvj-backup
fi
cat <<EOF > /etc/dnsmasq.conf
interface=wlan0
bind-interfaces
listen-address=$AP_GATEWAY
domain-needed
bogus-priv
dhcp-range=$AP_DHCP_RANGE_START,$AP_DHCP_RANGE_END,255.255.255.0,24h
address=/$HOSTNAME.local/$AP_GATEWAY
EOF
cat <<'EOF' > /etc/systemd/system/mpvj-ap-mode.service
[Unit]
Description=Prepare wlan0 for MPVJ access point mode
DefaultDependencies=no
After=systemd-udev-settle.service
Before=network-pre.target hostapd.service dnsmasq.service
Wants=network-pre.target hostapd.service dnsmasq.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bash -c 'rfkill unblock wlan || true; systemctl stop wpa_supplicant.service wpa_supplicant@wlan0.service 2>/dev/null || true; ip link set wlan0 down || true; ip addr flush dev wlan0 || true; iw dev wlan0 set power_save off || true; ip link set wlan0 up; ip address add 192.168.4.1/24 dev wlan0'
ExecStop=/usr/bin/bash -c 'systemctl stop hostapd.service dnsmasq.service 2>/dev/null || true; ip addr flush dev wlan0 || true'
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/NetworkManager/conf.d/99-mpvj-unmanage-wlan0.conf
[keyfile]
unmanaged-devices=interface-name:wlan0
EOF
cat <<EOF > /etc/sysctl.d/90-mpvj-ap.conf
net.ipv4.ip_forward=1
EOF
configure_wlan0_static_profile
systemctl daemon-reload
systemctl unmask hostapd dnsmasq 2>/dev/null || true
systemctl enable mpvj-ap-mode.service hostapd.service dnsmasq.service avahi-daemon.service
systemctl disable wpa_supplicant.service wpa_supplicant@wlan0.service 2>/dev/null || true
}
configure_access_point_stack() {
if command -v nmcli > /dev/null 2>&1 && systemctl list-unit-files NetworkManager.service --no-legend 2>/dev/null | grep -q '^NetworkManager\.service'; then
echo "Using NetworkManager hotspot configuration for wlan0..."
if ! configure_networkmanager_access_point; then
echo "Falling back to hostapd/dnsmasq hotspot configuration for wlan0..."
cleanup_networkmanager_access_point_stack
configure_legacy_access_point_stack
fi
else
echo "Using hostapd/dnsmasq hotspot configuration for wlan0..."
configure_legacy_access_point_stack
fi
}
if [ -z "$REPO_URL" ]; then if [ -z "$REPO_URL" ]; then
echo "Usage: $0 <REPO_URL>" echo "Usage: $0 <REPO_URL>"
@ -54,8 +294,15 @@ fi
echo "Interrogating user for configuration..." echo "Interrogating user for configuration..."
# 1.1 Hostname # 1.1 Hostname
HOSTNAME=$(whiptail --inputbox "Enter Hostname (e.g. mpvj)" 8 45 "mpvj" --title "Hostname Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1 while true; do
HOSTNAME=${HOSTNAME:-mpvj} HOSTNAME=$(whiptail --inputbox "Enter Hostname (e.g. mpvj)" 8 45 "mpvj" --title "Hostname Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
HOSTNAME=${HOSTNAME:-mpvj}
if echo "$HOSTNAME" | grep -qE '^[a-zA-Z0-9-]+$'; then
break
fi
whiptail --msgbox "Error: Hostname may only contain letters, numbers, and hyphens." 8 60 < /dev/tty
done
# 1.2 SSID # 1.2 SSID
WIFI_SSID=$(whiptail --inputbox "Enter WiFi SSID (e.g. MPVJ-AP)" 8 45 "MPVJ-AP" --title "WiFi SSID Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1 WIFI_SSID=$(whiptail --inputbox "Enter WiFi SSID (e.g. MPVJ-AP)" 8 45 "MPVJ-AP" --title "WiFi SSID Configuration" 3>&1 1>&2 2>&3 < /dev/tty) || exit 1
@ -101,9 +348,20 @@ fi
# 2.3 Install Dependencies # 2.3 Install Dependencies
echo "Installing Core Dependencies..." echo "Installing Core Dependencies..."
if command -v apt-get > /dev/null; then if command -v apt-get > /dev/null; then
DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget DEBIAN_FRONTEND=noninteractive apt-get install -y git hostapd dnsmasq avahi-daemon curl ffmpeg build-essential libzmq3-dev libavahi-compat-libdnssd-dev wget unzip \
libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \
libglew-dev libglfw3-dev liburiparser-dev \
libcurl4-openssl-dev libpugixml-dev libasound2-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav \
libgtk-3-dev libboost-filesystem-dev \
libfontconfig1-dev libfreetype-dev libx11-dev \
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \
freeglut3-dev libxxf86vm-dev
elif command -v pacman > /dev/null; then elif command -v pacman > /dev/null; then
pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget pacman -S --noconfirm git hostapd dnsmasq avahi curl ffmpeg base-devel zeromq wget unzip
fi fi
# Install Node.js if missing # Install Node.js if missing
@ -115,6 +373,7 @@ fi
# 2.4 Hostname & WiFi Country # 2.4 Hostname & WiFi Country
hostnamectl set-hostname "$HOSTNAME" hostnamectl set-hostname "$HOSTNAME"
sed -i "s/127.0.1.1.*/127.0.1.1\t$HOSTNAME/g" /etc/hosts || true sed -i "s/127.0.1.1.*/127.0.1.1\t$HOSTNAME/g" /etc/hosts || true
set_wifi_country
# 2.5 OS-Agnostic Swap Increase (2GB) # 2.5 OS-Agnostic Swap Increase (2GB)
echo "Ensuring 2GB Swap for build..." echo "Ensuring 2GB Swap for build..."
@ -127,33 +386,8 @@ fi
# 3. NETWORKING # 3. NETWORKING
echo "Configuring Networking..." echo "Configuring Networking..."
# hostapd rfkill unblock wlan || true
cat <<EOF > /etc/hostapd/hostapd.conf configure_access_point_stack
interface=wlan0
driver=nl80211
ssid=$WIFI_SSID
hw_mode=g
channel=7
wpa=2
wpa_passphrase=$WIFI_PASS
wpa_key_mgmt=WPA-PSK
EOF
[ -f /etc/default/hostapd ] && sed -i 's/#DAEMON_CONF=""/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd
# dnsmasq
[ -f /etc/dnsmasq.conf ] && mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak || true
cat <<EOF > /etc/dnsmasq.conf
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
address=/$HOSTNAME.local/192.168.4.1
EOF
# dhcpcd / network manager
if [ -f /etc/dhcpcd.conf ]; then
if ! grep -q "interface wlan0" /etc/dhcpcd.conf; then
echo -e "\ninterface wlan0\n static ip_address=192.168.4.1/24\n nohook wpa_supplicant" >> /etc/dhcpcd.conf
fi
fi
# 4. DEPLOYMENT # 4. DEPLOYMENT
echo "Deploying Application..." echo "Deploying Application..."
@ -204,100 +438,12 @@ MPVJ_SSID=$WIFI_SSID
MPVJ_MEDIA_DIR=$REAL_HOME/media MPVJ_MEDIA_DIR=$REAL_HOME/media
EOF EOF
# 4.5 THE PRE-BUILT ENGINE SOLUTION # 4.5 THE PRE-BUILT ENGINE SOLUTION (FASTEST)
echo "Installing Pre-compiled OpenFrameworks (FAST)..." echo "Installing Pre-compiled ofxPiMapper Binary..."
cd "$REAL_HOME" BINARY_URL="https://gitea.superwcpot.nl/timothy/mapper/raw/branch/main/bin/ofxPiMapper"
if [ ! -d "openFrameworks" ]; then if ! curl -sSL -o /usr/local/bin/ofxPiMapper "$BINARY_URL"; then
echo "Downloading OpenFrameworks v0.12.1..." wget -O /usr/local/bin/ofxPiMapper "$BINARY_URL"
ARCH=$(uname -m)
OF_FILE="of_v0.12.1_linuxaarch64_release.tar.gz"
[ "$ARCH" != "aarch64" ] && [ "$ARCH" != "x86_64" ] && OF_FILE="of_v0.12.1_linuxarmv6l_release.tar.gz"
DOWNLOAD_URL="https://github.com/openframeworks/openFrameworks/releases/download/0.12.1/$OF_FILE"
if ! sudo -u "$REAL_USER" wget "$DOWNLOAD_URL"; then
sudo -u "$REAL_USER" curl -L -O "$DOWNLOAD_URL"
fi
sudo -u "$REAL_USER" tar -xzf "$OF_FILE"
sudo -u "$REAL_USER" mv of_v0.12.1_linux*_release openFrameworks
sudo -u "$REAL_USER" rm "$OF_FILE"
fi fi
# ALWAYS verify dependencies, even if OF is already present
echo "Ensuring modern dependencies for Debian Trixie..."
if command -v apt-get > /dev/null; then
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libmpg123-dev libsndfile1-dev libopenal-dev libassimp-dev \
libglew-dev libglfw3-dev liburiparser-dev \
libcurl4-openssl-dev libpugixml-dev libasound2-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly gstreamer1.0-libav \
libgtk-3-dev libboost-filesystem-dev \
libfontconfig1-dev libfreetype-dev libx11-dev \
libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev \
libpulse-dev libudev-dev libfreeimage-dev librtaudio-dev \
freeglut3-dev libxxf86vm-dev
fi
echo "Downloading and building ofxPiMapper Addon..."
cd "$REAL_HOME/openFrameworks/addons"
# FORCE CLEAN CLONE to fix corrupted source files from previous failed runs
rm -rf ofxPiMapper
sudo -u "$REAL_USER" git clone --depth 1 https://github.com/kr15h/ofxPiMapper.git
# Apply patches to the addon before building
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper"
echo "Applying clean Global Compatibility Patches..."
# 1. Fix highlight patch
cat <<'EOF_PATCH' > /tmp/highlight.patch
if (m.getAddress() == "/ofxPiMapper/surface/highlight"){
int surfaceIndex = m.getArgAsInt32(0);
mapper->getSurfaceManager()->selectSurface(surfaceIndex);
return;
}
EOF_PATCH
sed -i '/if (m.getAddress() == "\/ofxPiMapper\/surface\/select"){/r /tmp/highlight.patch' src/Osc/OscControl.cpp
rm -f /tmp/highlight.patch
# 2. Fix unique_ptr and make_unique globally (Only if std:: is missing)
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)unique_ptr\b/\1std::unique_ptr/g' {} +
find src -type f \( -name "*.h" -o -name "*.cpp" \) -exec sed -i 's/\([^:a-zA-Z0-9]\)make_unique\b/\1std::make_unique/g' {} +
# 3. Create a single compatibility header for C++11
cat <<'EOF_COMPAT' > src/cpp11_compat.h
#ifndef OFXPIMAPPER_CPP11_COMPAT_H
#define OFXPIMAPPER_CPP11_COMPAT_H
#include <memory>
#include <utility>
#if __cplusplus < 201402L
namespace std {
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}
#endif
#endif
EOF_COMPAT
# 4. Include the compat header in the main addon header
sed -i '1i #include "cpp11_compat.h"' src/ofxPiMapper.h
# 5. Add memory header to all headers where unique_ptr is used
for f in $(grep -l "unique_ptr" src/*.h 2>/dev/null); do
sed -i '1i #include <memory>' "$f"
done
# Build Example
cd "$REAL_HOME/openFrameworks/addons/ofxPiMapper/example_basic"
echo "Cleaning old objects..."
sudo -u "$REAL_USER" make clean
echo "Starting compilation (Forcing C++11 for Symbol Compatibility)..."
# Use -O2 and -fno-tree-vrp to prevent Internal Compiler Errors (ICE) on ARM
GLOBAL_FLAGS="-Wno-error -Wno-reorder -Wno-sign-compare -Wno-delete-non-virtual-dtor -std=c++11 -O2 -fno-tree-vrp"
sudo -u "$REAL_USER" make -j1 PLATFORM_CFLAGS="$GLOBAL_FLAGS" USER_CFLAGS="$GLOBAL_FLAGS" USER_CPPFLAGS="-std=c++11"
cp bin/example_basic /usr/local/bin/ofxPiMapper
chmod +x /usr/local/bin/ofxPiMapper chmod +x /usr/local/bin/ofxPiMapper
# 5. FINALIZATION # 5. FINALIZATION
@ -305,5 +451,5 @@ echo "Cleaning up..."
swapoff /swapfile_mpvj 2>/dev/null || true swapoff /swapfile_mpvj 2>/dev/null || true
rm /swapfile_mpvj 2>/dev/null || true rm /swapfile_mpvj 2>/dev/null || true
whiptail --title "Success" --msgbox "INSTALL COMPLETE!\n\nRebooting into AP Mode.\nSSID: $WIFI_SSID\nIP: 192.168.4.1" 12 45 < /dev/tty whiptail --title "Success" --msgbox "INSTALL COMPLETE!\n\nRebooting into AP Mode.\nHostname: $HOSTNAME.local\nSSID: $WIFI_SSID\nPassword: $WIFI_PASS\nIP: $AP_GATEWAY" 14 60 < /dev/tty
reboot reboot

View File

@ -1,14 +1,25 @@
#!/bin/bash #!/bin/bash
echo "Switching to AP Mode..." set -euo pipefail
# Stop wpa_supplicant for client mode
systemctl stop wpa_supplicant
# Configure static IP for wlan0 (normally handled by dhcpcd or systemd-networkd) echo "Switching to AP mode..."
# ifconfig wlan0 192.168.4.1
# Start AP services rfkill unblock wlan || true
systemctl start hostapd
systemctl start dnsmasq
echo "AP Mode active: MPVJ-3B" if command -v nmcli > /dev/null 2>&1 && nmcli connection show MPVJ-AP > /dev/null 2>&1; then
nmcli radio wifi on || true
nmcli device set wlan0 managed yes || true
nmcli device set wlan0 autoconnect yes || true
nmcli connection up MPVJ-AP ifname wlan0
else
systemctl stop wpa_supplicant.service wpa_supplicant@wlan0.service 2>/dev/null || true
ip link set wlan0 down || true
ip addr flush dev wlan0 || true
ip link set wlan0 up
ip address add 192.168.4.1/24 dev wlan0
systemctl start mpvj-ap-mode.service
systemctl restart hostapd.service
systemctl restart dnsmasq.service
fi
echo "AP mode active on wlan0 at 192.168.4.1"

View File

@ -1,14 +1,19 @@
#!/bin/bash #!/bin/bash
echo "Switching to Client Mode..." set -euo pipefail
# Stop AP services
systemctl stop hostapd
systemctl stop dnsmasq
# Start wpa_supplicant echo "Switching to client mode..."
systemctl start wpa_supplicant
# Normally would trigger a re-scan or wait for IP if command -v nmcli > /dev/null 2>&1 && nmcli connection show MPVJ-AP > /dev/null 2>&1; then
# dhclient wlan0 nmcli connection down MPVJ-AP 2>/dev/null || true
nmcli device set wlan0 autoconnect yes || true
nmcli device connect wlan0 2>/dev/null || true
else
systemctl stop mpvj-ap-mode.service 2>/dev/null || true
systemctl stop hostapd.service dnsmasq.service
ip addr flush dev wlan0 || true
ip link set wlan0 up || true
systemctl start wpa_supplicant.service || systemctl start wpa_supplicant@wlan0.service
fi
echo "Client Mode active. Connecting to configured SSID..." echo "Client mode active. wlan0 returned to wpa_supplicant."