I’m working on a project that has 2 modules. WiFI and AWS. These 2 modules are handled independently from different tasks.
I want to connect to AWS only if the WiFI is on. That means, the aws needs to do a “get” method from the wifi module. I want to avoid global flags, but I also don’t know how to do it with a queue, because AWS can ask “is wifi on?” at any time.
I suppose a get function exposed from the WiFi module is a solution, but I would like to know if this is the best approach.
There is nothing wrong with a module providing a hook to let people know its status, like if WiFi is up.
Modules should not be “polling” such a status waiting for the module to be ready if at all possible.
I would probably have the WiFi module include a “EventGroup” that other modules can block on to wait for the status, or include a “subscription” entry, where the subscribing module provides a short function that the scribed module will call o certain events, allowing that function to signal the subscribing module in whatever way it wants.