/** * Machine-readable error codes for all Beacio operations. * Use in catch blocks to handle specific failure modes. * * @example * ```typescript * try { * await device.read('heart_rate', 'heart_rate_measurement') * } catch (e) { * if (e instanceof BeacioError) { * switch (e.code) { * case 'DEVICE_DISCONNECTED': await device.connect(); break; * case 'CHARACTERISTIC_NOT_READABLE': device.subscribe(...); break; * default: console.error(e.suggestion); * } * } * } * ``` */ type BeacioErrorCode = /** Invalid argument passed to an SDK method (e.g. negative timeout, malformed UUID). Not retriable. */ 'INVALID_PARAMETER' /** Browser or platform does not support Web Bluetooth at all. Not retriable. */ | 'BLUETOOTH_UNAVAILABLE' /** The Beacio Safari extension is not installed. Show an install banner via `@beacio/core/detect`. Not retriable. */ | 'EXTENSION_NOT_INSTALLED' /** * The Beacio Safari extension is installed but has not been enabled for THIS * origin (Safari's per-site extension grant), so `navigator.bluetooth` is inert * here. Distinct from {@link EXTENSION_NOT_INSTALLED} (nothing installed at all) * and from `DEVICE_NOT_FOUND` (the radio ran and found nothing) — the recovery is * "aA → Manage Extensions → {@link IOS_GRANT_WORDING_CANONICAL}", not "move the device closer". * Not retriable. */ | 'EXTENSION_NOT_ENABLED' /** User denied Bluetooth permission, or the call was not triggered by a user gesture. Not retriable. */ | 'PERMISSION_DENIED' /** No BLE device matched the given scan filters, or the device picker returned empty. Not retriable. */ | 'DEVICE_NOT_FOUND' /** GATT operation attempted on a disconnected device. Retriable -- call `connect()` first. */ | 'DEVICE_DISCONNECTED' /** Device did not respond within the connection timeout window. Retriable -- check range and advertising state. */ | 'CONNECTION_TIMEOUT' /** The requested GATT service UUID was not found on the connected device. Not retriable. */ | 'SERVICE_NOT_FOUND' /** The requested characteristic UUID was not found in the specified service. Not retriable. */ | 'CHARACTERISTIC_NOT_FOUND' /** The characteristic does not support the read property. Use `subscribe()` for notify-only characteristics. Not retriable. */ | 'CHARACTERISTIC_NOT_READABLE' /** The characteristic does not support write or writeWithoutResponse. Not retriable. */ | 'CHARACTERISTIC_NOT_WRITABLE' /** The characteristic does not support notify or indicate. Use `read()` for polling. Not retriable. */ | 'CHARACTERISTIC_NOT_NOTIFIABLE' /** Generic GATT failure (device busy, stack error, disconnected mid-operation). Retriable. */ | 'GATT_OPERATION_FAILED' /** A BLE scan is already running. Stop the current scan before starting a new one. Retriable. */ | 'SCAN_ALREADY_IN_PROGRESS' /** `Beacio.maxConnections` limit reached. Disconnect another device before connecting. Not retriable. */ | 'CONNECTION_LIMIT_REACHED' /** User dismissed the device picker without selecting a device. Not retriable. */ | 'USER_CANCELLED' /** A read/write/connect operation did not complete within the specified timeout. Retriable. */ | 'TIMEOUT' /** A chunked write was only partially completed. Retry with smaller chunks or reconnect. Retriable. */ | 'WRITE_INCOMPLETE'; export type { BeacioErrorCode as B };