2023-11-18 15:31:48 +00:00
|
|
|
import { getAudioDevices, getSerialDevices } from "./api";
|
|
|
|
|
|
|
|
let audioDevices = await getAudioDevices();
|
|
|
|
let serialDevices = await getSerialDevices();
|
|
|
|
|
2023-12-19 01:46:19 +00:00
|
|
|
//Add an ignore option for rig and ptt for transceivers that don't require them
|
|
|
|
serialDevices.push({description:"-- ignore --", port:"ignore"})
|
|
|
|
|
2023-11-26 06:07:04 +00:00
|
|
|
//Dummy device data sent if unable to get devices from modem to prevent GUI crash
|
|
|
|
const skel = JSON.parse(`
|
|
|
|
[{
|
|
|
|
"api": "MME",
|
|
|
|
"id": "0000",
|
|
|
|
"name": "No devices received from modem",
|
|
|
|
"native_index": 0
|
2023-11-26 06:07:52 +00:00
|
|
|
}]`);
|
2023-12-19 01:46:19 +00:00
|
|
|
|
2023-11-18 15:31:48 +00:00
|
|
|
export function loadAudioDevices() {
|
|
|
|
getAudioDevices().then((devices) => {
|
|
|
|
audioDevices = devices;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function loadSerialDevices() {
|
|
|
|
getSerialDevices().then((devices) => {
|
|
|
|
serialDevices = devices;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function audioInputOptions() {
|
2023-11-26 06:07:52 +00:00
|
|
|
if (audioDevices === undefined) {
|
2023-11-26 06:07:04 +00:00
|
|
|
return skel;
|
|
|
|
}
|
2023-11-18 15:31:48 +00:00
|
|
|
return audioDevices.in;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function audioOutputOptions() {
|
2023-11-26 06:07:52 +00:00
|
|
|
if (audioDevices === undefined) {
|
2023-11-26 06:07:04 +00:00
|
|
|
return skel;
|
|
|
|
}
|
2023-12-19 01:46:19 +00:00
|
|
|
|
2023-11-18 15:31:48 +00:00
|
|
|
return audioDevices.out;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function serialDeviceOptions() {
|
|
|
|
return serialDevices;
|
|
|
|
}
|