Removing the need for nullrdc-noframer

This commit is contained in:
Simon Duquennoy 2017-05-16 21:38:02 +02:00
parent e1f8a1e0db
commit 35a9984122
5 changed files with 10 additions and 163 deletions

View File

@ -1,112 +0,0 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* 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.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A MAC protocol that does not do anything.
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "net/mac/nullrdc-noframer.h"
#include "net/packetbuf.h"
#include "net/queuebuf.h"
#include "net/netstack.h"
#include <string.h>
/*---------------------------------------------------------------------------*/
static void
send_packet(mac_callback_t sent, void *ptr)
{
int ret;
if(NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()) == RADIO_TX_OK) {
ret = MAC_TX_OK;
} else {
ret = MAC_TX_ERR;
}
mac_call_sent_callback(sent, ptr, ret, 1);
}
/*---------------------------------------------------------------------------*/
static void
send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
{
if(buf_list != NULL) {
queuebuf_to_packetbuf(buf_list->buf);
send_packet(sent, ptr);
}
}
/*---------------------------------------------------------------------------*/
static void
packet_input(void)
{
NETSTACK_MAC.input();
}
/*---------------------------------------------------------------------------*/
static int
on(void)
{
return NETSTACK_RADIO.on();
}
/*---------------------------------------------------------------------------*/
static int
off(int keep_radio_on)
{
if(keep_radio_on) {
return NETSTACK_RADIO.on();
} else {
return NETSTACK_RADIO.off();
}
}
/*---------------------------------------------------------------------------*/
static unsigned short
channel_check_interval(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static void
init(void)
{
on();
}
/*---------------------------------------------------------------------------*/
const struct rdc_driver nullrdc_noframer_driver = {
"nullrdc-noframer",
init,
send_packet,
send_list,
packet_input,
on,
off,
channel_check_interval,
};
/*---------------------------------------------------------------------------*/

View File

@ -1,48 +0,0 @@
/*
* Copyright (c) 2007, Swedish Institute of Computer Science.
* 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.
*
* This file is part of the Contiki operating system.
*
*/
/**
* \file
* A MAC protocol implementation that does not do anything.
* \author
* Adam Dunkels <adam@sics.se>
*/
#ifndef NULLRDC_NOFRAMER_H_
#define NULLRDC_NOFRAMER_H_
#include "net/mac/rdc.h"
#include "dev/radio.h"
extern const struct rdc_driver nullrdc_noframer_driver;
#endif /* NULLRDC_NOFRAMER_H_ */

View File

@ -91,6 +91,12 @@ create(void)
/*---------------------------------------------------------------------------*/
static int
parse(void)
{
return 0;
}
/*---------------------------------------------------------------------------*/
int
no_framer_parse_802154_frame(void)
{
frame802154_t frame;
int len;

View File

@ -60,7 +60,7 @@
#define NETSTACK_CONF_MAC nullmac_driver
#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC nullrdc_noframer_driver
#define NETSTACK_CONF_RDC nullrdc_driver
#undef NETSTACK_CONF_NETWORK
#define NETSTACK_CONF_NETWORK slipnet_driver

View File

@ -53,7 +53,8 @@ extern const struct slip_radio_sensors SLIP_RADIO_CONF_SENSORS;
#endif
void slip_send_packet(const uint8_t *ptr, int len);
void no_framer_parse_802154_frame(void);
/* max 16 packets at the same time??? */
uint8_t packet_ids[16];
int packet_pos;
@ -124,7 +125,7 @@ slip_radio_cmd_handler(const uint8_t *data, int len)
data[2], packetbuf_datalen());
/* parse frame before sending to get addresses, etc. */
no_framer.parse();
no_framer_parse_802154_frame();
NETSTACK_MAC.send(packet_sent, &packet_ids[packet_pos]);
packet_pos++;