Firrt commit

This commit is contained in:
2026-07-15 17:46:28 +07:00
parent fbdd711abb
commit 368e03b32b
55 changed files with 4420 additions and 1066 deletions
+33
View File
@@ -0,0 +1,33 @@
import { Config } from '@/constants/Config';
export const bleService = {
async scanForHeartRateSensors(onDeviceFound: (device: any) => void): Promise<void> {
console.log('Quét cảm biến nhịp tim BLE...');
// Giả lập tìm thấy thiết bị sau 1.5s
setTimeout(() => {
onDeviceFound({
id: 'HR_SENSOR_POLAR',
name: 'Polar H10',
serviceUUIDs: [Config.BLE.HEART_RATE_SERVICE_UUID]
});
}, 1500);
},
async connectToDevice(
deviceId: string,
onHeartRateUpdate: (hr: number) => void
): Promise<() => void> {
console.log(`Đang kết nối tới thiết bị BLE: ${deviceId}...`);
// Giả lập đẩy gói dữ liệu nhịp tim liên tục mỗi giây
const interval = setInterval(() => {
const simulatedHR = Math.round(120 + Math.random() * 20 - 10);
onHeartRateUpdate(simulatedHR);
}, 1000);
return () => {
console.log('Ngắt kết nối Bluetooth BLE');
clearInterval(interval);
};
}
};