@ovok/native/bluetooth

Bluetooth: one `Bluetooth` entry point, one `Device` handle per paired device whose actions all run on the same

  • Stable unknown
  • Release candidate not available
  • Development since 1.17.0-dev.2305+58d9b20

Bluetooth: one Bluetooth entry point, one Device handle per paired device whose actions all run on the same link, and React hooks over both. Import from @ovok/native/bluetooth.

Classes

Bluetooth

The one entry point: the catalog, discovery, pairing, and a handle per paired device.

Constructors

Constructor
new Bluetooth(options): Bluetooth;
Parameters
ParameterType
optionsBluetoothOptions
Returns

Bluetooth

Methods

adapter()
adapter(): AdapterSnapshot;

The radio state and permission as last reported.

Returns

AdapterSnapshot

destroy()
destroy(): Promise<void>;

Stops watching the adapter and the app, stops syncing by itself, and disconnects every device.

Returns

Promise<void>

device()
device(address): Device | undefined;

The handle of the device paired at address, undefined when none is.

Parameters
ParameterType
addressstring
Returns

Device | undefined

devices()
devices(): readonly Device[];

The handle of every paired device.

Returns

readonly Device[]

discover()
discover(selector?, __namedParameters?): Discovery;

Scans for the devices the selector names; identifies against the whole catalog, then filters.

Parameters
ParameterType
selector?DeviceSelector
__namedParameters?DiscoverOptions
Returns

Discovery

forget()
forget(address): Promise<void>;

Disconnects a paired device, then removes it from the store and from devices.

Parameters
ParameterType
addressstring
Returns

Promise<void>

openSettings()
openSettings(): Promise<void>;

Opens the system settings, the only place a blocked permission can be granted.

Returns

Promise<void>

pair()
pair(found, choice?): Promise<Device>;

Pairs a found device and returns its handle, still connected so the first sync needs no reconnect.

Parameters
ParameterType
foundFound
choice?{ model?: string; }
choice.model?string
Returns

Promise<Device>

pairedSnapshots()
pairedSnapshots(): readonly DeviceSnapshot[];

The snapshot of every paired device, replaced whenever one changes.

Returns

readonly DeviceSnapshot[]

pinToEnter()
pinToEnter(model): string | null;

The PIN to show the user while model pairs, because the system prompt asks for it and this platform cannot enter it; null otherwise.

Parameters
ParameterType
modelDeviceModel
Returns

string | null

readings()
readings(): readonly ReceivedReading[];

The readings received this session, oldest first, with how each save went.

Returns

readonly ReceivedReading[]

requestPermission()
requestPermission(): Promise<BluetoothPermission>;

Prompts for Bluetooth permission if needed and returns the answer.

Returns

Promise<BluetoothPermission>

runnable()
runnable(model): boolean;

Whether this runtime has the protocol and the radio a model needs.

Parameters
ParameterType
modelDeviceModel
Returns

boolean

subscribeAdapter()
subscribeAdapter(listener): () => void;

Calls listener when the radio state or permission changes; returns the unsubscribe.

Parameters
ParameterType
listener() => void
Returns

() => void

subscribeDevices()
subscribeDevices(listener): () => void;

Calls listener when a device is paired or forgotten, or a paired one changes; returns the unsubscribe.

Parameters
ParameterType
listener() => void
Returns

() => void

subscribeReadings()
subscribeReadings(listener): () => void;

Calls listener when a reading arrives or its save state changes; returns the unsubscribe.

Parameters
ParameterType
listener() => void
Returns

() => void

Properties

PropertyModifierTypeDescription
catalogpublic readonlyCatalogThe models this runtime knows, whether or not it can run them.
readypublic readonlyPromise<void>Resolves once the stored paired devices are loaded.

Catalog

The models the SDK knows, in the order their defaults are chosen.

Constructors

Constructor
new Catalog(all): Catalog;
Parameters
ParameterTypeDescription
allreadonly DeviceModel[]Every model, in the order their defaults are chosen.
Returns

Catalog

Methods

model()
model(id): DeviceModel | undefined;

The model with this id, undefined when the catalog does not have it.

Parameters
ParameterType
idstring
Returns

DeviceModel | undefined

models()
models(selector?): DeviceModel[];

The models the selector names; every model when it names none.

Parameters
ParameterType
selector?DeviceSelector
Returns

DeviceModel[]

vendors()
vendors(): Vendor[];

The distinct vendors, sorted by name.

Returns

Vendor[]

Properties

PropertyModifierTypeDescription
allpublic readonlyreadonly DeviceModel[]Every model, in the order their defaults are chosen.

Device

One paired device: it owns the link, queues every action on it, and reconnects when a press needs it.

Accessors

address
Get Signature
get address(): string;

The address its record is stored under.

Returns

string

Constructors

Constructor
new Device(
   record,
   deps,
   latestAdvertisement?
): Device;
Parameters
ParameterType
recordPairedDevice
depsDeviceDeps
latestAdvertisement?Advertisement
Returns

Device

Methods

acknowledge()
acknowledge(recordId): Promise<void>;

Moves the cursor past a record once the app saved it, so the next sync skips it.

Parameters
ParameterType
recordIdstring
Returns

Promise<void>

change()
change(change): Promise<void>;

Changes one of the device's settings, such as a hearing aid's volume.

Parameters
ParameterType
changeHearingAidChange
Returns

Promise<void>

configure()
configure(settings): Promise<void>;

Changes and stores whether it syncs by itself, stays connected in the background, and records what it streams.

Parameters
ParameterType
settingsPartial<DeviceSettings>
Returns

Promise<void>

disconnect()
disconnect(): Promise<void>;

Stops live, waits for queued actions, then closes the link.

Returns

Promise<void>

fetch()
fetch(recordId): Promise<void>;

Delivers one stored record as a record event, whatever the cursor says.

Parameters
ParameterType
recordIdstring
Returns

Promise<void>

pair()
pair(): Promise<void>;

Opens the link for pairing, so the first sync runs on the same link; a broadcasting device opens none.

Returns

Promise<void>

records()
records(): Promise<RecordInfo[]>;

Lists the records stored on the device, without delivering them.

Returns

Promise<RecordInfo[]>

release()
release(recordId): void;

Forgets a delivered record without saving it, so the next sync delivers it again.

Parameters
ParameterType
recordIdstring
Returns

void

seen()
seen(ad): void;

A scan saw the device again; a broadcasting device's result is delivered once, until it sends a different one.

Parameters
ParameterType
adAdvertisement
Returns

void

setClock()
setClock(): Promise<void>;

Sets the device's clock to now.

Returns

Promise<void>

snapshot()
snapshot(): DeviceSnapshot;

What a UI shows now; replaced, never changed in place.

Returns

DeviceSnapshot

startLive()
startLive(): Promise<void>;

Starts live and waveform events, which the device also records and saves while it measures with record on.

Returns

Promise<void>

stopLive()
stopLive(): Promise<void>;

Stops the stream and waits until the device has stopped sending.

Returns

Promise<void>

stored()
stored(): PairedDevice;

The device as it is stored.

Returns

PairedDevice

subscribe()
subscribe(listener): () => void;

Calls listener for every event, state changes included; returns the unsubscribe.

Parameters
ParameterType
listener(event) => void
Returns

() => void

sync()
sync(): Promise<SyncSummary>;

Delivers each record past the cursor as a record event; the cursor moves on acknowledge.

Returns

Promise<SyncSummary>


DeviceError

A failed device action, with a stable code to branch on.

Extends

  • Error

Constructors

Constructor
new DeviceError(
   code,
   message,
   cause?
): DeviceError;
Parameters
ParameterTypeDescription
codeDeviceErrorCodeA stable code to branch on.
messagestring-
cause?unknownWhat threw underneath, when there was something.
Returns

DeviceError

Overrides

Error.constructor

Properties

PropertyModifierTypeDescriptionInherited from
cause?public readonlyunknownWhat threw underneath, when there was something.Error.cause
codepublic readonlyDeviceErrorCodeA stable code to branch on.-

Discovery

One scan: rows keyed by address and updated in place.

Constructors

Constructor
new Discovery(deps): Discovery;
Parameters
ParameterType
depsDiscoveryDeps
Returns

Discovery

Methods

snapshot()
snapshot(): DiscoverySnapshot;

The current rows and scan state, replaced on each change.

Returns

DiscoverySnapshot

start()
start(): void;

Starts scanning; a null filter means no model the selector names can run here, so nothing is scanned.

Returns

void

stop()
stop(): void;

Stops scanning; the rows already found stay in the snapshot.

Returns

void

subscribe()
subscribe(listener): () => void;

Calls listener whenever the snapshot changes; returns the unsubscribe.

Parameters
ParameterType
listener() => void
Returns

() => void

Functions

androidForegroundService()

function androidForegroundService(text?, __namedParameters?): KeepAlive;

Android's connected-device foreground service, which keeps the process alive for background sync; nothing elsewhere. With an outbox, its notification says how many readings wait to upload.

Parameters

ParameterType
text?ForegroundServiceText
__namedParameters?ForegroundServiceOptions

Returns

KeepAlive


blePlxCentral()

function blePlxCentral(manager): BleCentral;

The device's Bluetooth LE radio through react-native-ble-plx.

Parameters

ParameterType
managerBleManager

Returns

BleCentral


BluetoothProvider()

function BluetoothProvider(__namedParameters): Element;

Makes one Bluetooth available to the hooks below it.

Parameters

ParameterType
__namedParametersBluetoothProviderProps

Returns

Element


createBluetooth()

function createBluetooth(__namedParameters): Bluetooth;

Bluetooth for a React Native app, over react-native-ble-plx, saving readings to Ovok and syncing in the background. Call it as soon as the app starts: iOS relaunches an app it ended when a kept device connects, and gives it about 10 seconds.

Parameters

ParameterType
__namedParametersCreateBluetoothOptions

Returns

Bluetooth


osBluetoothPermissions()

function osBluetoothPermissions(): BluetoothPermissions;

The platform's Bluetooth permissions through react-native-permissions.

Returns

BluetoothPermissions


ovokOutboxWatch()

function ovokOutboxWatch(outbox, logger?): OutboxWatch;

Watches the signed-in account's Ovok outbox, so the reading log and the notification follow what it sends.

Parameters

ParameterTypeDefault value
outboxWatchedOutboxundefined
logger?LoggersilentLogger

Returns

OutboxWatch


ovokReadingSink()

function ovokReadingSink(client, savesFor?): ReadingSink;

Saves readings through the Ovok measurements API, queueing them offline: for the signed-in account, or for the patient savesFor names, or holds them when it returns HOLD. A reading with a series also saves it; a stored record then removes the live recordings it replaces, once it is saved.

Parameters

ParameterType
clientOvokSinkClient
savesFor?SavesFor

Returns

ReadingSink


reactNativeLifecycle()

function reactNativeLifecycle(): AppLifecycle;

The app's foreground and background through React Native's AppState.

Returns

AppLifecycle


storagePairedDevices()

function storagePairedDevices(storage, key?): PairedDeviceStore;

Paired devices as one JSON list under one key; writes run one after another so none is lost.

Parameters

ParameterTypeDefault value
storageOvokStorageundefined
key?stringDEFAULT_KEY

Returns

PairedDeviceStore


useBluetooth()

function useBluetooth(): Bluetooth;

The Bluetooth given to the nearest BluetoothProvider.

Returns

Bluetooth


useBluetoothAdapter()

function useBluetoothAdapter(): AdapterState;

The adapter and the Bluetooth permission, with the ways to change them.

Returns

AdapterState


useCatalog()

function useCatalog(selector?): DeviceModel[];

The models the selector names; the catalog never changes, so this renders once.

Parameters

ParameterType
selector?DeviceSelector

Returns

DeviceModel[]


useDevice()

function useDevice(address): object;

A paired device's snapshot and its actions; the actions never rely on this, so onPress={device.sync} works.

Parameters

ParameterType
addressstring

Returns

NameTypeDescription
deviceDevice | undefinedThe handle to run actions on, undefined until it is paired.
snapshotDeviceSnapshot | undefinedThe device's snapshot, undefined until it is paired.

useDiscovery()

function useDiscovery(selector?, __namedParameters?): DiscoveryState;

Scans for the devices the selector names while mounted, unless auto is false. In a browser that scan lists only the devices the site may already use; start from a click handler also opens the browser's chooser.

Parameters

ParameterType
selector?DeviceSelector
__namedParameters?{ auto?: boolean; }
__namedParameters.auto?boolean

Returns

DiscoveryState


useLiveValues()

function useLiveValues(address): LiveValues | null;

The newest live values a device streamed, such as its heart rate; null until one arrives.

Parameters

ParameterType
addressstring

Returns

LiveValues | null


usePairedDevices()

function usePairedDevices(): readonly DeviceSnapshot[];

Every paired device's snapshot.

Returns

readonly DeviceSnapshot[]


useReadings()

function useReadings(address?, __namedParameters?): readonly ReceivedReading[];

Readings received this session with their save state, newest last; one device's when address is given.

Parameters

ParameterType
address?string
__namedParameters?{ limit?: number; }
__namedParameters.limit?number

Returns

readonly ReceivedReading[]


useWaveform()

function useWaveform(address, __namedParameters?): WaveformBuffer;

A streamed waveform for a trace; it re-renders at most once per animation frame, never per sample.

Parameters

ParameterType
addressstring
__namedParameters?{ seconds?: number; }
__namedParameters.seconds?number

Returns

WaveformBuffer

Interfaces

AppLifecycle

The app's lifecycle as the OS reports it.

Methods

watch()
watch(listener): () => void;

Reports the visibility now and on each change, until the returned stop is called.

Parameters
ParameterType
listener(visibility) => void
Returns

() => void


BleCentral

The platform's Bluetooth Low Energy radio.

Methods

connect()
connect(address): Promise<GattLink>;

Opens a GATT connection to the device at address.

Parameters
ParameterType
addressstring
Returns

Promise<GattLink>

scan()
scan(filter, handlers): () => void;

Reports advertisements until the returned stop is called.

Parameters
ParameterType
filterScanFilter
handlersScanHandlers
Returns

() => void

watchState()
watchState(listener): () => void;

Reports the adapter state now and on each change, until the returned stop is called.

Parameters
ParameterType
listener(state) => void
Returns

() => void


BluetoothPermissions

The OS permission prompts Bluetooth needs.

Methods

check()
check(): Promise<BluetoothPermission>;

The current permission, without prompting.

Returns

Promise<BluetoothPermission>

openSettings()
openSettings(): Promise<void>;

Opens the system settings for the app.

Returns

Promise<void>

request()
request(): Promise<BluetoothPermission>;

Prompts if the OS still allows it, then returns the answer.

Returns

Promise<BluetoothPermission>


DeviceProtocol

One device family's conversation over an open link. C is the protocol's own per-link state. Each optional member is a capability: a protocol without live has no live button.

Type Parameters

Type ParameterDefault type
Cunknown

Methods

battery()?
battery?(connection): Promise<Omit<Battery, "at">>;

Reads the battery level.

Parameters
ParameterType
connectionC
Returns

Promise<Omit<Battery, "at">>

broadcast()?
broadcast?(advertisement, receivedAt): HistoryRecord | null;

Reads the result a device sends in its advertisement, for a device that opens no link; null when it carries none. The id must stay the same while the device repeats one result, so the result is delivered once. receivedAt is when the advertisement arrived, for a device that sends no time.

Parameters
ParameterType
advertisementAdvertisement
receivedAtDate
Returns

HistoryRecord | null

change()?
change?(connection, change): Promise<void>;

