This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-zigbee/libnymea-zigbee/backends/nxp/zigbeebridgecontrollernxp.h
2020-10-07 14:43:17 +02:00

74 lines
2.2 KiB
C++

#ifndef ZIGBEEBRIDGECONTROLLERNXP_H
#define ZIGBEEBRIDGECONTROLLERNXP_H
#include <QHash>
#include <QTimer>
#include <QQueue>
#include <QObject>
#include "zigbee.h"
#include "zigbeeaddress.h"
#include "zigbeenetworkkey.h"
#include "zigbeenetworkrequest.h"
#include "zigbeebridgecontroller.h"
#include "interface/zigbeeinterfacenxp.h"
#include "interface/zigbeeinterfacenxpreply.h"
class ZigbeeBridgeControllerNxp : public ZigbeeBridgeController
{
Q_OBJECT
friend class ZigbeeNetworkNxp;
public:
explicit ZigbeeBridgeControllerNxp(QObject *parent = nullptr);
~ZigbeeBridgeControllerNxp() override;
enum ControllerState {
ControllerStateRunning = 0x00,
ControllerStateBooting = 0x01,
ControllerStateStarting = 0x02,
ControllerStateRunningUninitialized = 0x03,
ControllerStateNotRunning = 0x04
};
Q_ENUM(ControllerState)
ControllerState controllerState() const;
// Controllere requests
ZigbeeInterfaceNxpReply *requestVersion();
ZigbeeInterfaceNxpReply *requestControllerState();
ZigbeeInterfaceNxpReply *requestSoftResetController();
ZigbeeInterfaceNxpReply *requestFactoryResetController();
ZigbeeInterfaceNxpReply *requestSetPanId(quint64 panId);
ZigbeeInterfaceNxpReply *requestSetChannelMask(quint32 channelMask);
signals:
void controllerStateChanged(ControllerState controllerState);
void interfaceNotificationReceived(Nxp::Notification notification, const QByteArray &data);
private:
ZigbeeInterfaceNxp *m_interface = nullptr;
ControllerState m_controllerState = ControllerStateNotRunning;
quint8 m_sequenceNumber = 0;
ZigbeeInterfaceNxpReply *m_currentReply = nullptr;
QQueue<ZigbeeInterfaceNxpReply *> m_replyQueue;
ZigbeeInterfaceNxpReply *createReply(Nxp::Command command, quint8 sequenceNumber, const QString &requestName, const QByteArray &requestData, QObject *parent);
void bumpSequenceNumber();
private slots:
void onInterfaceAvailableChanged(bool available);
void onInterfacePackageReceived(const QByteArray &package);
void sendNextRequest();
public slots:
bool enable(const QString &serialPort, qint32 baudrate);
void disable();
};
#endif // ZIGBEEBRIDGECONTROLLERNXP_H