Revision 363
Add battery stuff to charging station
wl_charging_station.c | ||
---|---|---|
45 | 45 |
void wl_charging_send_cancel(int dest); |
46 | 46 |
void wl_charging_send_seeking(int dest); |
47 | 47 |
void wl_charging_send_docked(int dest); |
48 |
void wl_charging_send_battery(int dest); |
|
48 | 49 |
|
49 | 50 |
// the handler |
50 | 51 |
PacketGroupHandler wl_charging_handler = |
... | ... | |
60 | 61 |
#define CANCEL_FRAME 4 |
61 | 62 |
#define SEEKING_FRAME 5 |
62 | 63 |
#define DOCKED_FRAME 6 |
64 |
#define BATTERY_FRAME 7 |
|
63 | 65 |
|
64 | 66 |
/** |
65 | 67 |
* Register this packet group with the wireless library. |
... | ... | |
159 | 161 |
} |
160 | 162 |
|
161 | 163 |
/** |
164 |
* Sends a packet to request for the robot's battery reading |
|
165 |
* |
|
166 |
* @param dest the robot to request |
|
167 |
**/ |
|
168 |
void wl_charging_send_battery(int dest) |
|
169 |
{ |
|
170 |
wl_send_robot_to_robot_global_packet(WL_RECHARGE_GROUP, WL_RECHARGE_BATTERY, NULL, 0, dest, BATTERY_FRAME); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
162 | 174 |
* Called when this packet is unregistered with the wireless library. |
163 | 175 |
**/ |
164 | 176 |
void wl_charging_cleanup(void) |
... | ... | |
268 | 280 |
case WL_RECHARGE_DOCKED: |
269 | 281 |
wl_charging_docked(source); |
270 | 282 |
break; |
283 |
case WL_RECHARGE_BATTERY: |
|
284 |
wl_charging_battery(source,packet,length); |
|
271 | 285 |
default: |
272 | 286 |
STATION_DEBUG_PRINT("Error packet of unknown type received.\n"); |
273 | 287 |
break; |
... | ... | |
284 | 298 |
{ |
285 | 299 |
if (charging_is_space_available() && !charging_is_robot_seeking()) |
286 | 300 |
wl_charging_send_station_available(source); |
301 |
wl_charging_send_battery(source); |
|
287 | 302 |
} |
288 | 303 |
|
289 | 304 |
/** |
... | ... | |
424 | 439 |
charging_dock(source); |
425 | 440 |
} |
426 | 441 |
|
442 |
/** |
|
443 |
* Called when we recieve a packet with a battery reading |
|
444 |
* |
|
445 |
* @param source the robot that is sending the battery reading |
|
446 |
**/ |
|
447 |
void wl_charging_battery(int source, unsigned char* packet, int length) |
|
448 |
{ |
|
449 |
if (charging_get_robot_state(source)==STATE_NOT_CHARGING) |
|
450 |
check_battery(source, (int)packet[0]); |
|
451 |
else |
|
452 |
update_battery(source, (int)packet[0]); |
|
453 |
} |
Also available in: Unified diff