A simple yet powerful client-server system for controlling home appliances, built in C with support for both IPv4 and IPv6 connections.
- Dual Stack Support: Works with both IPv4 and IPv6 connections
- Multi-threading: Efficient server handling with separate threads for:
- Client requests
- File handling
- Automated backups
- Device Control: Currently supports:
- Light switches (On/Off)
- Boiler control (On/Off)
- State Persistence: Maintains device states across restarts
- Activity Logging: Comprehensive logging system with:
- Command history
- State changes
- Error tracking
- Automated Backups: Daily backups of all system logs and states
- GCC Compiler
- POSIX-compliant system (Linux/Unix)
- pthread library
- Basic network connectivity
- Clone the repository:
git clone https://github.com/rudokir/hac.git
cd hac- Build the project:
chmod +x build.sh
./build.sh./ServerConnect to localhost (default):
./UserConnect to specific host:
./User hostnameConnect and send command:
./User hostname command| Command | Description |
|---|---|
| b_on | Turn boiler on |
| b_off | Turn boiler off |
| sw_on | Turn light on |
| sw_off | Turn light off |
- Client Request Handler: Manages incoming connections and command processing
- File Handler: Handles state persistence and logging
- Backup System: Performs daily backups at 3:00 AM
├── Database Files
│ ├── database.txt # Main log file
│ ├── light.txt # Light state
│ ├── boiler.txt # Boiler state
│ ├── sw_light.txt # Light switch history
│ └── sw_boiler.txt # Boiler switch history
├── Source Files
│ ├── smart_home_server.c # Server implementation
│ └── user.c # Client implementation
└── build.sh # Build script
- Error Handling: Comprehensive error checking and reporting
- Buffer Overflow Protection: Safe string handling and buffer size checking
- State Validation: Prevents invalid state transitions
- Connection Management: Proper handling of connection failures and timeouts
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- No authentication system implemented yet
- Limited to binary state devices (on/off)
- Backup system requires sufficient disk space
This project is licensed under the MIT License - see the LICENSE.md file for details
- Inspired by the need for a lightweight home automation solution
- Built with security and reliability in mind
- Designed for extensibility and ease of use
Feel free to contribute to this project or report any issues you encounter! 🌟