Skip to content

Conversation

@ajlennon
Copy link
Member

Summary

This PR adds a comprehensive configuration system for the CGA Coordinate Mapping application, making MQTT topics and other settings configurable via appsettings.json.

Changes

  • Configuration System: Added Microsoft.Extensions.Configuration packages and AppConfig.cs for type-safe configuration loading
  • Hardware ID Detection: Created HardwareId.cs to detect unique board identifiers (machine-id, DMI UUID, MAC address, or hostname)
  • MQTT Configuration: Made all MQTT settings configurable (server, port, topics, credentials, keepalive, etc.)
  • Board ID Placeholder: Added support for {$BoardID} placeholder in topic strings for board-specific topics
  • Default Values: Topics default to original hardcoded values (DotnetMQTT/Test/in and DotnetMQTT/Test/out)
  • Auto Client ID: MQTT client ID automatically generated from hardware ID if not configured

Configuration File

  • appsettings.json added with all configurable settings
  • Comments included explaining board ID placeholder usage
  • Environment variable override support (e.g., MQTT__ReceiveTopic)

Example Usage

To use board-specific topics, update appsettings.json:

{
  "MQTT": {
    "ReceiveTopic": "uwb/{$BoardID}/network/in",
    "SendTopic": "uwb/{$BoardID}/coordinates/out"
  }
}

The {$BoardID} placeholder will be automatically replaced with the hardware-based MQTT client ID (e.g., UwbManager-machine-xxx).

Testing

  • ✅ Build succeeds
  • ✅ Configuration loads correctly
  • ✅ Placeholder resolution works
  • ✅ Default topics match original hardcoded values
  • ✅ Hardware ID detection works (falls back through multiple methods)

Reviewer

@Jen42 - Please review this PR when you have a chance.

- Add Microsoft.Extensions.Configuration packages for JSON configuration support
- Create AppConfig.cs with configuration model and placeholder resolution
- Create HardwareId.cs for unique board identifier detection (machine-id, DMI UUID, MAC, hostname)
- Add appsettings.json with configurable MQTT settings and application settings
- Update MQTTControl.cs to use configuration instead of hardcoded values
- Update Program.cs to load configuration and resolve {} placeholders
- Support {} placeholder in topic strings for board-specific topics
- Default topics match original hardcoded values (DotnetMQTT/Test/in and /out)
- Add comments in appsettings.json explaining board ID placeholder usage
- Auto-generate MQTT client ID from hardware ID if not configured
@ajlennon ajlennon requested a review from Jen42 November 24, 2025 20:25
@ajlennon ajlennon changed the title Add configurable MQTT topics with board ID placeholder support Add configuration system with MQTT topic and board ID support Nov 24, 2025
@Jen42 Jen42 merged commit 719197a into main Nov 24, 2025
1 check passed
@Jen42 Jen42 deleted the feature/add-configuration-system branch November 24, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants