Project

General

Profile

Statistics
| Revision:

root / demos / joystick / lib / src / libwireless / wl_basic.h @ 1736

History | View | Annotate | Download (2.03 KB)

1 1379 cmar
/**
2
 * @file wl_basic.h
3
 * @brief High Level Wireless Packet Sending-Receiving Functions
4
 *
5
 * Abstracted wireless functionality for sending and receiving packets
6
 *
7 1380 cmar
 * @author Christopher Mar, Colony Project, CMU Robotics Club
8 1379 cmar
 **/
9
10 1380 cmar
/**
11
 * @defgroup wl_basic Wireless Basic
12
 * @brief Wireless abstraction for easily sending and receing packets.
13
 *
14
 * A high level abstraction of the wireless library.
15
 *
16
 * This will allow you to easily send and receive packets.
17
 *
18
 * @{
19
 **/
20 1379 cmar
21 1380 cmar
#ifndef WL_BASIC_H
22
#define WL_BASIC_H
23
24 1440 alevkoy
#include "wireless.h"
25 1379 cmar
26 1425 cmar
/** @brief default wireless group for basic sending and receiving packets **/
27 1379 cmar
#define WL_BASIC_GROUP 8
28
29
/** @brief PacketGroupHandler struct for Basic Group **/
30
PacketGroupHandler wl_basic_group_handler;
31
32 1425 cmar
/**
33
 * @brief struct that contains relevant packet information
34
 **/
35 1396 cmar
struct PacketInfo {
36
    char new_flag;
37
    char type;
38
    int source;
39 1425 cmar
    unsigned char* data;
40 1396 cmar
    int length;
41
};
42
43
/**
44
 * @brief current packet information, correct after wl_basic_do()
45
 **/
46
struct PacketInfo current_packet;
47
48 1425 cmar
/** @brief init wireless for Basic Group **/
49
int wl_basic_init( void (*handle_receive) (char type, int source, unsigned char* packet, int length) );
50
/** @brief init wireless for Basic Group with default packet handling **/
51
int wl_basic_init_default( void );
52
/** @brief internal function to register a packet handler function **/
53
void wl_basic_register_handler( void (*handle_receive) (char type, int source, unsigned char* packet, int length) );
54
/** @brief send a packet to a single robot in Basic Group **/
55
void wl_basic_send_robot_packet( char type, char* data, int len, int dest );
56
/** @brief send a packet to all robots in Basic Group **/
57
void wl_basic_send_global_packet( char type, char* data, int len );
58
/** @brief internal default packet handler if none is specified on init **/
59
void wl_basic_packet_receive_handler( char type, int source, unsigned char* packet, int length );
60
/** @brief wrapper for wl_do() to return packet data buffer **/
61 1427 cmar
unsigned char* wl_basic_do_default( int *length );
62 1380 cmar
/** @} **/ // end defgroup
63
64
#endif