Changes one setting; rejects when the device refuses it.

Parameters
ParameterType
connectionC
changeHearingAidChange
Returns

Promise<void>

close()?
close?(connection): Promise<void>;

Lets go of the per-link state when the link ends.

Parameters
ParameterType
connectionC
Returns

Promise<void>

fetch()?
fetch?(connection, recordId): Promise<DecodedReading | null>;

null for a record the protocol cannot decode, which then counts as handled.

Parameters
ParameterType
connectionC
recordIdstring
Returns

Promise<DecodedReading | null>

history()?
history?(connection, saved): AsyncIterable<HistoryRecord>;

Reads the stored records of a device that sends them in order, oldest first, for a device without records. saved holds the ids already saved, newest last, so a protocol that can ask for records after one starts there.

Parameters
ParameterType
connectionC
savedreadonly string[]
Returns

AsyncIterable<HistoryRecord>

identify()?
identify?(connection): Promise<Omit<DeviceIdentity, "at">>;

Reads the serial, firmware and hardware the device reports.

Parameters
ParameterType
connectionC
Returns

Promise<Omit<DeviceIdentity, "at">>

live()?
live?(
   connection,
   onFrame,
   signal
): Promise<void>;

Streams until signal aborts, then stops the device's stream before it resolves.

Parameters
ParameterType
connectionC
onFrame(frame) => void
signalAbortSignal
Returns

Promise<void>

open()
open(context): Promise<C>;

Starts the conversation and returns the state every other member receives.

Parameters
ParameterType
contextProtocolContext
Returns

Promise<C>

pairing()?
pairing?(connection): Promise<void>;

What pairing needs after the connect steps, on a link of its own that closes once it is done.

Parameters
ParameterType
connectionC
Returns

Promise<void>

records()?
records?(connection): Promise<RecordInfo[]>;

Lists the records stored on the device, without reading them.

Parameters
ParameterType
connectionC
Returns

Promise<RecordInfo[]>

setClock()?
setClock?(connection, now): Promise<void>;

Sets the device's clock to now.

Parameters
ParameterType
connectionC
nowDate
Returns

Promise<void>

Properties

PropertyModifierTypeDescription
idreadonlystringWhat DeviceModel.protocol names.
servicesreadonlyreadonly string[]The GATT services it uses, full upper-case UUIDs.

An open GATT connection: bytes in, bytes out, no knowledge of any device.

Methods

close()
close(): Promise<void>;

Ends the connection.

Returns

Promise<void>

onDisconnect()
onDisconnect(listener): () => void;

Calls listener when the device drops the link; returns the unsubscribe.

Parameters
ParameterType
listener() => void
Returns

() => void

read()
read(service, characteristic): Promise<Uint8Array<ArrayBufferLike>>;

Reads one characteristic once.

Parameters
ParameterType
servicestring
characteristicstring
Returns

Promise<Uint8Array<ArrayBufferLike>>

subscribe()
subscribe(
   service,
   characteristic,
   onValue
): Promise<() => void>;

Calls onValue for each notification or indication; resolves to the unsubscribe once it is enabled.

Parameters
ParameterType
servicestring
characteristicstring
onValue(bytes) => void
Returns

Promise<() => void>

write()
write(
   service,
   characteristic,
   bytes
): Promise<void>;

Writes with response.

Parameters
ParameterType
servicestring
characteristicstring
bytesUint8Array
Returns

Promise<void>

writeWithoutResponse()
writeWithoutResponse(
   service,
   characteristic,
   bytes
): Promise<void>;

Writes without waiting for the device to confirm, for a characteristic that only accepts that.

Parameters
ParameterType
servicestring
characteristicstring
bytesUint8Array
Returns

Promise<void>


KeepAlive

Keeps the app process alive while devices are connected or kept connected; Android needs a foreground service.

Methods

start()
start(): Promise<void>;

Starts keeping the process alive.

Returns

Promise<void>

stop()
stop(): Promise<void>;

Lets the OS manage the process again.

Returns

Promise<void>


Logger

Structured logging: a stable event name and a context; never readings, frames or other health data.

Methods

debug()
debug(event, context?): void;

Development detail.

Parameters
ParameterType
eventstring
context?LogContext
Returns

void

error()
error(event, context?): void;

A failure, possibly recoverable.

Parameters
ParameterType
eventstring
context?LogContext
Returns

void

info()
info(event, context?): void;

A success or an expected but notable event.

Parameters
ParameterType
eventstring
context?LogContext
Returns

void

warn()
warn(event, context?): void;

Something unexpected that is not a failure.

Parameters
ParameterType
eventstring
context?LogContext
Returns

void


OutboxWatch

The offline queue behind a sink, which the reading log and the foreground notification watch; the sink side provides it.

Methods

subscribe()
subscribe(listener): () => void;

Calls listener with the view now and after every change, until the returned stop is called.

Parameters
ParameterType
listener(view) => void
Returns

() => void


PairedDeviceStore

Where paired devices are kept between app starts.

Methods

load()
load(): Promise<PairedDevice[]>;

Every stored device.

Returns

Promise<PairedDevice[]>

remove()
remove(address): Promise<void>;

Deletes the device stored at address.

Parameters
ParameterType
addressstring
Returns

Promise<void>

save()
save(device): Promise<void>;

Adds the device, or replaces the one with the same address.

Parameters
ParameterType
devicePairedDevice
Returns

Promise<void>


ReadingSink

Where readings are saved; device is the snapshot of the device that took it.

Methods

save()
save(reading, device): Promise<SaveOutcome | SaveReceipt>;

Saves one reading, and says which outbox items hold it when it was queued; rejects when it could be neither saved nor queued.

Parameters
ParameterType
readingReading
deviceDeviceSnapshot
Returns

Promise<SaveOutcome | SaveReceipt>

Type Aliases

AdapterSnapshot

type AdapterSnapshot = object;

What the radio and the app's permission look like right now.

Properties

permission
permission: BluetoothPermission;

Whether the app may use it.

state
state: AdapterState;

Whether the radio is usable.


AdapterState

type AdapterState = "unknown" | "on" | "off" | "unauthorized" | "unsupported";

The Bluetooth adapter; unknown until the platform reports it.


AdvertisementTest

type AdvertisementTest =
  | {
  kind: "service";
  uuid: string;
}
  | {
  at: number;
  company: number;
  equals: string;
  kind: "manufacturer";
  mask?: string;
}
  | {
  at: number;
  equals: string;
  kind: "serviceData";
  mask?: string;
  uuid: string;
};

A test on advertised bytes; mask and equals are hex.

Union Members

Type Literal
{
  kind: "service";
  uuid: string;
}
NameTypeDescription
kind"service"Passes when the advertisement lists a service.
uuidstringThe service UUID, short or full.

Type Literal
{
  at: number;
  company: number;
  equals: string;
  kind: "manufacturer";
  mask?: string;
}
NameTypeDescription
atnumberByte offset where the comparison starts.
companynumberThe company id the data is keyed by.
equalsstringThe bytes expected after masking.
kind"manufacturer"Reads bytes of the manufacturer data; no such data means no verdict.
mask?stringANDed with the bytes before comparing; without it every bit counts.

Type Literal
{
  at: number;
  equals: string;
  kind: "serviceData";
  mask?: string;
  uuid: string;
}
NameTypeDescription
atnumberByte offset where the comparison starts.
equalsstringThe bytes expected after masking.
kind"serviceData"Reads bytes of a service's data; no such data means no verdict.
mask?stringANDed with the bytes before comparing; without it every bit counts.
uuidstringThe service whose data is read, short or full.

AppVisibility

type AppVisibility = "foreground" | "background";

Whether the app is in front of the user.


Battery

type Battery = object;

The device's battery as it last reported it.

Properties

at
at: Date;

When the device reported it.

charging
charging: boolean | null;

Whether it is charging, null when the device does not say.

percent
percent: number;

