Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configuration in non-retain mode #11

Closed
user2684 opened this issue Mar 9, 2021 · 1 comment
Closed

Add support for configuration in non-retain mode #11

user2684 opened this issue Mar 9, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@user2684
Copy link
Collaborator

user2684 commented Mar 9, 2021

Describe the solution you'd like
Add support for a scenario where the configuration cannot be entirely retained on the gateway

**Is your feature request related to a problem? **
egeoffrey/egeoffrey-controller#25

@user2684 user2684 added the enhancement New feature or request label Mar 9, 2021
@user2684
Copy link
Collaborator Author

user2684 commented Jul 21, 2021

Design

  • Configuration is no retained on the bus so has to be requested by each module when needed (and upon startup)
  • When this feature is on, every time a module subscribes to a topic will also broadcast a message to controller/config notifying about the subscription
  • controller/config listens for those subscription messages and send the configuration(s) over, acknowledging then the sender
  • If the module does not receive the configuration, periodically resend the request (controller/config may be not running yet)
  • To ensure interoperability between modules and backward compatibility, they must all be configured to use the same communication protocol version

Scopes

  • Configuration messages
  • Manifests
  • Last Value

Implementation

SDK

  • Added EGEOFFREY_GATEWAY_VERSION global variable which superceed the static API_VERSION. The gateway protocol version is used to allow modules to communicate each other in the same way. If set to "1", the old communication mechanism is used (configuration and messages retained in the bus), if set to "2", the new one is used.

Configuration messages

  • Added add_configuration_listener() in Mqtt_client class as a wrapper of add_listener(). This will send a SUBSCRIBE message to controller/config notifying about the subscription and queue the requested topics
  • SUBSCRIBE_ACK messages coming from controller/config are processed in Mqtt_consumer class to remove from the queue already answered subscription requests
  • Periodically the module re-send the same SUBSCRIBE message for all requests not answered yet (by using the Scheduler helper class)

Manifests messages

  • Watchdog subscribes to REQ_MANIFEST messages and deliver the manifests upon demand
  • Added add_manifest_listener() wrapping add_broadcast_listener() which will also send a REQ_MANIFEST broadcast message if this feature is on

controller/config

  • keeping in memory also the content of the configuration file when building the index if this feature is on
  • no configuration is obviously unsolicited published to the bus
  • When a SUBSCRIBE message is received the requested configurations are sent over to the requesting module only by matching the requested topic pattern with the configurations available and a SUBSCRIBE_ACK is also sent upon completion
  • on start, add a manifest listener for requesting all the manifests from already running modules to retrieve default configurations

Other changes

  • Scheduler object previously used by the Service class has been made public so to be shared between multiple consumers
  • Messages are no more broadcasted to */* but addressed to the sender, otherwise each module may get the same configuration multiple times when another is requesting it. This required normalising the topic (with "+/+" instead of "*/*" to ensure replied messages are correctly handled
  • controller/hub has now a new setting called pin_last_values (default to false) which prevent latest values of every sensor to be retained on the bus unless explicitly needed by the user
  • The gui has been modified so to allow the user to choose which gateway version to use

Checks

  • no more messages are retained on the bus -> DONE
  • module and controller/config are communicating correctly -> DONE
  • manifests files are correctly received by the gui and by controller/config -> DONE
  • Ensure interoperability between modules with different SDK versions -> DONE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant