The XBee class is used to represents the local XBee. More...

Inheritance diagram for QtXBee::XBee:

Public Types

enum  Mode { CommandMode, API1Mode, API2Mode }
 

Public Slots

void loadAddressingProperties ()
 Loads the XBee's addressing properties. More...
 
bool open ()
 Opens the XBee' serial port. More...
 
bool close ()
 Closes the XBee' serial port. More...
 
void displayATCommandResponse (ATCommandResponse *digiMeshPacket)
 
void displayModemStatus (ModemStatus *digiMeshPacket)
 
void displayTransmitStatus (ZBTxStatusResponse *digiMeshPacket)
 
void displayRxIndicator (ZBRxResponse *digiMeshPacket)
 
void displayRxIndicatorExplicit (ZBExplicitRxResponse *digiMeshPacket)
 
void displayNodeIdentificationIndicator (ZBIONodeIdentificationResponse *digiMeshPacket)
 
void displayRemoteCommandResponse (RemoteATCommandResponse *digiMeshPacket)
 

Signals

void rawDataReceived (const QByteArray &data)
 Emitted when raw data are received on the serial port (only in XBee::CommandMode). More...
 
void receivedATCommandResponse (QtXBee::ATCommandResponse *response)
 Emitted when a ATCommandResponse frame is received.
 
void receivedModemStatus (QtXBee::ModemStatus *response)
 Emitted when a ModemStatus frame is received.
 
void receivedRemoteCommandResponse (QtXBee::RemoteATCommandResponse *response)
 Emitted when a RemoteATCommandResponse frame is received.
 
void receivedTransmitStatus (QtXBee::ZigBee::ZBTxStatusResponse *response)
 Emitted when a ZigBee::ZBTxStatusResponse frame is received.
 
void receivedRxIndicator (QtXBee::ZigBee::ZBRxResponse *response)
 Emitted when a ZigBee::ZBRxResponse frame is received.
 
void receivedRxIndicatorExplicit (QtXBee::ZigBee::ZBExplicitRxResponse *response)
 Emitted when a ZigBee::ZBExplicitRxResponse frame is received.
 
void receivedNodeIdentificationIndicator (QtXBee::ZigBee::ZBIONodeIdentificationResponse *response)
 Emitted when a ZigBee::ZBIONodeIdentificationResponse frame is received.
 
void receivedTransmitStatus (QtXBee::Wpan::TxStatusResponse *response)
 Emitted when a Wpan::TxStatusResponse frame is received.
 
void receivedRxResponse16 (QtXBee::Wpan::RxResponse16 *response)
 Emitted when a Wpan::RxResponse16 frame is received.
 
void receivedRxResponse64 (QtXBee::Wpan::RxResponse64 *response)
 Emitted when a Wpan::RxResponse64 frame is received.
 
void DHChanged (const quint32 dh)
 Emitted when DH property changes. More...
 
void DLChanged (const quint32 dl)
 Emitted when DL property changes. More...
 
void MYChanged (const quint16 my)
 Emitted when MY property changes. More...
 
void MPChanged (const quint16 mp)
 Emitted when MP property changes. More...
 
void NCChanged (const quint32 nc)
 Emitted when NC property changes. More...
 
void SHChanged (const quint32 sh)
 Emitted when SH property changes. More...
 
void SLChanged (const quint32 sl)
 Emitted when SL property changes. More...
 
void NIChanged (const QString &ni)
 Emitted when NI property changes. More...
 
void SEChanged (const quint8 se)
 Emitted when SE property changes. More...
 
void DEChanged (const quint8 de)
 Emitted when DE property changes. More...
 
void CIChanged (const quint8 ci)
 Emitted when CI property changes. More...
 
void TOChanged (const quint8 to)
 Emitted when TO property changes. More...
 
void NPChanged (const quint8 np)
 Emitted when NP property changes. More...
 
void DDChanged (const quint16 dd)
 Emitted when DD property changes. More...
 
void CRChanged (const quint8 cr)
 Emitted when CR property changes. More...
 

Public Member Functions

 XBee (QObject *parent=0)
 XBee's default constructor. More...
 
 XBee (const QString &serialPort, QObject *parent=0)
 XBee's constructor. More...
 
 ~XBee ()
 Destroyes the XBee instance, frees allocated resources and close the serial port.
 
bool applyDefaultSerialPortConfig ()
 Applies the default configuration to the serial port. More...
 
bool sendCommandAsync (const QByteArray &command)
 Sends asynchronously the given command in command mode. More...
 
