telldus-core/client/telldus-core.h
00001 //
00002 // Copyright (C) 2012 Telldus Technologies AB. All rights reserved.
00003 //
00004 // Copyright: See COPYING file that comes with this distribution
00005 //
00006 //
00007 #ifndef TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_
00008 #define TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_
00009 
00010 // The following ifdef block is the standard way of creating macros
00011 // which make exporting from a DLL simpler.  All files within this DLL
00012 // are compiled with the TELLDUSCORE_EXPORTS symbol defined on the command line.
00013 // This symbol should not be defined on any project that uses this DLL.
00014 // This way any other project whose source files include this file see
00015 // TELLSTICK_API functions as being imported from a DLL, whereas this DLL
00016 // sees symbols defined with this macro as being exported.
00017
00018 #ifdef _WINDOWS
00019         #if defined(TELLDUSCORE_EXPORTS)
00020                 #if defined(_CL64)
00021                         #define TELLSTICK_API
00022                 #else
00023                         #define TELLSTICK_API __declspec(dllexport)
00024                 #endif
00025         #else
00026                 #define TELLSTICK_API __declspec(dllimport)
00027         #endif
00028         #define WINAPI __stdcall
00029 #else
00030         #define WINAPI
00031         #define TELLSTICK_API __attribute__ ((visibility("default")))
00032 #endif
00033 
00034 typedef void (WINAPI *TDDeviceEvent)(int deviceId, int method, const char *data, int callbackId, void *context);
00035 typedef void (WINAPI *TDDeviceChangeEvent)(int deviceId, int changeEvent, int changeType, int callbackId, void *context);
00036 typedef void (WINAPI *TDRawDeviceEvent)(const char *data, int controllerId, int callbackId, void *context);
00037 typedef void (WINAPI *TDSensorEvent)(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *context);
00038 typedef void (WINAPI *TDControllerEvent)(int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context);
00039
00040 #ifndef __cplusplus
00041         #define bool char
00042 #endif
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047         TELLSTICK_API void WINAPI tdInit(void);
00048         TELLSTICK_API int WINAPI tdRegisterDeviceEvent( TDDeviceEvent eventFunction, void *context );
00049         TELLSTICK_API int WINAPI tdRegisterDeviceChangeEvent( TDDeviceChangeEvent eventFunction, void *context);
00050         TELLSTICK_API int WINAPI tdRegisterRawDeviceEvent( TDRawDeviceEvent eventFunction, void *context );
00051         TELLSTICK_API int WINAPI tdRegisterSensorEvent( TDSensorEvent eventFunction, void *context );
00052         TELLSTICK_API int WINAPI tdRegisterControllerEvent( TDControllerEvent eventFunction, void *context);
00053         TELLSTICK_API int WINAPI tdUnregisterCallback( int callbackId );
00054         TELLSTICK_API void WINAPI tdClose(void);
00055         TELLSTICK_API void WINAPI tdReleaseString(char *thestring);
00056
00057         TELLSTICK_API int WINAPI tdTurnOn(int intDeviceId);
00058         TELLSTICK_API int WINAPI tdTurnOff(int intDeviceId);
00059         TELLSTICK_API int WINAPI tdBell(int intDeviceId);
00060         TELLSTICK_API int WINAPI tdDim(int intDeviceId, unsigned char level);
00061         TELLSTICK_API int WINAPI tdExecute(int intDeviceId);
00062         TELLSTICK_API int WINAPI tdUp(int intDeviceId);
00063         TELLSTICK_API int WINAPI tdDown(int intDeviceId);
00064         TELLSTICK_API int WINAPI tdStop(int intDeviceId);
00065         TELLSTICK_API int WINAPI tdLearn(int intDeviceId);
00066         TELLSTICK_API int WINAPI tdMethods(int id, int methodsSupported);
00067         TELLSTICK_API int WINAPI tdLastSentCommand( int intDeviceId, int methodsSupported );
00068         TELLSTICK_API char *WINAPI tdLastSentValue( int intDeviceId );
00069
00070         TELLSTICK_API int WINAPI tdGetNumberOfDevices();
00071         TELLSTICK_API int WINAPI tdGetDeviceId(int intDeviceIndex);
00072         TELLSTICK_API int WINAPI tdGetDeviceType(int intDeviceId);
00073
00074         TELLSTICK_API char * WINAPI tdGetErrorString(int intErrorNo);
00075
00076         TELLSTICK_API char * WINAPI tdGetName(int intDeviceId);
00077         TELLSTICK_API bool WINAPI tdSetName(int intDeviceId, const char* chNewName);
00078         TELLSTICK_API char * WINAPI tdGetProtocol(int intDeviceId);
00079         TELLSTICK_API bool WINAPI tdSetProtocol(int intDeviceId, const char* strProtocol);
00080         TELLSTICK_API char * WINAPI tdGetModel(int intDeviceId);
00081         TELLSTICK_API bool WINAPI tdSetModel(int intDeviceId, const char *intModel);
00082
00083         TELLSTICK_API char * WINAPI tdGetDeviceParameter(int intDeviceId, const char *strName, const char *defaultValue);
00084         TELLSTICK_API bool WINAPI tdSetDeviceParameter(int intDeviceId, const char *strName, const char* strValue);
00085
00086         TELLSTICK_API int WINAPI tdAddDevice();
00087         TELLSTICK_API bool WINAPI tdRemoveDevice(int intDeviceId);
00088
00089         TELLSTICK_API int WINAPI tdSendRawCommand(const char *command, int reserved);
00090
00091         TELLSTICK_API void WINAPI tdConnectTellStickController(int vid, int pid, const char *serial);
00092         TELLSTICK_API void WINAPI tdDisconnectTellStickController(int vid, int pid, const char *serial);
00093
00094         TELLSTICK_API int WINAPI tdSensor(char *protocol, int protocolLen, char *model, int modelLen, int *id, int *dataTypes);
00095         TELLSTICK_API int WINAPI tdSensorValue(const char *protocol, const char *model, int id, int dataType, char *value, int len, int *timestamp);
00096
00097         TELLSTICK_API int WINAPI tdController(int *controllerId, int *controllerType, char *name, int nameLen, int *available);
00098         TELLSTICK_API int WINAPI tdControllerValue(int controllerId, const char *name, char *value, int valueLen);
00099         TELLSTICK_API int WINAPI tdSetControllerValue(int controllerId, const char *name, const char *value);
00100         TELLSTICK_API int WINAPI tdRemoveController(int controllerId);
00101
00102 #ifdef __cplusplus
00103 }
00104 #endif
00105 
00106 // Device methods
00107 #define TELLSTICK_TURNON        1
00108 #define TELLSTICK_TURNOFF       2
00109 #define TELLSTICK_BELL          4
00110 #define TELLSTICK_TOGGLE        8
00111 #define TELLSTICK_DIM           16
00112 #define TELLSTICK_LEARN         32
00113 #define TELLSTICK_EXECUTE       64
00114 #define TELLSTICK_UP            128
00115 #define TELLSTICK_DOWN          256
00116 #define TELLSTICK_STOP          512
00117 
00118 // Sensor value types
00119 #define TELLSTICK_TEMPERATURE   1
00120 #define TELLSTICK_HUMIDITY              2
00121 #define TELLSTICK_RAINRATE              4
00122 #define TELLSTICK_RAINTOTAL             8
00123 #define TELLSTICK_WINDDIRECTION 16
00124 #define TELLSTICK_WINDAVERAGE   32
00125 #define TELLSTICK_WINDGUST              64
00126 
00127 // Error codes
00128 #define TELLSTICK_SUCCESS 0
00129 #define TELLSTICK_ERROR_NOT_FOUND -1
00130 #define TELLSTICK_ERROR_PERMISSION_DENIED -2
00131 #define TELLSTICK_ERROR_DEVICE_NOT_FOUND -3
00132 #define TELLSTICK_ERROR_METHOD_NOT_SUPPORTED -4
00133 #define TELLSTICK_ERROR_COMMUNICATION -5
00134 #define TELLSTICK_ERROR_CONNECTING_SERVICE -6
00135 #define TELLSTICK_ERROR_UNKNOWN_RESPONSE -7
00136 #define TELLSTICK_ERROR_SYNTAX -8
00137 #define TELLSTICK_ERROR_BROKEN_PIPE -9
00138 #define TELLSTICK_ERROR_COMMUNICATING_SERVICE -10
00139 #define TELLSTICK_ERROR_CONFIG_SYNTAX -11
00140 #define TELLSTICK_ERROR_UNKNOWN -99
00141 
00142 // Device typedef
00143 #define TELLSTICK_TYPE_DEVICE   1
00144 #define TELLSTICK_TYPE_GROUP    2
00145 #define TELLSTICK_TYPE_SCENE    3
00146 
00147 // Controller typedef
00148 #define TELLSTICK_CONTROLLER_TELLSTICK      1
00149 #define TELLSTICK_CONTROLLER_TELLSTICK_DUO  2
00150 #define TELLSTICK_CONTROLLER_TELLSTICK_NET  3
00151 
00152 // Device changes
00153 #define TELLSTICK_DEVICE_ADDED                  1
00154 #define TELLSTICK_DEVICE_CHANGED                2
00155 #define TELLSTICK_DEVICE_REMOVED                3
00156 #define TELLSTICK_DEVICE_STATE_CHANGED  4
00157 
00158 // Change types
00159 #define TELLSTICK_CHANGE_NAME                   1
00160 #define TELLSTICK_CHANGE_PROTOCOL               2
00161 #define TELLSTICK_CHANGE_MODEL                  3
00162 #define TELLSTICK_CHANGE_METHOD                 4
00163 #define TELLSTICK_CHANGE_AVAILABLE              5
00164 #define TELLSTICK_CHANGE_FIRMWARE               6
00165 
00166 #endif  // TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_