/*
 * SmartHome server: Plug-in xbee
 *
 * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 */

/**
 * @file xbinterface.h
 * @brief Interfaces Digi XBee2 module via serial port
 * @author Daniel Pisi
 */

#ifndef XBINTERFACE_H
#define XBINTERFACE_H

#include <QObject>
#include "qextserialport.h"
#include "xbpacket.h"

// -----------------------------------------------------------------------------

/**
 * \class XbInterface
 * \brief Interfaces Digi XBee2 module via serial port
 */
class XbInterface : public QObject
{
    Q_OBJECT

public:
    XbInterface(QString param, QObject *parent = 0);

    void sendPacket(XbPacket &packet);

signals:
    void newPacketReceived(QByteArray data);

private slots:
    void onReadyRead();

private:
    QextSerialPort *mXbeePort;

    char mBuffer[100];
    int mState;
    int mSize;
    int mIndex;
};
// -----------------------------------------------------------------------------

#endif // XBINTERFACE_H
