This is an experimental driver for the XBee 900 HP pro module's SPI connection. This driver is unfinished and stability is not guaranteed. Use with caution.
Dependents: Sentinel_BASE Sentinel_NODE
Diff: xbee900hp.h
- Revision:
- 9:d4542525b218
- Parent:
- 7:3cb67634fa4e
- Child:
- 10:f559e7af4fe6
--- a/xbee900hp.h Wed Apr 27 01:19:54 2016 +0000 +++ b/xbee900hp.h Wed Apr 27 04:40:55 2016 +0000 @@ -12,6 +12,13 @@ /** * Initialize the xBee Module + * + * pin_mosi -> mbed SPI MOSI pin + * pin_miso -> mbed SPI MISO pin + * pin_sck -> mbed SPI SCK pin + * pin_attn -> Signals that some message from the XBee module is available + * pin_rst -> Resets the XBee module + * freq -> sets the SPI clock frequency. The XBee has a maximum SPI clock rate of 3.5 MHz. */ xbee900hp(PinName pin_mosi,PinName pin_miso,PinName pin_sck,PinName pin_attn, PinName pin_rst, unsigned int freq); @@ -27,27 +34,45 @@ /** * Send packet over spi to xBee for TX + * + * data -> char array of the message to be sent wirelessly. + * length -> then length of the char array excluding any null termination. + * enMesh -> true enables DigiMesh. + * + * Returns 0 upon successful completion, else returns 1. */ int sendPacket(char* data, unsigned int length, bool enMesh); /** * Get signal strength of last recieved packet + * + * Returns RSSI in -dBm units (0x00-0xFF), else returns 1 indicating failure. */ unsigned int getRSSI(); /** - * Set the transmission power level + * Set the transmission power level. + * 0 = +7 dBm, (5 mW) + * 1 = +15 dBm, (32 mW) + * 2 = +18 dBm, (63 mW) + * 3 = +21 dBm, (125 mW) + * 4 = +24 dBm, (250 mW) + * + * Returns 0 upon successful completion, else returns 1. */ int setPower(int value); /** - * Get serial number of xbee module + * Get serial number of XBee module + * + * Returns the XBee's unique 64-bit (0-0xFFFFFFFF) Serial/MAC address, else returns 1. */ unsigned long long getSerial(); /** * Wait for and read incoming data packet - * Returns the source address if successful, or 0 if it failed. + * + * Returns the 64-bit (0-0xFFFFFFFF) Serial/MAC address of the sending XBee if successful, or 0 if it failed. */ unsigned long long readPacket(char* data); @@ -58,25 +83,29 @@ /** * Check ATTN signal + * + * Returns the state of the ATTN pin. + * NOTE: This pin is inverse logic. (i.e. 0 = message waiting, 1 = no messages availiable) */ int attn(); /** * Read raw data in from module + * + * Returns a single char from the XBee. + * NOTE: Check the status of the XBee's ATTN pin to see if data is available first. */ - char debug(); + char xbee_getc(); private: // Setup pin input types. - // Reset + // Reset pin (Pin 5 on XBee) DigitalOut _pin_rst; - // Asert Pin Use Interrupts for Super Speed + // Attention Pin (Pin 19 on XBee DigitalIn _pin_attn; - void readDataISR(); - - // SPI + // Define SPI connection for the XBee SPI _xbeespi; };