basically complete retrieving found peripherals.
This commit is contained in:
@@ -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(() => {
|
||||
|
Reference in New Issue
Block a user