XBee API mode library
Diff: XBee.h
- Revision:
- 8:776b8dc51932
- Parent:
- 7:19f03567ec4e
- Child:
- 10:3da24a020e67
diff -r 19f03567ec4e -r 776b8dc51932 XBee.h --- a/XBee.h Fri Jan 25 02:26:14 2013 +0000 +++ b/XBee.h Tue Jan 29 13:46:41 2013 +0000 @@ -1,5 +1,5 @@ /* -Copyright (c) 2011, Senio Networks, Inc. +Copyright (c) 2013, Senio Networks, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,13 @@ #ifndef XBEE_H #define XBEE_H +#define XBEE_RTOS + +#ifdef XBEE_RTOS +#include "rtos.h" +#include "ThreadBase.h" +#include "RingBuffer.h" +#endif #include "mbed.h" #include "XBeeDataTypes.h" @@ -37,7 +44,11 @@ /** * class for XBee module API mode interface */ +#ifndef XBEE_RTOS class XBee : public Serial { +#else +class XBee : public Serial, ThreadBase { +#endif public: /** @@ -195,7 +206,6 @@ RawData }; - /** * creates an XBee interface object. * @@ -203,7 +213,7 @@ * @param apiMode API mode either 1 or 2 (use escape; default) * @param debug display debugging (I/O state) information through LEDs */ - XBee(Serial& ser, int apiMode = 2, bool debug = false); + XBee(Serial& ser, int apiMode = 2, bool debug = true); /** * creates an XBee interface object. @@ -213,7 +223,7 @@ * @param apiMode API mode either 1 or 2 (use escape; default) * @param debug display debugging (I/O state) information through LEDs */ - XBee(PinName tx, PinName rx, int apiMode = 2, bool debug = false); + XBee(PinName tx, PinName rx, int apiMode = 2, bool debug = true); /** * creates an XBee interface object. @@ -223,7 +233,7 @@ * @param apiMode API mode either 1 or 2 (use escape; default) * @param debug display debugging (I/O state) information through LEDs */ - XBee(Serial& ser, Serial& mon, int apiMode = 2, bool debug = false); + XBee(Serial& ser, Serial& mon, int apiMode = 2, bool debug = true); /** * creates an XBee interface object. @@ -234,7 +244,7 @@ * @param apiMode API mode either 1 or 2 (use escape; default) * @param debug display debugging (I/O state) information through LEDs */ - XBee(PinName tx, PinName rx, Serial& mon, int apiMode = 2, bool debug = false); + XBee(PinName tx, PinName rx, Serial& mon, int apiMode = 2, bool debug = true); /** * initializes XBee module. @@ -480,8 +490,11 @@ char destination64[8]; char destination16[2]; char buf[BUFSIZE]; + RingBuffer<char, 32> rxBuf; bool debug; - +#ifdef XBEE_RTOS + Mutex mutex; +#endif void send(char c); void send2(char c); void sendFrame(const char *frame, int length); @@ -492,9 +505,12 @@ FrameType getFrameType(char c); bool scan(int i, ValueType type, char *value, int maxlength = 1, int *length = 0); void flush(); +#ifndef XBEE_RTOS void rxInterruptHandler(); - void rxInterruptHandler2(); - +#else + void rxISR(); + virtual void run(); +#endif void dump(const char *data, int length); void dumpIOSample(const char *data, int length); void copy(char *toBuf, int fromIndex, int length);