Net Layer


Data Structures

struct  net_proto
 Net protocol data structure. More...

Defines

#define NET_BUF_FULL   -20
 No space left in the comBuf.
#define NET_PROTO_INVALID   -1
 Not a valid protocol id.
#define NET_PROTO_MAX   3
 Maximum number of protocols.
#define SIMPLE_PROTO_ID   17
#define MST_PROTO_ID   18
#define RTS_PROTO_ID   19
#define DELUGE_PROTO_ID   20
#define CTP_PROTO_ID   0xC4
#define DUTY_CYCLE_UP_TIME   10000
#define DUTY_CYCLE_PERIOD   60000

Typedefs

typedef int8_t(* net_proto_send )(comBuf *pkt, va_list args)
typedef boolean(* net_proto_recv )(comBuf *pkt, uint8_t **footer, uint8_t port)
typedef int8_t(* net_proto_ioctl )(uint8_t request, va_list args)

Functions

void net_init ()
void net_init_duty_cycle (uint32_t recvTimeout)
 Initialize the net layer variables. Use duty cycling.
void setNetRecvTimeout (uint32_t recvTimeout)
 Set receive timeout for duty cycling. The radio will wait for timeout ms to receive a packet upon turning on, before turning off again.
uint32_t getNetRecvTimeout ()
 Get receive timeout for duty cycling.
int8_t net_send (comBuf *pkt, uint8_t proto_id, uint8_t port,...)
 Send an event with the currently selected protocol.
int8_t net_proto_register (uint8_t proto, net_proto_send sfunc, net_proto_recv rfunc, net_proto_ioctl ifunc)
 Register a new protocol to be used with the net layer.
int8_t net_ioctl (uint8_t proto, uint8_t request,...)
 Set some protocol specific options.
boolean is_app_waiting_on (uint8_t port)
comBufnet_recv (uint8_t port)
 net_recv method called by applications
void net_thread ()

Detailed Description

The network layer allows the application to abstract away routing to a lower level. Different routing protocols can be implemented using the net layer, and then used from an application.

Define Documentation

#define DUTY_CYCLE_UP_TIME   10000
 

END PROTOCOL LIST

Definition at line 96 of file net.h.

#define SIMPLE_PROTO_ID   17
 

PROTOCOL LIST

Definition at line 86 of file net.h.


Function Documentation

uint32_t getNetRecvTimeout  ) 
 

Returns:
Receive timeout in ms.

boolean is_app_waiting_on uint8_t  port  ) 
 

For internal use only.

is_app_waiting_on() method called by protocols

Parameters:
port check all waiting threads for the specified port
Returns:
true if it sent the packet to an app, false if it did not.

void net_init  ) 
 

Setup the net layer.

int8_t net_ioctl uint8_t  proto,
uint8_t  request,
  ...
 

Parameters:
proto Protocol
request IO Request
Returns:
NET_PROTO_INVALID if protocol invalid, else return retval

int8_t net_proto_register uint8_t  proto,
net_proto_send  sfunc,
net_proto_recv  rfunc,
net_proto_ioctl  ifunc
 

Parameters:
proto New protocol
sfunc Protocol send function
rfunc Protocol receive function
ifunc Protocol io control function
Returns:
NET_PROTO_INVALID if protocol invalid, -1 if no space left, else return

comBuf* net_recv uint8_t  port  ) 
 

Parameters:
port listening on specified port
Returns:
returns comBuf to application

int8_t net_send comBuf pkt,
uint8_t  proto_id,
uint8_t  port,
  ...
 

Parameters:
event_id Event ID
pkt Packet sent
Returns:
NET_PROTO_INVALID if protocol invalid, else return ret

void net_thread  ) 
 

For internal use only.

A background thread that listens on everything for event traffic.

void setNetRecvTimeout uint32_t  recvTimeout  ) 
 

Parameters:
recvTimeout Receive timeout in ms.


Generated on Mon Nov 23 06:26:00 2009 for MANTIS by  doxygen 1.4.6