Add function com.telldus.core.sensor() to script as wrapper for tdSensor(). See #96

This commit is contained in:
Micke Prag 2011-10-26 15:48:29 +02:00
parent 6c325fd0e6
commit 486753d411
2 changed files with 23 additions and 0 deletions

View file

@ -103,6 +103,26 @@ int TelldusCoreObject::stop(int deviceId) {
return retval;
}
QVariant TelldusCoreObject::sensor() const {
const int DATA_LENGTH = 20;
char protocol[DATA_LENGTH], model[DATA_LENGTH];
int sensorId = 0, dataTypes = 0;
if (tdSensor(protocol, DATA_LENGTH, model, DATA_LENGTH, &sensorId, &dataTypes) != TELLSTICK_SUCCESS) {
return 0;
}
QVariantMap retval;
retval["protocol"] = protocol;
retval["model"] = model;
retval["sensorId"] = sensorId;
retval["dataTypes"] = dataTypes;
return retval;
}
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
char *errorString = tdGetErrorString( errorId );
QString message = QString::fromUtf8( errorString );

View file

@ -2,6 +2,7 @@
#define TELLDUSCOREOBJECT_H
#include <QObject>
#include <QVariantMap>
#include <telldus-core.h>
class TelldusCoreObject : public QObject
@ -27,6 +28,8 @@ public slots:
QString lastSentValue( int deviceId );
int methods( int deviceId, int methodsSupported );
QVariant sensor() const;
int turnOn( int deviceId );
int turnOff( int deviceId );
int up( int deviceId );