XBeeResponsesendSync (XBeePacket *packet)
 Sends synchronously the given packet. More...
 
ATCommandResponsesendATCommandSync (ATCommand *command)
 Sends an ATCommand synchronously. More...
 
ATCommandResponsesendATCommandSync (const QByteArray &atcommand)
 Sends an ATCommand synchronously. More...
 
QByteArray sendCommandSync (const QByteArray &command)
 Sends synchronously the given command using in command mode. More...
 
void sendAsync (XBeePacket *packet)
 Sends asynchronously the given packet. More...
 
void sendATCommandAsync (ATCommand *command)
 Sends an ATCommand asynchronously. More...
 
void sendATCommandAsync (const QByteArray &data)
 Sends an ATCommand asynchronously. More...
 
bool setMode (const Mode mode)
 Sets the XBee's mode. More...
 
Mode mode () const
 Returns the XBee's mode. More...
 
bool setSerialPort (const QString &serialPort)
 Sets the XBee's serial port, which we be used to communicate with it. More...
 
bool setSerialPort (const QString &serialPort, const QSerialPort::BaudRate baudRate, const QSerialPort::DataBits dataBits, const QSerialPort::Parity parity, const QSerialPort::StopBits stopBits, const QSerialPort::FlowControl flowControl)
 Configures the serial port used to communicate with the XBee. More...
 
bool setSerialPortConfiguration (const QSerialPort::BaudRate baudRate, const QSerialPort::DataBits dataBits, const QSerialPort::Parity parity, const QSerialPort::StopBits stopBits, const QSerialPort::FlowControl flowControl)
 Configures the serial port used to communicate with the XBee. More...
 
bool setDH (const quint32 dh)
 
bool setDL (const quint32 dl)
 
bool setMY (const quint16 my)
 
bool setMP (const quint16 mp)
 
bool setNC (const quint32 nc)
 
bool setSH (const quint32 sh)
 
bool setSL (const quint32 sl)
 
bool setNI (const QString &ni)
 
bool setSE (const quint8 se)
 
bool setDE (const quint8 de)
 
bool setCI (const quint8 ci)
 
bool setTO (const quint8 to)
 
bool setNP (const quint8 np)
 
bool setDD (const quint16 dd)
 
bool setCR (const quint8 cr)
 
quint32 DH () const
 
quint32 DL () const
 
quint16 MY () const
 
quint16 MP () const
 
quint32 NC () const
 
quint32 SH () const
 
quint32 SL () const
 
QString NI () const
 
quint8 SE () const
 
quint8 DE () const
 
quint8 CI () const
 
quint8 TO () const
 
quint8 NO () const
 
quint16 DD () const
 
quint8 CR () const
 

Detailed Description

The XBee class is used to represents the local XBee.

You can :

  • Open/Close and configure the serial interface
  • Get/Set all XBee's parameters
  • Send/Receive packets to/from other remote XBees
Todo:
What to do when the XBee is in XBee::CommandMode at the user wants to send API packets ? Auto switch to the correct mode ? Stay in QtXBee::XBee::CommandMode and do nothing but warn the user ?
Note
The whole QtXBee lib is mainly designed to work in API Mode

Member Enumeration Documentation

Enumerator
CommandMode 

Command mode. This mode is used to configure the XBee module. Once the mode is set to CommandMode, you need to send the command '+++'

See Also
sendCommandSync()
sendCommandAsync()
http://knowledge.digi.com/articles/Knowledge_Base_Article/The-AT-Command-Set
API1Mode 

API Operation (AP=1)

API2Mode 

API Operation with escaped characters (AP=2)

Constructor & Destructor Documentation

QtXBee::XBee::XBee ( QObject *  parent = 0)
explicit

XBee's default constructor.

Allocates and initializes all parameters to there default values.

Note
At this stage, no serial communication is initialized, so you can't communicate with your physical XBee until the serial port is initialized.
Parameters
parentparent object
See Also
XBee::XBee(const QString &serialPort, QObject *parent)
XBee::setSerialPort()
QtXBee::XBee::XBee ( const QString &  serialPort,
QObject *  parent = 0 
)

XBee's constructor.

Allocates and initializes all parameters to there default values and try to open the serial port specified in argument.

Parameters
serialPortserial port path (eg. /dev/ttyUSB0) on with the XBee is plugged.
parentparent object
Note
In this case, the serial port configuration will ba set to :
  • Baud Rate : 9600
  • Data Bits : 8 bits
  • Parity : No
  • Stop Bits : One stop bit
  • Flow Control : No flow control

