2007-05-18 13:45:19 +00:00
|
|
|
/*
|
2010-03-09 08:11:05 +00:00
|
|
|
* Copyright (c) 2010, Swedish Institute of Computer Science.
|
2007-05-18 13:45:19 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
#include <stdio.h>
|
2007-05-18 13:45:19 +00:00
|
|
|
#include <string.h>
|
2010-03-09 08:11:05 +00:00
|
|
|
|
2007-05-18 13:45:19 +00:00
|
|
|
#include "contiki.h"
|
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
#include "sys/cooja_mt.h"
|
|
|
|
#include "lib/simEnvChange.h"
|
|
|
|
|
2010-06-14 19:19:16 +00:00
|
|
|
#include "net/packetbuf.h"
|
2010-03-09 08:11:05 +00:00
|
|
|
#include "net/netstack.h"
|
|
|
|
|
2007-05-18 13:45:19 +00:00
|
|
|
#include "dev/radio.h"
|
|
|
|
#include "dev/cooja-radio.h"
|
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
#define COOJA_RADIO_BUFSIZE PACKETBUF_SIZE
|
|
|
|
#define CCA_SS_THRESHOLD -95
|
2007-05-18 13:45:19 +00:00
|
|
|
|
|
|
|
const struct simInterface radio_interface;
|
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
/* COOJA */
|
2007-05-29 12:53:49 +00:00
|
|
|
char simReceiving = 0;
|
2007-05-18 13:45:19 +00:00
|
|
|
char simInDataBuffer[COOJA_RADIO_BUFSIZE];
|
2007-05-29 12:53:49 +00:00
|
|
|
int simInSize = 0;
|
2016-09-06 13:14:10 +00:00
|
|
|
rtimer_clock_t simLastPacketTimestamp = 0;
|
2007-05-18 13:45:19 +00:00
|
|
|
char simOutDataBuffer[COOJA_RADIO_BUFSIZE];
|
2007-05-29 12:53:49 +00:00
|
|
|
int simOutSize = 0;
|
2007-05-18 13:45:19 +00:00
|
|
|
char simRadioHWOn = 1;
|
2010-03-09 08:11:05 +00:00
|
|
|
int simSignalStrength = -100;
|
|
|
|
int simLastSignalStrength = -100;
|
2007-05-18 13:45:19 +00:00
|
|
|
char simPower = 100;
|
2008-03-18 16:22:00 +00:00
|
|
|
int simRadioChannel = 26;
|
2012-12-11 11:09:33 +00:00
|
|
|
int simLQI = 105;
|
2007-05-18 13:45:19 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
static const void *pending_data;
|
2007-05-18 13:45:19 +00:00
|
|
|
|
2016-09-06 13:14:10 +00:00
|
|
|
/* If we are in the polling mode, poll_mode is 1; otherwise 0 */
|
|
|
|
static int poll_mode = 0; /* default 0, disabled */
|
|
|
|
static int auto_ack = 0; /* AUTO_ACK is not supported; always 0 */
|
|
|
|
static int addr_filter = 0; /* ADDRESS_FILTER is not supported; always 0 */
|
|
|
|
static int send_on_cca = (COOJA_TRANSMIT_ON_CCA != 0);
|
2007-05-18 13:45:19 +00:00
|
|
|
|
2016-09-06 13:14:10 +00:00
|
|
|
PROCESS(cooja_radio_process, "cooja radio process");
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
set_send_on_cca(uint8_t enable)
|
|
|
|
{
|
|
|
|
send_on_cca = enable;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
set_frame_filtering(int enable)
|
|
|
|
{
|
|
|
|
addr_filter = enable;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
set_auto_ack(int enable)
|
|
|
|
{
|
|
|
|
auto_ack = enable;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
set_poll_mode(int enable)
|
|
|
|
{
|
|
|
|
poll_mode = enable;
|
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-18 13:45:19 +00:00
|
|
|
void
|
2010-03-09 08:11:05 +00:00
|
|
|
radio_set_channel(int channel)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
2010-03-09 08:11:05 +00:00
|
|
|
simRadioChannel = channel;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
void
|
2010-03-09 08:11:05 +00:00
|
|
|
radio_set_txpower(unsigned char power)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
2010-03-09 08:11:05 +00:00
|
|
|
/* 1 - 100: Number indicating output power */
|
|
|
|
simPower = power;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-18 13:45:19 +00:00
|
|
|
int
|
2010-03-09 08:11:05 +00:00
|
|
|
radio_signal_strength_last(void)
|
2007-05-18 15:20:20 +00:00
|
|
|
{
|
|
|
|
return simLastSignalStrength;
|
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-18 15:20:20 +00:00
|
|
|
int
|
2010-03-09 08:11:05 +00:00
|
|
|
radio_signal_strength_current(void)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
|
|
|
return simSignalStrength;
|
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2012-12-11 11:09:33 +00:00
|
|
|
int
|
|
|
|
radio_LQI(void)
|
|
|
|
{
|
2016-09-06 13:14:10 +00:00
|
|
|
return simLQI;
|
2012-12-11 11:09:33 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-03-09 08:11:05 +00:00
|
|
|
static int
|
|
|
|
radio_on(void)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
2010-03-09 08:11:05 +00:00
|
|
|
simRadioHWOn = 1;
|
|
|
|
return 1;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
radio_off(void)
|
|
|
|
{
|
|
|
|
simRadioHWOn = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-18 13:45:19 +00:00
|
|
|
static void
|
|
|
|
doInterfaceActionsBeforeTick(void)
|
|
|
|
{
|
2012-03-13 13:17:43 +00:00
|
|
|
if(!simRadioHWOn) {
|
2007-05-18 13:45:19 +00:00
|
|
|
simInSize = 0;
|
|
|
|
return;
|
|
|
|
}
|
2012-03-13 13:17:43 +00:00
|
|
|
if(simReceiving) {
|
2007-05-18 15:20:20 +00:00
|
|
|
simLastSignalStrength = simSignalStrength;
|
2007-05-18 13:45:19 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2012-03-13 13:17:43 +00:00
|
|
|
if(simInSize > 0) {
|
2010-03-09 08:11:05 +00:00
|
|
|
process_poll(&cooja_radio_process);
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-03-09 08:11:05 +00:00
|
|
|
static void
|
|
|
|
doInterfaceActionsAfterTick(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
2007-11-25 22:44:06 +00:00
|
|
|
radio_read(void *buf, unsigned short bufsize)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
2010-03-09 08:11:05 +00:00
|
|
|
int tmp = simInSize;
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2012-03-13 13:17:43 +00:00
|
|
|
if(simInSize == 0) {
|
2009-04-16 14:38:41 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
if(bufsize < simInSize) {
|
|
|
|
simInSize = 0; /* rx flush */
|
|
|
|
return 0;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
|
|
|
|
memcpy(buf, simInDataBuffer, simInSize);
|
|
|
|
simInSize = 0;
|
2016-09-06 13:14:10 +00:00
|
|
|
if(!poll_mode) {
|
|
|
|
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, simSignalStrength);
|
|
|
|
packetbuf_set_attr(PACKETBUF_ATTR_LINK_QUALITY, simLQI);
|
|
|
|
}
|
2012-12-11 11:09:33 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
return tmp;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
2012-03-09 13:58:13 +00:00
|
|
|
channel_clear(void)
|
|
|
|
{
|
|
|
|
if(simSignalStrength > CCA_SS_THRESHOLD) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
2007-11-25 22:44:06 +00:00
|
|
|
radio_send(const void *payload, unsigned short payload_len)
|
2007-05-18 13:45:19 +00:00
|
|
|
{
|
2010-03-23 12:13:43 +00:00
|
|
|
int radiostate = simRadioHWOn;
|
|
|
|
|
2013-08-15 12:32:35 +00:00
|
|
|
/* Simulate turnaround time of 2ms for packets, 1ms for acks*/
|
2016-09-06 13:14:10 +00:00
|
|
|
#if COOJA_SIMULATE_TURNAROUND
|
2012-03-09 13:58:13 +00:00
|
|
|
simProcessRunValue = 1;
|
|
|
|
cooja_mt_yield();
|
2013-08-15 12:32:35 +00:00
|
|
|
if(payload_len > 3) {
|
|
|
|
simProcessRunValue = 1;
|
|
|
|
cooja_mt_yield();
|
|
|
|
}
|
2016-09-06 13:14:10 +00:00
|
|
|
#endif /* COOJA_SIMULATE_TURNAROUND */
|
2012-03-09 13:58:13 +00:00
|
|
|
|
2007-05-18 13:45:19 +00:00
|
|
|
if(!simRadioHWOn) {
|
2010-03-23 12:13:43 +00:00
|
|
|
/* Turn on radio temporarily */
|
|
|
|
simRadioHWOn = 1;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
|
|
|
if(payload_len > COOJA_RADIO_BUFSIZE) {
|
2010-03-09 08:11:05 +00:00
|
|
|
return RADIO_TX_ERR;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
if(payload_len == 0) {
|
|
|
|
return RADIO_TX_ERR;
|
|
|
|
}
|
|
|
|
if(simOutSize > 0) {
|
|
|
|
return RADIO_TX_ERR;
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2012-03-13 13:17:43 +00:00
|
|
|
/* Transmit on CCA */
|
2016-09-06 13:14:10 +00:00
|
|
|
#if COOJA_TRANSMIT_ON_CCA
|
2016-09-06 13:14:10 +00:00
|
|
|
if(send_on_cca && !channel_clear()) {
|
2012-03-09 13:58:13 +00:00
|
|
|
return RADIO_TX_COLLISION;
|
|
|
|
}
|
2016-09-06 13:14:10 +00:00
|
|
|
#endif /* COOJA_TRANSMIT_ON_CCA */
|
2012-03-09 13:58:13 +00:00
|
|
|
|
2007-05-18 13:45:19 +00:00
|
|
|
/* Copy packet data to temporary storage */
|
|
|
|
memcpy(simOutDataBuffer, payload, payload_len);
|
|
|
|
simOutSize = payload_len;
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
/* Transmit */
|
|
|
|
while(simOutSize > 0) {
|
|
|
|
cooja_mt_yield();
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2008-03-17 09:48:00 +00:00
|
|
|
|
2010-03-23 12:13:43 +00:00
|
|
|
simRadioHWOn = radiostate;
|
2010-03-09 08:11:05 +00:00
|
|
|
return RADIO_TX_OK;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
prepare_packet(const void *data, unsigned short len)
|
|
|
|
{
|
|
|
|
pending_data = data;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
transmit_packet(unsigned short len)
|
|
|
|
{
|
|
|
|
int ret = RADIO_TX_ERR;
|
|
|
|
if(pending_data != NULL) {
|
|
|
|
ret = radio_send(pending_data, len);
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
receiving_packet(void)
|
|
|
|
{
|
|
|
|
return simReceiving;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
pending_packet(void)
|
|
|
|
{
|
|
|
|
return !simReceiving && simInSize > 0;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(cooja_radio_process, ev, data)
|
|
|
|
{
|
|
|
|
int len;
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
PROCESS_BEGIN();
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
while(1) {
|
|
|
|
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
|
2016-09-06 13:14:10 +00:00
|
|
|
if(poll_mode) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
|
|
|
|
packetbuf_clear();
|
|
|
|
len = radio_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
|
|
|
if(len > 0) {
|
|
|
|
packetbuf_set_datalen(len);
|
2017-05-17 13:09:19 +00:00
|
|
|
NETSTACK_MAC.input();
|
2010-03-09 08:11:05 +00:00
|
|
|
}
|
2007-05-28 15:47:07 +00:00
|
|
|
}
|
2009-04-01 13:44:34 +00:00
|
|
|
|
2010-03-09 08:11:05 +00:00
|
|
|
PROCESS_END();
|
2007-05-18 13:45:19 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int
|
|
|
|
init(void)
|
2007-08-21 13:09:40 +00:00
|
|
|
{
|
2010-03-09 08:11:05 +00:00
|
|
|
process_start(&cooja_radio_process, NULL);
|
|
|
|
return 1;
|
2007-08-21 13:09:40 +00:00
|
|
|
}
|
2010-03-09 08:11:05 +00:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2014-04-01 14:23:52 +00:00
|
|
|
static radio_result_t
|
|
|
|
get_value(radio_param_t param, radio_value_t *value)
|
|
|
|
{
|
2016-09-06 13:14:10 +00:00
|
|
|
switch(param) {
|
|
|
|
case RADIO_PARAM_RX_MODE:
|
|
|
|
*value = 0;
|
|
|
|
if(addr_filter) {
|
|
|
|
*value |= RADIO_RX_MODE_ADDRESS_FILTER;
|
|
|
|
}
|
|
|
|
if(auto_ack) {
|
|
|
|
*value |= RADIO_RX_MODE_AUTOACK;
|
|
|
|
}
|
|
|
|
if(poll_mode) {
|
|
|
|
*value |= RADIO_RX_MODE_POLL_MODE;
|
|
|
|
}
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
case RADIO_PARAM_TX_MODE:
|
|
|
|
*value = 0;
|
|
|
|
if(send_on_cca) {
|
|
|
|
*value |= RADIO_TX_MODE_SEND_ON_CCA;
|
|
|
|
}
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
case RADIO_PARAM_LAST_RSSI:
|
|
|
|
*value = simSignalStrength;
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
case RADIO_PARAM_LAST_LINK_QUALITY:
|
|
|
|
*value = simLQI;
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
default:
|
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
|
|
|
}
|
2014-04-01 14:23:52 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static radio_result_t
|
|
|
|
set_value(radio_param_t param, radio_value_t value)
|
|
|
|
{
|
2016-09-06 13:14:10 +00:00
|
|
|
switch(param) {
|
|
|
|
case RADIO_PARAM_RX_MODE:
|
|
|
|
if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER |
|
|
|
|
RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_POLL_MODE)) {
|
|
|
|
return RADIO_RESULT_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Only disabling is acceptable for RADIO_RX_MODE_ADDRESS_FILTER */
|
|
|
|
if ((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0) {
|
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
set_frame_filtering((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0);
|
|
|
|
|
|
|
|
/* Only disabling is acceptable for RADIO_RX_MODE_AUTOACK */
|
|
|
|
if ((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0) {
|
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
set_auto_ack((value & RADIO_RX_MODE_AUTOACK) != 0);
|
|
|
|
|
|
|
|
set_poll_mode((value & RADIO_RX_MODE_POLL_MODE) != 0);
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
case RADIO_PARAM_TX_MODE:
|
|
|
|
if(value & ~(RADIO_TX_MODE_SEND_ON_CCA)) {
|
|
|
|
return RADIO_RESULT_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
set_send_on_cca((value & RADIO_TX_MODE_SEND_ON_CCA) != 0);
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
case RADIO_PARAM_CHANNEL:
|
|
|
|
if(value < 11 || value > 26) {
|
|
|
|
return RADIO_RESULT_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
radio_set_channel(value);
|
|
|
|
return RADIO_RESULT_OK;
|
|
|
|
default:
|
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
|
|
|
}
|
2014-04-01 14:23:52 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static radio_result_t
|
|
|
|
get_object(radio_param_t param, void *dest, size_t size)
|
|
|
|
{
|
2016-09-06 13:14:10 +00:00
|
|
|
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;
|
|
|
|
}
|
2016-09-06 13:14:10 +00:00
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
2014-04-01 14:23:52 +00:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static radio_result_t
|
|
|
|
set_object(radio_param_t param, const void *src, size_t size)
|
|
|
|
{
|
|
|
|
return RADIO_RESULT_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2010-03-09 08:11:05 +00:00
|
|
|
const struct radio_driver cooja_radio_driver =
|
|
|
|
{
|
|
|
|
init,
|
|
|
|
prepare_packet,
|
|
|
|
transmit_packet,
|
|
|
|
radio_send,
|
|
|
|
radio_read,
|
2010-03-23 15:10:27 +00:00
|
|
|
channel_clear,
|
2010-03-09 08:11:05 +00:00
|
|
|
receiving_packet,
|
|
|
|
pending_packet,
|
|
|
|
radio_on,
|
|
|
|
radio_off,
|
2014-04-01 14:23:52 +00:00
|
|
|
get_value,
|
|
|
|
set_value,
|
|
|
|
get_object,
|
|
|
|
set_object
|
2010-03-09 08:11:05 +00:00
|
|
|
};
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2007-05-18 13:45:19 +00:00
|
|
|
SIM_INTERFACE(radio_interface,
|
2016-09-06 13:14:10 +00:00
|
|
|
doInterfaceActionsBeforeTick,
|
|
|
|
doInterfaceActionsAfterTick);
|