#include "message.h"
#include "AM.h"
-module CC2420ReceiveP {
+module CC2420ReceiveP @safe() {
provides interface Init;
provides interface StdControl;
reset_state();
m_state = S_STARTED;
atomic receivingPacket = FALSE;
+ /* Note:
+ We use the falling edge because the FIFOP polarity is reversed.
+ This is done in CC2420Power.startOscillator from CC2420ControlP.nc.
+ */
call InterruptFIFOP.enableFallingEdge();
}
return SUCCESS;
task void receiveDone_task() {
cc2420_metadata_t* metadata = call CC2420PacketBody.getMetadata( m_p_rx_buf );
cc2420_header_t* header = call CC2420PacketBody.getHeader( m_p_rx_buf);
+ uint8_t length = header->length;
uint8_t tmpLen __DEPUTY_UNUSED__ = sizeof(message_t) - (offsetof(message_t, data) - sizeof(cc2420_header_t));
uint8_t* COUNT(tmpLen) buf = TCAST(uint8_t* COUNT(tmpLen), header);
- metadata->crc = buf[ rxFrameLength ] >> 7;
- metadata->lqi = buf[ rxFrameLength ] & 0x7f;
- metadata->rssi = buf[ rxFrameLength - 1 ];
+ metadata->crc = buf[ length ] >> 7;
+ metadata->lqi = buf[ length ] & 0x7f;
+ metadata->rssi = buf[ length - 1 ];
- if(passesAddressCheck(m_p_rx_buf)) {
+ if (passesAddressCheck(m_p_rx_buf) && length >= CC2420_SIZE) {
m_p_rx_buf = signal Receive.receive( m_p_rx_buf, m_p_rx_buf->data,
- rxFrameLength );
+ length - CC2420_SIZE);
}
atomic receivingPacket = FALSE;