diff options
Diffstat (limited to 'xbee.h')
-rw-r--r-- | xbee.h | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -0,0 +1,40 @@ +#ifndef XBEE_H +#define XBEE_H + +void xbee_send(int len, const uint8_t* buf) { + // Start and length. + usart_send(0x7e); + usart_send(((len + 14) >> 8) & 0xff); + usart_send((len + 14) & 0xff); + + // Frame type and ID. + usart_send(0x10); + usart_send(0x01); + + // Destination address. + usart_send(0x00); + usart_send(0x13); + usart_send(0xa2); + usart_send(0x00); + usart_send(0x40); + usart_send(0x6f); + usart_send(0x19); + usart_send(0xf1); + + usart_send(0x00); + usart_send(0x00); + usart_send(0x00); + usart_send(0x00); + + uint8_t chsum = 0x80; + + // Payload + for(int i = 0; i < len; i++) { + usart_send(buf[i]); + chsum -= buf[i]; + } + + usart_send(chsum); +} + +#endif |