Categorygithub.com/benmeehan/iot-agent
module
0.0.0-20250218154321-862d6bbfd0fd
Repository: https://github.com/benmeehan/iot-agent.git
Documentation: pkg.go.dev

# README

IoT Agent

A modular and configurable IoT agent designed to support a variety of services and run on any Unix-based system. It enables secure communication and interaction with an MQTT backend. You can use IOT-Cloud or build your own MQTT backend.

šŸ›  Pre-Alpha Discussions: Here

šŸ“Œ Features

āœ”ļø Modular service-based architecture
āœ”ļø Secure communication via MQTT
āœ”ļø Supports multiple services (Registration, Metrics, SSH, Updates, etc.)
āœ”ļø Configurable through YAML files
āœ”ļø Designed for low-resource IoT devices

šŸš€ Installation & Setup

1. Clone the Repository

git clone https://github.com/BenMeehan/iot-agent.git
cd iot-agent

2. Configure the Agent

Modify config/config.yaml to suit your needs. Ensure correct MQTT broker settings and service configurations.

3. Run the Agent

go run cmd/agent/main.go

šŸ”§ Configuration

The agent is configured via config/config.yaml. Each service has its own parameters, such as MQTT topics, intervals, and authentication details.

For detailed service-specific documentation, check the /docs folder.


šŸ›  TODO

  • Cross-Compilation: Easier compilation for different architectures

šŸ“Œ Architecture

arch.png


āš™ļø Adding a New Service

  1. Update Configuration

    • Add necessary configurations in config/config.yaml.
  2. Create Service Logic

    • Add a new file in internal/services (e.g., new_service.go).
    • Implement the service logic similar to existing services (e.g., heartbeat_service.go).

šŸ“– Services Overview

šŸ“Œ Detailed service documentation is available in the /docs directory.

1ļøāƒ£ Registration Service

šŸ”¹ Handles secure device registration via MQTT using JWT authentication.
šŸ”¹ Implements exponential backoff for retries.

2ļøāƒ£ Heartbeat Service

šŸ”¹ Sends periodic heartbeat messages to indicate device activity.

3ļøāƒ£ Metrics Service

šŸ”¹ Collects system metrics (CPU, memory, disk usage) and sends them via MQTT.

4ļøāƒ£ Command Service

šŸ”¹ Executes commands on the IoT device and publishes output via MQTT.

5ļøāƒ£ Geolocation Service

šŸ”¹ Retrieves device location via GPS or Google Geolocation API.

6ļøāƒ£ SSH Service

šŸ”¹ Establishes a secure reverse SSH tunnel for remote access.

7ļøāƒ£ Update Service

šŸ”¹ Handles OTA (Over-the-Air) updates for firmware or software.


šŸ” Code Guidelines

1. Naming Conventions

  • Use camel case for variables/constants (e.g., deviceId, maxRetries).
  • Use snake case for files/folders (e.g., heartbeat_service.go).

2. Code Style

  • Keep code clean and readable.
  • Comments should explain why something is done, not just what it does.

3. Logging

  • Use structured logs with relevant context.
  • Ensure logs are useful for debugging.

šŸ¤ Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch (feature/your-feature-name)
  3. Commit your changes (git commit -m "Added new feature")
  4. Push to your branch
  5. Open a Pull Request

This project is under Apache License 2.0

# Packages

No description provided by the author
No description provided by the author
No description provided by the author