2 * Copyright (c) 2011, Olivier MATZ <zer0@droids-corp.org>
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the University of California, Berkeley nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef _XBEE_PROTO_H_
29 #define _XBEE_PROTO_H_
31 /* protocol headers */
33 #define XBEE_DELIMITER 0x7E
34 #define XBEE_MAX_FRAME_LEN 0x40
41 } __attribute__((packed));
43 #define XBEE_TYPE_ATCMD 0x08
44 struct xbee_atcmd_hdr {
47 } __attribute__((packed));
49 #define XBEE_TYPE_ATCMD_Q 0x09
50 struct xbee_atcmd_q_hdr {
53 } __attribute__((packed));
55 #define XBEE_TYPE_XMIT 0x10
56 struct xbee_xmit_hdr {
62 } __attribute__((packed));
64 #define XBEE_TYPE_EXPL_XMIT 0x11
65 struct xbee_expl_xmit_hdr {
75 } __attribute__((packed));
77 #define XBEE_TYPE_RMT_ATCMD 0x17
78 struct xbee_rmt_atcmd_hdr {
84 } __attribute__((packed));
86 #define XBEE_TYPE_ATRESP 0x88
87 struct xbee_atresp_hdr {
91 } __attribute__((packed));
93 #define XBEE_TYPE_MODEM_STATUS 0x8A
94 struct xbee_modem_status_hdr {
96 } __attribute__((packed));
98 #define XBEE_TYPE_XMIT_STATUS 0x8B
99 struct xbee_xmit_status_hdr {
101 uint8_t xmit_retry_cnt;
102 uint8_t delivery_status;
103 uint8_t discovery_status;
104 } __attribute__((packed));
106 #define XBEE_TYPE_RECV 0x90
107 struct xbee_recv_hdr {
112 } __attribute__((packed));
114 #define XBEE_TYPE_EXPL_RECV 0x91
115 struct xbee_expl_recv_hdr {
118 uint8_t src_endpoint;
119 uint8_t dst_endpoint;
124 } __attribute__((packed));
126 #define XBEE_TYPE_NODE_ID 0x95
127 struct xbee_node_id_hdr {
134 /* uint16_t parentaddr; after variable field */
135 } __attribute__((packed));
137 #define XBEE_TYPE_RMT_ATRESP 0x97
138 struct xbee_rmt_atresp_hdr {
144 } __attribute__((packed));
148 /* return negative on error, 0 if there is not frame, or framelen */
149 int xbee_proto_get_frame(struct xbee_dev *dev, void *buf, unsigned len);
152 int xbee_proto_xmit(struct xbee_dev *dev, uint8_t id, uint8_t type,
153 void *buf, unsigned len);
155 void xbee_proto_rx(struct xbee_dev *dev);
157 #endif /* _XBEE_PROTO_H_ */