Open wegendt-bosch opened 5 years ago
Dear @wegendt-bosch , This is what i am thinking and was looking for. As your comments, event functions can't do alot yet because we don't have payload.
Can we implement something like this?
every mqtt.t.message {
var payload = mqtt.t.read();
/* implement stuff here */
}
or better ways we should modify the event function to add payload (maybe it may requires the changes in Mita)
PR #344 already allows the following:
import platforms.xdk110;
every MQTT.msgReceived(msg) { // msg has type array<500>. Reacts to *any* incoming message.
println(msg);
}
The next step is then to implement this RFC, which should be a lot easier than #344, since its mostly language design and scoping. Then we would have full interactivity like this:
every mqtt.t.msgReceived(msg) {
}
Introduction
The root elements in platforms are system resources. They offer events, modalities and signals. Users can supply event handlers to these events, can read modalities and read and write signals. Modalities and events are singular in the sense that per application there is only one instance of each of them. In contrast to that signals can be set up multiple times in signal instances.
This makes it so that users can for example react to an event in the accelerometer but not to an MQTT message.
Current Situation
Currently events per signal instance are not supported.
Proposal
I propose adding events to signal instances. For example an MQTT topic signal offers an
message
event or a GPIO pin offers input events likerisingEdge
,fallingEdge
.Code Example
The platform could declare signal instance events like this:
A user would react like this: