Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / colonet / lib / colonet_wireless / colonet_wireless.h @ 175

History | View | Annotate | Download (1.45 KB)

1
/** @file colonet_wireless.h
2
 *
3
 * @brief Wireless library for communicating with colony robots
4
 *
5
 * @author Eugene Marinelli
6
 * @date 10/10/07
7
 */
8

    
9
#ifndef COLONET_WIRELESS_H_
10
#define COLONET_WIRELESS_H_
11

    
12
#include <colonet_defs.h>
13

    
14
typedef int(*MsgHandlerFunction)(unsigned char type, short source, int dest,
15
                                 unsigned char* data, int len);
16

    
17
/** @brief Initializes colonet wireless library
18
 *
19
 * @param wl_port Either SERIAL_PORT or USB_PORT (as defined in COLONET_DEFS)
20
 * @param log_filename Path to log file - outputs all raw data on the network
21
 * If set to NULL, logging is disabled.
22
 * @param msg_handler Function to be called when a packet is received.
23
 * Must take a ColonetPacket as an argument (see defn of MsgHandlerFunction)
24
 *
25
 * @return new ColonetWireless object
26
 */
27
void colonet_wl_init(char* wl_port, MsgHandlerFunction message_handler_,
28
                     char* log_filename_);
29

    
30
/** @brief Spawns a thread which reads data from the hardware interface
31
 * with the colony (either a dongle or a robot programmed to relay data)
32
 * and runs msg_handler when a full packet is received
33
 *
34
 * @return pointer to the thread
35
 */
36
int colonet_wl_run_listener_thread(void);
37

    
38
void colonet_wl_kill_listener_thread(void);
39

    
40
/**
41
 * @brief ...
42
 *
43
 * @return void
44
 */
45
void colonet_wl_send(short client_source, short dest,
46
                     ColonetMessageType msg_type, unsigned char msg_code,
47
                     unsigned char* args);
48

    
49
#endif