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.cpp
- Revision:
- 9:d4542525b218
- Parent:
- 8:fa84dacc45b9
--- a/xbee900hp.cpp Wed Apr 27 01:19:54 2016 +0000 +++ b/xbee900hp.cpp Wed Apr 27 04:40:55 2016 +0000 @@ -13,15 +13,8 @@ // Xbee is up and running! } - -/** -* Destructor -*/ xbee900hp::~xbee900hp() {} -/** -* Reset xBee to SPI mode -*/ void xbee900hp::reset() { _pin_rst = 0; @@ -52,10 +45,6 @@ } } - -/** -* Send packet out on RF -*/ int xbee900hp::sendPacket(char* data, unsigned int length, bool enMesh) { // checksum unsigned int checksum; @@ -131,10 +120,6 @@ return 0; } - -/** -* Wait for and read incoming data packet -*/ unsigned long long xbee900hp::readPacket(char* data) { unsigned long long temp1; unsigned int temp2; @@ -218,17 +203,10 @@ return srcAddr; } - -/** -* Check ATTN signal -*/ int xbee900hp::attn() { return _pin_attn; } -/** -* Get signal strength of last recieved packet -*/ unsigned int xbee900hp::getRSSI() { // checksum Variables unsigned int checksum = 0; @@ -337,9 +315,6 @@ return rssi; } -/** -* Set the transmission power level. -*/ int xbee900hp::setPower(int value) { if ((value > 4) || (value < 0)) { return 1; @@ -447,9 +422,6 @@ return 0; } -/** -* Get serial number of xbee module -*/ unsigned long long xbee900hp::getSerial() { // checksum Variables unsigned int checksum = 0; @@ -506,7 +478,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x7E) { // drop packet - return 0; + return 1; } // Get length of message (we don't care we know how long) _xbeespi.write(0x00); @@ -516,7 +488,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x88) { // drop packet - return 0; + return 1; } checksumsub += temp1; @@ -524,7 +496,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x52) { // drop packet - return 0; + return 1; } checksumsub += temp1; @@ -535,14 +507,14 @@ checksumsub += temp2; if ((temp1 != 0x53) || (temp2 != 0x48)) { - return 0; + return 1; // drop } // Check OK flag temp1 = _xbeespi.write(0x00); if (temp1 != 0x00) { - return 0; + return 1; // drop } checksumsub += temp1; @@ -569,7 +541,7 @@ // Check the checksum if (temp1 != checksum) { // Checksum failure, flag to discard packet - return 0; + return 1; } ///////////////////////////////////////////////////Send portion @@ -625,7 +597,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x7E) { // drop packet - return 0; + return 1; } // Get length of message (dont care again) _xbeespi.write(0x00); @@ -635,7 +607,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x88) { // drop packet - return 0; + return 1; } checksumsub += temp1; @@ -643,7 +615,7 @@ temp1 = _xbeespi.write(0x00); if (temp1 != 0x52) { // drop packet - return 0; + return 1; } checksumsub += temp1; @@ -654,14 +626,14 @@ checksumsub += temp2; if ((temp1 != 0x53) || (temp2 != 0x4C)) { - return 0; + return 1; // drop } // Check OK flag temp1 = _xbeespi.write(0x00); if (temp1 != 0x00) { - return 0; + return 1; // drop } checksumsub += temp1; @@ -687,26 +659,18 @@ // Check the checksum if (temp1 != checksum) { // Checksum failure, flag to discard packet - return 0; + return 1; } return serialNumber; } - -/** -* Clear output buffer -*/ void xbee900hp::clearBuff() { while(_pin_attn == 0) { _xbeespi.write(0x00); } } - -/** -* Read raw data in from module -*/ -char xbee900hp::debug() { +char xbee900hp::xbee_getc() { return _xbeespi.write(0x00); }