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 /* protocol headers */
30 #define XBEE_DELIMITER 0x7E
31 #define XBEE_MAX_FRAME_LEN 0x40
38 } __attribute__((packed));
40 #define XBEE_TYPE_ATCMD 0x08
41 struct xbee_atcmd_hdr {
44 } __attribute__((packed));
46 #define XBEE_TYPE_ATCMD_Q 0x09
47 struct xbee_atcmd_q_hdr {
50 } __attribute__((packed));
52 #define XBEE_TYPE_XMIT 0x10
53 struct xbee_xmit_hdr {
59 } __attribute__((packed));
61 #define XBEE_TYPE_EXPL_XMIT 0x11
62 struct xbee_expl_xmit_hdr {
72 } __attribute__((packed));
74 #define XBEE_TYPE_RMT_ATCMD 0x17
75 struct xbee_rmt_atcmd_hdr {
81 } __attribute__((packed));
83 #define XBEE_TYPE_ATRESP 0x88
84 struct xbee_atresp_hdr {
88 } __attribute__((packed));
90 #define XBEE_TYPE_MODEM_STATUS 0x8A
91 struct xbee_modem_status_hdr {
93 } __attribute__((packed));
95 #define XBEE_TYPE_XMIT_STATUS 0x8B
96 struct xbee_xmit_status_hdr {
98 uint8_t xmit_retry_cnt;
99 uint8_t delivery_status;
100 uint8_t discovery_status;
101 } __attribute__((packed));
103 #define XBEE_TYPE_RECV 0x90
104 struct xbee_recv_hdr {
109 } __attribute__((packed));
111 #define XBEE_TYPE_EXPL_RECV 0x91
112 struct xbee_expl_recv_hdr {
115 uint8_t src_endpoint;
116 uint8_t dst_endpoint;
121 } __attribute__((packed));
123 #define XBEE_TYPE_NODE_ID 0x95
124 struct xbee_node_id_hdr {
131 /* uint16_t parentaddr; after variable field */
132 } __attribute__((packed));
134 #define XBEE_TYPE_RMT_ATRESP 0x97
135 struct xbee_rmt_atresp_hdr {
141 } __attribute__((packed));
145 /* return negative on error, 0 if there is not frame, or framelen */
146 int xbee_proto_get_frame(struct xbee_dev *dev, void *buf, unsigned len);
149 int xbee_proto_xmit(struct xbee_dev *dev, uint8_t id, uint8_t type,
150 void *buf, unsigned len);
152 void xbee_proto_rx(struct xbee_dev *dev);