Skip to content

Commit

Permalink
fix: fix up stream de-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanzyTHEbar committed Apr 30, 2023
1 parent b335907 commit af95746
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 14 deletions.
13 changes: 7 additions & 6 deletions GUI/ETVR/src-tauri/src/modules/m_dnsquery/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A mdns query client.

use log::error;
use log::{error, info};
use mdns_sd::{ServiceDaemon, ServiceEvent};
use serde::Serialize;
use std::collections::hash_map::HashMap;
Expand Down Expand Up @@ -92,7 +92,7 @@ pub async fn run_query(
if let Ok(event) = receiver.recv_async().await {
match event {
ServiceEvent::ServiceResolved(info) => {
println!(
info!(
"At {:?}: Resolved a new service: {} IP: {:#?}:{:#?} Hostname: {:#?}",
now.elapsed(),
info.get_fullname(),
Expand All @@ -102,13 +102,13 @@ pub async fn run_query(
);
//* split the fullname by '.' and take the first element
let name = info.get_hostname();
println!("Service name: {}", name);
info!("Service name: {}", name);
//* remove the period at the end of the name
let mut name = name.trim_end_matches('.');
//* append name to 'http://' to get the base url
let mut base_url = String::from("http://");
base_url.push_str(name);
println!("Base URL: {}", base_url);
info!("Base URL: {}", base_url);
//* add the base url to the hashmap
instance
.base_url
Expand All @@ -128,7 +128,7 @@ pub async fn run_query(
mdns_data.ips = instance.ip.clone();
}
other_event => {
println!(
info!(
"At {:?} : Received other event: {:?}",
now.elapsed(),
&other_event
Expand All @@ -138,7 +138,8 @@ pub async fn run_query(
}
}
std::thread::sleep(std::time::Duration::from_nanos(1));
mdns.stop_browse(&service_type).map_err(|e| e.to_string())?;
//mdns.stop_browse(&service_type).map_err(|e| e.to_string())?;
info!("Stopping mDNS query daemon - refresh to restart");
mdns.shutdown().map_err(|e| e.to_string())?;
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions GUI/ETVR/src-tauri/src/modules/tauri_commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ pub async fn run_mdns_query(
service_type: String,
scan_time: u64,
) -> Result<m_dnsquery::MdnsData, String> {
println!("Starting MDNS query to find devices");
info!("Starting MDNS query to find devices");
let mut mdns: m_dnsquery::Mdns = m_dnsquery::Mdns::new();
let mut mdns_data = m_dnsquery::MdnsData::new();
let ref_mdns = &mut mdns;
println!("MDNS Service Thread acquired lock");
info!("MDNS Service Thread acquired lock");
m_dnsquery::run_query(ref_mdns, service_type, &mut mdns_data, scan_time)
.await
.expect("Error in mDNS query");
println!("MDNS query complete");
println!(
info!("MDNS query complete");
info!(
"MDNS query results: {:#?}",
m_dnsquery::get_urls(&*ref_mdns)
); // get's an array of the base urls found
Expand Down Expand Up @@ -129,7 +129,7 @@ pub fn handle_debug<R: tauri::Runtime>(
) -> Result<log::LevelFilter, String> {
// read the Store file
let stores = app.state::<tauri_plugin_store::StoreCollection<R>>();
let path = std::path::PathBuf::from(".app-settings.etvr");
let path = std::path::PathBuf::from(".app-settings.bin");
// match the store value to a LogFilter
let mut debug_state: String = String::new();
with_store(app.clone(), stores, path, |store| {
Expand Down
82 changes: 82 additions & 0 deletions GUI/ETVR/src/pages/AppSettings/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { EraseButton } from '@components/Button/EraseButton'
import { OpenDocs } from '@components/Button/OpenDocs'
import { WebSerial } from '@components/Button/WebSerial'
import { FirmwareList } from '@components/FirmwareList'
import { Form } from '@components/Form'
import { useAppAPIContext } from '@src/store/context/api'
import { useAppNotificationsContext } from '@src/store/context/notifications'
import AppSettings from '@src/views/AppSettings'

const AppSettingsPage = () => {
let download: (firmware: string) => Promise<void> = () => Promise.resolve()

const { downloadAsset } = useAppAPIContext()

if (downloadAsset) download = downloadAsset

const { handleSound } = useAppNotificationsContext()

return (
<div class="flex justify-center items-center content-center flex-col pt-[100px] text-white">
<AppSettings
onClickFlipLeftXAxis={() => console.log('onClickFlipLeftXAxis')}
onClickFlipRightXAxis={() => {
console.log('onClickFlipRightXAxis')
}}
onClickFlipYAxis={() => {
console.log('onClickFlipYAxis')
}}
onClickDualEyeFalloff={() => {
console.log('onClickDualEyeFalloff')
}}
onClickSyncBlinks={() => {
console.log('onClickSyncBlinks')
}}
onClickBlobFallback={() => {
console.log('onClickBlobFallback')
}}
onChange={(format, value) => {
console.log(format, value)
}}
onChangeAddress={() => {
console.log('onChangeAddress')
}}
onChangeOSCPort={() => {
console.log('onChangeOSCPort')
}}
onChangeOSCReceiverPort={() => {
console.log('onChangeOSCReceiverPort')
}}
onChangeOSCRecenterPort={() => {
console.log('onChangeOSCRecenterPort')
}}
onChangeOSCRecalibrateAddress={() => {
console.log('onChangeOSCRecalibrateAddress')
}}
/>
<button
class="rounded-[8px] bg-blue-700 p-2 text-white mt-1 hover:bg-blue-600 focus:bg-blue-500"
onClick={() => {
download('esp32AIThinker')
console.log('[Download Asset]: Downloading...')
}}>
Download Release Asset
</button>
<button
class="rounded-[8px] bg-blue-700 p-2 text-white mt-1 hover:bg-blue-600 focus:bg-blue-500"
onClick={() => {
handleSound('EyeTrackApp_Audio_start.wav')
console.log('[Audio Handler]: Sound Played')
}}>
Play Sound
</button>
<EraseButton />
<WebSerial />
<OpenDocs />
<FirmwareList />
<Form />
</div>
)
}

export default AppSettingsPage
3 changes: 1 addition & 2 deletions GUI/ETVR/src/routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ const AppRoutes = () => {
generateWebsocketClients()
//})
})

// TODO: check notif perms and request GH data
checkPermission()
doGHRequest()
})
Expand All @@ -75,6 +73,7 @@ const AppRoutes = () => {
enableNotificationsSounds: getEnableNotificationsSounds(),
globalNotificationsType: getGlobalNotificationsType(),
enableMDNS: getEnableMDNS(),
// TODO: expose the debug levels to the user
debugMode: 'info',
scanForCamerasOnStartup: getScanForCamerasOnStartup(),
}
Expand Down
2 changes: 1 addition & 1 deletion GUI/ETVR/src/store/tauriStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Store } from 'tauri-plugin-store-api'
import type { PersistentSettings } from '@src/static/types'

const persistentStore = new Store('.app-settings.etvr')
const persistentStore = new Store('.app-settings.bin')

export const usePersistentStore = () => {
const save = async () => {
Expand Down

0 comments on commit af95746

Please sign in to comment.