basically complete retrieving found peripherals.

This commit is contained in:
Vixalie
2025-02-28 13:20:27 +08:00
parent 63c7d49943
commit c6043b612f
3 changed files with 28 additions and 22 deletions

View File

@@ -1,16 +1,19 @@
import { invoke } from '@tauri-apps/api/core';
import { useAtomValue } from 'jotai';
import { useAtomValue, useSetAtom } from 'jotai';
import { RESET } from 'jotai/utils';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { BleState } from '../../context/EstimContext';
import { BleState, FoundPeripherals } from '../../context/EstimContext';
import styles from './BleControl.module.css';
const BleControl: FC = () => {
const bleState = useAtomValue(BleState);
const setFound = useSetAtom(FoundPeripherals);
const timerRef = useRef<number | null>(null);
const [searchRemains, setSearchRemains] = useState(60);
const handleStartScan = useCallback(async () => {
timerRef.current !== null && clearInterval(timerRef.current);
setSearchRemains(60);
setFound(RESET);
try {
await invoke('start_scan_devices');
timerRef.current = setInterval(() => {