From 2a7e30708aed165843c925d08128bf3987ff9844 Mon Sep 17 00:00:00 2001 From: Jet Pham <55770902+jetpham@users.noreply.github.com> Date: Sat, 7 Jun 2025 12:48:27 -0700 Subject: [PATCH] feat: update readme to reflect current state of the project --- README.md | 85 ++++++++++++++++++++----------------------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 0cb5880..cf31eb8 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,12 @@ This is build by Jet Pham to be used at Noisebridge to replace their old discord ## Features - GPIO circuit monitoring with configurable pin -- Webhook notifications with retry mechanism -- REST API for managing webhook endpoints +>TODO: - Webhook notifications with retry mechanism +>TODO: - REST API for managing webhook endpoints - Daily rotating log files - Cross-compilation support for Raspberry Pi deployment +> Temporarialy calls the discord bot directly +- Debouncing using a finite state machine ## Requirements @@ -31,58 +33,6 @@ cd noisebell cargo build --release ``` -## Configuration - -### GPIO Pin -The default GPIO pin is set to 17. You can modify this in `src/main.rs`. - -### Webhook Endpoints -Webhook endpoints are stored in `endpoints.json`. The file should follow this format: -```json -{ - "endpoints": [ - { - "url": "https://your-webhook-url.com", - "description": "Description of this endpoint" - } - ] -} -``` - -## Usage - -1. Start the server: -```bash -./target/release/noisebell -``` - -The server will: -- Start listening on `127.0.0.1:8080` -- Begin monitoring the configured GPIO pin -- Send webhook notifications when circuit state changes - -### API Endpoints - -#### Add Webhook Endpoint -```bash -curl -X POST http://localhost:8080/endpoints \ - -H "Content-Type: application/json" \ - -d '{ - "url": "https://your-webhook-url.com", - "description": "My webhook" - }' -``` - -### Webhook Payload Format -When a circuit state change is detected, the following JSON payload is sent to all configured endpoints: -```json -{ - "event_type": "circuit_state_change", - "timestamp": "2024-03-21T12:34:56Z", - "new_state": "open" // or "closed" -} -``` - ## Deployment The project includes a deployment script for Raspberry Pi. To deploy: @@ -104,4 +54,29 @@ This will: ## Logging -Logs are stored in the `logs` directory with daily rotation for the past 7 days \ No newline at end of file +Logs are stored in the `logs` directory with daily rotation for the past 7 days + +## Configuration + +The following parameters can be configured in `src/main.rs`: + +### GPIO Settings +- `DEFAULT_GPIO_PIN`: The GPIO pin number to monitor (default: 17) +- `DEFAULT_POLL_INTERVAL_MS`: How frequently to check the GPIO pin state in milliseconds (default: 100ms) +- `DEFAULT_DEBOUNCE_DELAY_SECS`: How long the switch must remain in a stable state before triggering a change, in seconds (default: 5s) + +### Discord Settings +The following environment variables must be set: +- `DISCORD_TOKEN`: Your Discord bot token +- `DISCORD_CHANNEL_ID`: The ID of the channel where status updates will be posted + +### Logging Settings +- `LOG_DIR`: Directory where log files are stored (default: "logs") +- `LOG_PREFIX`: Prefix for log filenames (default: "noisebell") +- `LOG_SUFFIX`: Suffix for log filenames (default: "log") +- `MAX_LOG_FILES`: Maximum number of log files to keep (default: 7) + +To modify these settings: +1. Edit the constants in `src/main.rs` +2. Rebuild the project +3. For Discord keys and channel id, ensure the environment variables are set before running the bot (Done for you in deploy.sh) \ No newline at end of file