stbroadcast.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rime
00003  * @{
00004 */
00005 
00006 /**
00007  * \defgroup rimestbroadcast Stubborn best-effort local area broadcast
00008  * @{
00009  *
00010  * The stbroadcast module provides stubborn anonymous best-effort local area
00011  * broadcast. A message sent with the stbroadcast module is repeated until
00012  * either the message is canceled or a new message is sent. Messages
00013  * sent with the stbroadcast module are not identified with a sender ID.
00014  *
00015  * \section channels Channels
00016  *
00017  * The stbroadcast module uses 1 channel.
00018  *
00019  */
00020 
00021 /*
00022  * Copyright (c) 2006, Swedish Institute of Computer Science.
00023  * All rights reserved.
00024  *
00025  * Redistribution and use in source and binary forms, with or without
00026  * modification, are permitted provided that the following conditions
00027  * are met:
00028  * 1. Redistributions of source code must retain the above copyright
00029  *    notice, this list of conditions and the following disclaimer.
00030  * 2. Redistributions in binary form must reproduce the above copyright
00031  *    notice, this list of conditions and the following disclaimer in the
00032  *    documentation and/or other materials provided with the distribution.
00033  * 3. Neither the name of the Institute nor the names of its contributors
00034  *    may be used to endorse or promote products derived from this software
00035  *    without specific prior written permission.
00036  *
00037  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00038  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00039  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00040  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00041  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00042  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00043  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00044  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00045  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00046  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  *
00049  * This file is part of the Contiki operating system.
00050  *
00051  * $Id: stbroadcast.h,v 1.4 2010/06/14 19:19:17 adamdunkels Exp $
00052  */
00053 
00054 /**
00055  * \file
00056  *         Header file for the Rime module Stubborn Anonymous BroadCast (stbroadcast)
00057  * \author
00058  *         Adam Dunkels <adam@sics.se>
00059  */
00060 
00061 #ifndef __STBROADCAST_H__
00062 #define __STBROADCAST_H__
00063 
00064 #include "sys/ctimer.h"
00065 
00066 #include "net/rime/broadcast.h"
00067 #include "net/queuebuf.h"
00068 
00069 struct stbroadcast_conn;
00070 
00071 struct stbroadcast_callbacks {
00072   void (* recv)(struct stbroadcast_conn *c);
00073   void (* sent)(struct stbroadcast_conn *c);
00074 };
00075 
00076 /**
00077  * A stbroadcast connection. This is an opaque structure with no user-visible
00078  * fields. The stbroadcast_open() function is used for setting up a stbroadcast
00079  * connection.
00080  */
00081 struct stbroadcast_conn {
00082   struct broadcast_conn c;
00083   struct ctimer t;
00084   struct queuebuf *buf;
00085   const struct stbroadcast_callbacks *u;
00086 };
00087 
00088 
00089 /**
00090  * \brief      Set up a stbroadcast connection.
00091  * \param c    A pointer to a user-supplied struct stbroadcast variable.
00092  * \param channel The Rime channel on which messages should be sent.
00093  * \param u    Pointer to the upper layer functions that should be used
00094  *             for this connection.
00095  *
00096  *             This function sets up a stbroadcast connection on the
00097  *             specified channel. No checks are made if the channel is
00098  *             currently used by another connection.
00099  *
00100  *             This function must be called before any other function
00101  *             that operates on the connection is called.
00102  *
00103  */
00104 void stbroadcast_open(struct stbroadcast_conn *c, uint16_t channel,
00105                 const struct stbroadcast_callbacks *u);
00106 void stbroadcast_close(struct stbroadcast_conn *c);
00107 
00108 /**
00109  * \brief      Send a stubborn message.
00110  * \param c    A stbroadcast connection that must have been previously set up
00111  *             with stbroadcast_open()
00112  * \param t    The time between message retransmissions.
00113  *
00114  *             This function sends a message from the Rime buffer. The
00115  *             message must have been previously constructed in the
00116  *             Rime buffer. When this function returns, the message
00117  *             has been copied into a queue buffer.
00118  *
00119  *             If another message has previously been sent, the old
00120  *             message is canceled.
00121  *
00122  */
00123 int stbroadcast_send_stubborn(struct stbroadcast_conn *c, clock_time_t t);
00124 
00125 /**
00126  * \brief      Cancel the current stubborn message.
00127  * \param c    A stbroadcast connection that must have been previously set up
00128  *             with stbroadcast_open()
00129  *
00130  *             This function cancels a stubborn message that has
00131  *             previously been sent with the stbroadcast_send_stubborn()
00132  *             function.
00133  *
00134  */
00135 void stbroadcast_cancel(struct stbroadcast_conn *c);
00136 
00137 
00138 
00139 /**
00140  * \brief      Set the retransmission time of the current stubborn message.
00141  * \param c    A stbroadcast connection that must have been previously set up
00142  *             with stbroadcast_open()
00143  * \param t    The new time between message retransmissions.
00144  *
00145  *             This function sets the retransmission timer for the
00146  *             current stubborn message to a new value.
00147  *
00148  */
00149 void stbroadcast_set_timer(struct stbroadcast_conn *c, clock_time_t t);
00150 
00151 #endif /* __STBROADCAST_H__ */
00152 
00153 /** @} */
00154 /** @} */

Generated on Mon Apr 11 14:23:31 2011 for Contiki 2.5 by  doxygen 1.6.1