Dear tinyOS help list,
I think my question was already aksed several times, as I think it is a very
common configuration.
I am using micaz motes together with tinyOS 2.1.1 and an eprb.
My problem is, that the motes won't communicate with each other. After a
time of debugging, I came to the conclusion, that the event:
'event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len)' is never reached.
Also the tutorial program under tos/apps/tutorial/BlinkToRadio/ won't work
for me, so I think that my Makefile or my configuration is wrong.
I will post my sources down here and I hope that someone is able to tell me
the trick, to get the example running.
I thank you very much in advance !
Regards,
Robin
######## Makefile ########
COMPONENT=SendingAppC
include $(MAKERULES)
// I added these lines after reading a while in the internet, but I also
tried without:
CFLAGS += -DRADIO_XMIT_POWER=0xFF
CFLAGS += -DCC2420_TXPOWER=TXPOWER_MAX
CFLAGS += -DCC2420_DEF_CHANNEL=12
######## bash call ########
// eprb is configured with ip-address 192.168.0.2 and working
// For mote 1:
make micaz install,1 eprb,192.168.0.2
// For mote 2:
make micaz install,2 eprb,192.168.0.2
######## SendingAppC.nc ########
#include <Timer.h>
#include "Sending.h"
configuration SendingAppC{
}
implementation{
components MainC;
components LedsC;
components SendingC as App;
components new TimerMilliC() as ledT;
components ActiveMessageC;
components new AMSenderC(AM_SENDING);
components new AMReceiverC(AM_SENDING);
App.Boot -> MainC.Boot;
App.Leds -> LedsC.Leds;
App.ledT -> ledT;
App.Packet -> AMSenderC;
App.AMPacket -> AMSenderC;
App.AMSend -> AMSenderC;
App.AMControl -> ActiveMessageC;
App.Receive -> AMReceiverC;
App.Ack -> AMSenderC.Acks;
}
######## SendingC.nc ########
#include<Timer.h>
#include "Sending.h"
module SendingC {
uses interface Boot;
uses interface Leds;
uses interface Timer<TMilli> as ledT;
uses interface Packet;
uses interface AMPacket;
uses interface AMSend;
uses interface SplitControl as AMControl;
uses interface Receive;
uses interface PacketAcknowledgements as Ack;
}
implementation{
bool busy = FALSE;
message_t pkt;
uint16_t counter = 0;
event void Boot.booted(){
call AMControl.start();
}
event void ledT.fired(){
counter++;
if (!busy) {
SendingMsg* btrpkt = (SendingMsg*)(call Packet.getPayload(&pkt,
sizeof(SendingMsg)));
if(btrpkt == NULL) {
return;
}
btrpkt->nodeid = TOS_NODE_ID;
btrpkt->counter = counter;
if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(SendingMsg)) ==
SUCCESS) {
busy = TRUE;
if(call Ack.requestAck(&pkt) == SUCCESS){
call Leds.led0On();
}
}
}
}
event void AMControl.startDone(error_t err){
if (err == SUCCESS) {
call ledT.startPeriodic(TIMER_PERIOD_MILLI);
call Leds.led1On();
}
else {
call AMControl.start();
}
}
event void AMControl.stopDone(error_t err) {
call Leds.led1Off();
}
event void AMSend.sendDone(message_t* msg, error_t error) {
if (&pkt == msg) {
while(call Ack.wasAcked(msg) == FALSE){
// do nothing while msg not ack'd
}
call Leds.led0Off();
busy = FALSE;
}
}
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len) {
call Leds.led2Toggle();
if (len == sizeof(SendingMsg)) {
SendingMsg* btrpkt = (SendingMsg*)payload;
call Leds.set(btrpkt->counter);
call Leds.led2Toggle();
}
return msg;
}
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help