simulating 1 ms turnaround time (before transmissions) by default, and no transmissions on channel busy

This commit is contained in:
Fredrik Osterlind 2012-03-09 14:58:13 +01:00
parent eba1079991
commit 97c7a55eea

View file

@ -148,10 +148,28 @@ radio_read(void *buf, unsigned short bufsize)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int static int
channel_clear(void)
{
if(simSignalStrength > CCA_SS_THRESHOLD) {
return 0;
}
return 1;
}
/*---------------------------------------------------------------------------*/
static int
radio_send(const void *payload, unsigned short payload_len) radio_send(const void *payload, unsigned short payload_len)
{ {
int radiostate = simRadioHWOn; int radiostate = simRadioHWOn;
/* XXX Simulate turnaround time of 1ms? */
#define WITH_TURNAROUND 1
#if WITH_TURNAROUND
printf("WITH_TURNAROUND\n");
simProcessRunValue = 1;
cooja_mt_yield();
printf("WITH_TURNAROUND post\n");
#endif /* WITH_TURNAROUND */
if(!simRadioHWOn) { if(!simRadioHWOn) {
/* Turn on radio temporarily */ /* Turn on radio temporarily */
simRadioHWOn = 1; simRadioHWOn = 1;
@ -166,6 +184,15 @@ radio_send(const void *payload, unsigned short payload_len)
return RADIO_TX_ERR; return RADIO_TX_ERR;
} }
/* XXX Transmit only on CCA? */
#define WITH_SEND_CCA 1
#if WITH_SEND_CCA
if (!channel_clear()) {
printf("WITH_SEND_CCA return\n");
return RADIO_TX_COLLISION;
}
#endif /* WITH_SEND_CCA */
/* Copy packet data to temporary storage */ /* Copy packet data to temporary storage */
memcpy(simOutDataBuffer, payload, payload_len); memcpy(simOutDataBuffer, payload, payload_len);
simOutSize = payload_len; simOutSize = payload_len;
@ -208,15 +235,6 @@ pending_packet(void)
return !simReceiving && simInSize > 0; return !simReceiving && simInSize > 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int
channel_clear(void)
{
if(simSignalStrength > CCA_SS_THRESHOLD) {
return 0;
}
return 1;
}
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cooja_radio_process, ev, data) PROCESS_THREAD(cooja_radio_process, ev, data)
{ {
int len; int len;