Charge level from 0 to 100.


BluetoothOptions

type BluetoothOptions = object;

The ports and data Bluetooth runs on; each platform entry point fills them in.

Properties

autoSync?
autoSync?: boolean;

Whether paired devices sync by themselves when seen; turn it off where a scan needs the user, as in a browser.

central
central: BleCentral;

The platform's BLE radio.

keepAlive?
keepAlive?: KeepAlive;

Keeps the process alive while devices are connected; nothing extra, by default.

lifecycle?
lifecycle?: AppLifecycle;

Whether the app is in the foreground; always, by default.

logger?
logger?: Logger;

Where structured events go; silent by default.

lostAfterMs?
lostAfterMs?: number;

A scan row silent this long is dropped.

models
models: readonly DeviceModel[];

The models to identify, usually the built-in ones.

now?
now?: () => Date;

The clock; a test passes a fixed one.

Returns

Date

outbox?
outbox?: OutboxWatch;

The offline queue behind the sink; the reading log follows it, so a queued reading becomes saved. Nothing waits, by default.

pairingAgent?
pairingAgent?: PairingAgent;

Enters a model's fixed PIN for the user; without one, the user types it into the system prompt.

permissions
permissions: BluetoothPermissions;

The OS permission prompts.

protocols
protocols: readonly DeviceProtocol[];

The protocols that talk to them; a model whose protocol is missing is unsupported here.

sink
sink: ReadingSink;

Where readings are saved.

store
store: PairedDeviceStore;

Where paired devices are kept.


BluetoothPermission

type BluetoothPermission = "unknown" | "granted" | "denied" | "blocked";

Whether the app may use Bluetooth; blocked means only the system settings can grant it.


BluetoothProviderProps

type BluetoothProviderProps = object;

What BluetoothProvider takes.

Properties

bluetooth
bluetooth: Bluetooth;

The instance every hook below it reads.

children
children: ReactNode;

The tree that may use the hooks.


ConnectionState

type ConnectionState =
  | "disconnected"
  | "connecting"
  | "pairing"
  | "connected"
  | "disconnecting";

Where the link stands; pairing is a new device's first connect.


CreateBluetoothOptions

type CreateBluetoothOptions = object & Partial<BluetoothOptions>;

What createBluetooth needs; every port can be swapped, for tests or a custom store or sink.

Type Declaration

NameTypeDescription
ovokOvokSinkClientThe Ovok client readings are saved through.
savesFor?SavesForThe patient readings are saved for when the person measuring isn't the patient, such as a clinician; see SavesFor.
storageOvokStorageWhere paired devices are kept between app starts.

DeviceAction

type DeviceAction = "sync" | "records" | "fetch" | "live" | "setClock" | "change";

A button a device may offer.


DeviceChange

type DeviceChange = HearingAidChange;

One setting to change on a device, one shape per kind of device.


DeviceErrorCode

type DeviceErrorCode =
  | "unsupported"
  | "adapter-off"
  | "permission"
  | "connect-failed"
  | "timeout"
  | "protocol"
  | "disconnected"
  | "save-failed";

Why a device action failed.


DeviceEvent

type DeviceEvent =
  | {
  kind: "state";
  snapshot: DeviceSnapshot;
}
  | {
  kind: "record";
  reading: Reading;
}
  | {
  kind: "reading";
  reading: Reading;
}
  | {
  kind: "live";
  values: LiveValues;
}
  | {
  kind: "waveform";
  waveform: Waveform;
};

What a device handle reports: its new snapshot, and readings to save or show.

Union Members

Type Literal
{
  kind: "state";
  snapshot: DeviceSnapshot;
}
NameTypeDescription
kind"state"The snapshot changed.
snapshotDeviceSnapshotThe snapshot after the change.

Type Literal
{
  kind: "record";
  reading: Reading;
}

Stored on the device; acknowledge it once saved.

NameTypeDescription
kind"record"A record stored on the device; save it, then acknowledge it.
readingReadingThe decoded record; source.recordId names it.

Type Literal
{
  kind: "reading";
  reading: Reading;
}

A finished measurement the device does not store.

NameTypeDescription
kind"reading"A finished measurement; save it, there is nothing to acknowledge.
readingReadingThe measurement; source.recordId is null.

Type Literal
{
  kind: "live";
  values: LiveValues;
}
NameTypeDescription
kind"live"Streaming numbers for display only; never saved.
valuesLiveValuesThe numbers one notification carried.

Type Literal
{
  kind: "waveform";
  waveform: Waveform;
}
NameTypeDescription
kind"waveform"Streaming samples for display only; never saved.
waveformWaveformOne batch of samples, as one notification delivered it.

DeviceFlag

type DeviceFlag = object;

A flag exactly as the device reported it; never an interpretation.

Properties

code
code: string;

The flag's name, as the device defines it.

raw
raw: number;

The raw bits or value the device sent for it.


DeviceIdentity

type DeviceIdentity = object;

What a device reports about itself; a field is null when it leaves it out.

Properties

at
at: Date;

When it was read.

firmware
firmware: string | null;

The firmware version.

hardware
hardware: string | null;

The hardware revision.

manufacturer
manufacturer: string | null;

The maker, as the device names itself.

model
model: string | null;

The model, as the device names itself; it may differ from the catalog's name.

serial
serial: string | null;

The serial number.


DeviceModel

type DeviceModel = object;

One device model the SDK knows.

Properties

direction
direction: "phone_connects" | "device_connects" | "cloud";

Who opens the connection: the phone, the device, or nobody because the data is in a cloud.

generic
generic: boolean;

No named vendor, such as a generic heart-rate strap; a specific match always wins over it.

id
id: string;

Our model slug, e.g. viatom/bp2.

imageUrl?
imageUrl?: string;

Picture of the device, when one is known.

links: readonly LinkOption[];

How it is found and read; this SDK runs a model only when one link reads over ble.

match
match: MatchRule;

What picks it out of the advertisements.

measures
measures: readonly MeasurementType[];

What it measures.

name
name: string;

The name people know it by, e.g. DuoEK-S.

nameCheck
nameCheck: "none" | "exact" | "last4";

How a paired device is re-checked when it is seen again: no check, the exact name, or its last 4 characters.

pin
pin: Pin;

What its pairing prompt expects.

protocol
protocol: string;

The DeviceProtocol.id that talks to it.

serialPairing
serialPairing: boolean;

Pairing is tied to the serial number of the device.

userBound
userBound: boolean;

The device belongs to one user rather than being shared.

vendor
vendor: Vendor;

Who sells it.


DeviceSecret

type DeviceSecret = object;

A value a device hands over when it pairs and wants back on later links, such as a password; kept with the paired device.

Properties

read
read: () => Promise<string | null>;

The kept value, null before the device gave one.

Returns

Promise<string | null>

write
write: (value) => Promise<void>;

Keeps the value the device gave.

Parameters
ParameterType
valuestring
Returns

Promise<void>


DeviceSelector

type DeviceSelector = object;

Narrows models: fields combine with AND, the values within one field with OR.

Properties

model?
model?: string | readonly string[];

Model ids to keep.

type?
type?:
  | MeasurementType
  | readonly MeasurementType[];

Measurement types to keep; a model that measures any one of them stays.

vendor?
vendor?: string | readonly string[];

Vendor ids to keep.


DeviceSettings

type DeviceSettings = Pick<PairedDevice, "autoSync" | "keepInBackground" | "record">;

The settings a user can change on a paired device.


DeviceSnapshot

type DeviceSnapshot = object;

Everything a UI shows about one paired device; the same keys for every model.

Properties

actions
actions: readonly DeviceAction[];

The actions its protocol supports; offer a button for each.

activity
activity: Exclude<DeviceAction, "live"> | null;

What the action queue is running; live runs beside it.

address
address: string;

The address it is paired under; Bluetooth.device takes it.

autoSync
autoSync: boolean;

