Hello,
I would like to know what do I need to do to send and receive a message using
the protocols of the Route library. Do I need to asociate every TOS_Msg with a
TOS_MHopMsg? In Surge example they do the following:
if (pReading = (SurgeMsg *)call Send.getBuffer(&gMsgBuffer,&Len)) {
pReading->type = SURGE_TYPE_SENSORREADING;
pReading->parentaddr = call RouteControl.getParent();
pReading->reading = gSensorData;
call Send.send(&gMsgBuffer,sizeof(SurgeMsg)));
}
I have seen the code of these function but I do not understand what are they
doing.
command void *Send.getBuffer[uint8_t id](TOS_MsgPtr pMsg, uint16_t* length) {
TOS_MHopMsg *pMHMsg = (TOS_MHopMsg *)pMsg->data;
*length = TOSH_DATA_LENGTH - offsetof(TOS_MHopMsg,data);
return (&pMHMsg->data[0]);
}
command result_t Send.send[uint8_t id](TOS_MsgPtr pMsg, uint16_t PayloadLen) {
uint16_t usMHLength = offsetof(TOS_MHopMsg,data) + PayloadLen;
if (usMHLength > TOSH_DATA_LENGTH) {
return FAIL;
}
//dbg(DBG_ROUTE,"MHop: send\n");
call RouteSelect.initializeFields(pMsg,id);
if (call RouteSelect.selectRoute(pMsg,id) != SUCCESS) {
return FAIL;
}
//dbg(DBG_ROUTE,"MHop: out pkt 0x%x\n",((TOS_MHopMsg *)pMsg->data)->seqno);
if (call SendMsg.send[id](pMsg->addr, usMHLength, pMsg) != SUCCESS) {
return FAIL;
}
return SUCCESS;
}
Thank you very much.
Sofia
_________________________________________________________________
Nuevo Windows Live, un mundo lleno de posibilidades. Descúbrelo.
http://www.microsoft.com/windows/windowslive/default.aspx_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help