|
|
@ -1,10 +1,12 @@ |
|
|
|
import { NavBar, SpinLoading, Toast } from 'antd-mobile'; |
|
|
|
import './Bluetooth.scss'; |
|
|
|
import { useEffect } from 'react'; |
|
|
|
import { useAppSelector } from '../utils/hooks'; |
|
|
|
import { useAppDispatch, useAppSelector } from '../utils/hooks'; |
|
|
|
import Bridge from '../utils/bridge'; |
|
|
|
import { updateBleLinkStatus } from '../store/features/contextSlice'; |
|
|
|
|
|
|
|
export default function Bluetooth() { |
|
|
|
const dispatch = useAppDispatch(); |
|
|
|
const contextState = useAppSelector((state) => state.context); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
@ -22,6 +24,8 @@ export default function Bluetooth() { |
|
|
|
Bridge.connectPeripheral({ id }).then((res) => { |
|
|
|
if (!res.success) { |
|
|
|
Toast.show(res.message); |
|
|
|
} else { |
|
|
|
dispatch(updateBleLinkStatus({id, link: true})) |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
@ -29,6 +33,8 @@ export default function Bluetooth() { |
|
|
|
Bridge.disconnectPeripheral().then((res) => { |
|
|
|
if (!res.success) { |
|
|
|
Toast.show(res.message); |
|
|
|
} else { |
|
|
|
dispatch(updateBleLinkStatus({id, link: false})) |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|