UNPKG

react-native-obd-retriver

Version:

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

2 lines 2.72 kB
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.DTCManager=void 0;var _react=_interopRequireDefault(require("react"));var _reactNative=require("react-native");var _useECU2=require("../ecu/hooks/useECU");var _constants=require("../ecu/utils/constants");var _jsxRuntime=require("react/jsx-runtime");var _this=this,_jsxFileName="/Users/rakshitbharat/hardware/react-native-obd-retriver/src/components/DTCManager.tsx";var DTCManager=exports.DTCManager=function DTCManager(){var _state$protocolName;var _useECU=(0,_useECU2.useECU)(),state=_useECU.state;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.title,children:"Diagnostic Trouble Codes"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{children:["Status: ",state.status]}),state.status===_constants.ECUConnectionStatus.CONNECTED&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[state.activeProtocol&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{children:["Protocol: ",(_state$protocolName=state.protocolName)!=null?_state$protocolName:state.activeProtocol]}),state.deviceVoltage&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{children:["Voltage: ",state.deviceVoltage]})]}),state.lastError&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.errorText,children:["Last Error: ",state.lastError]}),state.dtcLoading&&(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Loading DTCs..."}),state.dtcClearing&&(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Clearing DTCs..."}),state.rawDTCLoading&&(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"Loading Raw DTCs..."}),state.status===_constants.ECUConnectionStatus.CONNECTED&&state.currentDTCs&&(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.subTitle,children:"Current DTCs:"}),state.currentDTCs.length===0?(0,_jsxRuntime.jsx)(_reactNative.Text,{children:"None"}):state.currentDTCs.map(function(dtc){return(0,_jsxRuntime.jsx)(_reactNative.Text,{children:dtc},dtc);})]}),state.status!==_constants.ECUConnectionStatus.CONNECTED&&state.status!==_constants.ECUConnectionStatus.CONNECTING&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.notConnectedText,children:"Please connect to Bluetooth and ECU first."})]});};var styles=_reactNative.StyleSheet.create({container:{backgroundColor:'#f5f5f7',borderRadius:8,margin:16,padding:16},title:{fontSize:18,fontWeight:'bold',marginBottom:16},subTitle:{fontSize:16,fontWeight:'600',marginTop:12,marginBottom:4},errorText:{color:'red',marginTop:8},notConnectedText:{color:'#888',fontStyle:'italic',marginTop:16}}); //# sourceMappingURL=DTCManager.js.map