Project

General

Profile

Revision 743

Fixed compilation errors.

View differences:

wireless.h
1 1
/**
2 2
 * Copyright (c) 2007 Colony Project
3
 * 
3
 *
4 4
 * Permission is hereby granted, free of charge, to any person
5 5
 * obtaining a copy of this software and associated documentation
6 6
 * files (the "Software"), to deal in the Software without
......
9 9
 * copies of the Software, and to permit persons to whom the
10 10
 * Software is furnished to do so, subject to the following
11 11
 * conditions:
12
 * 
12
 *
13 13
 * The above copyright notice and this permission notice shall be
14 14
 * included in all copies or substantial portions of the Software.
15
 * 
15
 *
16 16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
......
34 34

  
35 35
#ifndef WIRELESS_H
36 36
#define WIRELESS_H
37
 
37

  
38 38
//Note: If this is raised above 16, we will need to do
39 39
//something about frame numbers for TX Status packets.
40 40
/**
41 41
 * The maximum number of packet groups.
42 42
 **/
43
//TODO: a PacketGroupHandler is at least 10 bytes (I don't know if function pointers are 2 bytes
44
// or 4 bytes).  That means that in the c file, your array of packet groups is at least 160 bytes.
45
// Normally that might be fine (the robot's avr chips have 4k SRAM), but austin's chip only has
46
// 1k SRAM, so if this number can be reduced or if the size of the struct could be reduced, that would be a plus.
43 47
#define WL_MAX_PACKET_GROUPS 16
44 48

  
45 49
/**
......
48 52
 *
49 53
 * Contains functions and definitions for dealing with wireless functionality.<br><br>
50 54
 *
51
 * The wireless library provides a modular method for dealing with 
55
 * The wireless library provides a modular method for dealing with
52 56
 * wireless packets, by allowing packet groups to be registered.
53 57
 * A packet group is a collection of packets which share a packet
54
 * group code. Each packet in the group also has a type. A packet 
58
 * group code. Each packet in the group also has a type. A packet
55 59
 * group code and type are sent with each packet. When a packet
56
 * with a group code registered in the wireless library is 
60
 * with a group code registered in the wireless library is
57 61
 * received, the corresponding event handler is called. The
58 62
 * event handler uses the packet type and other information
59 63
 * stored in the packet to respond.<br><br>
......
67 71

  
68 72
/**
69 73
 * @struct PacketGroupHandler
70
 * A PacketGroupHandler represents a packet group, and is used to 
74
 * A PacketGroupHandler represents a packet group, and is used to
71 75
 * register a packet group with the wireless library. It contains
72 76
 * handlers for various events which can occur related to a packet
73 77
 * group.
74 78
 **/
79
//TODO: the order of member variables in this struct should be changed in case the compile packs the struct
80
// In order to achieve the best packing, the variables should be listed in order of decreasing memory size.
81
// Thus, pointers should be first, followed by int, followed by char.
75 82
typedef struct
76 83
{
77 84
	/**
......
79 86
	 * must be unique. The maximum number of packet groups
80 87
	 * is defined by WL_MAX_PACKET_GROUPS.
81 88
	 **/
89
  //TODO: if this number must be less than or equal to WL_MAX_PACKET_GROUPS, don't you only need
90
  // one byte for it and it can be made an unsigned char?
82 91
	unsigned int groupCode;
83 92

  
84 93
	/**
......
86 95
	 * but in wl_do).
87 96
	 **/
88 97
	void (*timeout_handler) (void);
89
	
98

  
90 99
	/**
91 100
	 * Called when a transmit status packet is received
92 101
	 * from the XBee where the first four bits of the frame
......
97 106
	 * we did not.
98 107
	 **/
99 108
	void (*handle_response) (int frame, int received);
100
	
109

  
101 110
	/**
102 111
	 * Called when we receive a packet from this group.
103 112
	 *
......
107 116
	 * @param packet the packet received
108 117
	 * @param length the length of the packet
109 118
	 **/
110
	void (*handle_receive) (char type, int source, unsigned char* packet,
111
							int length);
112
	
119
	void (*handle_receive) (char type, int source, unsigned char* packet, int length);
120

  
113 121
	/**
114 122
	 * Called for any cleanup when the network is turned off.
115 123
	 **/
116 124
	void (*unregister) (void);
117
	
125

  
118 126
} PacketGroupHandler;
119 127

  
120 128
/**@brief Initialize the wireless library **/
......
129 137
void wl_unregister_packet_group(PacketGroupHandler* h);
130 138

  
131 139
/**@brief Send a packet to a specific robot in any PAN **/
132
void wl_send_robot_to_robot_global_packet(char group, char type,
133
		char* data, int len, int dest, char frame);
140
int wl_send_robot_to_robot_global_packet(char group, char type, char* data, int len, int dest, char frame);
134 141
/**@brief Send a packet to a specific robot in our PAN **/
135
void wl_send_robot_to_robot_packet(char group, char type,
136
		char* data, int len, int dest, char frame);
142
int wl_send_robot_to_robot_packet(char group, char type, char* data, int len, int dest, char frame);
137 143
/**@brief Send a packet to all robots **/
138
void wl_send_global_packet(char group, char type,
139
		char* data, int len, char frame);
144
int wl_send_global_packet(char group, char type, char* data, int len, char frame);
140 145
/**@brief Send a packet to all robots in our PAN **/
141
void wl_send_pan_packet(char group, char type,
142
		char* data, int len, char frame);
146
void wl_send_pan_packet(char group, char type, char* data, int len, char frame);
143 147

  
144 148
/**@brief Set the PAN we are using **/
145
void wl_set_pan(int pan);
149
int wl_set_pan(int pan);
146 150
/**@brief Get the PAN we are using **/
147 151
int wl_get_pan(void);
148 152
/**@brief Set the channel we are using **/
149
void wl_set_channel(int channel);
153
int wl_set_channel(int channel);
150 154
/**@brief Get the channel we are using **/
151 155
int wl_get_channel(void);
152 156
/**@brief Get the 16-bit address of the XBee module **/

Also available in: Unified diff