safeNumber

fun <Error class: unknown class>.safeNumber(fallbackValue: Int = -1): Int

Safely extracts the hardware model number from a HardwareModel enum.

This function handles unknown enum values gracefully by catching IllegalArgumentException and returning a fallback value. This prevents crashes when the app receives data from devices with hardware models not yet defined in the current protobuf version.

Return

The hardware model number, or the fallback value if the enum is unknown

Parameters

fallbackValue

The value to return if the enum is unknown (defaults to 0 for UNSET)