Member Function Documentation

bool QtXBee::XBee::applyDefaultSerialPortConfig ( )

Applies the default configuration to the serial port.

  • Baud Rate : 9600
  • Data Bits : 8 bits
  • Parity : No
  • Stop Bits : One stop bit
  • Flow Control : No flow control
Note
You serial port must be set before calling this method
Returns
true if succeeded; false otherwise.
See Also
XBee::setSerialPort()
void QtXBee::XBee::CIChanged ( const quint8  ci)
signal

Emitted when CI property changes.

See Also
XBee::setCI()
XBee::CI()
bool QtXBee::XBee::close ( )
slot

Closes the XBee' serial port.

Returns
true if succeeded; false otherwise
void QtXBee::XBee::CRChanged ( const quint8  cr)
signal

Emitted when CR property changes.

See Also
XBee::setCR()
XBee::CR()
void QtXBee::XBee::DDChanged ( const quint16  dd)
signal

Emitted when DD property changes.

See Also
XBee::setDD()
XBee::DD()
void QtXBee::XBee::DEChanged ( const quint8  de)
signal

Emitted when DE property changes.

See Also
XBee::setDE()
XBee::DE()
void QtXBee::XBee::DHChanged ( const quint32  dh)
signal

Emitted when DH property changes.

See Also
XBee::setDH()
XBee::DH()
void QtXBee::XBee::DLChanged ( const quint32  dl)
signal

Emitted when DL property changes.

See Also
XBee::setDL()
XBee::DL()
void QtXBee::XBee::loadAddressingProperties ( )
slot

Loads the XBee's addressing properties.

  • DH
  • DL
  • MY
  • MP
  • NC
  • SH
  • SL
  • NI
  • SE
  • DE
  • CI
  • TO
  • NP
  • DD
  • CR
XBee::Mode QtXBee::XBee::mode ( ) const

Returns the XBee's mode.

Returns
the XBee's mode
See Also
XBee::setMode()
XBee::Mode
void QtXBee::XBee::MPChanged ( const quint16  mp)
signal

Emitted when MP property changes.

See Also
XBee::setMP()
XBee::MP()
void QtXBee::XBee::MYChanged ( const quint16  my)
signal

Emitted when MY property changes.

See Also
XBee::setMY()
XBee::MY()
void QtXBee::XBee::NCChanged ( const quint32  nc)
signal

Emitted when NC property changes.

See Also
XBee::setNC()
XBee::NC()
void QtXBee::XBee::NIChanged ( const QString &  ni)
signal

Emitted when NI property changes.

See Also
XBee::setNI()
XBee::NI()
void QtXBee::XBee::NPChanged ( const quint8  np)
signal

Emitted when NP property changes.

See Also
XBee::setNP()
XBee::NP()
bool QtXBee::XBee::open ( )
slot

Opens the XBee' serial port.

Returns
true if succeeded; false otherwise.
See Also
XBee::close()
XBee::setSerialPort()
void QtXBee::XBee::rawDataReceived ( const QByteArray &  data)
signal

Emitted when raw data are received on the serial port (only in XBee::CommandMode).

See Also
XBee::setMode()
XBee::Mode
void QtXBee::XBee::SEChanged ( const quint8  se)
signal

Emitted when SE property changes.

See Also
XBee::setSE()
XBee::SE()
void QtXBee::XBee::sendAsync ( XBeePacket packet)

Sends asynchronously the given packet.

Parameters
packetthe packet to send.
Note
A signal (corresponding the given packet) will be emitted when a response is received.

For example, if the given packet is an ATCommand, the XBee::receivedATCommandResponse() will be emitted.

void QtXBee::XBee::sendATCommandAsync ( ATCommand command)

Sends an ATCommand asynchronously.

The XBee::receivedATCommandResponse() signal will be emmited when a response to the sent ATCommand is received.

Parameters
command
void QtXBee::XBee::sendATCommandAsync ( const QByteArray &  data)

Sends an ATCommand asynchronously.

The XBee::receivedATCommandResponse() signal will be emmited when a response to the sent ATCommand is received.

Parameters
command
Note
This method is not implemented yet
Todo:
Implement this method
ATCommandResponse * QtXBee::XBee::sendATCommandSync ( ATCommand command)

Sends an ATCommand synchronously.

Parameters
command
Returns
the corresponding ATCommandResponse; or null.
Note
XBee don't take the ATCommandResponse's ownership, you have to.
ATCommandResponse * QtXBee::XBee::sendATCommandSync ( const QByteArray &  atcommand)

