mirror of https://github.com/OpenIPC/firmware.git
[no ci] Update wifibroadcast-ng (#1722)
parent
18bb2419fe
commit
f4686db177
|
@ -1,5 +1,5 @@
|
|||
wireless:
|
||||
txpower: 10
|
||||
txpower: 1
|
||||
channel: 161
|
||||
mode: HT20
|
||||
broadcast:
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
wfb_key=/etc/drone.key
|
||||
wfb_dev=wlan0
|
||||
|
||||
echo_log() {
|
||||
echo "$1" | logger -s -t wifibroadcast
|
||||
}
|
||||
|
||||
wfb_yaml() {
|
||||
if [ -e "$1" ]; then
|
||||
while IFS=: read -r key value; do
|
||||
|
@ -38,14 +42,13 @@ load_modules() {
|
|||
done
|
||||
|
||||
if [ -z "$driver" ]; then
|
||||
echo "- Wireless module not detected!"
|
||||
echo_log "Wireless module not detected!"
|
||||
exit 1
|
||||
else
|
||||
echo "- Detected driver: $driver"
|
||||
fi
|
||||
|
||||
echo_log "Detected driver: $driver"
|
||||
if ! ifconfig "$wfb_dev" up; then
|
||||
echo "- Wireless driver not found!"
|
||||
echo_log "Wireless driver not found!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
@ -61,13 +64,13 @@ load_interface() {
|
|||
}
|
||||
|
||||
start_broadcast() {
|
||||
echo "- Starting wfb_tx"
|
||||
echo_log "Starting wfb_tx"
|
||||
wfb_tx -K "$wfb_key" -M "$wfb_index" -B "$bandwidth" -C 8000 -G short \
|
||||
-k "$fec_k" -n "$fec_n" -i "$link_id" "$wfb_dev" &> /dev/null &
|
||||
}
|
||||
|
||||
start_tunnel() {
|
||||
echo "- Starting wfb_tun"
|
||||
echo_log "Starting wfb_tun"
|
||||
wfb_rx -p 160 -u 5800 -K "$wfb_key" -i "$link_id" "$wfb_dev" &> /dev/null &
|
||||
wfb_tx -p 32 -u 5801 -K "$wfb_key" -M "$tun_index" \
|
||||
-k "$fec_k" -n "$fec_n" -i "$link_id" "$wfb_dev" &> /dev/null &
|
||||
|
@ -78,7 +81,7 @@ start_telemetry() {
|
|||
chipset=$(ipcinfo -c)
|
||||
[ "$chipset" = "ssc33x" ] && devmem 0x1F207890 16 0x8
|
||||
|
||||
echo "- Starting $router"
|
||||
echo_log "Starting $router"
|
||||
if [ "$router" = "msposd" ]; then
|
||||
config=$(curl -s localhost/api/v1/config.json)
|
||||
[ -n "$config" ] && size=$(echo "$config" | jsonfilter -e "@.video0.size")
|
||||
|
@ -102,8 +105,6 @@ video_settings() {
|
|||
cli -s .outgoing.server udp://0.0.0.0:5600
|
||||
cli -s .fpv.enabled true
|
||||
cli -s .fpv.noiseLevel 1
|
||||
|
||||
killall -1 majestic
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -126,7 +127,7 @@ start() {
|
|||
stop() {
|
||||
for process in wfb_rx wfb_tx wfb_tun msposd mavfwd; do
|
||||
if [ -n "$(pidof $process)" ]; then
|
||||
echo "- Stopping $process"
|
||||
echo_log "Stopping $process"
|
||||
killall -q "$process"
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -3,114 +3,8 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Camera</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Helvetica;
|
||||
background-color: #1e1e1e;
|
||||
color: #dcdcdc;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #252526;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
color: white;
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
color: #dee2e6bf;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background-color: #2d2d2d;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
max-width: 40%;
|
||||
padding: 20px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.form-section label {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0 5px;
|
||||
width: 150px;
|
||||
vertical-align: top;
|
||||
color: #dee2e6;
|
||||
}
|
||||
|
||||
.form-section select {
|
||||
width: 120px;
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #555;
|
||||
background-color: #3c3c3c;
|
||||
color: #dcdcdc;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-section input {
|
||||
width: 120px;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-section button {
|
||||
width: 160px;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
color: white;
|
||||
box-shadow: 0 2px 10px #00000040;
|
||||
}
|
||||
|
||||
#apply-video-button, #apply-wfb-button {
|
||||
background-color: #0d4aa5;
|
||||
}
|
||||
|
||||
#apply-video-button:hover, #apply-wfb-button:hover {
|
||||
background-color: #115fd4;
|
||||
}
|
||||
|
||||
#reset-video-button, #reset-wfb-button {
|
||||
background-color: #b81414;
|
||||
}
|
||||
|
||||
#reset-video-button:hover, #reset-wfb-button:hover {
|
||||
background-color: #e61919;
|
||||
}
|
||||
|
||||
#preview {
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
background-color: #000;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<title>OpenIPC</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -243,110 +137,7 @@
|
|||
</div>
|
||||
|
||||
<script src="js-yaml.min.js"></script>
|
||||
<script>
|
||||
let configData = { majestic: {}, wfb: {} };
|
||||
|
||||
async function loadYAML(url, setter) {
|
||||
const response = await fetch(url);
|
||||
const text = await response.text();
|
||||
setter(jsyaml.load(text));
|
||||
}
|
||||
|
||||
async function uploadYAML(data, location) {
|
||||
const yamlData = jsyaml.dump(data);
|
||||
await fetch('/upload', {
|
||||
method: 'POST',
|
||||
headers: { 'File-Location': location },
|
||||
body: yamlData
|
||||
});
|
||||
}
|
||||
|
||||
async function runCommand(command) {
|
||||
await fetch('/command', {
|
||||
method: 'POST',
|
||||
headers: { 'Run-Command': command }
|
||||
});
|
||||
}
|
||||
|
||||
function syncForm(data, formPrefix, mode) {
|
||||
Object.keys(data).forEach((section) => {
|
||||
Object.keys(data[section]).forEach((key) => {
|
||||
const field = document.getElementsByName(formPrefix + '.' + section + '.' + key)[0];
|
||||
if (!field) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isCheckbox = field.type === "checkbox";
|
||||
const value = data[section][key];
|
||||
|
||||
if (mode === "setup") {
|
||||
if (isCheckbox) {
|
||||
field.checked = value === true;
|
||||
} else {
|
||||
field.value = value;
|
||||
}
|
||||
} else if (mode === "update") {
|
||||
if (isCheckbox) {
|
||||
data[section][key] = field.checked;
|
||||
} else {
|
||||
data[section][key] = field.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function executeDelay(button, command) {
|
||||
button.disabled = true;
|
||||
runCommand(command);
|
||||
setTimeout(() => {
|
||||
button.disabled = false;
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function populateSelect(id, start, end, step) {
|
||||
const select = document.getElementById(id);
|
||||
for (let i = start; i <= end; i += step) {
|
||||
const option = document.createElement('option');
|
||||
option.value = i;
|
||||
option.textContent = i;
|
||||
select.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
populateSelect('bitrate', 1024, 20480, 1024);
|
||||
populateSelect('txpower', 1, 58, 1);
|
||||
populateSelect('wfb_index', 0, 8, 1);
|
||||
populateSelect('tun_index', 0, 8, 1);
|
||||
|
||||
function addClickListener(buttonId, command, configKey, yamlPath) {
|
||||
document.getElementById(buttonId).addEventListener('click', function () {
|
||||
if (configKey && configData[configKey]) {
|
||||
syncForm(configData[configKey], configKey, "update");
|
||||
var yamlPath = '/etc/' + configKey + '.yaml';
|
||||
uploadYAML(configData[configKey], yamlPath);
|
||||
}
|
||||
executeDelay(this, command);
|
||||
});
|
||||
}
|
||||
|
||||
addClickListener('apply-video-button', 'killall -1 majestic', 'majestic');
|
||||
addClickListener('apply-wfb-button', 'wifibroadcast start', 'wfb');
|
||||
|
||||
addClickListener('reset-video-button', 'wifibroadcast resetv');
|
||||
addClickListener('reset-wfb-button', 'wifibroadcast resetw');
|
||||
|
||||
loadYAML('/etc/majestic.yaml', (data) => {
|
||||
configData.majestic = data;
|
||||
syncForm(configData.majestic, 'majestic', "setup");
|
||||
});
|
||||
|
||||
loadYAML('/etc/wfb.yaml', (data) => {
|
||||
configData.wfb = data;
|
||||
syncForm(configData.wfb, 'wfb', "setup");
|
||||
});
|
||||
</script>
|
||||
<script src="script.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
let configData = { majestic: {}, wfb: {} };
|
||||
|
||||
async function loadYAML(url, setter) {
|
||||
const response = await fetch(url);
|
||||
const text = await response.text();
|
||||
setter(jsyaml.load(text));
|
||||
}
|
||||
|
||||
async function uploadYAML(data, location) {
|
||||
const yamlData = jsyaml.dump(data);
|
||||
await fetch('/upload', {
|
||||
headers: { 'File-Location': location },
|
||||
body: yamlData
|
||||
});
|
||||
}
|
||||
|
||||
async function runCommand(command) {
|
||||
await fetch('/command', {
|
||||
headers: { 'Run-Command': command }
|
||||
});
|
||||
}
|
||||
|
||||
function syncForm(data, formPrefix, mode) {
|
||||
Object.keys(data).forEach((section) => {
|
||||
Object.keys(data[section]).forEach((key) => {
|
||||
const field = document.getElementsByName(formPrefix + '.' + section + '.' + key)[0];
|
||||
if (!field) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isCheckbox = field.type === "checkbox";
|
||||
const value = data[section][key];
|
||||
|
||||
if (mode === "setup") {
|
||||
if (isCheckbox) {
|
||||
field.checked = value === true;
|
||||
} else {
|
||||
field.value = value;
|
||||
}
|
||||
} else if (mode === "update") {
|
||||
if (isCheckbox) {
|
||||
data[section][key] = field.checked;
|
||||
} else {
|
||||
data[section][key] = field.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function executeDelay(button, command) {
|
||||
button.disabled = true;
|
||||
runCommand(command);
|
||||
setTimeout(() => {
|
||||
button.disabled = false;
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
function addClickListener(buttonId, command, configKey) {
|
||||
document.getElementById(buttonId).addEventListener('click', function () {
|
||||
if (configKey && configData[configKey]) {
|
||||
syncForm(configData[configKey], configKey, "update");
|
||||
var yamlPath = '/etc/' + configKey + '.yaml';
|
||||
uploadYAML(configData[configKey], yamlPath);
|
||||
}
|
||||
executeDelay(this, command);
|
||||
});
|
||||
}
|
||||
|
||||
addClickListener('apply-video-button', 'killall -1 majestic', 'majestic');
|
||||
addClickListener('apply-wfb-button', 'wifibroadcast start', 'wfb');
|
||||
addClickListener('reset-video-button', 'wifibroadcast resetv');
|
||||
addClickListener('reset-wfb-button', 'wifibroadcast resetw');
|
||||
|
||||
function populateSelect(id, start, end, step) {
|
||||
const select = document.getElementById(id);
|
||||
for (let i = start; i <= end; i += step) {
|
||||
const option = document.createElement('option');
|
||||
option.value = i;
|
||||
option.textContent = i;
|
||||
select.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
populateSelect('bitrate', 1024, 20480, 1024);
|
||||
populateSelect('txpower', 1, 58, 1);
|
||||
populateSelect('wfb_index', 0, 8, 1);
|
||||
populateSelect('tun_index', 0, 8, 1);
|
||||
|
||||
loadYAML('/etc/majestic.yaml', (data) => {
|
||||
configData.majestic = data;
|
||||
syncForm(configData.majestic, 'majestic', "setup");
|
||||
});
|
||||
|
||||
loadYAML('/etc/wfb.yaml', (data) => {
|
||||
configData.wfb = data;
|
||||
syncForm(configData.wfb, 'wfb', "setup");
|
||||
});
|
|
@ -0,0 +1,105 @@
|
|||
body {
|
||||
font-family: Helvetica;
|
||||
background-color: #1e1e1e;
|
||||
color: #dcdcdc;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header {
|
||||
background-color: #252526;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
color: white;
|
||||
padding: 15px 0;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1.5rem;
|
||||
margin-top: 1rem;
|
||||
color: #dee2e6bf;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background-color: #2d2d2d;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
max-width: 40%;
|
||||
padding: 20px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.form-section label {
|
||||
display: inline-block;
|
||||
font-weight: bold;
|
||||
margin: 10px 0 5px;
|
||||
width: 150px;
|
||||
vertical-align: top;
|
||||
color: #dee2e6;
|
||||
}
|
||||
|
||||
.form-section select {
|
||||
width: 120px;
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #555;
|
||||
background-color: #3c3c3c;
|
||||
color: #dcdcdc;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-section input {
|
||||
width: 120px;
|
||||
height: 25px;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.form-section button {
|
||||
width: 160px;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
color: white;
|
||||
box-shadow: 0 2px 10px #00000040;
|
||||
}
|
||||
|
||||
#apply-video-button, #apply-wfb-button {
|
||||
background-color: #0d4aa5;
|
||||
}
|
||||
|
||||
#apply-video-button:hover, #apply-wfb-button:hover {
|
||||
background-color: #115fd4;
|
||||
}
|
||||
|
||||
#reset-video-button, #reset-wfb-button {
|
||||
background-color: #a11212;
|
||||
}
|
||||
|
||||
#reset-video-button:hover, #reset-wfb-button:hover {
|
||||
background-color: #cf1717;
|
||||
}
|
||||
|
||||
#preview {
|
||||
width: 100%;
|
||||
max-width: 1200px;
|
||||
background-color: #000;
|
||||
box-shadow: 0 2px 10px #00000080;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.row {
|
||||
margin-bottom: 15px;
|
||||
}
|
Loading…
Reference in New Issue