X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=xbee_user.h;fp=xbee_user.h;h=ced53630cc5429f38e2c4ce7ea6cb076ce26a72e;hp=0000000000000000000000000000000000000000;hb=c17da94fafe8e0fa1a467f0c8fb7922fec8386e5;hpb=58822b8f01bbc479c273d2c440e6415c754cba9e diff --git a/xbee_user.h b/xbee_user.h new file mode 100644 index 0000000..ced5363 --- /dev/null +++ b/xbee_user.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Olivier MATZ + * All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the University of California, Berkeley nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _XBEE_USER_H_ +#define _XBEE_USER_H_ + +#include + +/* used for timeouts and xbee rx callback */ +struct xbee_ctx { + int foreground; + int channel; + char atcmd_query[2]; + int (*func)(void *frame, unsigned len, void *arg); + void *arg; + struct callout timeout; +}; + +//extern cmdline_parse_ctx_t main_ctx; +extern struct xbee_dev *xbee_dev; +extern int xbee_raw; +extern int xbee_hexdump; +extern int xbee_debug; + +int8_t xbeeapp_rx(struct xbee_dev *dev, int channel, int type, + void *frame, unsigned len, void *opaque); +int xbeeapp_send_atcmd(const char *atcmd_str, + void *param, unsigned param_len, int foreground, + int (*func)(void *frame, unsigned len, void *arg), + void *arg); +int xbeeapp_send_msg(uint64_t addr, void *data, + unsigned data_len, int foreground); + +void xbee_stdin_enable(void); +void xbee_stdin_disable(void); + +void xbee_load_timeout(struct xbee_ctx *ctx); +void xbee_unload_timeout(struct xbee_ctx *ctx); + +void xbee_mainloop(void); + +#endif /* _XBEE_USER_H_ */