separated send-to-simulator.function from uIP
This commit is contained in:
parent
7c8665fb89
commit
8ebb7dbf27
1 changed files with 31 additions and 15 deletions
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: radio-arch.c,v 1.12 2006/12/04 15:26:33 fros4943 Exp $
|
* $Id: radio-arch.c,v 1.13 2007/03/18 19:31:36 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dev/radio-arch.h"
|
#include "dev/radio-arch.h"
|
||||||
|
@ -132,33 +132,30 @@ doInterfaceActionsAfterTick(void)
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
u8_t
|
u8_t
|
||||||
simDoSend(void)
|
simDoLLSend(unsigned char *buf, int len)
|
||||||
{
|
{
|
||||||
// If radio is turned off, do nothing
|
/* If radio is turned off, do nothing */
|
||||||
if (!simRadioHWOn) {
|
if (!simRadioHWOn) {
|
||||||
// TODO Should we reset uip_len if radio is off?
|
|
||||||
uip_len = 0;
|
|
||||||
return UIP_FW_DROPPED;
|
return UIP_FW_DROPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop packet if data size too large
|
/* Drop packet if data size too large */
|
||||||
if(uip_len > UIP_BUFSIZE) {
|
if(len > UIP_BUFSIZE) {
|
||||||
uip_len = 0;
|
|
||||||
return UIP_FW_TOOLARGE;
|
return UIP_FW_TOOLARGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop packet if no data length
|
/* Drop packet if no data length */
|
||||||
if (uip_len <= 0) {
|
if (len <= 0) {
|
||||||
return UIP_FW_ZEROLEN;
|
return UIP_FW_ZEROLEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ** Good place to add explicit manchester/gcr-decoding
|
/* ** Good place to add explicit manchester/gcr-decoding */
|
||||||
|
|
||||||
// Copy packet data to temporary storage
|
/* Copy packet data to temporary storage */
|
||||||
memcpy(&simOutDataBuffer[0], &uip_buf[UIP_LLH_LEN], uip_len);
|
memcpy(&simOutDataBuffer[0], &buf[UIP_LLH_LEN], len);
|
||||||
simOutSize = uip_len;
|
simOutSize = len;
|
||||||
|
|
||||||
// Busy-wait until both radio HW and ether is ready
|
/* Busy-wait until both radio HW and ether is ready */
|
||||||
int retries=0;
|
int retries=0;
|
||||||
while (retries < MAX_RETRIES && !simNoYield &&
|
while (retries < MAX_RETRIES && !simNoYield &&
|
||||||
(simSignalStrength > SS_INTERFERENCE || simReceiving))
|
(simSignalStrength > SS_INTERFERENCE || simReceiving))
|
||||||
|
@ -187,6 +184,25 @@ simDoSend(void)
|
||||||
return UIP_FW_OK;
|
return UIP_FW_OK;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
u8_t
|
||||||
|
simDoSend()
|
||||||
|
{
|
||||||
|
/* If radio is turned off, reset uip_len */
|
||||||
|
if (!simRadioHWOn) {
|
||||||
|
uip_len = 0;
|
||||||
|
return UIP_FW_DROPPED;
|
||||||
|
}
|
||||||
|
if (uip_len > UIP_BUFSIZE) {
|
||||||
|
uip_len = 0;
|
||||||
|
return UIP_FW_DROPPED;
|
||||||
|
}
|
||||||
|
if (uip_len <= 0) {
|
||||||
|
return UIP_FW_ZEROLEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return simDoLLSend(uip_buf, uip_len);
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \brief Turn radio on.
|
* \brief Turn radio on.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue