Support RADIO_PARAM_LAST_PACKET_TIMESTAMP with get_object()

This commit is contained in:
Yasuyuki Tanaka 2016-09-06 15:14:10 +02:00
parent ca715fdd6b
commit 33e86042e5
2 changed files with 11 additions and 1 deletions

View file

@ -55,6 +55,7 @@ const struct simInterface radio_interface;
char simReceiving = 0;
char simInDataBuffer[COOJA_RADIO_BUFSIZE];
int simInSize = 0;
rtimer_clock_t simLastPacketTimestamp = 0;
char simOutDataBuffer[COOJA_RADIO_BUFSIZE];
int simOutSize = 0;
char simRadioHWOn = 1;
@ -287,7 +288,13 @@ set_value(radio_param_t param, radio_value_t value)
static radio_result_t
get_object(radio_param_t param, void *dest, size_t size)
{
return RADIO_RESULT_NOT_SUPPORTED;
if(param == RADIO_PARAM_LAST_PACKET_TIMESTAMP) {
if(size != sizeof(rtimer_clock_t) || !dest) {
return RADIO_RESULT_INVALID_VALUE;
}
*(rtimer_clock_t *)dest = (rtimer_clock_t)simLastPacketTimestamp;
return RADIO_RESULT_OK;
}
}
/*---------------------------------------------------------------------------*/
static radio_result_t

View file

@ -62,6 +62,7 @@ import org.contikios.cooja.util.CCITT_CRC;
* <p>
* <li>int simInSize (size of received data packet)
* <li>byte[] simInDataBuffer (data of received data packet)
* <li>int64_t simLastPacketTimestamp (timestamp of the last received data packet)
* <p>
* <li>int simOutSize (size of transmitted data packet)
* <li>byte[] simOutDataBuffer (data of transmitted data packet)
@ -190,6 +191,8 @@ public class ContikiRadio extends Radio implements ContikiMoteInterface, PolledA
lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED;
myMoteMemory.setInt64ValueOf("simLastPacketTimestamp", lastEventTime);
this.setChanged();
this.notifyObservers();
}