Whether it syncs by itself when a scan sees it.

battery
battery: Battery | null;

The latest battery report, null until the device gives one.

connection
connection: ConnectionState;

The link's state; actions reconnect on demand, so disconnected between presses is normal.

deviceState
deviceState: DeviceState | null;

What the device reports about itself while its stream runs, null otherwise.

deviceStatus
deviceStatus:
  | {
  at: Date;
  code: string;
}
  | null;

The device's own run status, raw; null until its protocol reports one.

Union Members
Type Literal
{
  at: Date;
  code: string;
}
at
at: Date;

When the device reported it.

code
code: string;

The status code exactly as the device sent it.


null

identity
identity: DeviceIdentity | null;

The latest serial, firmware and hardware report, null until read.

keepInBackground
keepInBackground: boolean;

Whether its link stays open while the app is in the background.

lastConnectedAt
lastConnectedAt: Date | null;

When a link last opened.

lastError
lastError: DeviceError | null;

Cleared by the next action that succeeds.

lastReadingAt
lastReadingAt: Date | null;

When a record was last delivered.

lastSeenAt
lastSeenAt: Date | null;

When a scan last saw it this session.

lastSyncedAt
lastSyncedAt: Date | null;

When a sync last succeeded.

lastSyncOutcome
lastSyncOutcome: "success" | "failed" | null;

How the latest sync ended, null before the first.

live
live: boolean;

Whether a live stream is running.

measuringSince
measuringSince: Date | null;

Since when live frames have kept arriving, so the device is measuring; null once they stop for a few seconds.

model
model: object;

The catalog model, flattened for display.

id
id: string;

The catalog id, e.g. viatom/bp2.

name
name: string;

The model's display name.

vendor
vendor: string;

The vendor's display name.

name
name: string;

The title to show: the user's, else the advertised name, else the model's.

pairedAt
pairedAt: Date;

When it was first paired.

progress
progress:
  | {
  done: number;
  total: number | null;
}
  | null;

How far a running sync has got; null when none is running.

Union Members
Type Literal
{
  done: number;
  total: number | null;
}
done
done: number;

Records fetched so far.

total
total: number | null;

Records the sync will fetch, null when unknown.


null

record
record: boolean;

Whether what it streams while measuring is recorded and saved, as well as shown.

rssi
rssi: number | null;

Signal strength in dBm from that scan.

unacknowledged
unacknowledged: number;

Records delivered and not yet acknowledged.


DeviceState

type DeviceState = HearingAidState;

What a device reports about itself beyond its battery and identity, one shape per kind of device.


DiscoverOptions

type DiscoverOptions = object;

How Bluetooth.discover scans.

Properties

chooser?
chooser?: boolean;

In a browser, whether to open its device chooser, which it allows only from a click; without it the scan lists only the devices the site may already use. Defaults to true.


DiscoverySnapshot

type DiscoverySnapshot = object;

What a scan shows right now.

Properties

error
error: DeviceError | null;

Why the scan failed, null when it has not.

found
found: readonly Found[];

One row per device, without the ones that went silent.

scanning
scanning: boolean;

Whether the radio is scanning.


EarSide

type EarSide = "left" | "right";

One ear of a pair.


EarState

type EarState = object;

One ear of a hearing aid pair as it last reported itself; a field is null until the ear answers.

Properties

battery
battery: number | null;

Charge level from 0 to 100.

charging
charging: boolean | null;

Whether it is charging.

inCase
inCase: boolean | null;

Whether it sits in its charging case.

inEar
inEar: boolean | null;

Whether its sensor says it sits in the ear.


FactoryReset

type FactoryReset = object;

The maker's defaults restored on a hearing aid: volume 9, noise reduction on, mixed mode, Chinese prompts.

Properties

kind
kind: "factory-reset";

Which setting changes.


ForegroundServiceOptions

type ForegroundServiceOptions = object;

What the service watches and reports besides its text.

Properties

logger?
logger?: Logger;

Where structured events go; silent by default.

outbox?
outbox?: OutboxWatch;

The offline queue whose waiting readings the notification counts; with none, it never shows a count.


ForegroundServiceText

type ForegroundServiceText = object;

The notification Android shows while the service runs.

Properties

notificationBody?
notificationBody?: string;

The notification's body.

notificationTitle?
notificationTitle?: string;

The notification's title.

unsentBody?
unsentBody?: (unsent) => string;

The body while readings wait to upload, given how many; "3 readings waiting to upload" by default.

Parameters
ParameterType
unsentnumber
Returns

string


Found

type Found = object;

A device a scan found, one row per address.

Extended by

Properties

address
address: string;

Its address, in the one-spelling form addressKey makes.

lastSeenAt
lastSeenAt: Date;

When its latest advertisement arrived.

match
match: Identification;

What the catalog makes of it.

name
name: string | null;

The advertised name, null when it has none.

rssi
rssi: number | null;

Signal strength in dBm, null when the platform gives none.


HearingAidChange

type HearingAidChange =
  | VolumeChange
  | ModeChange
  | NoiseReductionChange
  | MicrophoneChange
  | InEarDetectionChange
  | PromptLanguageChange
  | FactoryReset;

One setting to change on a hearing aid.


HearingAidMode

type HearingAidMode = "mixed" | "hearing-aid" | "earphone";

How a hearing aid plays sound: amplifying what it hears, playing Bluetooth audio, or both.


HearingAidState

type HearingAidState = object;

A hearing aid pair as it reports itself while linked, every value as the aid sent it.

Properties

ears
ears: Partial<Record<EarSide, EarState>>;

The linked ears.

inEarDetection
inEarDetection: boolean | null;

Whether it pauses when taken out of the ear, null until read.

kind
kind: "hearing-aid";

The kind of device the state comes from.

mainEar
mainEar: EarSide;

The ear that speaks for the pair.

microphone
microphone: MicrophoneDirection | null;

Where it listens, null until changed, since the aid cannot be asked.

mode
mode: HearingAidMode | null;

How it plays sound, null until read or for a value the aid reserves.

noiseReduction
noiseReduction: boolean | null;

Whether noise reduction is on, null until read.

noiseScene
noiseScene: NoiseScene | null;

The surroundings noise reduction is tuned for, null until read.

promptLanguage
promptLanguage: PromptLanguage | null;

The language of its voice prompts, null until read.

volume
volume: VolumeStep | null;

The volume step and the highest step, null until read.


HistoryRecord

type HistoryRecord = object;

A stored record read in order by a device that does not address its records one by one.

Properties

id
id: string;

The device's stable id for it, such as a sequence number or its time; the cursor stores it.

reading
reading: DecodedReading | null;

null for a record the protocol cannot decode, which then counts as handled.


Identification

type Identification =
  | {
  device: PairedDevice;
  kind: "paired";
}
  | {
  kind: "supported";
  variants: readonly [DeviceModel, ...DeviceModel[]];
}
  | {
  kind: "unsupported";
  known: readonly DeviceModel[];
};

What an advertisement is: a paired device, the models it matches, or known models this platform cannot run.

Union Members

Type Literal
{
  device: PairedDevice;
  kind: "paired";
}
NameTypeDescription
devicePairedDeviceIts stored record.
kind"paired"Already paired, and its stored name and bytes still agree.

Type Literal
{
  kind: "supported";
  variants: readonly [DeviceModel, ...DeviceModel[]];
}

The first variant is the default.

NameTypeDescription
kind"supported"Not paired, in the catalog, and runnable here.
variantsreadonly [DeviceModel, ...DeviceModel[]]The models it may be.

Type Literal
{
  kind: "unsupported";
  known: readonly DeviceModel[];
}

Known models this platform cannot run.

NameTypeDescription
kind"unsupported"Not paired and in the catalog, but nothing here can run it.
knownreadonly DeviceModel[]The models it matches.

InEarDetectionChange

type InEarDetectionChange = object;

Whether a hearing aid pauses when taken out of the ear.

