UNPKG

react-native-obd-retriver

Version:

A React Native hook library to manage Bluetooth Low Energy connections and communication with ELM327 OBD-II adapters.

70 lines 2.09 kB
import React, { type ReactNode, type FC } from 'react'; import type { ECUContextValue } from '../utils/types'; /** * React Context for ECU communication * * This context provides access to all ECU-related functionality including: * - Connection management (connect/disconnect) * - State information (connection status, protocol, voltage) * - Vehicle data retrieval (VIN, DTCs) * - Raw command execution * * @example * ```tsx * // Consuming the context directly (usually prefer useECU hook instead) * function VehicleStatus() { * return ( * <ECUContext.Consumer> * {(ecuContext) => { * if (!ecuContext) return <Text>No ECU context available</Text>; * * const { state } = ecuContext; * return ( * <View> * <Text>Status: {state.status}</Text> * <Text>Protocol: {state.protocolName || 'Unknown'}</Text> * <Text>Voltage: {state.deviceVoltage || 'Unknown'}</Text> * </View> * ); * }} * </ECUContext.Consumer> * ); * } * ``` */ export declare const ECUContext: React.Context<ECUContextValue | null>; /** * Props for the ECUProvider component */ interface ECUProviderProps { /** React children components */ children: ReactNode; } /** * Provider component for ECU communication * * This component creates the ECU context and provides all ECU-related * functionality to its children components. It manages the ECU connection * state and provides methods for interacting with the vehicle's ECU. * * Must be placed within a BluetoothProvider from react-native-bluetooth-obd-manager. * * @example * ```tsx * import { ECUProvider } from 'react-native-obd-retriver'; * import { BluetoothProvider } from 'react-native-bluetooth-obd-manager'; * * function App() { * return ( * <BluetoothProvider> * <ECUProvider> * <VehicleMonitor /> * </ECUProvider> * </BluetoothProvider> * ); * } * ``` */ export declare const ECUProvider: FC<ECUProviderProps>; export {}; //# sourceMappingURL=ECUContext.d.ts.map