-
Notifications
You must be signed in to change notification settings - Fork 3
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
C++ Expert wanted ... #94
Comments
If you subclass all your different actuators from a common super Actuator which has a virtual inputReceived() method you can then pass across a reference to the actuator object instead of passing the callback. That can then be held in your subscriptions collection and then the MQTT object can call actuator.inputReceived() on each such subscribed actuator object. The appropriate concrete inputReceived() method will then get executed. I think that might work. |
Yes - it might, the challenge is that about half of the sensors/actuators/control are not done as Classes - they are using the "setup/loop" paradigm of Arduino IDE. Its a gradual rewrite to turn them into classes. |
If you don't want to rewrite all your actuators as classes you'll just have to stick to the callback approach and where you have a class you'll need to define a callback free function outside the class that calls this->inputReceived(). Not pretty, but you can't pass an object method as a function pointer parameter AFAIK. But then, I'm not an expert. |
Ok - its quite possibly the time to bite the bullet and rewrite as classes, not just for this reason. I've got a issue for this somewhere and will stick a proposed class hierarchy there after the break. #25 |
In sensor.cpp you wanted to declare sensors as a static member of Sensor. You can do this but you do need to initialise the static member before 'main' runs. Somewhere in sensor.cpp add the line std::vector<Sensor*> Sensor::sensors = std::vector<Sensor*>(); |
There are a few challenges that an expert C++ coder could help with .
The text was updated successfully, but these errors were encountered: