-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbasic_aps_plugin.h
85 lines (69 loc) · 2.34 KB
/
basic_aps_plugin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright (C) 2013 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*
*/
#ifndef BASIC_APS_PLUGIN_H
#define BASIC_APS_PLUGIN_H
#include <QObject>
#include <list>
#include <deconz.h>
#if DECONZ_LIB_VERSION < 0x010100
#error "The basic aps plugin requires at least deCONZ library version 1.1.0."
#endif
/*! \class BasicApsPlugin
Plugin to demonstrate the library support for sending and receiving APS frames via
APSDE-DATA.request, APSDE-DATA.confirm and APSDE-DATA.indication primitives.
The plugin executes a state machine which does the following:
1) Enter idle state and start timer
2) On timout send broadcast request to search for lights
3) Enter Wait state, start timer and wait for responses to print them
4) On timeout go back to 1)
*/
class BasicApsPlugin : public QObject,
public deCONZ::NodeInterface
{
Q_OBJECT
Q_INTERFACES(deCONZ::NodeInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.dresden-elektronik.BasicApsPlugin")
#endif
public:
//!< State machine states
enum State
{
StateIdle,
StateWaitMatchDescriptorResponse
};
//!< State machine events
enum Event
{
EventSendDone,
EventSendFailed,
EventTimeout
};
explicit BasicApsPlugin(QObject *parent = 0);
~BasicApsPlugin();
// node interface
const char *name();
bool hasFeature(Features feature);
public Q_SLOTS:
void stateMachineEventHandler(Event event);
void apsdeDataIndication(const deCONZ::ApsDataIndication &ind);
void apsdeDataConfirm(const deCONZ::ApsDataConfirm &conf);
void handleMatchDescriptorResponse(const deCONZ::ApsDataIndication &ind);
void timerFired();
bool sendMatchDescriptorRequest();
void setState(State state);
private:
State m_state; //!< current state machine state
QTimer *m_timer; //!< common timer
quint8 m_matchDescrZdpSeq; //!< ZDP transaction sequence number of Match_Descr_req
std::list<deCONZ::ApsDataRequest> m_apsReqQueue; //!< queue of active APS requests
deCONZ::ApsController *m_apsCtrl; //!< pointer to ApsController instance
};
#endif // BASIC_APS_PLUGIN_H