Hi,
I am working with mintroute. I would like to change the
payload of the data packet on each hop (intermediate) motes before they
 forward the data packet to the next hop and finally to the destination.
But the "Intercept" interface was never flagged. Why??


My code:

includes ctcp;
includes ctcpCmd;
includes MultiHop;

configuration ctcp {
}
implementation {
components Main, ctcpM, TimerC, LedsC, NoLeds, Photo, RandomLFSR,
GenericCommPromiscuous as Comm, Bcast, WMEWMAMultiHopRouter as multihopM, 
QueuedSend, Sounder;
Main.StdControl -> ctcpM.StdControl;
Main.StdControl -> Photo;
Main.StdControl -> Bcast.StdControl;
Main.StdControl -> multihopM.StdControl;
Main.StdControl -> QueuedSend.StdControl;
Main.StdControl -> TimerC;
Main.StdControl -> Comm;
// multihopM.CommControl -> Comm;
ctcpM.ADC -> Photo;
ctcpM.Timer -> TimerC.Timer[unique("Timer")];
ctcpM.Leds -> LedsC; // NoLeds;
ctcpM.Sounder -> Sounder;
ctcpM.Bcast -> Bcast.Receive[AM_CTCPCMDMSG];
Bcast.ReceiveMsg[AM_CTCPCMDMSG] -> Comm.ReceiveMsg[AM_CTCPCMDMSG];
ctcpM.RouteControl -> multihopM;
ctcpM.Send -> multihopM.Send[AM_CTCPMSG];
ctcpM.SendUART -> QueuedSend.SendMsg[AM_CTCPMSG];
ctcpM.ReceiveMsg -> Comm.ReceiveMsg[AM_CTCPMSG];
ctcpM.teste -> multihopM.Intercept[AM_CTCPMSG];
//multihopM.ReceiveMsg[AM_MULTIHOPMSG] -> Comm.ReceiveMsg[AM_MULTIHOPMSG];
}


includes ctcp;
includes ctcpCmd;
/*
* Data gather application
*/
module ctcpM {
provides {
interface StdControl;
}
uses {
interface ADC;
interface Timer;
interface SendMsg as SendUART;
interface Send;
interface Receive as Bcast;
interface RouteControl;
interface ReceiveMsg;
interface Intercept as teste;
}
}
implementation {
enum {
TIMER_GETADC_COUNT = 1, // Timer ticks for ADC
TIMER_CHIRP_COUNT = 10, // Timer on/off chirp count
};
bool sleeping; // application command state
bool focused;
bool rebroadcast_adc_packet;
TOS_Msg gMsgBuffer;
norace uint16_t gSensorData; // protected by gfSendBusy flag
bool gfSendBusy;

int timer_rate;
int timer_ticks;
int count;
/***********************************************************************
* Initialization
***********************************************************************/
static void initialize() {
timer_rate = INITIAL_TIMER_RATE;
atomic gfSendBusy = FALSE;
sleeping = FALSE;
rebroadcast_adc_packet = FALSE;
focused = FALSE;
count = 0;
}
task void SendData() {
ctcpMsg *pReading;
uint16_t Len;
dbg(DBG_USR1, "ctcpM: Sending sensor reading\n");
if ((pReading =((ctcpMsg *)call Send.getBuffer(&gMsgBuffer,&Len)))) {
count++;
pReading->type = SURGE_TYPE_SENSORREADING;
pReading->sourceaddress = TOS_LOCAL_ADDRESS;
pReading->parentaddr = call RouteControl.getParent();
pReading->reading = gSensorData;
pReading->campo5 = 5;
pReading->campo6 = 6;
pReading->campo7 = 0;
pReading->campo8 = TOS_LOCAL_ADDRESS;
}
}

command result_t StdControl.init() {
initialize();
return SUCCESS;
}
command result_t StdControl.start() {
return call Timer.start(TIMER_REPEAT, timer_rate);
return SUCCESS;
}
command result_t StdControl.stop() {
return call Timer.stop();
}
/***********************************************************************
* Commands and events
***********************************************************************/
event result_t Timer.fired() {
dbg(DBG_USR1, "ctcpM: Timer fired\n");
timer_ticks++;
if (timer_ticks % TIMER_GETADC_COUNT == 0) {
call ADC.getData();
}
// If we're the focused node, chirp
if (focused && timer_ticks % TIMER_CHIRP_COUNT == 0) {
call Sounder.start();
}
// If we're the focused node, chirp
if (focused && timer_ticks % TIMER_CHIRP_COUNT == 1) {
call Sounder.stop();
}
return SUCCESS;
}
async event result_t ADC.dataReady(uint16_t data) {
dbg(DBG_USR1, "ctcpM: Got ADC reading: 0x%x\n", data);
atomic {
if (!gfSendBusy) {
gfSendBusy = TRUE;
gSensorData = data;
post SendData();
}
}
return SUCCESS;
}
event result_t Send.sendDone(TOS_MsgPtr pMsg, result_t success) {
dbg(DBG_USR1, "ctcpM: output complete 0x%x\n", success);
atomic gfSendBusy = FALSE;
return SUCCESS;
}
event result_t SendUART.sendDone(TOS_MsgPtr pMsg, result_t success) {
dbg(DBG_USR3, "ctcpM: output para UART complete 0x%x\n", success);
return SUCCESS;
}
event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr pMsg) {
TOS_MHopMsg *pMhop;
ctcpMsg *pctcp;
dbg(DBG_USR3, "ctcpM: Recebi uma mensagem, conteudo:\n");
pMhop = (TOS_MHopMsg *)pMsg->data;
dbg(DBG_USR3, "<TOS_MHopMsg>\n");
dbg(DBG_USR3, "[sourceaddr] %d\n", pMhop->sourceaddr);
dbg(DBG_USR3, "[originaddr] %d\n", pMhop->originaddr);
dbg(DBG_USR3, "[seqno] %d\n", pMhop->seqno);
dbg(DBG_USR3, "[hopcount] %d\n", pMhop->hopcount);
pctcp = (ctcpMsg *)pMhop->data;
dbg(DBG_USR3, "<ctcpMsg>\n");
pctcp->reading++;

//Enviando a msg pela UART
if (TOS_LOCAL_ADDRESS==0) {
call SendUART.send(TOS_UART_ADDR, 21, pMsg);
dbg(DBG_USR3, "ENTREI NO IF\n");
}
return pMsg;
}
event result_t teste.intercept(TOS_MsgPtr pMsg, void* payload, uint16_t 
payloadLen) {
dbg(DBG_USR3, "HERE IS THE PROBLEM!!!!!!!!!!!!\n");
return FAIL;
}
}


Thanks
Eugênia 

_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to