Blame view

RIOT/sys/include/net/gnrc/lwmac/timeout.h 2.75 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  /*
   * Copyright (C) 2015 Daniel Krebs
   *               2016 INRIA
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup     net_gnrc_lwmac
   * @{
   *
   * @file
   * @brief       Timeout handling of LWMAC
   *
   *
   * @author      Daniel Krebs <github@daniel-krebs.net>
   * @author      Shuguo Zhuo  <shuguo.zhuo@inria.fr>
   */
  
  #ifndef NET_GNRC_LWMAC_TIMEOUT_H
  #define NET_GNRC_LWMAC_TIMEOUT_H
  
  #include <stdint.h>
  #include <stdbool.h>
  
  #include "net/gnrc/netdev.h"
  #include "net/gnrc/lwmac/types.h"
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  /**
   * @brief   Static initializer for @ref gnrc_lwmac_timeout_t.
   */
  #define GNRC_LWMAC_TIMEOUT_INITIAL  { {}, {}, false, TIMEOUT_DISABLED }
  
  /**
   * @brief   Set LWMAC timeout of type @p type of offset @p offset.
   *
   * @param[in,out] gnrc_netdev  gnrc_netdev structure
   * @param[in]     type         LWMAC timeout type
   * @param[in]     offset       timeout offset
   */
  void gnrc_lwmac_set_timeout(gnrc_netdev_t *gnrc_netdev,
                              gnrc_lwmac_timeout_type_t type,
                              uint32_t offset);
  
  /**
   * @brief   Clear LWMAC timeout of type @p type.
   *
   * @param[in,out] gnrc_netdev  gnrc_netdev structure
   * @param[in]     type         LWMAC timeout type
   */
  void gnrc_lwmac_clear_timeout(gnrc_netdev_t *gnrc_netdev, gnrc_lwmac_timeout_type_t type);
  
  /**
   * @brief   Check whether LWMAC timeout of type @p type is running.
   *
   * @param[in]     gnrc_netdev  gnrc_netdev structure
   * @param[in]     type         LWMAC timeout type
   *
   * @return        true, if timeout of type @p type is running.
   * @return        false, if timeout of type @p type is not running.
   */
  bool gnrc_lwmac_timeout_is_running(gnrc_netdev_t *gnrc_netdev,
                                     gnrc_lwmac_timeout_type_t type);
  
  /**
   * @brief   Check whether LWMAC timeout of type @p type is expired. It will clear
   *          the timeout once it is found expired.
   *
   * @param[in,out] gnrc_netdev  gnrc_netdev structure
   * @param[in]     type         LWMAC timeout type
   *
   * @return        true, if timeout of type @p type is expired.
   * @return        false, if timeout of type @p type is not expired, or not exist.
   */
  bool gnrc_lwmac_timeout_is_expired(gnrc_netdev_t *gnrc_netdev, gnrc_lwmac_timeout_type_t type);
  
  /**
   * @brief   Reset all LWMAC timeouts.
   *
   * @param[in,out] gnrc_netdev  gnrc_netdev structure
   */
  void gnrc_lwmac_reset_timeouts(gnrc_netdev_t *gnrc_netdev);
  
  /**
   * @brief   Make a specific LWMAC timeout expired.
   *
   * @param[in,out] timeout   LWMAC tiemout
   */
  void gnrc_lwmac_timeout_make_expire(gnrc_lwmac_timeout_t *timeout);
  
  #ifdef __cplusplus
  }
  #endif
  
  #endif /* NET_GNRC_LWMAC_TIMEOUT_H */
  /** @} */