![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
Diff: xbee/xbee_lib.cpp
- Revision:
- 0:84a3b029656e
- Child:
- 1:3a46d2725374
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xbee/xbee_lib.cpp Sat Apr 14 03:53:45 2012 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "types.h" +#include "config.h" +#include "XBee.h" +#include "xbee_lib.h" + +#include "leds.h" +extern Serial pc; + +XBee xbee(p13, p14); +ZBRxResponse zbRx = ZBRxResponse(); + +extern PrefServer pref; + +void xbeeInit(void) +{ + LPC_UART1->MCR |= (1<<7); // CTSEN + LPC_PINCON->PINSEL1 &= ~(3 << 2); + LPC_PINCON->PINSEL1 |= (1 << 2); // UART CTS + xbee.begin(kXBeeBoudRate); + pref.xbeeAdress = kMyXBeeAddress; + pc.printf("XBee setup OK! XBee serial boudrate:%d address:%04X\r\n",kXBeeBoudRate,pref.xbeeAdress); +} + +void xbeeSend(uint32_t addr , Payload *_payload) +{ + ledXBeeTx(); + + XBeeAddress64 deviceAdr = XBeeAddress64(0x0013a200, addr); + + uint16_t length = sizeof(Payload); + _payload->size = length; + uint8_t tmp[length]; + + memcpy(tmp , (uint8_t*)_payload , length); + + payloadToNetwork((Payload*)tmp); + ZBTxRequest zbTx = ZBTxRequest(deviceAdr , tmp , length ); + + xbee.send(zbTx); + DBGF("+++++ xbee send!!\r\n"); + + +} + +void xbeeReadPacket(void) +{ + xbee.readPacket(); +} +bool isXbeeAvaiable(void) +{ + return xbee.getResponse().isAvailable(); +} \ No newline at end of file