Add basic structure for nxp backend
This commit is contained in:
parent
8e7af1f5e8
commit
1d3eb034e4
@ -155,7 +155,6 @@ private slots:
|
|||||||
void resetControllerWatchdog();
|
void resetControllerWatchdog();
|
||||||
void sendNextRequest();
|
void sendNextRequest();
|
||||||
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool enable(const QString &serialPort, qint32 baudrate);
|
bool enable(const QString &serialPort, qint32 baudrate);
|
||||||
void disable();
|
void disable();
|
||||||
|
|||||||
32
libnymea-zigbee/backends/nxp/interface/nxp.h
Normal file
32
libnymea-zigbee/backends/nxp/interface/nxp.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef NXP_H
|
||||||
|
#define NXP_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class Nxp
|
||||||
|
{
|
||||||
|
Q_GADGET
|
||||||
|
public:
|
||||||
|
enum Command {
|
||||||
|
CommandGetVersion = 0x00,
|
||||||
|
CommandGetDeviceState = 0x01
|
||||||
|
};
|
||||||
|
Q_ENUM(Command)
|
||||||
|
|
||||||
|
enum Notification {
|
||||||
|
NotificationDeviceStatusChanged = 0x7D,
|
||||||
|
NotificationDebugMessage = 0xFE
|
||||||
|
};
|
||||||
|
Q_ENUM(Notification)
|
||||||
|
|
||||||
|
enum Status {
|
||||||
|
StatusSuccess = 0x00,
|
||||||
|
StatusProtocolError = 0x01,
|
||||||
|
StatusUnknownCommand = 0x02,
|
||||||
|
StatusInvalidCrc = 0x03
|
||||||
|
};
|
||||||
|
Q_ENUM(Status)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NXP_H
|
||||||
17
libnymea-zigbee/backends/nxp/zigbeebridgecontrollernxp.cpp
Normal file
17
libnymea-zigbee/backends/nxp/zigbeebridgecontrollernxp.cpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#include "zigbeebridgecontrollernxp.h"
|
||||||
|
|
||||||
|
ZigbeeBridgeControllerNxp::ZigbeeBridgeControllerNxp(QObject *parent) :
|
||||||
|
ZigbeeBridgeController(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZigbeeBridgeControllerNxp::enable(const QString &serialPort, qint32 baudrate)
|
||||||
|
{
|
||||||
|
return m_interface->enable(serialPort, baudrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeBridgeControllerNxp::disable()
|
||||||
|
{
|
||||||
|
m_interface->disable();
|
||||||
|
}
|
||||||
35
libnymea-zigbee/backends/nxp/zigbeebridgecontrollernxp.h
Normal file
35
libnymea-zigbee/backends/nxp/zigbeebridgecontrollernxp.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#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"
|
||||||
|
|
||||||
|
class ZigbeeBridgeControllerNxp : public ZigbeeBridgeController
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ZigbeeBridgeControllerNxp(QObject *parent = nullptr);
|
||||||
|
~ZigbeeBridgeControllerNxp() override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZigbeeInterfaceNxp *m_interface = nullptr;
|
||||||
|
quint8 m_sequenceNumber = 0;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
bool enable(const QString &serialPort, qint32 baudrate);
|
||||||
|
void disable();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZIGBEEBRIDGECONTROLLERNXP_H
|
||||||
72
libnymea-zigbee/backends/nxp/zigbeenetworknxp.cpp
Normal file
72
libnymea-zigbee/backends/nxp/zigbeenetworknxp.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "zigbeenetworknxp.h"
|
||||||
|
#include "loggingcategory.h"
|
||||||
|
#include "zigbeeutils.h"
|
||||||
|
|
||||||
|
ZigbeeNetworkNxp::ZigbeeNetworkNxp(QObject *parent) :
|
||||||
|
ZigbeeNetwork(parent)
|
||||||
|
{
|
||||||
|
m_controller = new ZigbeeBridgeControllerNxp(this);
|
||||||
|
connect(m_controller, &ZigbeeBridgeControllerNxp::availableChanged, this, &ZigbeeNetworkNxp::onControllerAvailableChanged);
|
||||||
|
//connect(m_controller, &ZigbeeBridgeControllerNxp::apsDataConfirmReceived, this, &ZigbeeNetworkNxp::onApsDataConfirmReceived);
|
||||||
|
//connect(m_controller, &ZigbeeBridgeControllerNxp::apsDataIndicationReceived, this, &ZigbeeNetworkNxp::onApsDataIndicationReceived);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ZigbeeBridgeController *ZigbeeNetworkNxp::bridgeController() const
|
||||||
|
{
|
||||||
|
if (!m_controller)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return qobject_cast<ZigbeeBridgeController *>(m_controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZigbeeNetworkReply *ZigbeeNetworkNxp::sendRequest(const ZigbeeNetworkRequest &request)
|
||||||
|
{
|
||||||
|
Q_UNUSED(request)
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZigbeeNetworkReply *ZigbeeNetworkNxp::setPermitJoin(quint16 shortAddress, quint8 duration)
|
||||||
|
{
|
||||||
|
Q_UNUSED(shortAddress)
|
||||||
|
Q_UNUSED(duration)
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeNetworkNxp::onControllerAvailableChanged(bool available)
|
||||||
|
{
|
||||||
|
qCDebug(dcZigbeeNetwork()) << "Controller is" << (available ? "now available" : "not available any more");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeNetworkNxp::startNetwork()
|
||||||
|
{
|
||||||
|
loadNetwork();
|
||||||
|
|
||||||
|
if (!m_controller->enable(serialPortName(), serialBaudrate())) {
|
||||||
|
m_permitJoining = false;
|
||||||
|
emit permitJoiningChanged(m_permitJoining);
|
||||||
|
setState(StateOffline);
|
||||||
|
setError(ErrorHardwareUnavailable);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_permitJoining = false;
|
||||||
|
emit permitJoiningChanged(m_permitJoining);
|
||||||
|
|
||||||
|
// Wait for the network to be started
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeNetworkNxp::stopNetwork()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeNetworkNxp::reset()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZigbeeNetworkNxp::factoryResetNetwork()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
41
libnymea-zigbee/backends/nxp/zigbeenetworknxp.h
Normal file
41
libnymea-zigbee/backends/nxp/zigbeenetworknxp.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef ZIGBEENETWORKNXP_H
|
||||||
|
#define ZIGBEENETWORKNXP_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "zigbeenetwork.h"
|
||||||
|
#include "zigbeechannelmask.h"
|
||||||
|
#include "zcl/zigbeeclusterlibrary.h"
|
||||||
|
#include "zigbeebridgecontrollernxp.h"
|
||||||
|
|
||||||
|
class ZigbeeNetworkNxp : public ZigbeeNetwork
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ZigbeeNetworkNxp(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
ZigbeeBridgeController *bridgeController() const override;
|
||||||
|
|
||||||
|
ZigbeeNetworkReply *sendRequest(const ZigbeeNetworkRequest &request) override;
|
||||||
|
ZigbeeNetworkReply *setPermitJoin(quint16 shortAddress = Zigbee::BroadcastAddressAllRouters, quint8 duration = 0xfe);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZigbeeBridgeControllerNxp *m_controller = nullptr;
|
||||||
|
bool m_networkRunning = false;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onControllerAvailableChanged(bool available);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void startNetwork() override;
|
||||||
|
void stopNetwork() override;
|
||||||
|
void reset() override;
|
||||||
|
void factoryResetNetwork() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ZIGBEENETWORKNXP_H
|
||||||
@ -9,6 +9,8 @@ SOURCES += \
|
|||||||
backends/deconz/zigbeebridgecontrollerdeconz.cpp \
|
backends/deconz/zigbeebridgecontrollerdeconz.cpp \
|
||||||
backends/deconz/zigbeenetworkdeconz.cpp \
|
backends/deconz/zigbeenetworkdeconz.cpp \
|
||||||
backends/nxp/interface/zigbeeinterfacenxp.cpp \
|
backends/nxp/interface/zigbeeinterfacenxp.cpp \
|
||||||
|
backends/nxp/zigbeebridgecontrollernxp.cpp \
|
||||||
|
backends/nxp/zigbeenetworknxp.cpp \
|
||||||
zcl/general/zigbeeclusteridentify.cpp \
|
zcl/general/zigbeeclusteridentify.cpp \
|
||||||
zcl/general/zigbeeclusterlevelcontrol.cpp \
|
zcl/general/zigbeeclusterlevelcontrol.cpp \
|
||||||
zcl/general/zigbeeclusteronoff.cpp \
|
zcl/general/zigbeeclusteronoff.cpp \
|
||||||
@ -60,7 +62,10 @@ HEADERS += \
|
|||||||
backends/deconz/interface/zigbeeinterfacedeconzreply.h \
|
backends/deconz/interface/zigbeeinterfacedeconzreply.h \
|
||||||
backends/deconz/zigbeebridgecontrollerdeconz.h \
|
backends/deconz/zigbeebridgecontrollerdeconz.h \
|
||||||
backends/deconz/zigbeenetworkdeconz.h \
|
backends/deconz/zigbeenetworkdeconz.h \
|
||||||
|
backends/nxp/interface/nxp.h \
|
||||||
backends/nxp/interface/zigbeeinterfacenxp.h \
|
backends/nxp/interface/zigbeeinterfacenxp.h \
|
||||||
|
backends/nxp/zigbeebridgecontrollernxp.h \
|
||||||
|
backends/nxp/zigbeenetworknxp.h \
|
||||||
zcl/general/zigbeeclusteridentify.h \
|
zcl/general/zigbeeclusteridentify.h \
|
||||||
zcl/general/zigbeeclusterlevelcontrol.h \
|
zcl/general/zigbeeclusterlevelcontrol.h \
|
||||||
zcl/general/zigbeeclusteronoff.h \
|
zcl/general/zigbeeclusteronoff.h \
|
||||||
|
|||||||
Reference in New Issue
Block a user