Contiki-NG
nullradio.c
1 #include "dev/nullradio.h"
2 /*---------------------------------------------------------------------------*/
3 /*
4  * The maximum number of bytes this driver can accept from the MAC layer for
5  * "transmission".
6  */
7 #define MAX_PAYLOAD_LEN ((unsigned short) - 1)
8 /*---------------------------------------------------------------------------*/
9 static int
10 init(void)
11 {
12  return 0;
13 }
14 /*---------------------------------------------------------------------------*/
15 static int
16 prepare(const void *payload, unsigned short payload_len)
17 {
18  return 1;
19 }
20 /*---------------------------------------------------------------------------*/
21 static int
22 transmit(unsigned short transmit_len)
23 {
24  return RADIO_TX_OK;
25 }
26 /*---------------------------------------------------------------------------*/
27 static int
28 send(const void *payload, unsigned short payload_len)
29 {
30  prepare(payload, payload_len);
31  return transmit(payload_len);
32 }
33 /*---------------------------------------------------------------------------*/
34 static int
35 radio_read(void *buf, unsigned short buf_len)
36 {
37  return 0;
38 }
39 /*---------------------------------------------------------------------------*/
40 static int
41 channel_clear(void)
42 {
43  return 1;
44 }
45 /*---------------------------------------------------------------------------*/
46 static int
47 receiving_packet(void)
48 {
49  return 0;
50 }
51 /*---------------------------------------------------------------------------*/
52 static int
53 pending_packet(void)
54 {
55  return 0;
56 }
57 /*---------------------------------------------------------------------------*/
58 static int
59 on(void)
60 {
61  return 0;
62 }
63 /*---------------------------------------------------------------------------*/
64 static int
65 off(void)
66 {
67  return 0;
68 }
69 /*---------------------------------------------------------------------------*/
70 static radio_result_t
71 get_value(radio_param_t param, radio_value_t *value)
72 {
73  if(!value) {
75  }
76 
77  switch(param) {
78  case RADIO_CONST_MAX_PAYLOAD_LEN:
79  *value = (radio_value_t)MAX_PAYLOAD_LEN;
80  return RADIO_RESULT_OK;
81  default:
83  }
84 }
85 /*---------------------------------------------------------------------------*/
86 static radio_result_t
87 set_value(radio_param_t param, radio_value_t value)
88 {
90 }
91 /*---------------------------------------------------------------------------*/
92 static radio_result_t
93 get_object(radio_param_t param, void *dest, size_t size)
94 {
96 }
97 /*---------------------------------------------------------------------------*/
98 static radio_result_t
99 set_object(radio_param_t param, const void *src, size_t size)
100 {
102 }
103 /*---------------------------------------------------------------------------*/
104 const struct radio_driver nullradio_driver =
105  {
106  init,
107  prepare,
108  transmit,
109  send,
110  radio_read,
114  on,
115  off,
116  get_value,
117  set_value,
118  get_object,
119  set_object
120  };
121 /*---------------------------------------------------------------------------*/
radio_result_t(* get_object)(radio_param_t param, void *dest, size_t size)
Get a radio parameter object.
Definition: radio.h:762
int(* prepare)(const void *payload, unsigned short payload_len)
Prepare the radio with a packet to be sent.
Definition: radio.h:572
The parameter is not supported.
Definition: radio.h:473
int(* receiving_packet)(void)
Check if the radio driver is currently receiving a packet.
Definition: radio.h:676
radio_result_t(* set_value)(radio_param_t param, radio_value_t value)
Set a radio parameter value.
Definition: radio.h:748
int(* pending_packet)(void)
Check if a packet has been received and is available in the radio driver's buffers.
Definition: radio.h:689
The structure of a Contiki-NG radio device driver.
Definition: radio.h:526
The value argument was incorrect.
Definition: radio.h:474
The parameter was set/read successfully.
Definition: radio.h:472
int(* channel_clear)(void)
Perform a Clear-Channel Assessment (CCA) to find out if there is a packet in the air or not...
Definition: radio.h:664
int radio_value_t
Each radio has a set of parameters that designate the current configuration and state of the radio...
Definition: radio.h:88
int(* send)(const void *payload, unsigned short payload_len)
Prepare & transmit a packet.
Definition: radio.h:623
int(* transmit)(unsigned short transmit_len)
Send the packet that has previously been prepared.
Definition: radio.h:611
int(* off)(void)
Turn the radio off.
Definition: radio.h:721
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
int(* init)(void)
Initialise the radio hardware.
Definition: radio.h:547
radio_result_t(* get_value)(radio_param_t param, radio_value_t *value)
Get a radio parameter value.
Definition: radio.h:733
radio_result_t(* set_object)(radio_param_t param, const void *src, size_t size)
Set a radio parameter object.
Definition: radio.h:779
TX was successful and where an ACK was requested one was received.
Definition: radio.h:490
int(* on)(void)
Turn the radio on.
Definition: radio.h:703