Exported tdUp(), tdDown() and tdStop() to the script engine
This commit is contained in:
parent
18b56f2069
commit
75affe3f5c
3 changed files with 38 additions and 8 deletions
|
@ -77,6 +77,30 @@ int TelldusCoreObject::turnOff(int deviceId) {
|
|||
return retval;
|
||||
}
|
||||
|
||||
int TelldusCoreObject::up(int deviceId) {
|
||||
int retval = tdUp( deviceId );
|
||||
if (retval != TELLSTICK_SUCCESS) {
|
||||
triggerError(deviceId, retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int TelldusCoreObject::down(int deviceId) {
|
||||
int retval = tdDown( deviceId );
|
||||
if (retval != TELLSTICK_SUCCESS) {
|
||||
triggerError(deviceId, retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int TelldusCoreObject::stop(int deviceId) {
|
||||
int retval = tdStop( deviceId );
|
||||
if (retval != TELLSTICK_SUCCESS) {
|
||||
triggerError(deviceId, retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void TelldusCoreObject::triggerError(int deviceId, int errorId) {
|
||||
char *errorString = tdGetErrorString( errorId );
|
||||
QString message = QString::fromUtf8( errorString );
|
||||
|
|
|
@ -10,7 +10,7 @@ class TelldusCoreObject : public QObject
|
|||
public:
|
||||
TelldusCoreObject( QObject * parent = 0 );
|
||||
virtual ~TelldusCoreObject();
|
||||
|
||||
|
||||
signals:
|
||||
void deviceChange( int deviceId, int eventId );
|
||||
void deviceEvent( int deviceId, int method, const QString &data );
|
||||
|
@ -25,19 +25,22 @@ public slots:
|
|||
int lastSentCommand( int deviceId, int methodsSupported );
|
||||
QString lastSentValue( int deviceId );
|
||||
int methods( int deviceId, int methodsSupported );
|
||||
|
||||
|
||||
int turnOn( int deviceId );
|
||||
int turnOff( int deviceId );
|
||||
|
||||
int up( int deviceId );
|
||||
int down( int deviceId );
|
||||
int stop( int deviceId );
|
||||
|
||||
private:
|
||||
void triggerError( int, int );
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
int deviceEventId;
|
||||
int deviceChangeEventId;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TELLDUSCOREOBJECT_H
|
||||
|
|
|
@ -21,12 +21,15 @@ void TelldusCorePlugin::initialize ( const QString & key, QScriptEngine * engine
|
|||
value.setProperty("TELLSTICK_BELL", TELLSTICK_BELL);
|
||||
value.setProperty("TELLSTICK_TOGGLE", TELLSTICK_TOGGLE);
|
||||
value.setProperty("TELLSTICK_DIM", TELLSTICK_DIM);
|
||||
|
||||
value.setProperty("TELLSTICK_UP", TELLSTICK_UP);
|
||||
value.setProperty("TELLSTICK_DOWN", TELLSTICK_DOWN);
|
||||
value.setProperty("TELLSTICK_STOP", TELLSTICK_STOP);
|
||||
|
||||
value.setProperty("TELLSTICK_DEVICE_ADDED", TELLSTICK_DEVICE_ADDED);
|
||||
value.setProperty("TELLSTICK_DEVICE_CHANGED", TELLSTICK_DEVICE_CHANGED);
|
||||
value.setProperty("TELLSTICK_DEVICE_REMOVED", TELLSTICK_DEVICE_REMOVED);
|
||||
value.setProperty("TELLSTICK_DEVICE_STATE_CHANGED", TELLSTICK_DEVICE_STATE_CHANGED);
|
||||
|
||||
|
||||
engine->globalObject().property("com").property("telldus").setProperty("core", value);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue