summaryrefslogtreecommitdiff
path: root/xbee.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbee.h')
-rw-r--r--xbee.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/xbee.h b/xbee.h
index f99fe55..53f9288 100644
--- a/xbee.h
+++ b/xbee.h
@@ -1,11 +1,11 @@
#ifndef XBEE_H
#define XBEE_H
-void xbee_send(int len, const uint8_t* buf) {
+void xbee_send(uint16_t type, int len, const uint8_t* buf) {
// Start and length.
usart_send(0x7e);
- usart_send(((len + 14) >> 8) & 0xff);
- usart_send((len + 14) & 0xff);
+ usart_send(((len + 16) >> 8) & 0xff);
+ usart_send((len + 16) & 0xff);
// Frame type and ID.
usart_send(0x10);
@@ -28,6 +28,11 @@ void xbee_send(int len, const uint8_t* buf) {
uint8_t chsum = 0x83;
+ usart_send(type & 0xff);
+ chsum -= type & 0xff;
+ usart_send(type >> 8);
+ chsum -= type >> 8;
+
// Payload
for(int i = 0; i < len; i++) {
usart_send(buf[i]);