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
xbee900hp.h
- Committer:
- ottaviano3
- Date:
- 2016-04-27
- Revision:
- 12:7b29ddc34cc1
- Parent:
- 11:9013b28438cb
- Child:
- 13:273adaa03a61
File content as of revision 12:7b29ddc34cc1:
#ifndef XBEE900HP_H #define XBEE900HP_H #include "mbed.h" /** * Wrapper for the xBee 900 HP Module */ class xbee900hp { public: /** * 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); /** * Destructor */ ~xbee900hp(); /** * Subroutine to reset the xBee Module */ void reset(); /** * 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. * 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 success * 1 upon failure */ int setPower(int value); /** * 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 64-bit (0-0xFFFFFFFF) Serial/MAC address of the sending XBee if successful, or 0 if it failed. */ unsigned long long readPacket(char* data); /** * Clear output buffer */ void clearBuff(); /** * 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 xbee_getc(); private: // Setup pin input types. // Reset pin (Pin 5 on XBee) DigitalOut _pin_rst; // Attention Pin (Pin 19 on XBee DigitalIn _pin_attn; // Define SPI connection for the XBee SPI _xbeespi; }; #endif