Skip to content

Commit

Permalink
Support RADIO_PARAM_LAST_PACKET_TIMESTAMP with get_object()
Browse files Browse the repository at this point in the history
  • Loading branch information
yatch committed Sep 6, 2016
1 parent ca715fd commit 33e8604
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion platform/cooja/dev/cooja-radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* <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)
Expand Down Expand Up @@ -190,6 +191,8 @@ public void signalReceptionStart() {
lastEventTime = mote.getSimulation().getSimulationTime();
lastEvent = RadioEvent.RECEPTION_STARTED;

myMoteMemory.setInt64ValueOf("simLastPacketTimestamp", lastEventTime);

this.setChanged();
this.notifyObservers();
}
Expand Down

0 comments on commit 33e8604

Please sign in to comment.