testing rover self update

This commit is contained in:
legop3
2026-11-17 13:27:14 -05:00
parent 9735e3c0c2
commit f1e7820caf
7 changed files with 30 additions and 15 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+7 -7
View File
@@ -265,7 +265,7 @@ func DefaultConfig() Config {
Video: VideoMediaConfig{ Video: VideoMediaConfig{
Profile: "v4l2", Profile: "v4l2",
Enabled: false, Enabled: true,
Device: "/dev/video0", InputFormat: "mjpeg", Device: "/dev/video0", InputFormat: "mjpeg",
Width: 640, Width: 640,
@@ -277,7 +277,7 @@ func DefaultConfig() Config {
}, },
AudioCapture: AudioCaptureConfig{ AudioCapture: AudioCaptureConfig{
Profile: "alsa", Profile: "alsa",
Enabled: false, Enabled: true,
SampleRate: 48000, SampleRate: 48000,
Channels: 2, Channels: 2,
@@ -285,7 +285,7 @@ func DefaultConfig() Config {
}, },
AudioPlayback: AudioPlaybackConfig{ AudioPlayback: AudioPlaybackConfig{
Profile: "alsa", Profile: "alsa",
Enabled: false, Enabled: true,
Normalize: true, Normalize: true,
NormalizeFilter: "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled", NormalizeFilter: "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled",
@@ -293,13 +293,13 @@ func DefaultConfig() Config {
}, },
Audio: AudioConfig{ Audio: AudioConfig{
InputDevice: "hw:0,0", OutputDevice: "hw:0,0", MixerCard: "0", OutputSampleRate: 48000, OutputChannels: 2, InputDevice: "hw:0,0", OutputDevice: "hw:0,0", MixerCard: "0", OutputSampleRate: 48000, OutputChannels: 2,
TTSEnabled: false, TTSEnabled: true,
DefaultEngine: "flite", DefaultEngine: "google",
DefaultVoice: "rms", DefaultVoice: "rms",
DefaultPitch: 50, DefaultPitch: 50,
}, },
Horn: HornConfig{ Horn: HornConfig{
Enabled: false, Enabled: true,
Volume: 0.25, Volume: 0.25,
SampleRate: 48000, SampleRate: 48000,
Channels: 1, Channels: 1,
@@ -460,7 +460,7 @@ func clampFloat(value, min, max float64) float64 {
func validateAudioConfig(cfg *AudioConfig) { func validateAudioConfig(cfg *AudioConfig) {
if cfg.DefaultEngine == "" { if cfg.DefaultEngine == "" {
cfg.DefaultEngine = "flite" cfg.DefaultEngine = "google"
} }
if cfg.DefaultVoice == "" { if cfg.DefaultVoice == "" {
cfg.DefaultVoice = "rms" cfg.DefaultVoice = "rms"
@@ -18,6 +18,7 @@ function snapshot(record) {
schema: record.schema, schema: record.schema,
profiles: record.profiles, profiles: record.profiles,
mediaStatus: record.mediaStatus, mediaStatus: record.mediaStatus,
mediaOutput: record.mediaOutput,
updateStatus: record.updateStatus, updateStatus: record.updateStatus,
hostStats: record.hostStats || null, hostStats: record.hostStats || null,
notices: record.notices, notices: record.notices,
@@ -84,7 +85,7 @@ managementWSS.on('connection', (ws) => {
if (typeof msg.name !== 'string' || !msg.name || !msg.config || !msg.schema) throw new Error('Invalid management hello'); if (typeof msg.name !== 'string' || !msg.name || !msg.config || !msg.schema) throw new Error('Invalid management hello');
clearTimeout(helloTimeout); clearTimeout(helloTimeout);
const previous = rovers.get(msg.name); const previous = rovers.get(msg.name);
record = { roverId: msg.name, ws, config: msg.config, schema: msg.schema, profiles: msg.profiles, mediaStatus: msg.mediaStatus || {}, updateStatus: msg.updateStatus || null, notices: [] }; record = { roverId: msg.name, ws, config: msg.config, schema: msg.schema, profiles: msg.profiles, mediaStatus: msg.mediaStatus || {}, mediaOutput: {}, updateStatus: msg.updateStatus || null, notices: [] };
rovers.set(record.roverId, record); rovers.set(record.roverId, record);
previous?.ws.close(1000, 'Replaced by new connection'); previous?.ws.close(1000, 'Replaced by new connection');
notifyAdmins('roverManagement:changed', snapshot(record)); notifyAdmins('roverManagement:changed', snapshot(record));
@@ -103,8 +104,16 @@ managementWSS.on('connection', (ws) => {
notifyAdmins('roverManagement:hostStats', { roverId: record.roverId, ...msg }); notifyAdmins('roverManagement:hostStats', { roverId: record.roverId, ...msg });
} else if (msg.type === 'event') { } else if (msg.type === 'event') {
if (msg.event === 'media.status') record.mediaStatus[msg.data.category] = msg.data.message; if (msg.event === 'media.status') record.mediaStatus[msg.data.category] = msg.data.message;
record.notices.push(msg); if (msg.event === 'media.output') {
if (record.notices.length > 100) record.notices.shift(); const category = msg.data?.category;
if (['video', 'audioCapture', 'audioPlayback'].includes(category)) {
// Keep raw chunks per command so other streamers/notices cannot evict them.
record.mediaOutput[category] = ((record.mediaOutput[category] || '') + (msg.data.message || '')).slice(-65536);
}
} else {
record.notices.push(msg);
if (record.notices.length > 100) record.notices.shift();
}
notifyAdmins('roverManagement:event', { roverId: record.roverId, ...msg }); notifyAdmins('roverManagement:event', { roverId: record.roverId, ...msg });
if (!msg.event?.startsWith('media.')) sendAlert({ color: '#00bcd4', title: record.roverId, message: msg.data?.message || msg.event }); if (!msg.event?.startsWith('media.')) sendAlert({ color: '#00bcd4', title: record.roverId, message: msg.data?.message || msg.event });
} }
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import SchemaConfigurationForm from './SchemaConfigurationForm.jsx'; import SchemaConfigurationForm from './SchemaConfigurationForm.jsx';
function request(socket, event, payload = {}) { function request(socket, event, payload = {}) {
@@ -62,6 +62,12 @@ function RoverForm({ socket, record, online }) {
} }
function MediaProfiles({ socket, record, online, category, configDirty }) { function MediaProfiles({ socket, record, online, category, configDirty }) {
const outputRef = useRef(null);
const output = record.mediaOutput?.[category] || '';
useEffect(() => {
const element = outputRef.current;
if (element) element.scrollTop = element.scrollHeight;
}, [output]);
const [profile, setProfile] = useState({ id: 'custom', name: '', description: '', setup: '', run: '' }); const [profile, setProfile] = useState({ id: 'custom', name: '', description: '', setup: '', run: '' });
const [message, setMessage] = useState(''); const [message, setMessage] = useState('');
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
@@ -93,9 +99,7 @@ function MediaProfiles({ socket, record, online, category, configDirty }) {
<p role="status">{message}</p> <p role="status">{message}</p>
</details> </details>
<details><summary className="cursor-pointer">Streamer output</summary> <details><summary className="cursor-pointer">Streamer output</summary>
<pre className="max-h-80 overflow-auto whitespace-pre-wrap text-xs">{(record.notices || []) <pre ref={outputRef} className="max-h-80 overflow-auto whitespace-pre-wrap text-xs">{output || 'Waiting for command stdout/stderr…'}</pre></details>
.filter((event) => event.event?.startsWith('media.') && event.data?.category === category)
.map((event) => `${event.event === 'media.status' ? '[status] ' : ''}${event.data?.message || ''}`).join('\n')}</pre></details>
</div>; </div>;
} }
@@ -124,7 +128,9 @@ export default function RoverConfigurationEditor({ socket, selected, onSelect })
const mediaEvent = ({ roverId, ...event }) => { const mediaEvent = ({ roverId, ...event }) => {
if (!event.event?.startsWith('media.')) return; if (!event.event?.startsWith('media.')) return;
setRecords((previous) => previous[roverId] ? { ...previous, [roverId]: { setRecords((previous) => previous[roverId] ? { ...previous, [roverId]: {
...previous[roverId], mediaStatus: event.event === 'media.status' ...previous[roverId], mediaOutput: event.event === 'media.output'
? { ...previous[roverId].mediaOutput, [event.data.category]: ((previous[roverId].mediaOutput?.[event.data.category] || '') + (event.data.message || '')).slice(-65536) }
: previous[roverId].mediaOutput, mediaStatus: event.event === 'media.status'
? { ...previous[roverId].mediaStatus, [event.data.category]: event.data.message } : previous[roverId].mediaStatus, notices: [...(previous[roverId].notices || []), event].slice(-100), ? { ...previous[roverId].mediaStatus, [event.data.category]: event.data.message } : previous[roverId].mediaStatus, notices: [...(previous[roverId].notices || []), event].slice(-100),
} } : previous); } } : previous);
}; };