import { Config } from '@/constants/Config'; export const bleService = { async scanForHeartRateSensors(onDeviceFound: (device: any) => void): Promise { 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); }; } };