vendredi 10 mai 2019

Design flaw in own IoT-Device message-handling architecture

I am about to build a test environment for IoT devices that have different behaviors and communicate via various protocols. To achieve this and to stay open for extensions I decoupled the devices and their protocols from each other. The following diagram outlines the current structure of the application:

UML diagram of current structure

I think this kind of implementation is structurally correct, because a device has a configuration and a (replaceable) MessageHandler. Which means, the IOTDevice doesn't care how the message is send over the network.

The Problem: When I receive a message from the outside (i.e. a MessageHandler receives a message, the handle method is called), I want to be able to execute a pre-defined behaviour that is defined in one of the IOTDev_X classes (i.e. call a method doX(), doY() or doZ()). But the MessageHandler doesn't know anything about the IOTDevice. This way it's not possible to call a specific method when it receives an incoming message.

One solution I thought about would be that a MessageHandler contains the IOTDevice. But from my point of view, that feels like a bad design.

What would be a good method to overcome this problem (at best without discarding the complete design).

Aucun commentaire:

Enregistrer un commentaire