![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
Diff: xbee/xbee_rec_route.cpp
- Revision:
- 0:84a3b029656e
- Child:
- 1:3a46d2725374
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xbee/xbee_rec_route.cpp Sat Apr 14 03:53:45 2012 +0000 @@ -0,0 +1,104 @@ +#include "xbee_rec_route.h" +#include "config.h" +#include "XBee.h" + +#include "types.h" + +#include "xbee_lib.h" +#include "tcp_client.h" +#include "leds.h" + +extern XBee xbee; +extern ZBRxResponse zbRx; + + +void xbeeRecieveRouting(void) +{ + + xbeeReadPacket(); + + + if (isXbeeAvaiable()) { + + + + DBGF("xbee aviable!\r\n"); + + if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) { + + ledXBeeRx(); + + xbee.getResponse().getZBRxResponse(zbRx); + + Payload payload; + + uint16_t length = (unsigned char)zbRx.getData()[0]; + length =(length<<8) + (unsigned char)zbRx.getData()[1]; + + DBGV("length=%04X\r\n",length); + + memcpy(&payload, (unsigned char *)zbRx.getData(), length); + + + + networkToPayload(&payload); + + routing(&payload); + /* + pc.printf("xbee recieve!! size:%d\r\n",length); + + pc.printf("---------dump end\r\n"); + */ + + + + } + // pc.printf("\r\n"); + } + + +} + +void routing(Payload *_payload) +{ +// dumpPayload(_payload); + switch(_payload->frame.message.command) + { + case SEND_SINGLE: + { + // _payload->frame.message.command=ACK; + // xbeeSend(0x4086B0D5,_payload); + DBGF("******* send! *******\r\n"); + } + break; + + case RECIEVE: + { + udpSendPayload(_payload); + DBGF("****** recieve! *******\r\n"); + } + break; + + case PING: + { + + udpSendPayload(_payload); + DBGF("******* ping! **************\r\n"); + } + break; + + case ACK: + { + udpSendPayload(_payload); + DBGF("******* ACK! **************\r\n"); + } + + case SET_TX_GAIN: + case SET_LIGHT_CONTROL: + { + udpSendPayload(_payload); + } + break; + } + +}