Properties

kind
kind: "in-ear-detection";

Which setting changes.

on
on: boolean;

Whether in-ear detection is on.


LinkOption

type LinkOption = object;

One way to reach a model: how it is found, and how its data is read.

Properties

data
data: Transport;

What its data is read over.

discover
discover: Transport;

What the device advertises over.


LiveFrame

type LiveFrame = object;

What one live notification carries.

Properties

measuring?
measuring?: boolean;

Whether the device says it is measuring; without it, a frame with numbers or samples counts as measuring.

result?
result?: LiveResult;

A measurement that finished during the stream, saved like a synced record.

state?
state?: DeviceState;

What the device reports about itself, for a device whose stream is its state rather than a measurement.

values?
values?: LiveValues;

Numbers to show, when the notification had any.

waveform?
waveform?: Waveform;

Samples to trace, when it had any.


LiveResult

type LiveResult = object;

A finished measurement a live stream carries, such as a bedside monitor's cuff result.

Properties

id
id: string;

Stays the same while the device repeats one result, so the result is delivered once.

reading
reading: DecodedReading;

The measurement, as the protocol decoded it.


LiveSpan

type LiveSpan = object;

A stretch of a live stream the app recorded; a stored record that covers it replaces it.

Properties

channel
channel: string | null;

The waveform channel it holds, null for numbers.

from
from: Date;

When its first value or sample was taken.

metric
metric: MetricCode | Waveform["metric"];

What was recorded: a number's metric, or a waveform's.

to
to: Date;

When it ends.


LiveValues

type LiveValues = object;

Streaming numbers for display, such as the heart rate a strap sends every second.

Properties

at
at: Date;

When the notification arrived.

deviceFlags
deviceFlags: readonly DeviceFlag[];

The device's raw flags, never interpretations.

rrIntervalsMs?
rrIntervalsMs?: readonly number[];

Beat-to-beat intervals in milliseconds, when the device sends them.

values
values: Partial<Record<MetricCode, Quantity>>;

The streamed numbers.


MatchRule

type MatchRule = object;

How an advertisement is recognised as a model.

Properties

names?
names?: readonly string[];

Whole-string globs; any one matching is enough. Without names, requires alone decides.

requires?
requires?: readonly AdvertisementTest[];

Every test must pass.

services?
services?: readonly string[];

Confirm-only: a hit narrows the candidates, a miss never rejects.


MeasurementType

type MeasurementType = typeof MEASUREMENT_TYPES[number];

What a device measures.


MetricCode

type MetricCode =
  | "systolic"
  | "diastolic"
  | "mean_arterial_pressure"
  | "cuff_pressure"
  | "pulse_rate"
  | "heart_rate"
  | "fetal_heart_rate"
  | "ecg_qrs_duration"
  | "ecg_qtc_interval"
  | "pvc_count"
  | "energy_expended"
  | "blood_glucose"
  | "blood_ketone"
  | "blood_uric_acid"
  | "blood_cholesterol"
  | "hdl_cholesterol"
  | "ldl_cholesterol"
  | "triglycerides"
  | "blood_lactate"
  | "hemoglobin"
  | "hematocrit"
  | "body_weight"
  | "body_height"
  | "bmi"
  | "body_fat_percent"
  | "body_water_percent"
  | "muscle_percent"
  | "muscle_mass"
  | "fat_free_mass"
  | "soft_lean_mass"
  | "body_water_mass"
  | "bone_mass"
  | "visceral_fat"
  | "basal_metabolic_rate"
  | "metabolic_age"
  | "impedance"
  | "body_temperature"
  | "spo2"
  | "perfusion_index"
  | "pulse_amplitude_index"
  | "respiration_rate"
  | "fvc"
  | "fev1"
  | "fev1_fvc_ratio"
  | "pef"
  | "fef25_75"
  | "steps"
  | "distance"
  | "active_energy"
  | "urine_urobilinogen"
  | "urine_blood"
  | "urine_bilirubin"
  | "urine_ketones"
  | "urine_glucose"
  | "urine_protein"
  | "urine_ph"
  | "urine_nitrite"
  | "urine_leukocytes"
  | "urine_specific_gravity"
  | "urine_ascorbic_acid"
  | "urine_microalbumin"
  | "urine_creatinine"
  | "urine_calcium";

What one value in a reading is.


MicrophoneChange

type MicrophoneChange = object;

Where a hearing aid listens.

Properties

direction
direction: MicrophoneDirection;

The direction to set.

kind
kind: "microphone";

Which setting changes.


MicrophoneDirection

type MicrophoneDirection = "all-around" | "front";

Where a hearing aid listens: all around with one microphone, or ahead with two.


ModeChange

type ModeChange = object;

A new way for a hearing aid to play sound.

Properties

kind
kind: "mode";

Which setting changes.

mode
mode: HearingAidMode;

The mode to set.


NoiseReductionChange

type NoiseReductionChange = object;

Noise reduction turned on or off, tuned for a scene.

Properties

kind
kind: "noise-reduction";

Which setting changes.

on
on: boolean;

Whether noise reduction is on.

scene
scene: NoiseScene;

The surroundings it is tuned for.


NoiseScene

type NoiseScene = "general" | "outdoor" | "meeting" | "cinema";

The surroundings a hearing aid's noise reduction is tuned for.


OutboxView

type OutboxView = object;

Where each outbox item stands, by id, at one moment.

Properties

rejected
rejected: ReadonlySet<string>;

Items the server refused; they wait for a resend or a discard.

sent
sent: ReadonlySet<string>;

Items the server accepted lately; an item that is in none of the three sets was discarded, or is another account's.

waiting
waiting: ReadonlySet<string>;

Items still to be sent, including the one in flight.


OvokSinkClient

type OvokSinkClient = SupersessionClient;

What the sink saves with: the measurements API, the outbox that deletes, and the session that names the patient.


PairedDevice

type PairedDevice = object;

A paired device as it is stored, so it survives an app restart.

Properties

address
address: string;

The address in the form addressKey makes; the store key.

autoSync
autoSync: boolean;

Whether it syncs by itself when a scan sees it, as well as on a button press.

battery
battery: Battery | null;

The latest battery report.

cursor
cursor: readonly string[];

Ids of the device's records that were saved, kept only while the device still holds them.

identity
identity: DeviceIdentity | null;

The latest identity report.

keepInBackground
keepInBackground: boolean;

Whether its link stays open while the app is in the background, reconnecting when it drops.

lastConnectedAt
lastConnectedAt: Date | null;

When a link last opened.

lastReadingAt
lastReadingAt: Date | null;

When a record was last delivered.

lastSyncedAt
lastSyncedAt: Date | null;

When a sync last succeeded.

lastSyncOutcome
lastSyncOutcome: "success" | "failed" | null;

How the latest sync ended, null before the first.

modelId
modelId: string;

The catalog model it was paired as.

name
name: string | null;

The user's title, else the advertised name.

pairedAt
pairedAt: Date;

When it was first paired.

record
record: boolean;

Whether what it streams live is recorded and saved, as well as shown.

secret
secret: string | null;

The value the device handed over when it paired, such as a password; null when it gave none.


Pin

type Pin =
  | {
  kind: "none";
}
  | {
  kind: "fixed";
  value: string;
}
  | {
  kind: "ask";
};

The PIN a model expects when it pairs.

Union Members

Type Literal
{
  kind: "none";
}
NameTypeDescription
kind"none"Pairing asks for no PIN.

Type Literal
{
  kind: "fixed";
  value: string;
}
NameTypeDescription
kind"fixed"Pairing asks for one PIN, the same on every device.
valuestringThat PIN.

Type Literal
{
  kind: "ask";
}
NameTypeDescription
kind"ask"Pairing asks the user to type a PIN.

PromptLanguage

type PromptLanguage = "chinese" | "english";

The language of a hearing aid's voice prompts.


PromptLanguageChange

