Changed name of the sabc module to stbroadcast

This commit is contained in:
adamdunkels 2008-06-30 08:28:53 +00:00
parent 1093a8fe28
commit e6079870fe
4 changed files with 71 additions and 71 deletions

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rudolph0.c,v 1.9 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: rudolph0.c,v 1.10 2008/06/30 08:28:53 adamdunkels Exp $
*/
/**
@ -103,25 +103,25 @@ send_nack(struct rudolph0_conn *c)
}
/*---------------------------------------------------------------------------*/
static void
sent(struct sabc_conn *sabc)
sent(struct stbroadcast_conn *stbroadcast)
{
struct rudolph0_conn *c = (struct rudolph0_conn *)sabc;
struct rudolph0_conn *c = (struct rudolph0_conn *)stbroadcast;
if(c->current.datalen == RUDOLPH0_DATASIZE) {
c->current.h.chunk++;
PRINTF("Sending data chunk %d next time\n", c->current.h.chunk);
read_new_datapacket(c);
} else {
sabc_set_timer(&c->c, STEADY_TIME);
stbroadcast_set_timer(&c->c, STEADY_TIME);
PRINTF("Steady: Sending the same data chunk next time datalen %d, %d\n",
c->current.datalen, RUDOLPH0_DATASIZE);
}
}
/*---------------------------------------------------------------------------*/
static void
recv(struct sabc_conn *sabc)
recv(struct stbroadcast_conn *stbroadcast)
{
struct rudolph0_conn *c = (struct rudolph0_conn *)sabc;
struct rudolph0_conn *c = (struct rudolph0_conn *)stbroadcast;
struct rudolph0_datapacket *p = rimebuf_dataptr();
if(p->h.type == TYPE_DATA) {
@ -175,18 +175,18 @@ recv_nack(struct polite_conn *polite)
c->current.h.chunk = 0;
}
read_new_datapacket(c);
sabc_set_timer(&c->c, c->send_interval);
stbroadcast_set_timer(&c->c, c->send_interval);
}
}
/*---------------------------------------------------------------------------*/
static const struct polite_callbacks polite = { recv_nack, 0, 0 };
static const struct sabc_callbacks sabc = { recv, sent };
static const struct stbroadcast_callbacks stbroadcast = { recv, sent };
/*---------------------------------------------------------------------------*/
void
rudolph0_open(struct rudolph0_conn *c, uint16_t channel,
const struct rudolph0_callbacks *cb)
{
sabc_open(&c->c, channel, &sabc);
stbroadcast_open(&c->c, channel, &stbroadcast);
polite_open(&c->nackc, channel + 1, &polite);
c->cb = cb;
c->current.h.version = 0;
@ -197,7 +197,7 @@ rudolph0_open(struct rudolph0_conn *c, uint16_t channel,
void
rudolph0_close(struct rudolph0_conn *c)
{
sabc_close(&c->c);
stbroadcast_close(&c->c);
polite_close(&c->nackc);
}
/*---------------------------------------------------------------------------*/
@ -212,7 +212,7 @@ rudolph0_send(struct rudolph0_conn *c, clock_time_t send_interval)
read_new_datapacket(c);
rimebuf_reference(&c->current, sizeof(struct rudolph0_datapacket));
c->send_interval = send_interval;
sabc_send_stubborn(&c->c, c->send_interval);
stbroadcast_send_stubborn(&c->c, c->send_interval);
}
/*---------------------------------------------------------------------------*/
void
@ -225,7 +225,7 @@ rudolph0_force_restart(struct rudolph0_conn *c)
void
rudolph0_stop(struct rudolph0_conn *c)
{
sabc_cancel(&c->c);
stbroadcast_cancel(&c->c);
}
/*---------------------------------------------------------------------------*/
int

View file

@ -47,7 +47,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: rudolph0.h,v 1.9 2008/02/25 02:14:35 adamdunkels Exp $
* $Id: rudolph0.h,v 1.10 2008/06/30 08:28:53 adamdunkels Exp $
*/
/**
@ -60,7 +60,7 @@
#ifndef __RUDOLPH0_H__
#define __RUDOLPH0_H__
#include "net/rime/sabc.h"
#include "net/rime/stbroadcast.h"
#include "net/rime/polite.h"
struct rudolph0_conn;
@ -97,7 +97,7 @@ struct rudolph0_datapacket {
};
struct rudolph0_conn {
struct sabc_conn c;
struct stbroadcast_conn c;
struct polite_conn nackc;
const struct rudolph0_callbacks *cb;
clock_time_t send_interval;

View file

@ -1,5 +1,5 @@
/**
* \addtogroup rimesabc
* \addtogroup rimestbroadcast
* @{
*/
@ -33,57 +33,57 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sabc.c,v 1.8 2008/02/24 22:05:27 adamdunkels Exp $
* $Id: stbroadcast.c,v 1.1 2008/06/30 08:28:53 adamdunkels Exp $
*/
/**
* \file
* Implementation of the Rime module Stubborn Anonymous
* BroadCast (sabc)
* BroadCast (stbroadcast)
* \author
* Adam Dunkels <adam@sics.se>
*/
#include "net/rime/sabc.h"
#include "net/rime/stbroadcast.h"
#include "net/rime.h"
#include <string.h>
/*---------------------------------------------------------------------------*/
static void
recv_from_abc(struct abc_conn *abc)
recv_from_broadcast(struct broadcast_conn *broadcast, rimeaddr_t *sender)
{
register struct sabc_conn *c = (struct sabc_conn *)abc;
/* DEBUGF(3, "sabc: recv_from_abc from %d\n", from_id);*/
register struct stbroadcast_conn *c = (struct stbroadcast_conn *)broadcast;
/* DEBUGF(3, "stbroadcast: recv_from_broadcast from %d\n", from_id);*/
if(c->u->recv != NULL) {
c->u->recv(c);
}
}
/*---------------------------------------------------------------------------*/
static const struct abc_callbacks sabc = {recv_from_abc};
static const struct broadcast_callbacks stbroadcast = {recv_from_broadcast};
/*---------------------------------------------------------------------------*/
void
sabc_open(struct sabc_conn *c, uint16_t channel,
const struct sabc_callbacks *u)
stbroadcast_open(struct stbroadcast_conn *c, uint16_t channel,
const struct stbroadcast_callbacks *u)
{
abc_open(&c->c, channel, &sabc);
broadcast_open(&c->c, channel, &stbroadcast);
c->u = u;
}
/*---------------------------------------------------------------------------*/
void
sabc_close(struct sabc_conn *c)
stbroadcast_close(struct stbroadcast_conn *c)
{
abc_close(&c->c);
broadcast_close(&c->c);
ctimer_stop(&c->t);
}
/*---------------------------------------------------------------------------*/
static void
send(void *ptr)
{
struct sabc_conn *c = ptr;
struct stbroadcast_conn *c = ptr;
/* DEBUGF(3, "sabc: send()\n");*/
/* DEBUGF(3, "stbroadcast: send()\n");*/
queuebuf_to_rimebuf(c->buf);
abc_send(&c->c);
broadcast_send(&c->c);
ctimer_reset(&c->t);
if(c->u->sent != NULL) {
c->u->sent(c);
@ -91,13 +91,13 @@ send(void *ptr)
}
/*---------------------------------------------------------------------------*/
void
sabc_set_timer(struct sabc_conn *c, clock_time_t t)
stbroadcast_set_timer(struct stbroadcast_conn *c, clock_time_t t)
{
ctimer_set(&c->t, t, send, c);
}
/*---------------------------------------------------------------------------*/
int
sabc_send_stubborn(struct sabc_conn *c, clock_time_t t)
stbroadcast_send_stubborn(struct stbroadcast_conn *c, clock_time_t t)
{
if(c->buf != NULL) {
queuebuf_free(c->buf);
@ -107,13 +107,13 @@ sabc_send_stubborn(struct sabc_conn *c, clock_time_t t)
return 0;
}
send(c);
sabc_set_timer(c, t);
stbroadcast_set_timer(c, t);
return 1;
}
/*---------------------------------------------------------------------------*/
void
sabc_cancel(struct sabc_conn *c)
stbroadcast_cancel(struct stbroadcast_conn *c)
{
ctimer_stop(&c->t);
}

View file

@ -4,17 +4,17 @@
*/
/**
* \defgroup rimesabc Stubborn anonymous best-effort local area broadcast
* \defgroup rimestbroadcast Stubborn best-effort local area broadcast
* @{
*
* The sabc module provides stubborn anonymous best-effort local area
* broadcast. A message sent with the sabc module is repeated until
* The stbroadcast module provides stubborn anonymous best-effort local area
* broadcast. A message sent with the stbroadcast module is repeated until
* either the mssage is canceled or a new message is sent. Messages
* sent with the sabc module are not identified with a sender ID.
* sent with the stbroadcast module are not identified with a sender ID.
*
* \section channels Channels
*
* The sabc module uses 1 channel.
* The stbroadcast module uses 1 channel.
*
*/
@ -48,51 +48,51 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sabc.h,v 1.9 2008/06/26 11:19:22 adamdunkels Exp $
* $Id: stbroadcast.h,v 1.1 2008/06/30 08:28:53 adamdunkels Exp $
*/
/**
* \file
* Header file for the Rime module Stubborn Anonymous BroadCast (sabc)
* Header file for the Rime module Stubborn Anonymous BroadCast (stbroadcast)
* \author
* Adam Dunkels <adam@sics.se>
*/
#ifndef __SABC_H__
#define __SABC_H__
#ifndef __STBROADCAST_H__
#define __STBROADCAST_H__
#include "net/rime/abc.h"
#include "net/rime/broadcast.h"
#include "net/rime/ctimer.h"
#include "net/rime/queuebuf.h"
struct sabc_conn;
struct stbroadcast_conn;
struct sabc_callbacks {
void (* recv)(struct sabc_conn *c);
void (* sent)(struct sabc_conn *c);
struct stbroadcast_callbacks {
void (* recv)(struct stbroadcast_conn *c);
void (* sent)(struct stbroadcast_conn *c);
};
/**
* A sabc connection. This is an opaque structure with no user-visible
* fields. The sabc_open() function is used for setting up a sabc
* A stbroadcast connection. This is an opaque structure with no user-visible
* fields. The stbroadcast_open() function is used for setting up a stbroadcast
* connection.
*/
struct sabc_conn {
struct abc_conn c;
struct stbroadcast_conn {
struct broadcast_conn c;
struct ctimer t;
struct queuebuf *buf;
const struct sabc_callbacks *u;
const struct stbroadcast_callbacks *u;
};
/**
* \brief Set up a sabc connection.
* \param c A pointer to a user-supplied struct sabc variable.
* \brief Set up a stbroadcast connection.
* \param c A pointer to a user-supplied struct stbroadcast variable.
* \param channel The Rime channel on which messages should be sent.
* \param u Pointer to the upper layer functions that should be used
* for this connection.
*
* This function sets up a sabc connection on the
* This function sets up a stbroadcast connection on the
* specified channel. No checks are made if the channel is
* currently used by another connection.
*
@ -100,14 +100,14 @@ struct sabc_conn {
* that operates on the connection is called.
*
*/
void sabc_open(struct sabc_conn *c, uint16_t channel,
const struct sabc_callbacks *u);
void sabc_close(struct sabc_conn *c);
void stbroadcast_open(struct stbroadcast_conn *c, uint16_t channel,
const struct stbroadcast_callbacks *u);
void stbroadcast_close(struct stbroadcast_conn *c);
/**
* \brief Send a stubborn message.
* \param c A sabc connection that must have been previously set up
* with sabc_open()
* \param c A stbroadcast connection that must have been previously set up
* with stbroadcast_open()
* \param t The time between message retransmissions.
*
* This function sends a message from the Rime buffer. The
@ -119,35 +119,35 @@ void sabc_close(struct sabc_conn *c);
* message is canceled.
*
*/
int sabc_send_stubborn(struct sabc_conn *c, clock_time_t t);
int stbroadcast_send_stubborn(struct stbroadcast_conn *c, clock_time_t t);
/**
* \brief Cancel the current stubborn message.
* \param c A sabc connection that must have been previously set up
* with sabc_open()
* \param c A stbroadcast connection that must have been previously set up
* with stbroadcast_open()
*
* This function cancels a stubborn message that has
* previously been sent with the sabc_send_stubborn()
* previously been sent with the stbroadcast_send_stubborn()
* function.
*
*/
void sabc_cancel(struct sabc_conn *c);
void stbroadcast_cancel(struct stbroadcast_conn *c);
/**
* \brief Set the retransmission time of the current stubborn message.
* \param c A sabc connection that must have been previously set up
* with sabc_open()
* \param c A stbroadcast connection that must have been previously set up
* with stbroadcast_open()
* \param t The new time between message retransmissions.
*
* This function sets the retransmission timer for the
* current stubborn message to a new value.
*
*/
void sabc_set_timer(struct sabc_conn *c, clock_time_t t);
void stbroadcast_set_timer(struct stbroadcast_conn *c, clock_time_t t);
#endif /* __SABC_H__ */
#endif /* __STBROADCAST_H__ */
/** @} */
/** @} */