Project

General

Profile

Revision 1608

wl updates: compile issues

View differences:

branches/wireless/code/projects/libwireless/wireless.h
99 99

  
100 100
// TODO: this max may be too big b/c the packet handler array stores 3*MAX_PACKET_GROUPS bytes 
101 101
/**@brief maximum number of packet groups, size of handler array **/
102
#define MAX_PACKET_GROUPS UINT8_C(255)
102
#define MAX_PACKET_GROUPS UINT8_C(16)
103 103

  
104 104
/**@brief init_flag when library has not been initialized **/
105 105
#define INIT_NO UINT8_C(0)
......
145 145
// the send functions
146 146

  
147 147
/**@brief The core send function. This will take all possible arguments and send all types of packets. **/
148
int8_t wl_send(char *data, uint8_t length, uint8_t group, uint8_t scope, uint8_t dest, uint8_t mode);
148
int16_t wl_send(uint8_t *data, uint8_t length, uint8_t group, uint8_t scope, uint16_t dest, uint8_t mode);
149 149

  
150 150
/**@brief Wrapper for core send function that will send a global packet across the current channel. **/
151
int8_t wl_send_global(char *data, uint8_t length, uint8_t group);
151
int16_t wl_send_global(char *data, uint8_t length, uint8_t group);
152 152

  
153 153
/**@brief Wrapper for core send function that will send a packet across the current channel on the current pan. **/
154
int8_t wl_send_pan(char *data, uint8_t length, uint8_t group);
154
int16_t wl_send_pan(char *data, uint8_t length, uint8_t group);
155 155

  
156 156
/**@brief Wrapper for core send function that will send a packet across the current channel to a specific robot. **/
157
int8_t wl_send_robot(char *data, uint8_t length, uint8_t group, uint8_t dest, uint8_t mode);
157
int16_t wl_send_robot(char *data, uint8_t length, uint8_t group, uint8_t dest, uint8_t mode);
158 158

  
159 159
/**@brief Default (i.e. basic) send wrapper. **/
160
int8_t wl_send_basic(char *data, uint8_t length);
160
int16_t wl_send_basic(char *data, uint8_t length);
161 161

  
162 162

  
163 163
// the ack function
branches/wireless/code/projects/libwireless/wireless_send.c
35 35

  
36 36
#include "wl_defs.h"
37 37
#include "wireless.h"
38
#include "xbee.h"
38 39
#include <string.h>
39 40

  
40 41

  
......
64 65
/* private function prototypes */
65 66
void setack(uint8_t num,uint8_t val);
66 67
void ackhandle(uint8_t num,uint8_t val);
67
int8_t send_buf_add(uint8_t *ptr, uint8_t byte)
68
int8_t send_buf_add(uint8_t *ptr, uint8_t byte);
68 69
uint8_t send_buf_get(uint8_t *ptr);
69 70

  
70 71
// the send functions
......
145 146
  // save in ack system
146 147
  if (mode == FAST) {
147 148
    setack(nextframe,ACK_OK); // assume the send was successful
149
    nextframe = (nextframe == 0xFF)?1:nextframe+1; // increment frame number
150
    return WL_SUCCESS; // no frame number
148 151
  } else if (mode == RELIABLE) {
149 152
    setack(nextframe,SENDING); // set status to SENDING
150 153
    // save packet on sending buffer
......
171 174
    }
172 175
    send_buf_last = scope;
173 176
    send_buf_num_packets++;
177
    
178
    nextframe = (nextframe == 0xFF)?1:nextframe+1; // increment frame number
179
    return packet[0]; // return frame number for ack tracking
174 180
  }
175
  
176
  // increment frame number
177
  nextframe = (nextframe == 0xFF)?1:nextframe+1;
178

  
179
  return ret_val; // return frame number for ack tracking
180 181
}
181 182

  
182 183
/**
......
189 190
 * @return positive packet number for tracking acks, or error code (TBD)
190 191
 **/
191 192
int16_t wl_send_global(char *data, uint8_t length, uint8_t group) {
192
  return wl_send(*data, length, group, PAN, 0, RELIABLE);
193
  return wl_send(data, length, group, GLOBAL, BROADCAST, RELIABLE);
193 194
}
194 195

  
195 196
/**
......
202 203
 * @return positive packet number for tracking acks, or error code (TBD)
203 204
 **/
204 205
int16_t wl_send_pan(char *data, uint8_t length, uint8_t group) {
205
  return wl_send(*data, length, group, PAN, 0, RELIABLE);
206
  return wl_send(data, length, group, PAN, BROADCAST, RELIABLE);
206 207
}
207 208

  
208 209
/**
......
217 218
 * @return positive packet number for tracking acks, or error code (TBD)
218 219
 **/
219 220
int16_t wl_send_robot(char *data, uint8_t length, uint8_t group, uint16_t dest, uint8_t mode) {
220
  return wl_send(*data, length, group, GLOBAL, dest, mode);
221
  return wl_send(data, length, group, GLOBAL, dest, mode);
221 222
}
222 223

  
223 224
/**
......
230 231
 **/
231 232
int16_t wl_send_basic(char *data, uint8_t length) {
232 233
/** Check if it needs to adjust according to data type. **/
233
  return wl_send(*data, length, BASIC, GLOBAL, 0, RELIABLE);
234
  return wl_send(*data, length, BASIC, GLOBAL, BROADCAST, RELIABLE);
234 235
}
235 236

  
236 237

  
branches/wireless/code/projects/libwireless/wireless.c
67 67
    memset(wl_packet_handlers, sizeof(PacketGroupHandler)*MAX_PACKET_GROUPS, 0);
68 68

  
69 69
    // initialize xbee
70
    if(xbee_lib_init() == -1) {
70
    if(xbee_init() == -1) {
71 71
        return WL_ERROR_INIT_FAILED;
72 72
    }
73 73
    
......
94 94
    memset(wl_packet_handlers, sizeof(PacketGroupHandler)*MAX_PACKET_GROUPS, 0);
95 95

  
96 96
    if(xbee_terminate() != WL_SUCCESS) {
97
        return WL_ERROR_TERMINATION_FAILED
97
        return WL_ERROR_TERMINATION_FAILED;
98 98
    }
99 99

  
100 100
    return WL_SUCCESS;

Also available in: Unified diff