![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
UDPversion
Dependencies: XBee mbed NetServicesMin
xbee/xbee_lib.cpp
- Committer:
- recotana
- Date:
- 2012-04-14
- Revision:
- 0:84a3b029656e
- Child:
- 1:3a46d2725374
File content as of revision 0:84a3b029656e:
#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(); }