Contiki-NG
radio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005, Swedish Institute of Computer Science.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * This file is part of the Contiki operating system.
30 *
31 */
32
33/**
34 * \file
35 * Header file for the radio API
36 * \author
37 * Adam Dunkels <adam@sics.se>
38 * Joakim Eriksson <joakime@sics.se>
39 * Niclas Finne <nfi@sics.se>
40 * Nicolas Tsiftes <nvt@sics.se>
41 */
42
43/**
44 * \addtogroup dev
45 * @{
46 */
47
48/**
49 * \defgroup radio Radio API
50 *
51 * The radio API module defines a set of functions that a radio device
52 * driver must implement.
53 *
54 * @{
55 */
56
57#ifndef RADIO_H_
58#define RADIO_H_
59
60#include <stddef.h>
61
62/**
63 * Each radio has a set of parameters that designate the current
64 * configuration and state of the radio. Parameters can either have
65 * values of type `radio_value_t`, or, when this type is insufficient, a
66 * generic object that is specified by a memory pointer and the size
67 * of the object.
68 *
69 * The `radio_value_t` type is set to an integer type that can hold most
70 * values used to configure the radio, and is therefore the most
71 * common type used for a parameter. Certain parameters require
72 * objects of a considerably larger size than `radio_value_t`, however,
73 * and in these cases the documentation below for the parameter will
74 * indicate this.
75 *
76 * All radio parameters that can vary during runtime are prefixed by
77 * `RADIO_PARAM_`, whereas those "parameters" that are guaranteed to
78 * remain immutable are prefixed by `RADIO_CONST_`. Each mutable
79 * parameter has a set of valid parameter values. When attempting to
80 * set a parameter to an invalid value, the radio will return
81 * `RADIO_RESULT_INVALID_VALUE`.
82 *
83 * Some radios support only a subset of the defined radio parameters.
84 * When trying to set or get such an unsupported parameter, the radio
85 * will return `RADIO_RESULT_NOT_SUPPORTED`.
86 */
87
88typedef int radio_value_t;
89typedef unsigned radio_param_t;
90
91/**
92 * \brief Radio parameters and constants
93 *
94 * The fields of this enum are expected to be used as the `param` argument
95 * of `get_value()`, `set_value()`, `get_object()` and `set_object()`.
96 *
97 * More specifically, fields prefixed with `RADIO_PARAM_` may be passed as an
98 * argument to any of those four functions. Exceptions are documented on a
99 * per-field basis. Fields prefixed with `RADIO_CONST_` will only be passed as
100 * an argument to `get_value()` and `get_object()`.
101 */
103
104 /**
105 * When getting the value of this parameter, the radio driver should
106 * indicate whether the radio is on or not.
107 *
108 * `RADIO_POWER_MODE_ON`: The radio is powered and ready to receive frames
109 * `RADIO_POWER_MODE_OFF`: The radio is powered off
110 *
111 * When setting the value of this parameter, the driver should put the radio
112 * part in the corresponding state.
113 * `RADIO_POWER_MODE_ON`: The radio should be powered on and ready to receive
114 * frames. This is equivalent to a call to `NETSTACK_RADIO.on()`.
115 * `RADIO_POWER_MODE_OFF`: The radio should be put in the lowest power
116 * consumption state available. This is equivalent to a call to
117 * `NETSTACK_RADIO.off()`.
118 */
120
121 /**
122 * Channel used for radio communication. The channel depends on the
123 * communication standard used by the radio. The values can range
124 * from `RADIO_CONST_CHANNEL_MIN` to `RADIO_CONST_CHANNEL_MAX`.
125 *
126 * When setting this parameter, the change should take effect immediately
127 * if the radio is in `RADIO_POWER_MODE_ON`. Otherwise the change should take
128 * effect the next time the radio turns on.
129 *
130 * When reading this parameter, the driver should return the currently
131 * configured channel if the radio is in `RADIO_POWER_MODE_ON`, or the last
132 * used channel is the radio is currently in `RADIO_POWER_MODE_OFF`.
133 */
135
136 /**
137 * The personal area network identifier (PAN ID), which is used by the h/w
138 * frame filtering functionality of some radios.
139 *
140 * Setting this param will typically require the radio driver to commit the
141 * PAN ID to some radio hardware register used for frame filtering.
142 *
143 * Getting this param will typically require the radio driver to return the
144 * value currently stored in the respective hardware register.
145 *
146 * If the hardware does not support frame filtering, there is no expectation
147 * to perform such filtering in the radio driver software. In the case of
148 * such radios, the driver can simply return `RADIO_RESULT_NOT_SUPPORTED`.
149 */
151
152 /**
153 * The short address (16 bits) for the radio, which is used by the h/w
154 * filter.
155 *
156 * Setting this param will typically require the radio driver to commit the
157 * value to some radio hardware register used for frame filtering.
158 *
159 * Getting this param will typically require the radio driver to return the
160 * value currently stored in the respective hardware register.
161 *
162 * If the hardware does not support frame filtering, there is no expectation
163 * to perform such filtering in the radio driver software. In the case of
164 * such radios, the driver can simply return `RADIO_RESULT_NOT_SUPPORTED`.
165 */
167
168 /**
169 * Radio receiver mode determines if the radio has address filter
170 * (`RADIO_RX_MODE_ADDRESS_FILTER`) and auto-ACK (`RADIO_RX_MODE_AUTOACK`)
171 * enabled. This parameter is set as a bit mask.
172 */
174
175 /**
176 * Radio transmission mode determines if the radio has send on CCA
177 * (`RADIO_TX_MODE_SEND_ON_CCA`) enabled or not. This parameter is set
178 * as a bit mask.
179 */
181
182 /**
183 * Transmission power in dBm. The values can range from
184 * `RADIO_CONST_TXPOWER_MIN` to `RADIO_CONST_TXPOWER_MAX`.
185 *
186 * Some radios restrict the available values to a subset of this
187 * range. If an unavailable TXPOWER value is requested to be set,
188 * the radio may select another TXPOWER close to the requested
189 * one. When getting the value of this parameter, the actual value
190 * used by the radio will be returned.
191 */
193
194 /**
195 * Clear channel assessment threshold in dBm. This threshold
196 * determines the minimum RSSI level at which the radio will assume
197 * that there is a packet in the air.
198 *
199 * The CCA threshold must be set to a level above the noise floor of
200 * the deployment. Otherwise mechanisms such as send-on-CCA and
201 * low-power-listening duty cycling protocols may not work
202 * correctly. Hence, the default value of the system may not be
203 * optimal for any given deployment.
204 */
206
207 /**
208 * Received signal strength indicator in dBm.
209 *
210 * When getting this parameter, the radio driver should return the current
211 * RSSI value as reported by the radio.
212 *
213 * This may require turning on the radio and requesting an RSSI sample.
214 *
215 * This parameter will only be passed as an argument to the `get_value()`
216 * function.
217 */
219
220 /**
221 * The RSSI value of the last received packet.
222 *
223 * This parameter will only be passed as an argument to the `get_value()`
224 * function.
225 */
227
228 /**
229 * Link quality indicator of the last received packet.
230 *
231 * The value returned should be an unsigned number between 0x00 and 0xFF.
232 *
233 * This parameter will only be passed as an argument to the `get_value()`
234 * function.
235 */
237
238 /**
239 * Long (64 bits) address for the radio, which is used by the address filter.
240 * The address is specified in network byte order.
241 *
242 * Because this parameter value is larger than what fits in `radio_value_t`,
243 * it needs to be used with `get_object()`/`set_object()`.
244 *
245 * Setting this param will typically require the radio driver to commit the
246 * value to some radio hardware register used for frame filtering.
247 *
248 * Getting this param will typically require the radio driver to return the
249 * value currently stored in the respective hardware register.
250 *
251 * If the hardware does not support frame filtering, there is no expectation
252 * to perform such filtering in the radio driver software. In the case of
253 * such radios, the driver can simply return `RADIO_RESULT_NOT_SUPPORTED`.
254 */
256
257 /**
258 * Last packet timestamp, of type `rtimer_clock_t`.
259 *
260 * The timestamp corresponds to the point in time between the end of
261 * reception of the synchronisation header and the start of reception of the
262 * physical header (PHR).
263 *
264 * ```
265 * +---------------+-----+---------------+---------------+-----+
266 * | SHR | PHR | MHR | MAC Payload | MFR |
267 * +---------------+-----+---------------+---------------+-----+
268 * ^
269 * --- Timestamp --|
270 * ```
271 *
272 * Because this parameter value may be larger than what fits in `radio_value_t`,
273 * it needs to be used with `get_object()`/`set_object()`.
274 *
275 * This parameter will only be passed as an argument to the `get_object()`
276 * function.
277 */
279
280 /**
281 * For enabling and disabling the SHR search
282 *
283 * Setting this param to `RADIO_SHR_SEARCH_DIS` will disable SHR search.
284 * This means that when the radio is in receive mode it can be used to
285 * sample RSSI or to perform a clear channel assessment (CCA), but it will
286 * not receive frames.
287 *
288 * Setting this param to `RADIO_SHR_SEARCH_EN` will enable SHR search.
289 * This means that when the radio is in receive mode it will receive frames
290 * as normal.
291 *
292 * When setting this parameter, the change should take effect immediately
293 * if the radio is in `RADIO_POWER_MODE_ON`. Otherwise the change should take
294 * effect the next time the radio turns on.
295 */
297
298 /* Constants (read only) */
299
300 /**
301 * The lowest radio channel number
302 */
304
305 /**
306 * The highest radio channel number
307 */
309
310 /**
311 * The minimum transmission power in dBm
312 */
314
315 /**
316 * The maximum transmission power in dBm.
317 */
319
320 /* A pointer to TSCH timings in micro-seconds (tsch_timeslot_timing_usec *) */
321 RADIO_CONST_TSCH_TIMING,
322
323 /**
324 * The physical layer header (PHR) + MAC layer footer (MFR) overhead in
325 * bytes. This does _not_ include the synchronisation header (SHR).
326 *
327 * For example, on IEEE 802.15.4 at 2.4 GHz this will be 3 bytes: 1 byte for
328 * the frame length (PHR) + 2 bytes for the CRC (MFR)
329 */
331
332 /**
333 * The air time of one byte in usec, e.g. 32 for IEEE 802.15.4 at 2.4 GHz
334 */
336
337 /**
338 * The delay in usec between a call to the radio API's transmit function and
339 * the end of SFD transmission.
340 */
342
343 /**
344 * The delay in usec between turning on the radio and it being actually
345 * listening (able to hear a preamble)
346 */
348
349 /**
350 * The delay in usec between the end of SFD reception for an incoming frame
351 * and the radio API starting to return `receiving_packet() != 0`
352 */
354
355 /*
356 * The maximum payload the radio driver is able to handle.
357 *
358 * This includes the MAC header and MAC payload, but not any tail bytes
359 * added automatically by the radio. For example, in the typical case of
360 * .15.4 operation at 2.4GHz, this will be 125 bytes (127 bytes minus the
361 * FCS / CRC16).
362 *
363 * This is the maximum number of bytes that:
364 * - The MAC layer will ask the radio driver to transmit.
365 * This corresponds to the payload_len argument of the prepare() and
366 * send() and the transmit_len argument of transmit().
367 * - The radio driver will deliver to the MAC layer after frame reception.
368 * The buf_len of the read function will typically be greater than or
369 * equal to this value.
370 *
371 * Supporting this constant in the radio driver's get_value function is
372 * mandatory.
373 */
374 RADIO_CONST_MAX_PAYLOAD_LEN,
375};
376
377/**
378 * Radio power modes
379 *
380 * Used as the `value` argument of `get_value()` / `set_value()` when `param`
381 * is `RADIO_PARAM_POWER_MODE`.
382 */
384 /**
385 * Radio powered off and in the lowest possible power consumption state.
386 */
388
389 /**
390 * Radio powered on and able to receive frames.
391 */
393
394 /**
395 * Radio powered on and emitting unmodulated carriers.
396 */
398
399 /**
400 * Radio powered on, but not emitting unmodulated carriers.
401 */
404
405/**
406 * Possible values of the `get_value()` / `set_value()` `value` argument when
407 * the `param` argument is `RADIO_PARAM_SHR_SEARCH`.
408 */
410 RADIO_SHR_SEARCH_DIS = 0, /**< Disable SHR search or SHR search is enabled */
411 RADIO_SHR_SEARCH_EN = 1, /**< Enable SHR search or SHR search is enabled */
412};
413
414/*---------------------------------------------------------------------------*/
415/**
416 * \name Radio RX mode
417 *
418 * The radio reception mode controls address filtering and automatic
419 * transmission of acknowledgements in the radio (if such operations
420 * are supported by the radio). A single parameter is used to allow
421 * setting these features simultaneously as an atomic operation.
422 *
423 * These macros are meant to be used as the `value` argument of `get_value()`
424 * and `set_value()` when the `param` argument is `RADIO_PARAM_RX_MODE`.
425 *
426 * To enable both address filter and transmissions of automatic
427 * acknowledgments:
428 *
429 * ```
430 * NETSTACK_RADIO.set_value(RADIO_PARAM_RX_MODE,
431 * RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_AUTOACK);
432 * ```
433 * @{
434 */
435
436/**
437 * Enable address-based frame filtering.
438 *
439 * This will typically involve filtering based on PAN ID, Short address and
440 * long address. The filtering will consider the params RADIO_PARAM_PAN_ID,
441 * RADIO_PARAM_16BIT_ADDR and RADIO_PARAM_64BIT_ADDR respectively.
442 */
443#define RADIO_RX_MODE_ADDRESS_FILTER (1 << 0)
444
445/**
446 * Enable automatic transmission of ACK frames
447 */
448#define RADIO_RX_MODE_AUTOACK (1 << 1)
449
450/**
451 * Enable/disable/get the state of radio driver poll mode operation
452 */
453#define RADIO_RX_MODE_POLL_MODE (1 << 2)
454/** @} */
455/*---------------------------------------------------------------------------*/
456/**
457 * Radio TX mode control / retrieval
458 *
459 * The radio transmission mode controls whether transmissions should
460 * be done using clear channel assessment (if supported by the
461 * radio). If send-on-CCA is enabled, the radio's send function will
462 * wait for a radio-specific time window for the channel to become
463 * clear. If this does not happen, the send function will return
464 * `RADIO_TX_COLLISION`.
465 */
466#define RADIO_TX_MODE_SEND_ON_CCA (1 << 0)
467
468/**
469 * Radio return values when setting or getting radio parameters.
470 */
471typedef enum radio_result_e {
472 RADIO_RESULT_OK, /**< The parameter was set/read successfully */
473 RADIO_RESULT_NOT_SUPPORTED, /**< The parameter is not supported */
474 RADIO_RESULT_INVALID_VALUE, /**< The `value` argument was incorrect */
475
476 /**
477 * An error occurred when getting/setting the parameter, but the arguments
478 * were otherwise correct.
479 */
482
483/**
484 * Radio return values for the `transmit()` function.
485 */
487 /**
488 * TX was successful and where an ACK was requested one was received
489 */
491
492 /**
493 * An error occurred during transmission.
494 *
495 * This will typically signify that the transmitted frame was too long/short
496 * or that an error occurred at the radio driver level.
497 */
499
500 /**
501 * TX failed due to a collision
502 */
504
505 /**
506 * A unicast frame was sent OK but an ACK was _not_ received
507 */
509};
510/*---------------------------------------------------------------------------*/
511/**
512 * \name The Contiki-NG RF driver API
513 * @{
514 */
515/**
516 * The structure of a Contiki-NG radio device driver.
517 *
518 * Typically this data structure will represent the driver of an IEEE
519 * 802.15.4-compliant radio hardware.
520 *
521 * This data structure is the only required interface between the radio driver
522 * and the Contiki-NG network stack. All functions implemented in the radio
523 * driver, including those pointed to by the fields of this structure can
524 * be static.
525 */
527
528 /**
529 * Initialise the radio hardware.
530 *
531 * \retval 1 Initialisation successful
532 * \retval 0 Initialisation failed
533 *
534 * This function will be called once during boot. It shall perform one-off
535 * initialisation of the radio driver and hardware. Typical operations to
536 * implement as part of this function are initialisation of driver internal
537 * data structures and initial configuration of the radio hardware.
538 *
539 * This function is expected to apply configuration that persists across
540 * radio on/off cycles. Non-persistent changes should be implemented as part
541 * of `on()` instead.
542 *
543 * This function may, but is not strictly expected to put the radio in RX mode.
544 * The Contiki-NG boot sequence will put the radio in RX mode explicitly by
545 * a subsequent call to `on()`.
546 */
547 int (* init)(void);
548
549 /**
550 * Prepare the radio with a packet to be sent.
551 *
552 * \param payload A pointer to the location of the packet
553 * \param payload_len The length of the packet to be sent
554 * \retval 0 Packet copied successfully
555 * \retval 1 The packet could not be copied
556 *
557 * This function is expected to copy `payload_len` bytes from the location
558 * pointed to by `payload` to a location internal to the radio driver. In a
559 * typical scenario this will be a separate buffer in RAM, or the radio
560 * hardware's FIFO.
561 *
562 * `payload` will contain the MAC header (MHR) and MAC payload, but it
563 * will _not_ contain the physical header or the MAC footer (MFR).
564 *
565 * `payload_len` must be lower than or equal to the value retrieved when calling
566 * NETSTACK_RADIO.get_value(RADIO_CONST_MAX_PAYLOAD_LEN, ...)
567 *
568 * This function will return an error if the radio driver could not copy
569 * the packet to a location internal to the driver. Commonly this may happen
570 * if the latter is occupied by a previous packet which has yet to be sent.
571 */
572 int (* prepare)(const void *payload, unsigned short payload_len);
573
574 /**
575 * Send the packet that has previously been prepared.
576 *
577 * \param transmit_len The number of bytes to transmit
578 * \return This function will return one of the radio_tx_e enumerators
579 *
580 * The radio driver is not expected to remember the packet even if TX fails.
581 *
582 * `transmit_len` is equal the length of a previously prepared packet.
583 * Semantically it is identical to the `payload_len` argument of the
584 * `prepare()` function.
585 *
586 * A previously prepared packet shall contain the MAC header (MHR) and MAC
587 * payload, but it shall _not_ contain the physical header or the MAC footer
588 * (MFR). This function shall make sure that all necessary physical layer
589 * symbols are transmitted before the packet. In the case of .15.4 radios
590 * this includes the synch header (SHR), preamble and physical header (PHR).
591 * This function shall also make sure that the MFR is transmitted.
592 *
593 * Unless an error occurs, this function will wait until the packet has
594 * been fully transmitted.
595 *
596 * If `RADIO_PARAM_TX_MODE & RADIO_TX_MODE_SEND_ON_CCA` then this function
597 * should perform a CCA before transmission. If this CCA fails the function
598 * shall return `RADIO_TX_COLLISION`.
599 *
600 * This function may be called while the radio is powered-off, or while the
601 * radio is in RX mode. In the former case, it shall power on the radio and
602 * enter TX mode, ideally bypassing RX mode to reduce off->TX turnaround
603 * time. In the latter case, the function shall perform an RX-TX transition.
604 *
605 * This function may leave the radio in RX mode after transmission, but this
606 * is not necessary since the caller will explicitly request the correct
607 * radio state after this function returns: This will either be a request to
608 * revert to RX mode by a call to `on()`, or a request to power the radio
609 * down by a call to `off()`.
610 */
611 int (* transmit)(unsigned short transmit_len);
612
613 /**
614 * Prepare & transmit a packet.
615 *
616 * \param payload A pointer to the location of the packet
617 * \param payload_len The length of the packet to be sent
618 * \return This function will return one of the radio_tx_e enumerators
619 *
620 * This function shall behave exactly as a call to `prepare()`, immediately
621 * followed by a call to `transmit()`.
622 */
623 int (* send)(const void *payload, unsigned short payload_len);
624
625 /**
626 * Read a received packet into a buffer.
627 *
628 * \param buf A pointer the the buffer where the packet is to be copied
629 * \param buf_len The length of `buf`
630 * \return The number of bytes copied to `buf`
631 *
632 * If the radio has no correctly-received packets then this function will
633 * return 0.
634 *
635 * The buffer `buf` will be allocated by the caller.
636 *
637 * The radio driver is not expected to remember the packet after this call
638 * returns.
639 *
640 * This function is expected to be able to deliver a packet to the MAC layer
641 * even if the radio is powered down by a call to `off()`.
642 *
643 * When this function returns, `buf` will contain the MAC header (MHR) and
644 * MAC payload, but it will _not_ contain the physical header or the MAC
645 * footer (MFR).
646 */
647 int (* read)(void *buf, unsigned short buf_len);
648
649 /**
650 * Perform a Clear-Channel Assessment (CCA) to find out if there is
651 * a packet in the air or not.
652 *
653 * \retval 0 The channel is busy
654 * \retval 1 The channel is clear
655 *
656 * It is up to the radio driver's developer to decide how the CCA will be
657 * performed. Some radios have built-in, .15.4-compliant CCA operation; for
658 * those radios, it is up to the developer to decide which CCA mode to use.
659 *
660 * This function should not be called while the radio is not in RX mode. If
661 * this happens, this function shall return 0 and it will _not_ try to
662 * power-on the radio in order to perform a CCA.
663 */
664 int (* channel_clear)(void);
665
666 /**
667 * Check if the radio driver is currently receiving a packet.
668 *
669 * \retval 1 Reception of a packet is in progress
670 * \retval 0 No reception in progress
671 *
672 * If at the point of calling this function the radio is not in RX mode, for
673 * example as a result of a previous call to `off()`, this function will
674 * immediately return 0.
675 */
676 int (* receiving_packet)(void);
677
678 /**
679 * Check if a packet has been received and is available in the radio driver's
680 * buffers.
681 *
682 * \retval 1 One (or more) packet(s) is (are) available
683 * \retval 0 No packets available
684 *
685 * This function may be called while the radio is powered down by a previous
686 * call to `off()`. If that happens, the function shall not power on the
687 * radio.
688 */
689 int (* pending_packet)(void);
690
691 /**
692 * Turn the radio on.
693 *
694 * \retval 1 The call was successful and the radio is now in RX mode
695 * \retval 0 The call failed
696 *
697 * This function will put the radio in a state ready to receive packets. The
698 * function will power-on and configure the radio if necessary.
699 *
700 * This function shall not intentionally discard any previously received
701 * packets.
702 */
703 int (* on)(void);
704
705 /**
706 * Turn the radio off.
707 *
708 * \retval 1 Success
709 * \retval 0 Error
710 *
711 * This function shall put the radio to its lowest power consumption state.
712 *
713 * This function may be called immediately after the reception of a packet,
714 * but before this packet gets copied to the upper layers through a call to
715 * `read()`. If powering down the radio would result in the received packet
716 * getting lost, due to e.g. non-retention of the radio's hardware FIFO,
717 * then the radio driver shall make sure any received packets get copied to
718 * RAM first. This function shall not intentionally discard any previously
719 * received packets.
720 */
721 int (* off)(void);
722
723 /**
724 * Get a radio parameter value.
725 *
726 * \param param The parameter to retrieve: An enumerator of `radio_param_e`
727 * \param value A pointer to store the value of `param`
728 * \return An enumerator of `radio_result_t`
729 *
730 * This function shall copy the current value of parameter `param` to the
731 * location pointed to by `value`. The caller shall allocate `value`.
732 */
733 radio_result_t (* get_value)(radio_param_t param, radio_value_t *value);
734
735 /**
736 * Set a radio parameter value.
737 *
738 * \param param The parameter to set: An enumerator of `radio_param_e`
739 * \param value The new value for `param`
740 * \return An enumerator of `radio_result_t`
741 *
742 * This function shall set the value of a radio parameter.
743 *
744 * If this function is called while the radio is powered on, the requested
745 * change shall take effect immediately. If the radio is powered-off, the
746 * change shall take effect in the next power-on cycle.
747 */
748 radio_result_t (* set_value)(radio_param_t param, radio_value_t value);
749
750 /**
751 * Get a radio parameter object.
752 *
753 * \param param The parameter to retrieve: An enumerator of `radio_param_e`
754 * \param dest A pointer to a buffer where the value of `param` shall be stored
755 * \param size The size of the `dest` buffer
756 * \return An enumerator of `radio_result_t`
757 *
758 * The argument `dest` must point to a memory area of at least `size` bytes,
759 * and this memory area will contain the parameter object if the function
760 * succeeds. `dest` shall be allocated by the caller.
761 */
762 radio_result_t (* get_object)(radio_param_t param, void *dest, size_t size);
763
764 /**
765 * Set a radio parameter object.
766 *
767 * \param param The parameter to set: An enumerator of `radio_param_e`
768 * \param src A pointer to a buffer where the new value is stored
769 * \param size The size of the `src` buffer
770 * \return An enumerator of `radio_result_t`
771 *
772 * The memory area referred to by the argument `src` will not be accessed
773 * after the function returns.
774 *
775 * If this function is called while the radio is powered on, the requested
776 * change shall take effect immediately. If the radio is powered-off, the
777 * change shall take effect in the next power-on cycle.
778 */
779 radio_result_t (* set_object)(radio_param_t param, const void *src,
780 size_t size);
781};
782/** @} */
783/*---------------------------------------------------------------------------*/
784#endif /* RADIO_H_ */
785/*---------------------------------------------------------------------------*/
786/** @} */
787/** @} */
radio_result_e
Radio return values when setting or getting radio parameters.
Definition: radio.h:471
radio_param_e
Radio parameters and constants.
Definition: radio.h:102
radio_shr_search_e
Possible values of the get_value() / set_value() value argument when the param argument is RADIO_PARA...
Definition: radio.h:409
enum radio_result_e radio_result_t
Radio return values when setting or getting radio parameters.
radio_power_mode_e
Radio power modes.
Definition: radio.h:383
radio_tx_e
Radio return values for the transmit() function.
Definition: radio.h:486
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
@ RADIO_RESULT_ERROR
An error occurred when getting/setting the parameter, but the arguments were otherwise correct.
Definition: radio.h:480
@ RADIO_RESULT_NOT_SUPPORTED
The parameter is not supported.
Definition: radio.h:473
@ RADIO_RESULT_INVALID_VALUE
The value argument was incorrect.
Definition: radio.h:474
@ RADIO_RESULT_OK
The parameter was set/read successfully.
Definition: radio.h:472
@ RADIO_PARAM_POWER_MODE
When getting the value of this parameter, the radio driver should indicate whether the radio is on or...
Definition: radio.h:119
@ RADIO_CONST_PHY_OVERHEAD
The physical layer header (PHR) + MAC layer footer (MFR) overhead in bytes.
Definition: radio.h:330
@ RADIO_PARAM_RSSI
Received signal strength indicator in dBm.
Definition: radio.h:218
@ RADIO_PARAM_LAST_PACKET_TIMESTAMP
Last packet timestamp, of type rtimer_clock_t.
Definition: radio.h:278
@ RADIO_PARAM_LAST_RSSI
The RSSI value of the last received packet.
Definition: radio.h:226
@ RADIO_CONST_BYTE_AIR_TIME
The air time of one byte in usec, e.g.
Definition: radio.h:335
@ RADIO_PARAM_RX_MODE
Radio receiver mode determines if the radio has address filter (RADIO_RX_MODE_ADDRESS_FILTER) and aut...
Definition: radio.h:173
@ RADIO_PARAM_CHANNEL
Channel used for radio communication.
Definition: radio.h:134
@ RADIO_PARAM_SHR_SEARCH
For enabling and disabling the SHR search.
Definition: radio.h:296
@ RADIO_PARAM_LAST_LINK_QUALITY
Link quality indicator of the last received packet.
Definition: radio.h:236
@ RADIO_CONST_DELAY_BEFORE_RX
The delay in usec between turning on the radio and it being actually listening (able to hear a preamb...
Definition: radio.h:347
@ RADIO_PARAM_TXPOWER
Transmission power in dBm.
Definition: radio.h:192
@ RADIO_PARAM_64BIT_ADDR
Long (64 bits) address for the radio, which is used by the address filter.
Definition: radio.h:255
@ RADIO_CONST_DELAY_BEFORE_TX
The delay in usec between a call to the radio API's transmit function and the end of SFD transmission...
Definition: radio.h:341
@ RADIO_CONST_CHANNEL_MAX
The highest radio channel number.
Definition: radio.h:308
@ RADIO_PARAM_PAN_ID
The personal area network identifier (PAN ID), which is used by the h/w frame filtering functionality...
Definition: radio.h:150
@ RADIO_PARAM_CCA_THRESHOLD
Clear channel assessment threshold in dBm.
Definition: radio.h:205
@ RADIO_CONST_TXPOWER_MIN
The minimum transmission power in dBm.
Definition: radio.h:313
@ RADIO_CONST_CHANNEL_MIN
The lowest radio channel number.
Definition: radio.h:303
@ RADIO_CONST_TXPOWER_MAX
The maximum transmission power in dBm.
Definition: radio.h:318
@ RADIO_CONST_DELAY_BEFORE_DETECT
The delay in usec between the end of SFD reception for an incoming frame and the radio API starting t...
Definition: radio.h:353
@ RADIO_PARAM_16BIT_ADDR
The short address (16 bits) for the radio, which is used by the h/w filter.
Definition: radio.h:166
@ RADIO_PARAM_TX_MODE
Radio transmission mode determines if the radio has send on CCA (RADIO_TX_MODE_SEND_ON_CCA) enabled o...
Definition: radio.h:180
@ RADIO_SHR_SEARCH_EN
Enable SHR search or SHR search is enabled.
Definition: radio.h:411
@ RADIO_SHR_SEARCH_DIS
Disable SHR search or SHR search is enabled.
Definition: radio.h:410
@ RADIO_POWER_MODE_CARRIER_OFF
Radio powered on, but not emitting unmodulated carriers.
Definition: radio.h:402
@ RADIO_POWER_MODE_OFF
Radio powered off and in the lowest possible power consumption state.
Definition: radio.h:387
@ RADIO_POWER_MODE_ON
Radio powered on and able to receive frames.
Definition: radio.h:392
@ RADIO_POWER_MODE_CARRIER_ON
Radio powered on and emitting unmodulated carriers.
Definition: radio.h:397
@ RADIO_TX_NOACK
A unicast frame was sent OK but an ACK was not received.
Definition: radio.h:508
@ RADIO_TX_COLLISION
TX failed due to a collision.
Definition: radio.h:503
@ RADIO_TX_ERR
An error occurred during transmission.
Definition: radio.h:498
@ RADIO_TX_OK
TX was successful and where an ACK was requested one was received.
Definition: radio.h:490
The structure of a Contiki-NG radio device driver.
Definition: radio.h:526
radio_result_t(* get_object)(radio_param_t param, void *dest, size_t size)
Get a radio parameter object.
Definition: radio.h:762
int(* read)(void *buf, unsigned short buf_len)
Read a received packet into a buffer.
Definition: radio.h:647
int(* prepare)(const void *payload, unsigned short payload_len)
Prepare the radio with a packet to be sent.
Definition: radio.h:572
radio_result_t(* set_value)(radio_param_t param, radio_value_t value)
Set a radio parameter value.
Definition: radio.h:748
int(* off)(void)
Turn the radio off.
Definition: radio.h:721
int(* init)(void)
Initialise the radio hardware.
Definition: radio.h:547
int(* send)(const void *payload, unsigned short payload_len)
Prepare & transmit a packet.
Definition: radio.h:623
int(* receiving_packet)(void)
Check if the radio driver is currently receiving a packet.
Definition: radio.h:676
radio_result_t(* set_object)(radio_param_t param, const void *src, size_t size)
Set a radio parameter object.
Definition: radio.h:779
int(* on)(void)
Turn the radio on.
Definition: radio.h:703
int(* transmit)(unsigned short transmit_len)
Send the packet that has previously been prepared.
Definition: radio.h:611
int(* pending_packet)(void)
Check if a packet has been received and is available in the radio driver's buffers.
Definition: radio.h:689
radio_result_t(* get_value)(radio_param_t param, radio_value_t *value)
Get a radio parameter value.
Definition: radio.h:733
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