import { DeviceDriver } from '../../drivers/types'; import { sleep } from './element.helper'; import { scrollToAndTap } from './device-settings.helper'; export interface DeviceInfo { firmwareVersion?: string; macAddress?: string; batteryLevel?: string; bleVersion?: string; } export async function navigateToDeviceInfo(driver: DeviceDriver): Promise { return await scrollToAndTap(driver, 'Device Info'); } export async function getDeviceInfo(driver: DeviceDriver): Promise { const source = await driver.getSource(); const info: DeviceInfo = {}; if (driver.platform === 'android') { const macMatch = source.match(/text="([A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2}:[A-Fa-f0-9]{2})"/); if (macMatch) info.macAddress = macMatch[1]; const vMatch = source.match(/text="(V[\d.]+)"/); if (vMatch) info.firmwareVersion = vMatch[1]; } else { const macMatch = source.match(/name="([A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2}:[A-F0-9]{2})"/); if (macMatch) info.macAddress = macMatch[1]; const vMatch = source.match(/name="(V[\d.]+)"/); if (vMatch) info.firmwareVersion = vMatch[1]; } return info; }