|
| 1 | +// |
| 2 | +// Copyright (C) 2012 Telldus Technologies AB. All rights reserved. |
| 3 | +// |
| 4 | +// Copyright: See COPYING file that comes with this distribution |
| 5 | +// |
| 6 | +// |
| 7 | +#ifndef TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_ |
| 8 | +#define TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_ |
| 9 | + |
| 10 | +// The following ifdef block is the standard way of creating macros |
| 11 | +// which make exporting from a DLL simpler. All files within this DLL |
| 12 | +// are compiled with the TELLDUSCORE_EXPORTS symbol defined on the command line. |
| 13 | +// This symbol should not be defined on any project that uses this DLL. |
| 14 | +// This way any other project whose source files include this file see |
| 15 | +// TELLSTICK_API functions as being imported from a DLL, whereas this DLL |
| 16 | +// sees symbols defined with this macro as being exported. |
| 17 | + |
| 18 | +#ifdef _WINDOWS |
| 19 | + #if defined(TELLDUSCORE_EXPORTS) |
| 20 | + #if defined(_CL64) |
| 21 | + #define TELLSTICK_API |
| 22 | + #else |
| 23 | + #define TELLSTICK_API __declspec(dllexport) |
| 24 | + #endif |
| 25 | + #else |
| 26 | + #define TELLSTICK_API __declspec(dllimport) |
| 27 | + #endif |
| 28 | + #define WINAPI __stdcall |
| 29 | +#else |
| 30 | + #define WINAPI |
| 31 | + #define TELLSTICK_API __attribute__ ((visibility("default"))) |
| 32 | +#endif |
| 33 | + |
| 34 | +typedef void (WINAPI *TDDeviceEvent)(int deviceId, int method, const char *data, int callbackId, void *context); |
| 35 | +typedef void (WINAPI *TDDeviceChangeEvent)(int deviceId, int changeEvent, int changeType, int callbackId, void *context); |
| 36 | +typedef void (WINAPI *TDRawDeviceEvent)(const char *data, int controllerId, int callbackId, void *context); |
| 37 | +typedef void (WINAPI *TDSensorEvent)(const char *protocol, const char *model, int id, int dataType, const char *value, int timestamp, int callbackId, void *context); |
| 38 | +typedef void (WINAPI *TDControllerEvent)(int controllerId, int changeEvent, int changeType, const char *newValue, int callbackId, void *context); |
| 39 | + |
| 40 | +#ifndef __cplusplus |
| 41 | + #define bool char |
| 42 | +#endif |
| 43 | + |
| 44 | +#ifdef __cplusplus |
| 45 | +extern "C" { |
| 46 | +#endif |
| 47 | + TELLSTICK_API void WINAPI tdInit(void); |
| 48 | + TELLSTICK_API int WINAPI tdRegisterDeviceEvent( TDDeviceEvent eventFunction, void *context ); |
| 49 | + TELLSTICK_API int WINAPI tdRegisterDeviceChangeEvent( TDDeviceChangeEvent eventFunction, void *context); |
| 50 | + TELLSTICK_API int WINAPI tdRegisterRawDeviceEvent( TDRawDeviceEvent eventFunction, void *context ); |
| 51 | + TELLSTICK_API int WINAPI tdRegisterSensorEvent( TDSensorEvent eventFunction, void *context ); |
| 52 | + TELLSTICK_API int WINAPI tdRegisterControllerEvent( TDControllerEvent eventFunction, void *context); |
| 53 | + TELLSTICK_API int WINAPI tdUnregisterCallback( int callbackId ); |
| 54 | + TELLSTICK_API void WINAPI tdClose(void); |
| 55 | + TELLSTICK_API void WINAPI tdReleaseString(char *thestring); |
| 56 | + |
| 57 | + TELLSTICK_API int WINAPI tdTurnOn(int intDeviceId); |
| 58 | + TELLSTICK_API int WINAPI tdTurnOff(int intDeviceId); |
| 59 | + TELLSTICK_API int WINAPI tdBell(int intDeviceId); |
| 60 | + TELLSTICK_API int WINAPI tdDim(int intDeviceId, unsigned char level); |
| 61 | + TELLSTICK_API int WINAPI tdExecute(int intDeviceId); |
| 62 | + TELLSTICK_API int WINAPI tdUp(int intDeviceId); |
| 63 | + TELLSTICK_API int WINAPI tdDown(int intDeviceId); |
| 64 | + TELLSTICK_API int WINAPI tdStop(int intDeviceId); |
| 65 | + TELLSTICK_API int WINAPI tdLearn(int intDeviceId); |
| 66 | + TELLSTICK_API int WINAPI tdMethods(int id, int methodsSupported); |
| 67 | + TELLSTICK_API int WINAPI tdLastSentCommand( int intDeviceId, int methodsSupported ); |
| 68 | + TELLSTICK_API char *WINAPI tdLastSentValue( int intDeviceId ); |
| 69 | + |
| 70 | + TELLSTICK_API int WINAPI tdGetNumberOfDevices(); |
| 71 | + TELLSTICK_API int WINAPI tdGetDeviceId(int intDeviceIndex); |
| 72 | + TELLSTICK_API int WINAPI tdGetDeviceType(int intDeviceId); |
| 73 | + |
| 74 | + TELLSTICK_API char * WINAPI tdGetErrorString(int intErrorNo); |
| 75 | + |
| 76 | + TELLSTICK_API char * WINAPI tdGetName(int intDeviceId); |
| 77 | + TELLSTICK_API bool WINAPI tdSetName(int intDeviceId, const char* chNewName); |
| 78 | + TELLSTICK_API char * WINAPI tdGetProtocol(int intDeviceId); |
| 79 | + TELLSTICK_API bool WINAPI tdSetProtocol(int intDeviceId, const char* strProtocol); |
| 80 | + TELLSTICK_API char * WINAPI tdGetModel(int intDeviceId); |
| 81 | + TELLSTICK_API bool WINAPI tdSetModel(int intDeviceId, const char *intModel); |
| 82 | + |
| 83 | + TELLSTICK_API char * WINAPI tdGetDeviceParameter(int intDeviceId, const char *strName, const char *defaultValue); |
| 84 | + TELLSTICK_API bool WINAPI tdSetDeviceParameter(int intDeviceId, const char *strName, const char* strValue); |
| 85 | + |
| 86 | + TELLSTICK_API int WINAPI tdAddDevice(); |
| 87 | + TELLSTICK_API bool WINAPI tdRemoveDevice(int intDeviceId); |
| 88 | + |
| 89 | + TELLSTICK_API int WINAPI tdSendRawCommand(const char *command, int reserved); |
| 90 | + |
| 91 | + TELLSTICK_API void WINAPI tdConnectTellStickController(int vid, int pid, const char *serial); |
| 92 | + TELLSTICK_API void WINAPI tdDisconnectTellStickController(int vid, int pid, const char *serial); |
| 93 | + |
| 94 | + TELLSTICK_API int WINAPI tdSensor(char *protocol, int protocolLen, char *model, int modelLen, int *id, int *dataTypes); |
| 95 | + TELLSTICK_API int WINAPI tdSensorValue(const char *protocol, const char *model, int id, int dataType, char *value, int len, int *timestamp); |
| 96 | + |
| 97 | + TELLSTICK_API int WINAPI tdController(int *controllerId, int *controllerType, char *name, int nameLen, int *available); |
| 98 | + TELLSTICK_API int WINAPI tdControllerValue(int controllerId, const char *name, char *value, int valueLen); |
| 99 | + TELLSTICK_API int WINAPI tdSetControllerValue(int controllerId, const char *name, const char *value); |
| 100 | + TELLSTICK_API int WINAPI tdRemoveController(int controllerId); |
| 101 | + |
| 102 | +#ifdef __cplusplus |
| 103 | +} |
| 104 | +#endif |
| 105 | + |
| 106 | +// Device methods |
| 107 | +#define TELLSTICK_TURNON 1 |
| 108 | +#define TELLSTICK_TURNOFF 2 |
| 109 | +#define TELLSTICK_BELL 4 |
| 110 | +#define TELLSTICK_TOGGLE 8 |
| 111 | +#define TELLSTICK_DIM 16 |
| 112 | +#define TELLSTICK_LEARN 32 |
| 113 | +#define TELLSTICK_EXECUTE 64 |
| 114 | +#define TELLSTICK_UP 128 |
| 115 | +#define TELLSTICK_DOWN 256 |
| 116 | +#define TELLSTICK_STOP 512 |
| 117 | + |
| 118 | +// Sensor value types |
| 119 | +#define TELLSTICK_TEMPERATURE 1 |
| 120 | +#define TELLSTICK_HUMIDITY 2 |
| 121 | +#define TELLSTICK_RAINRATE 4 |
| 122 | +#define TELLSTICK_RAINTOTAL 8 |
| 123 | +#define TELLSTICK_WINDDIRECTION 16 |
| 124 | +#define TELLSTICK_WINDAVERAGE 32 |
| 125 | +#define TELLSTICK_WINDGUST 64 |
| 126 | + |
| 127 | +// Error codes |
| 128 | +#define TELLSTICK_SUCCESS 0 |
| 129 | +#define TELLSTICK_ERROR_NOT_FOUND -1 |
| 130 | +#define TELLSTICK_ERROR_PERMISSION_DENIED -2 |
| 131 | +#define TELLSTICK_ERROR_DEVICE_NOT_FOUND -3 |
| 132 | +#define TELLSTICK_ERROR_METHOD_NOT_SUPPORTED -4 |
| 133 | +#define TELLSTICK_ERROR_COMMUNICATION -5 |
| 134 | +#define TELLSTICK_ERROR_CONNECTING_SERVICE -6 |
| 135 | +#define TELLSTICK_ERROR_UNKNOWN_RESPONSE -7 |
| 136 | +#define TELLSTICK_ERROR_SYNTAX -8 |
| 137 | +#define TELLSTICK_ERROR_BROKEN_PIPE -9 |
| 138 | +#define TELLSTICK_ERROR_COMMUNICATING_SERVICE -10 |
| 139 | +#define TELLSTICK_ERROR_CONFIG_SYNTAX -11 |
| 140 | +#define TELLSTICK_ERROR_UNKNOWN -99 |
| 141 | + |
| 142 | +// Device typedef |
| 143 | +#define TELLSTICK_TYPE_DEVICE 1 |
| 144 | +#define TELLSTICK_TYPE_GROUP 2 |
| 145 | +#define TELLSTICK_TYPE_SCENE 3 |
| 146 | + |
| 147 | +// Controller typedef |
| 148 | +#define TELLSTICK_CONTROLLER_TELLSTICK 1 |
| 149 | +#define TELLSTICK_CONTROLLER_TELLSTICK_DUO 2 |
| 150 | +#define TELLSTICK_CONTROLLER_TELLSTICK_NET 3 |
| 151 | + |
| 152 | +// Device changes |
| 153 | +#define TELLSTICK_DEVICE_ADDED 1 |
| 154 | +#define TELLSTICK_DEVICE_CHANGED 2 |
| 155 | +#define TELLSTICK_DEVICE_REMOVED 3 |
| 156 | +#define TELLSTICK_DEVICE_STATE_CHANGED 4 |
| 157 | + |
| 158 | +// Change types |
| 159 | +#define TELLSTICK_CHANGE_NAME 1 |
| 160 | +#define TELLSTICK_CHANGE_PROTOCOL 2 |
| 161 | +#define TELLSTICK_CHANGE_MODEL 3 |
| 162 | +#define TELLSTICK_CHANGE_METHOD 4 |
| 163 | +#define TELLSTICK_CHANGE_AVAILABLE 5 |
| 164 | +#define TELLSTICK_CHANGE_FIRMWARE 6 |
| 165 | + |
| 166 | +#endif // TELLDUS_CORE_CLIENT_TELLDUS_CORE_H_ |
0 commit comments