I found it difficult to signal an event in nesC. Can anyone help? (EDIT: I omitted MainC components in code below).
I have defined a simple interface:
interface MyInterface {
command uint8_t action();
event void actionDone();
}
It has one action and one event.
What's more I have one component which provides MyInterface:
configuration MyComponentC {
provides interface MyInterface[uint8_t id];
}
implementation {
components MyComponentM;
MyInterface = MyComponentM.MyInterface;
}
module MyComponentM {
provides interface MyInterface[uint8_t id];
}
implementation {
command uint8_t MyInterface.action[uint8_t id]() {...}
...
event void bar() {
signal MyInterface.actionDone[foo]();
}
}
Event bar is from completely different interface. In this event I want to signal event actionDone with id == foo.
I have also "main" component:
configuration MyAppC {
}
implementation {
components MyC as App;
components MyComponentC as MC;
App.MyInterface -> MC.MyInterface[unique("Hello")];
}
module MyC {
uses interface MyInterface;
}
implementation {
event void MyInterface.actionDone() {...}
}
But during compilation I get an error:
MyInterface.actionDone not connected
Where did I make a mistake? How to properly connect components?
Not sure if this is the cause, but in your App try referring to MyC via alias, i.e. instead of
MyC.MyInterface -> MS.MyInterface[unique("Hello")];
try
App.MyInterface -> MS.MyInterface[unique("Hello")];
[UPDATE]
As explained in this link, since you are using parametrized interface and that there is no guarantee that all 256 instances will be wired to something you need to provide a default implementation in MyComponentM module
default event MyInterface.actionDone[foo]() {
return;
}