Basic MAC data interface for LoRa transceiver
Dependents: LoRaBaseStation LoRaTerminal
Diff: AlohaTransceiver.cpp
- Revision:
- 34:14b1472a79e4
- Parent:
- 33:810074d10fcf
- Child:
- 35:4cfad781d98b
--- a/AlohaTransceiver.cpp Sat Sep 03 05:01:19 2016 +0000 +++ b/AlohaTransceiver.cpp Sat Sep 03 05:39:15 2016 +0000 @@ -5,7 +5,7 @@ #include "AlohaFrame.h" #include "RingBuffer.h" -#define ALLOW_CALLBACK_DEBUG 0 +#define ALLOW_CALLBACK_DEBUG 1 #define SET_FLAG(t, x) (t) |= 1 << (x) #define CLEAR_FLAG(t, x) (t) &= ~(1 << (x)) @@ -199,7 +199,7 @@ uint8_t foreign_seqid = frame->getSequenceID(); // compare the local sequence id and foreign sequence id for specific host - if (seqid[src_addr] <= foreign_seqid) + if (seqid[src_addr] == foreign_seqid) { setAckedFlag(src_addr); } @@ -277,19 +277,7 @@ // determined by the type of the frame, only data frame need to be cleared before transmitting switch (frame->getType()) { - // ack frame can transmit directly - case AlohaFrame::Aloha_ACK: - { - sendFrame(frame); - - // block the next transmission until previous transmission is done - clearTxDoneFlag(); - - // free memory - delete frame; - - break; - } + // Data frame need proper clearance case AlohaFrame::Aloha_Data: { uint8_t dest_addr = frame->getDestinationAddress(); @@ -321,7 +309,14 @@ default: { + sendFrame(frame); + + // block the next transmission until previous transmission is done + clearTxDoneFlag(); + + // free memory delete frame; + break; } }