From 5292005962bdd173e112bd4dd9e69260d43d5bd3 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 23 Feb 2010 18:18:53 +0000 Subject: [PATCH] A null radio driver that does not do anything - useful in the native port and as a template for new radio drivers --- Makefile.include | 6 ++-- core/dev/nullradio.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ core/dev/nullradio.h | 8 +++++ 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 core/dev/nullradio.c create mode 100644 core/dev/nullradio.h diff --git a/Makefile.include b/Makefile.include index 14afba6c9..4ad1afc7b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -53,7 +53,7 @@ SYSTEM = process.c procinit.c autostart.c elfloader.c profile.c \ THREADS = mt.c LIBS = memb.c mmem.c timer.c list.c etimer.c energest.c rtimer.c stimer.c \ print-stats.c ifft.c crc16.c random.c checkpoint.c ringbuf.c - +DEV = nullradio.c NET = netstack.c ifdef UIP_CONF_IPV6 @@ -72,9 +72,9 @@ CTK = ctk.c CTKVNC = $(CTK) ctk-vncserver.c libconio.c vnc-server.c vnc-out.c ctk-vncfont.c ifndef CONTIKI_NO_NET - CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(THREADS) $(DHCP) + CONTIKIFILES = $(SYSTEM) $(LIBS) $(NET) $(THREADS) $(DHCP) $(DEV) else - CONTIKIFILES = $(SYSTEM) $(LIBS) $(THREADS) sicslowpan.c fakeuip.c + CONTIKIFILES = $(SYSTEM) $(LIBS) $(THREADS) $(DEV) sicslowpan.c fakeuip.c endif CONTIKI_SOURCEFILES += $(CONTIKIFILES) diff --git a/core/dev/nullradio.c b/core/dev/nullradio.c new file mode 100644 index 000000000..c2b978f2b --- /dev/null +++ b/core/dev/nullradio.c @@ -0,0 +1,79 @@ +#include "dev/nullradio.h" + + +/*---------------------------------------------------------------------------*/ +static int +init(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +prepare(const void *payload, unsigned short payload_len) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int +transmit(unsigned short transmit_len) +{ + return RADIO_TX_OK; +} +/*---------------------------------------------------------------------------*/ +static int +send(const void *payload, unsigned short payload_len) +{ + prepare(payload, payload_len); + return transmit(payload_len); +} +/*---------------------------------------------------------------------------*/ +static int +read(void *buf, unsigned short buf_len) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +channel_clear(void) +{ + return 1; +} +/*---------------------------------------------------------------------------*/ +static int +receiving_packet(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +pending_packet(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +on(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +static int +off(void) +{ + return 0; +} +/*---------------------------------------------------------------------------*/ +const struct radio_driver nullradio_driver = + { + init, + prepare, + transmit, + send, + read, + channel_clear, + receiving_packet, + pending_packet, + on, + off, + }; +/*---------------------------------------------------------------------------*/ diff --git a/core/dev/nullradio.h b/core/dev/nullradio.h new file mode 100644 index 000000000..87acb3450 --- /dev/null +++ b/core/dev/nullradio.h @@ -0,0 +1,8 @@ +#ifndef NULLRADIO_H +#define NULLRADIO_H + +#include "dev/radio.h" + +extern const struct radio_driver nullradio_driver; + +#endif /* NULLRADIO_H */