type PromptLanguageChange = object;

The language of a hearing aid's voice prompts.

Properties

kind
kind: "prompt-language";

Which setting changes.

language
language: PromptLanguage;

The language to set.


ProtocolContext

type ProtocolContext = object;

What a protocol gets when a link opens.

Properties

advertisement?: Advertisement;

The latest advertisement a scan saw from the device; absent when none has since the app started.

link: GattLink;

The open connection to talk over.

logger
logger: Logger;

For structured events; never readings, frames or secrets.

now
now: () => Date;

The clock, for protocols that stamp what they read.

Returns

Date

secret
secret: DeviceSecret;

Where the device's pairing secret is kept between links.


Quantity

type Quantity = object;

A value with its UCUM unit.

Properties

unit
unit: string;

The UCUM unit code, e.g. mm[Hg].

value
value: number;

The number, in unit.


Reading

type Reading = object;

One measurement, keyed by metric.

Properties

deviceFlags
deviceFlags: readonly DeviceFlag[];

The device's raw flags, never interpretations.

live?
live?: LiveSpan;

Set when the app recorded this from a live stream, with the time it covers.

series?
series?: Series;

Values at a fixed interval, for a measurement that records them, such as a heart rate per second.

source
source: ReadingSource;

The model, protocol, address and record it came from.

supersedes?
supersedes?: readonly LiveSpan[];

The live recordings a stored record replaces; the sink removes them before it saves the record.

takenAt
takenAt: Date | null;

When the device took it, null when it sends no time.

type
type: MeasurementType;

What was measured.

values
values: Partial<Record<MetricCode, Quantity>>;

The measured numbers; only the metrics this measurement has.

waveform?
waveform?: Waveform;

The raw trace, for a measurement that records one, such as an ECG.


ReadingSource

type ReadingSource = object;

Where a reading came from; recordId names a record stored on the device, null for a live value.

Properties

address
address: string;

The device's address.

modelId
modelId: string;

The catalog model id.

protocolId
protocolId: string;

The protocol that decoded it.

recordId
recordId: string | null;

The device's id for the stored record, null for a live value or a measurement it does not store.


ReceivedReading

type ReceivedReading = object;

A reading received this session and how its save went.

Properties

id
id: string;

Unique in the log: the address and record id, or the receive time for a reading with no record.

queueIds?
queueIds?: readonly string[];

The outbox items that hold the reading while it is queued or rejected, as ovok.outbox.items lists them.

reading
reading: Reading;

The reading as the device delivered it.

receivedAt
receivedAt: Date;

When this session received it.

save
save: SaveState;

How its save is going.


RecordInfo

type RecordInfo = object;

A record the device stores, such as a Viatom file.

Properties

id
id: string;

The device's own name for the record; the cursor stores it.

takenAt
takenAt: Date | null;

When it was measured, null when the device does not say.


SaveOutcome

type SaveOutcome = "saved" | "queued";

How a sink took a reading: saved, or kept in an offline queue that will save it.


SaveReceipt

type SaveReceipt = object;

What a sink says about a save: how it went and, for a queued reading, which outbox items hold it.

Properties

queueIds?
queueIds?: readonly string[];

The outbox items that hold the queued part of the reading, as ovok.outbox.items lists them; one per queued measurement.

status
status: SaveOutcome;

Saved, or kept in the outbox.


SavesFor

type SavesFor = (reading, device) => string | typeof HOLD | undefined;

Names the patient a reading is saved for, when the person measuring isn't the patient (a clinician): read at every save, so it follows whoever is chosen now. HOLD keeps the reading until a patient is assigned, and undefined means nobody is chosen, so the reading is not saved.

Parameters

ParameterType
readingReading
deviceDeviceSnapshot

Returns

string | typeof HOLD | undefined


SaveState

type SaveState = "saving" | "queued" | "saved" | "rejected" | "failed";

queued means the reading waits in the outbox, and saved that the server has it. rejected means the server refused it there; it waits for a resend or a discard. failed means the sink threw; a stored record is then released, so the next sync delivers it again.


ScanFilter

type ScanFilter = object;

What to scan for, worked out from the wanted models.

Properties

chooser
chooser: readonly ChooserFilter[] | null;

Name prefixes or services that show the wanted models in a browser's chooser; null when it can show none.

optionalServices
optionalServices: readonly string[];

Services the protocols use after connecting, which a browser needs to know up front.

services
services: readonly string[] | null;

Services that cover every wanted model; null when some model is recognised by name only.


ScanHandlers

type ScanHandlers = object;

What a scan reports; onEnd fires when the platform ends it, as a browser chooser does after one pick.

Properties

onAdvertisement
onAdvertisement: (ad) => void;

Called for every advertisement the radio reports, repeats included.

Parameters
ParameterType
adAdvertisement
Returns

void

onEnd
onEnd: () => void;

Called when the platform ends the scan itself.

Returns

void

onError
onError: (error) => void;

Called when the scan fails; no onEnd follows.

Parameters
ParameterType
errorDeviceError
Returns

void


Series

type Series = object;

One value per fixed interval, such as a heart rate per second; null for an empty slot.

Properties

intervalMs
intervalMs: number;

Milliseconds between values.

metric
metric: MetricCode;

What the values measure.

start
start: Date;

When the first value was taken.

unit
unit: string;

The UCUM unit of every value.

values
values: readonly (number | null)[];

The values in time order, null for an empty slot.


SyncSummary

type SyncSummary = object;

What one sync found and read.

Properties

fetched
fetched: number;

Records this sync delivered.

onDevice
onDevice: number;

Records the device held when the sync listed them.


Transport

type Transport =
  | "ble"
  | "classic"
  | "mfi"
  | "nfc"
  | "ant"
  | "cloud"
  | "phone"
  | "vendor_sdk";

A radio or path a model can be reached through.


Vendor

type Vendor = object;

The brand on the box.

Properties

id
id: string;

A stable lower-case slug, e.g. viatom.

name
name: string;

The brand as printed, e.g. Viatom.


VolumeChange

type VolumeChange = object;

A new volume for a hearing aid.

Properties

kind
kind: "volume";

Which setting changes.

level
level: number;

The step to set; one past the aid's range is kept within it.


VolumeStep

type VolumeStep = object;

A volume step and the highest step the device has.

Properties

level
level: number;

The step it is set to.

max
max: number;

The highest step.


Waveform

type Waveform = object;

Samples at a fixed rate, one array per channel; while streaming, one batch per device notification.

Properties

channels
channels: readonly string[];

One name per channel, in the order of samples.

firstSampleAt
firstSampleAt: Date | null;

When the first sample was taken, null when the device sends no time.

metric
metric: "ecg_waveform" | "pleth_waveform";

Which trace this is.

sampleRateHz
sampleRateHz: number;

Samples per second, in each channel.

samples
samples: readonly Int16Array[];

Raw counts, one array per channel.

scale
scale: number;

unit per raw count.

unit
unit: string;

What scale converts a raw count to, e.g. mV.


WaveformBuffer

type WaveformBuffer = object;

The last seconds of a streamed waveform, one array per channel.

Properties

channels
channels: readonly (readonly number[])[];

One array of raw counts per channel, newest last.

sampleRateHz
sampleRateHz: number;

Samples per second, in each channel.

scale
scale: number;

unit per raw count.

unit
unit: string;

What scale converts a raw count to.

Variables

BUILT_IN_MODELS

const BUILT_IN_MODELS: readonly DeviceModel[];

Every model the SDK ships with; a new device on a known protocol is one more row here.


BUILT_IN_PROTOCOLS

const BUILT_IN_PROTOCOLS: readonly DeviceProtocol[];

The protocols the built-in models use.


HOLD

const HOLD: typeof HOLD;

What savesFor returns to keep a reading on the device, unsent, until ovok.outbox.assign names who was measured: for a shared monitor set to ask each time.

Last updated on

On this page

