Implemented TDSensorEvent in com.telldus.core
This commit is contained in:
parent
6ac0d706a5
commit
c7800b90ff
2 changed files with 11 additions and 1 deletions
|
@ -7,11 +7,13 @@ TelldusCoreObject::TelldusCoreObject( QObject * parent )
|
||||||
tdInit();
|
tdInit();
|
||||||
deviceEventId = tdRegisterDeviceEvent(reinterpret_cast<TDDeviceEvent>(&TelldusCoreObject::deviceEventCallback), this);
|
deviceEventId = tdRegisterDeviceEvent(reinterpret_cast<TDDeviceEvent>(&TelldusCoreObject::deviceEventCallback), this);
|
||||||
deviceChangeEventId = tdRegisterDeviceChangeEvent(reinterpret_cast<TDDeviceChangeEvent>(&TelldusCoreObject::deviceChangeEventCallback), this);
|
deviceChangeEventId = tdRegisterDeviceChangeEvent(reinterpret_cast<TDDeviceChangeEvent>(&TelldusCoreObject::deviceChangeEventCallback), this);
|
||||||
|
sensorEventId = tdRegisterSensorEvent(reinterpret_cast<TDSensorEvent>(&TelldusCoreObject::sensorEventCallback), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TelldusCoreObject::~TelldusCoreObject() {
|
TelldusCoreObject::~TelldusCoreObject() {
|
||||||
tdUnregisterCallback(deviceEventId);
|
tdUnregisterCallback(deviceEventId);
|
||||||
tdUnregisterCallback(deviceChangeEventId);
|
tdUnregisterCallback(deviceChangeEventId);
|
||||||
|
tdUnregisterCallback(sensorEventId);
|
||||||
tdClose();
|
tdClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +110,6 @@ void TelldusCoreObject::triggerError(int deviceId, int errorId) {
|
||||||
emit errorOccurred(deviceId, errorId, message);
|
emit errorOccurred(deviceId, errorId, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WINAPI TelldusCoreObject::deviceChangeEventCallback(int deviceId, int eventId, int changeType, int callbackId, void *context) {
|
void WINAPI TelldusCoreObject::deviceChangeEventCallback(int deviceId, int eventId, int changeType, int callbackId, void *context) {
|
||||||
TelldusCoreObject *parent = static_cast<TelldusCoreObject *>(context);
|
TelldusCoreObject *parent = static_cast<TelldusCoreObject *>(context);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
@ -123,3 +124,9 @@ void WINAPI TelldusCoreObject::deviceEventCallback(int deviceId, int method, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WINAPI TelldusCoreObject::sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *context) {
|
||||||
|
TelldusCoreObject *parent = static_cast<TelldusCoreObject *>(context);
|
||||||
|
if (parent) {
|
||||||
|
emit parent->sensorEvent(QString::fromUtf8(protocol), QString::fromUtf8(model), id, dataType, QString::fromUtf8(value), timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void deviceChange( int deviceId, int eventId );
|
void deviceChange( int deviceId, int eventId );
|
||||||
void deviceEvent( int deviceId, int method, const QString &data );
|
void deviceEvent( int deviceId, int method, const QString &data );
|
||||||
|
void sensorEvent( const QString &protocol, const QString &model, int id, int dataType, const QString &value, int timestamp);
|
||||||
void errorOccurred( int deviceId, int errorId, const QString &errorString );
|
void errorOccurred( int deviceId, int errorId, const QString &errorString );
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -37,9 +38,11 @@ private:
|
||||||
|
|
||||||
static void WINAPI deviceChangeEventCallback(int deviceId, int eventId, int changeType, int callbackId, void *context);
|
static void WINAPI deviceChangeEventCallback(int deviceId, int eventId, int changeType, int callbackId, void *context);
|
||||||
static void WINAPI deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *context);
|
static void WINAPI deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *context);
|
||||||
|
static void WINAPI sensorEventCallback(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *context);
|
||||||
|
|
||||||
int deviceEventId;
|
int deviceEventId;
|
||||||
int deviceChangeEventId;
|
int deviceChangeEventId;
|
||||||
|
int sensorEventId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue