Contiki-NG
mac.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007, 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  * MAC driver header file
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 #ifndef MAC_H_
41 #define MAC_H_
42 
43 #include "contiki.h"
44 #include "dev/radio.h"
45 
46 /**
47  *\brief The default channel for IEEE 802.15.4 networks.
48  */
49 #ifdef IEEE802154_CONF_DEFAULT_CHANNEL
50 #define IEEE802154_DEFAULT_CHANNEL IEEE802154_CONF_DEFAULT_CHANNEL
51 #else /* IEEE802154_CONF_DEFAULT_CHANNEL */
52 #define IEEE802154_DEFAULT_CHANNEL 26
53 #endif /* IEEE802154_CONF_DEFAULT_CHANNEL */
54 
55 typedef void (* mac_callback_t)(void *ptr, int status, int transmissions);
56 
57 void mac_call_sent_callback(mac_callback_t sent, void *ptr, int status, int num_tx);
58 
59 /**
60  * The structure of a MAC protocol driver in Contiki.
61  */
62 struct mac_driver {
63  char *name;
64 
65  /** Initialize the MAC driver */
66  void (* init)(void);
67 
68  /** Send a packet from the packetbuf */
69  void (* send)(mac_callback_t sent_callback, void *ptr);
70 
71  /** Callback for getting notified of incoming packet. */
72  void (* input)(void);
73 
74  /** Turn the MAC layer on. */
75  int (* on)(void);
76 
77  /** Turn the MAC layer off. */
78  int (* off)(void);
79 };
80 
81 /* Generic MAC return values. */
82 enum {
83  /**< The MAC layer transmission was OK. */
85 
86  /**< The MAC layer transmission could not be performed due to a
87  collision. */
89 
90  /**< The MAC layer did not get an acknowledgement for the packet. */
92 
93  /**< The MAC layer deferred the transmission for a later time. */
95 
96  /**< The MAC layer transmission could not be performed because of an
97  error. The upper layer may try again later. */
99 
100  /**< The MAC layer transmission could not be performed because of a
101  fatal error. The upper layer does not need to try again, as the
102  error will be fatal then as well. */
103  MAC_TX_ERR_FATAL,
104 };
105 
106 #endif /* MAC_H_ */
int(* on)(void)
Turn the MAC layer on.
Definition: mac.h:75
The MAC layer transmission could not be performed because of a fatal error.
Definition: mac.h:98
The structure of a MAC protocol driver in Contiki.
Definition: mac.h:62
Header file for the radio API
int(* off)(void)
Turn the MAC layer off.
Definition: mac.h:78
void(* input)(void)
Callback for getting notified of incoming packet.
Definition: mac.h:72
The MAC layer did not get an acknowledgement for the packet.
Definition: mac.h:88
The MAC layer transmission was OK.
Definition: mac.h:84
The MAC layer transmission could not be performed because of an error.
Definition: mac.h:94
The MAC layer deferred the transmission for a later time.
Definition: mac.h:91
void(* send)(mac_callback_t sent_callback, void *ptr)
Send a packet from the packetbuf.
Definition: mac.h:69
void(* init)(void)
Initialize the MAC driver.
Definition: mac.h:66