simulating 1 ms turnaround time (before transmissions) by default, and no transmissions on channel busy
This commit is contained in:
parent
eba1079991
commit
97c7a55eea
1 changed files with 27 additions and 9 deletions
|
@ -148,10 +148,28 @@ radio_read(void *buf, unsigned short bufsize)
|
|||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
/* Turn on radio temporarily */
|
||||
simRadioHWOn = 1;
|
||||
|
@ -166,6 +184,15 @@ radio_send(const void *payload, unsigned short payload_len)
|
|||
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 */
|
||||
memcpy(simOutDataBuffer, payload, payload_len);
|
||||
simOutSize = payload_len;
|
||||
|
@ -208,15 +235,6 @@ pending_packet(void)
|
|||
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)
|
||||
{
|
||||
int len;
|
||||
|
|
Loading…
Reference in a new issue