Contiki-Inga 3.x
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
core
net
rime
stbroadcast.h
Go to the documentation of this file.
1
/**
2
* \addtogroup rime
3
* @{
4
*/
5
6
/**
7
* \defgroup rimestbroadcast Stubborn best-effort local area broadcast
8
* @{
9
*
10
* The stbroadcast module provides stubborn anonymous best-effort local area
11
* broadcast. A message sent with the stbroadcast module is repeated until
12
* either the message is canceled or a new message is sent. Messages
13
* sent with the stbroadcast module are not identified with a sender ID.
14
*
15
* \section channels Channels
16
*
17
* The stbroadcast module uses 1 channel.
18
*
19
*/
20
21
/*
22
* Copyright (c) 2006, Swedish Institute of Computer Science.
23
* All rights reserved.
24
*
25
* Redistribution and use in source and binary forms, with or without
26
* modification, are permitted provided that the following conditions
27
* are met:
28
* 1. Redistributions of source code must retain the above copyright
29
* notice, this list of conditions and the following disclaimer.
30
* 2. Redistributions in binary form must reproduce the above copyright
31
* notice, this list of conditions and the following disclaimer in the
32
* documentation and/or other materials provided with the distribution.
33
* 3. Neither the name of the Institute nor the names of its contributors
34
* may be used to endorse or promote products derived from this software
35
* without specific prior written permission.
36
*
37
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
38
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
41
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
* SUCH DAMAGE.
48
*
49
* This file is part of the Contiki operating system.
50
*
51
*/
52
53
/**
54
* \file
55
* Header file for the Rime module Stubborn Anonymous BroadCast (stbroadcast)
56
* \author
57
* Adam Dunkels <adam@sics.se>
58
*/
59
60
#ifndef STBROADCAST_H_
61
#define STBROADCAST_H_
62
63
#include "
sys/ctimer.h
"
64
65
#include "
net/rime/broadcast.h
"
66
#include "
net/queuebuf.h
"
67
68
struct
stbroadcast_conn
;
69
70
struct
stbroadcast_callbacks {
71
void (* recv)(
struct
stbroadcast_conn
*c);
72
void (* sent)(
struct
stbroadcast_conn
*c);
73
};
74
75
/**
76
* A stbroadcast connection. This is an opaque structure with no user-visible
77
* fields. The stbroadcast_open() function is used for setting up a stbroadcast
78
* connection.
79
*/
80
struct
stbroadcast_conn
{
81
struct
broadcast_conn c;
82
struct
ctimer t;
83
struct
queuebuf *buf;
84
const
struct
stbroadcast_callbacks *u;
85
};
86
87
88
/**
89
* \brief Set up a stbroadcast connection.
90
* \param c A pointer to a user-supplied struct stbroadcast variable.
91
* \param channel The Rime channel on which messages should be sent.
92
* \param u Pointer to the upper layer functions that should be used
93
* for this connection.
94
*
95
* This function sets up a stbroadcast connection on the
96
* specified channel. No checks are made if the channel is
97
* currently used by another connection.
98
*
99
* This function must be called before any other function
100
* that operates on the connection is called.
101
*
102
*/
103
void
stbroadcast_open
(
struct
stbroadcast_conn
*c, uint16_t channel,
104
const
struct
stbroadcast_callbacks *u);
105
void
stbroadcast_close(
struct
stbroadcast_conn
*c);
106
107
/**
108
* \brief Send a stubborn message.
109
* \param c A stbroadcast connection that must have been previously set up
110
* with stbroadcast_open()
111
* \param t The time between message retransmissions.
112
*
113
* This function sends a message from the Rime buffer. The
114
* message must have been previously constructed in the
115
* Rime buffer. When this function returns, the message
116
* has been copied into a queue buffer.
117
*
118
* If another message has previously been sent, the old
119
* message is canceled.
120
*
121
*/
122
int
stbroadcast_send_stubborn
(
struct
stbroadcast_conn
*c, clock_time_t t);
123
124
/**
125
* \brief Cancel the current stubborn message.
126
* \param c A stbroadcast connection that must have been previously set up
127
* with stbroadcast_open()
128
*
129
* This function cancels a stubborn message that has
130
* previously been sent with the stbroadcast_send_stubborn()
131
* function.
132
*
133
*/
134
void
stbroadcast_cancel
(
struct
stbroadcast_conn
*c);
135
136
137
138
/**
139
* \brief Set the retransmission time of the current stubborn message.
140
* \param c A stbroadcast connection that must have been previously set up
141
* with stbroadcast_open()
142
* \param t The new time between message retransmissions.
143
*
144
* This function sets the retransmission timer for the
145
* current stubborn message to a new value.
146
*
147
*/
148
void
stbroadcast_set_timer
(
struct
stbroadcast_conn
*c, clock_time_t t);
149
150
#endif
/* STBROADCAST_H_ */
151
152
/** @} */
153
/** @} */
Generated on Thu Apr 24 2014 16:26:12 for Contiki-Inga 3.x by
1.8.3.1