initial commit

Signed-off-by: ale <ale@manalejandro.com>
Este commit está contenido en:
ale
2026-01-11 15:43:53 +01:00
commit 953a6739c1
Se han modificado 63 ficheros con 4144 adiciones y 0 borrados

230
README.md Archivo normal
Ver fichero

@@ -0,0 +1,230 @@
# OBD2 Bluetooth - Vehicle Diagnostic Application
A modern Android application for communicating with OBD2 ELM327 Bluetooth adapters to read vehicle diagnostics and send custom commands.
## Features
### 🔌 Bluetooth Connection
- Scan and connect to paired ELM327 Bluetooth devices
- Real-time connection status indicator
- Automatic ELM327 initialization
- Connection management
### 🚗 Vehicle Database
- Comprehensive database of vehicles and OBD signals
- Browse signals by vehicle make and model
- Search functionality for quick access
- Signal details including command, unit, frequency, and description
### 🔍 Quick Diagnostic
- Safe, read-only diagnostic test suite
- Common diagnostic parameters:
- Engine RPM
- Vehicle Speed
- Coolant Temperature
- Throttle Position
- Fuel Level
- Intake Air Temperature
- MAF Air Flow Rate
- Engine Load
- Automatic response parsing
- Command history with timestamps
### ⌨️ Custom Commands
- Send custom OBD2 commands
- Command editing before sending
- Response history
- Raw and parsed response display
- Common command shortcuts
- Resend functionality
### ⚠️ Safety Features
- Warning dialogs before sending any command
- Clear responsibility notices
- Distinction between safe and potentially dangerous commands
- User must explicitly accept risks
## Architecture
### Technology Stack
- **Kotlin** - Modern programming language for Android
- **Jetpack Compose** - Modern declarative UI framework
- **Material Design 3** - Latest Material Design implementation
- **Room Database** - SQLite ORM for vehicle data
- **Coroutines & Flow** - Asynchronous programming
- **MVVM Architecture** - Clean architecture pattern
- **Navigation Component** - Type-safe navigation
### Project Structure
```
app/
├── data/
│ ├── bluetooth/
│ │ └── BluetoothService.kt # Bluetooth communication
│ ├── database/
│ │ ├── entities/ # Room entities
│ │ ├── dao/ # Data Access Objects
│ │ ├── dto/ # Data Transfer Objects
│ │ └── ObdDatabase.kt # Room database
│ ├── obd/
│ │ └── ObdCommands.kt # OBD2 command definitions
│ └── repository/
│ └── ObdRepository.kt # Data repository
├── ui/
│ ├── components/
│ │ └── CommonComponents.kt # Reusable UI components
│ ├── navigation/
│ │ └── Screen.kt # Navigation routes
│ ├── screens/
│ │ ├── HomeScreen.kt # Main dashboard
│ │ ├── BluetoothScreen.kt # Device connection
│ │ ├── VehicleSelectionScreen.kt # Vehicle browser
│ │ ├── DiagnosticScreen.kt # Quick diagnostic
│ │ └── CustomCommandScreen.kt # Custom commands
│ ├── theme/ # App theming
│ └── viewmodel/
│ ├── MainViewModel.kt # Main app state
│ └── VehicleViewModel.kt # Vehicle data state
└── MainActivity.kt # App entry point
```
## Database Schema
### Tables
- **brands** - Vehicle manufacturers
- **models** - Vehicle models
- **generations** - Vehicle generations
- **obd_signals** - OBD command signals
- **dtc_codes** - Diagnostic Trouble Codes
### Views
- **vehicles_view** - Vehicles with signal counts
- **generations_view** - Generations with vehicle info
- **signals_view** - Signals with vehicle info
- **database_stats** - Database statistics
## Bluetooth Communication
### ELM327 Protocol
The app communicates with ELM327 adapters using AT commands and OBD2 PIDs:
#### Initialization Commands
- `ATZ` - Reset device
- `ATE0` - Echo off
- `ATL0` - Line feeds off
- `ATS0` - Spaces off
- `ATSP0` - Set protocol to automatic
#### Common OBD2 PIDs
- `010C` - Engine RPM
- `010D` - Vehicle Speed
- `0105` - Coolant Temperature
- `0111` - Throttle Position
- `012F` - Fuel Level
- And many more...
### Response Parsing
The app automatically parses common PID responses into human-readable format with appropriate units.
## Permissions
### Required Permissions
- **BLUETOOTH** (API ≤ 30) - Bluetooth communication
- **BLUETOOTH_ADMIN** (API ≤ 30) - Bluetooth management
- **BLUETOOTH_CONNECT** (API ≥ 31) - Connect to devices
- **BLUETOOTH_SCAN** (API ≥ 31) - Scan for devices
## Setup & Installation
### Prerequisites
- Android Studio Hedgehog or newer
- Android SDK 24+ (Android 7.0+)
- ELM327 Bluetooth adapter
- Vehicle with OBD2 port
### Build Instructions
1. Clone the repository
2. Open project in Android Studio
3. Sync Gradle dependencies
4. Add your vehicle database to `app/src/main/assets/obd_database.db`
5. Build and run on device (Bluetooth requires physical device)
### Database Setup
Place your SQLite database file with the required schema in:
```
app/src/main/assets/obd_database.db
```
## Usage
### Connecting to Vehicle
1. Pair your ELM327 adapter in Android Bluetooth settings
2. Open the app and navigate to "Bluetooth Connection"
3. Select your ELM327 device from paired devices list
4. Wait for connection confirmation
### Running Diagnostics
1. Ensure Bluetooth connection is active
2. Navigate to "Quick Diagnostic"
3. Tap "Run Test" button
4. Review diagnostic results
### Sending Custom Commands
1. Ensure Bluetooth connection is active
2. Navigate to "Custom Commands"
3. Enter OBD2 command (e.g., "010C")
4. Read and accept warning dialog
5. View response
### Browsing Vehicle Database
1. Navigate to "Vehicle Database"
2. Search or browse for your vehicle
3. Select vehicle to view available signals
4. Tap "Send" on any signal to execute (requires connection)
## Safety & Disclaimer
⚠️ **IMPORTANT**: This application allows direct communication with your vehicle's systems.
### Warnings
- Incorrect commands can damage your vehicle
- Some commands may void warranties
- Users are fully responsible for any consequences
- Read-only commands are generally safe
- Write commands require expert knowledge
### Best Practices
- Start with the safe diagnostic test
- Research commands before sending
- Never send commands while driving
- Keep a record of sent commands
- Consult professional if unsure
## Contributing
Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Follow Kotlin coding conventions
4. Add documentation for new features
5. Submit a pull request
## License
This project is provided as-is for educational purposes. Use at your own risk.
## Support
For issues, questions, or contributions, please open an issue on the project repository.
## Acknowledgments
- ELM327 protocol documentation
- OBD2 standard specifications
- Android Jetpack Compose team
- Material Design team
---
**Note**: This application is designed for diagnostic and educational purposes. Always prioritize safety and consult professional mechanics for vehicle repairs.