Sends an ATCommand synchronously.

Parameters
atcommand
Returns
the corresponding ATCommandResponse; or null.
Note
XBee don't take the ATCommandResponse's ownership, you have to.
bool QtXBee::XBee::sendCommandAsync ( const QByteArray &  command)

Sends asynchronously the given command in command mode.

To put the module in command mode, you need first to send '+++' When a response is received, the signal rawDataReceived() will be emitted.

See Also
http://knowledge.digi.com/articles/Knowledge_Base_Article/The-AT-Command-Set
Parameters
commandthe command to send
Returns
true if succeeded; false otherwise.
Note
The XBee must be in XBee::CommandMode,
See Also
XBee::setMode()
QByteArray QtXBee::XBee::sendCommandSync ( const QByteArray &  command)

Sends synchronously the given command using in command mode.

To put the module in command mode, you need first to send '+++'

See Also
http://knowledge.digi.com/articles/Knowledge_Base_Article/The-AT-Command-Set
Parameters
commandthe command to send
Returns
the response (the read data from the serial port are appended until the last received character is <CR> (0x0D))
Note
The XBee must be in XBee::CommandMode
See Also
XBee::setMode()
XBeeResponse * QtXBee::XBee::sendSync ( XBeePacket packet)

Sends synchronously the given packet.

Parameters
packetthe packet to send.
Return values
theassociated XBeeResponse in case of success
NULLif failed
Note
XBee don't take the XBeeResponse's ownership, you have to.
bool QtXBee::XBee::setMode ( const Mode  mode)

Sets the XBee's mode.

Parameters
mode
Returns
true if succeeded; false otherwise.
Todo:
Set the mode into the XBee, not only the class attribute
See Also
XBee::Mode
XBee::mode()
bool QtXBee::XBee::setSerialPort ( const QString &  serialPort)

Sets the XBee's serial port, which we be used to communicate with it.

Note
Default serial port will be used :
  • Baud Rate : 9600
  • Data Bits : 8 bits
  • Parity : No
  • Stop Bits : One stop bit
  • Flow Control : No flow control
Parameters
serialPortpath to the serial port
Returns
true if succeeded; false otherwise
See Also
XBee::setSerialPort(const QString &serialPort, const QSerialPort::BaudRate baudRate, const QSerialPort::DataBits dataBits, const QSerialPort::Parity parity, const QSerialPort::StopBits stopBits, const QSerialPort::FlowControl flowControl)
XBee::applyDefaultSerialPortConfig()
bool QtXBee::XBee::setSerialPort ( const QString &  serialPort,
const QSerialPort::BaudRate  baudRate,
const QSerialPort::DataBits  dataBits,
const QSerialPort::Parity  parity,
const QSerialPort::StopBits  stopBits,
const QSerialPort::FlowControl  flowControl 
)

Configures the serial port used to communicate with the XBee.

Parameters
serialPortpath to the serial port
baudRatethe baud rate
dataBitsthe data bits
paritythe parity
stopBitsthe stop bits
flowControlthe flow control
Returns
true if succeeded; false otherwise
bool QtXBee::XBee::setSerialPortConfiguration ( const QSerialPort::BaudRate  baudRate,
const QSerialPort::DataBits  dataBits,
const QSerialPort::Parity  parity,
const QSerialPort::StopBits  stopBits,
const QSerialPort::FlowControl  flowControl 
)

Configures the serial port used to communicate with the XBee.

Note
This method must be called after have defining the serial port
Parameters
baudRatethe baud rate
dataBitsthe data bits
paritythe parity
stopBitsthe stop bits
flowControlthe flow control
Returns
true if succeeded; false otherwise.
See Also
XBee::setSerialPort()
void QtXBee::XBee::SHChanged ( const quint32  sh)
signal

Emitted when SH property changes.

See Also
XBee::setSH()
XBee::SH()
void QtXBee::XBee::SLChanged ( const quint32  sl)
signal

Emitted when SL property changes.

See Also
XBee::setSL()
XBee::SL()
void QtXBee::XBee::TOChanged ( const quint8  to)
signal

Emitted when TO property changes.

See Also
XBee::setTO()
XBee::TO()

The documentation for this class was generated from the following files:
  • /home/thomas/Projects/QtXBee/src/qtxb/xbee.h
  • /home/thomas/Projects/QtXBee/src/qtxb/xbee.cpp
  • pages/xbee.dox