ClassesBluetoothConstructorsConstructorParametersReturnsMethodsadapter()Returnsdestroy()Returnsdevice()ParametersReturnsdevices()Returnsdiscover()ParametersReturnsforget()ParametersReturnsopenSettings()Returnspair()ParametersReturnspairedSnapshots()ReturnspinToEnter()ParametersReturnsreadings()ReturnsrequestPermission()Returnsrunnable()ParametersReturnssubscribeAdapter()ParametersReturnssubscribeDevices()ParametersReturnssubscribeReadings()ParametersReturnsPropertiesCatalogConstructorsConstructorParametersReturnsMethodsmodel()ParametersReturnsmodels()ParametersReturnsvendors()ReturnsPropertiesDeviceAccessorsaddressGet SignatureReturnsConstructorsConstructorParametersReturnsMethodsacknowledge()ParametersReturnschange()ParametersReturnsconfigure()ParametersReturnsdisconnect()Returnsfetch()ParametersReturnspair()Returnsrecords()Returnsrelease()ParametersReturnsseen()ParametersReturnssetClock()Returnssnapshot()ReturnsstartLive()ReturnsstopLive()Returnsstored()Returnssubscribe()ParametersReturnssync()ReturnsDeviceErrorExtendsConstructorsConstructorParametersReturnsOverridesPropertiesDiscoveryConstructorsConstructorParametersReturnsMethodssnapshot()Returnsstart()Returnsstop()Returnssubscribe()ParametersReturnsFunctionsandroidForegroundService()ParametersReturnsblePlxCentral()ParametersReturnsBluetoothProvider()ParametersReturnscreateBluetooth()ParametersReturnsosBluetoothPermissions()ReturnsovokOutboxWatch()ParametersReturnsovokReadingSink()ParametersReturnsreactNativeLifecycle()ReturnsstoragePairedDevices()ParametersReturnsuseBluetooth()ReturnsuseBluetoothAdapter()ReturnsuseCatalog()ParametersReturnsuseDevice()ParametersReturnsuseDiscovery()ParametersReturnsuseLiveValues()ParametersReturnsusePairedDevices()ReturnsuseReadings()ParametersReturnsuseWaveform()ParametersReturnsInterfacesAppLifecycleMethodswatch()ParametersReturnsBleCentralMethodsconnect()ParametersReturnsscan()ParametersReturnswatchState()ParametersReturnsBluetoothPermissionsMethodscheck()ReturnsopenSettings()Returnsrequest()ReturnsDeviceProtocolType ParametersMethodsbattery()?ParametersReturnsbroadcast()?ParametersReturnschange()?ParametersReturnsclose()?ParametersReturnsfetch()?ParametersReturnshistory()?ParametersReturnsidentify()?ParametersReturnslive()?ParametersReturnsopen()ParametersReturnspairing()?ParametersReturnsrecords()?ParametersReturnssetClock()?ParametersReturnsPropertiesGattLinkMethodsclose()ReturnsonDisconnect()ParametersReturnsread()ParametersReturnssubscribe()ParametersReturnswrite()ParametersReturnswriteWithoutResponse()ParametersReturnsKeepAliveMethodsstart()Returnsstop()ReturnsLoggerMethodsdebug()ParametersReturnserror()ParametersReturnsinfo()ParametersReturnswarn()ParametersReturnsOutboxWatchMethodssubscribe()ParametersReturnsPairedDeviceStoreMethodsload()Returnsremove()ParametersReturnssave()ParametersReturnsReadingSinkMethodssave()ParametersReturnsType AliasesAdapterSnapshotPropertiespermissionstateAdapterStateAdvertisementTestUnion MembersType LiteralType LiteralType LiteralAppVisibilityBatteryPropertiesatchargingpercentBluetoothOptionsPropertiesautoSync?centralkeepAlive?lifecycle?logger?lostAfterMs?modelsnow?Returnsoutbox?pairingAgent?permissionsprotocolssinkstoreBluetoothPermissionBluetoothProviderPropsPropertiesbluetoothchildrenConnectionStateCreateBluetoothOptionsType DeclarationDeviceActionDeviceChangeDeviceErrorCodeDeviceEventUnion MembersType LiteralType LiteralType LiteralType LiteralType LiteralDeviceFlagPropertiescoderawDeviceIdentityPropertiesatfirmwarehardwaremanufacturermodelserialDeviceModelPropertiesdirectiongenericidimageUrl?linksmatchmeasuresnamenameCheckpinprotocolserialPairinguserBoundvendorDeviceSecretPropertiesreadReturnswriteParametersReturnsDeviceSelectorPropertiesmodel?type?vendor?DeviceSettingsDeviceSnapshotPropertiesactionsactivityaddressautoSyncbatteryconnectiondeviceStatedeviceStatusUnion MembersType LiteralatcodeidentitykeepInBackgroundlastConnectedAtlastErrorlastReadingAtlastSeenAtlastSyncedAtlastSyncOutcomelivemeasuringSincemodelidnamevendornamepairedAtprogressUnion MembersType LiteraldonetotalrecordrssiunacknowledgedDeviceStateDiscoverOptionsPropertieschooser?DiscoverySnapshotPropertieserrorfoundscanningEarSideEarStatePropertiesbatterycharginginCaseinEarFactoryResetPropertieskindForegroundServiceOptionsPropertieslogger?outbox?ForegroundServiceTextPropertiesnotificationBody?notificationTitle?unsentBody?ParametersReturnsFoundExtended byPropertiesaddresslastSeenAtmatchnamerssiHearingAidChangeHearingAidModeHearingAidStatePropertiesearsinEarDetectionkindmainEarmicrophonemodenoiseReductionnoiseScenepromptLanguagevolumeHistoryRecordPropertiesidreadingIdentificationUnion MembersType LiteralType LiteralType LiteralInEarDetectionChangePropertieskindonLinkOptionPropertiesdatadiscoverLiveFramePropertiesmeasuring?result?state?values?waveform?LiveResultPropertiesidreadingLiveSpanPropertieschannelfrommetrictoLiveValuesPropertiesatdeviceFlagsrrIntervalsMs?valuesMatchRulePropertiesnames?requires?services?MeasurementTypeMetricCodeMicrophoneChangePropertiesdirectionkindMicrophoneDirectionModeChangePropertieskindmodeNoiseReductionChangePropertieskindonsceneNoiseSceneOutboxViewPropertiesrejectedsentwaitingOvokSinkClientPairedDevicePropertiesaddressautoSyncbatterycursoridentitykeepInBackgroundlastConnectedAtlastReadingAtlastSyncedAtlastSyncOutcomemodelIdnamepairedAtrecordsecretPinUnion MembersType LiteralType LiteralType LiteralPromptLanguagePromptLanguageChangePropertieskindlanguageProtocolContextPropertiesadvertisement?linkloggernowReturnssecretQuantityPropertiesunitvalueReadingPropertiesdeviceFlagslive?series?sourcesupersedes?takenAttypevalueswaveform?ReadingSourcePropertiesaddressmodelIdprotocolIdrecordIdReceivedReadingPropertiesidqueueIds?readingreceivedAtsaveRecordInfoPropertiesidtakenAtSaveOutcomeSaveReceiptPropertiesqueueIds?statusSavesForParametersReturnsSaveStateScanFilterPropertieschooseroptionalServicesservicesScanHandlersPropertiesonAdvertisementParametersReturnsonEndReturnsonErrorParametersReturnsSeriesPropertiesintervalMsmetricstartunitvaluesSyncSummaryPropertiesfetchedonDeviceTransportVendorPropertiesidnameVolumeChangePropertieskindlevelVolumeStepPropertieslevelmaxWaveformPropertieschannelsfirstSampleAtmetricsampleRateHzsamplesscaleunitWaveformBufferPropertieschannelssampleRateHzscaleunitVariablesBUILT_IN_MODELSBUILT_IN_PROTOCOLSHOLD