Changed the prefix "dev" to "td" for our new platform independent API

This commit is contained in:
Micke Prag 2008-10-19 19:06:12 +00:00
parent 6dd66d7d7e
commit 5fe95ef98a
4 changed files with 81 additions and 81 deletions

View file

@ -1,25 +1,25 @@
LIBRARY telldus-core LIBRARY telldus-core
EXPORTS EXPORTS
devGetNumberOfDevices @1 tdGetNumberOfDevices @1
devGetDeviceId @2 tdGetDeviceId @2
devGetName @3 tdGetName @3
devGetVendor @4 tdGetVendor @4
devGetModel @5 tdGetModel @5
devGetArgument @6 tdGetArgument @6
devSetName @7 tdSetName @7
devSetVendor @8 tdSetVendor @8
devSetModel @9 tdSetModel @9
devSetArgument @10 tdSetArgument @10
devAddDevice @11 tdAddDevice @11
devRemoveDevice @12 tdRemoveDevice @12
devMethods @13 tdMethods @13
devTurnOn @14 tdTurnOn @14
devTurnOff @15 tdTurnOff @15
devBell @16 tdBell @16
devDim @17 tdDim @17
devGetErrorString @18 tdGetErrorString @18

View file

@ -22,19 +22,19 @@ using namespace std;
/** /**
* @def TELLSTICK_TURNON * @def TELLSTICK_TURNON
* Device-flag for devices supporting the devTurnOn() call. * Device-flag for devices supporting the tdTurnOn() call.
* *
* @def TELLSTICK_TURNOFF * @def TELLSTICK_TURNOFF
* Device-flag for devices supporting the devTurnOff() call. * Device-flag for devices supporting the tdTurnOff() call.
* *
* @def TELLSTICK_BELL * @def TELLSTICK_BELL
* Device-flag for devices supporting the devBell() call. * Device-flag for devices supporting the tdBell() call.
* *
* @def TELLSTICK_TOGGLE * @def TELLSTICK_TOGGLE
* This method is currently unimplemented. * This method is currently unimplemented.
* *
* @def TELLSTICK_DIM * @def TELLSTICK_DIM
* Device-flag for devices supporting the devDim() call. * Device-flag for devices supporting the tdDim() call.
* *
* @def TELLSTICK_SUCCESS * @def TELLSTICK_SUCCESS
* Error code. Returned when the command succeeded. * Error code. Returned when the command succeeded.
@ -51,7 +51,7 @@ using namespace std;
* *
* @def TELLSTICK_ERROR_METHOD_NOT_SUPPORTED * @def TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
* Error code. The requested method is not supported device. * Error code. The requested method is not supported device.
* This should be avoided by a call to devMethods(). * This should be avoided by a call to tdMethods().
* *
* @def TELLSTICK_ERROR_UNKNOWN * @def TELLSTICK_ERROR_UNKNOWN
* Error code. An unkown error has occurred. * Error code. An unkown error has occurred.
@ -65,11 +65,11 @@ using namespace std;
/** /**
* Turns a device on. * Turns a device on.
* Make sure the device supports this by calling devMethods() before any * Make sure the device supports this by calling tdMethods() before any
* call to this function. * call to this function.
* @param intDeviceId The device id to turn on. * @param intDeviceId The device id to turn on.
**/ **/
int WINAPI devTurnOn(int intDeviceId){ int WINAPI tdTurnOn(int intDeviceId){
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -101,11 +101,11 @@ int WINAPI devTurnOn(int intDeviceId){
/** /**
* Turns a device off. * Turns a device off.
* Make sure the device supports this by calling devMethods() before any * Make sure the device supports this by calling tdMethods() before any
* call to this function. * call to this function.
* @param intDeviceId The device id to turn off. * @param intDeviceId The device id to turn off.
*/ */
int WINAPI devTurnOff(int intDeviceId){ int WINAPI tdTurnOff(int intDeviceId){
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -136,11 +136,11 @@ int WINAPI devTurnOff(int intDeviceId){
/** /**
* Sends bell command to devices supporting this. * Sends bell command to devices supporting this.
* Make sure the device supports this by calling devMethods() before any * Make sure the device supports this by calling tdMethods() before any
* call to this function. * call to this function.
* @param intDeviceId The device id to send bell to * @param intDeviceId The device id to send bell to
*/ */
int WINAPI devBell(int intDeviceId){ int WINAPI tdBell(int intDeviceId){
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -171,12 +171,12 @@ int WINAPI devBell(int intDeviceId){
/** /**
* Dims a device. * Dims a device.
* Make sure the device supports this by calling devMethods() before any * Make sure the device supports this by calling tdMethods() before any
* call to this function. * call to this function.
* @param intDeviceId The device id to dim * @param intDeviceId The device id to dim
* @param level The level the device should dim to. This value should be 0-255 * @param level The level the device should dim to. This value should be 0-255
*/ */
int WINAPI devDim(int intDeviceId, unsigned char level){ int WINAPI tdDim(int intDeviceId, unsigned char level){
try{ try{
TelldusSettings ts; TelldusSettings ts;
Device* dev = ts.getDevice(intDeviceId); Device* dev = ts.getDevice(intDeviceId);
@ -214,7 +214,7 @@ int WINAPI devDim(int intDeviceId, unsigned char level){
* This function returns the number of devices configured * This function returns the number of devices configured
* @returns an integer of the total number of devices configured * @returns an integer of the total number of devices configured
*/ */
int WINAPI devGetNumberOfDevices(void){ int WINAPI tdGetNumberOfDevices(void){
int intReturn = -1; int intReturn = -1;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -231,16 +231,16 @@ int WINAPI devGetNumberOfDevices(void){
* This function returns the unique id of a device with a specific index. * This function returns the unique id of a device with a specific index.
* To get all the id numbers you should loop over all the devices: * To get all the id numbers you should loop over all the devices:
* \code * \code
* int intNumberOfDevices = devGetNumberOfDevices(); * int intNumberOfDevices = tdGetNumberOfDevices();
* for (int i = 0; i < intNumberOfDevices; i++) { * for (int i = 0; i < intNumberOfDevices; i++) {
* int id = devGetDeviceId( i ); * int id = tdGetDeviceId( i );
* // id now contains the id number of the device with index of i * // id now contains the id number of the device with index of i
* } * }
* \endcode * \endcode
* @param intDeviceIndex The device index to query. The index starts from 0. * @param intDeviceIndex The device index to query. The index starts from 0.
* @returns the unique id for the device or -1 if the device is not found. * @returns the unique id for the device or -1 if the device is not found.
*/ */
int WINAPI devGetDeviceId(int intDeviceIndex){ int WINAPI tdGetDeviceId(int intDeviceIndex){
int intReturn = -1; int intReturn = -1;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -258,7 +258,7 @@ int WINAPI devGetDeviceId(int intDeviceIndex){
* @param intDeviceId The unique id of the device to query * @param intDeviceId The unique id of the device to query
* @returns The name of the device or an empty string if the device is not found. * @returns The name of the device or an empty string if the device is not found.
*/ */
char * WINAPI devGetName(int intDeviceId){ char * WINAPI tdGetName(int intDeviceId){
char* strReturn; char* strReturn;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -274,7 +274,7 @@ char * WINAPI devGetName(int intDeviceId){
return strReturn; return strReturn;
} }
bool WINAPI devSetName(int intDeviceId, const char* strNewName){ bool WINAPI tdSetName(int intDeviceId, const char* strNewName){
bool blnSuccess = false; bool blnSuccess = false;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -287,7 +287,7 @@ bool WINAPI devSetName(int intDeviceId, const char* strNewName){
return blnSuccess; return blnSuccess;
} }
char* WINAPI devGetVendor(int intDeviceId){ char* WINAPI tdGetVendor(int intDeviceId){
char* strReturn = ""; char* strReturn = "";
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -303,7 +303,7 @@ char* WINAPI devGetVendor(int intDeviceId){
return strReturn; return strReturn;
} }
bool WINAPI devSetVendor(int intDeviceId, const char* strVendor){ bool WINAPI tdSetVendor(int intDeviceId, const char* strVendor){
bool blnSuccess = false; bool blnSuccess = false;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -316,7 +316,7 @@ bool WINAPI devSetVendor(int intDeviceId, const char* strVendor){
return blnSuccess; return blnSuccess;
} }
int WINAPI devGetModel(int intDeviceId){ int WINAPI tdGetModel(int intDeviceId){
int intReturn = 0; int intReturn = 0;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -329,7 +329,7 @@ int WINAPI devGetModel(int intDeviceId){
return intReturn; return intReturn;
} }
bool WINAPI devSetModel(int intDeviceId, int intModel){ bool WINAPI tdSetModel(int intDeviceId, int intModel){
bool blnSuccess = false; bool blnSuccess = false;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -342,7 +342,7 @@ bool WINAPI devSetModel(int intDeviceId, int intModel){
return blnSuccess; return blnSuccess;
} }
bool WINAPI devSetArgument(int intDeviceId, const char *strName, const char *strValue){ bool WINAPI tdSetArgument(int intDeviceId, const char *strName, const char *strValue){
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -354,7 +354,7 @@ bool WINAPI devSetArgument(int intDeviceId, const char *strName, const char *str
return false; return false;
} }
const char * WINAPI devGetArgument(int intDeviceId, const char *strName, const char *defaultValue){ const char * WINAPI tdGetArgument(int intDeviceId, const char *strName, const char *defaultValue){
char *strReturn = ""; char *strReturn = "";
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -372,7 +372,7 @@ const char * WINAPI devGetArgument(int intDeviceId, const char *strName, const c
return strReturn; return strReturn;
} }
int WINAPI devAddDevice(){ int WINAPI tdAddDevice(){
int intNewDeviceId = -1; int intNewDeviceId = -1;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -385,7 +385,7 @@ int WINAPI devAddDevice(){
return intNewDeviceId; return intNewDeviceId;
} }
bool WINAPI devRemoveDevice(int intDeviceId){ bool WINAPI tdRemoveDevice(int intDeviceId){
bool blnSuccess = false; bool blnSuccess = false;
try{ try{
TelldusSettings ts; TelldusSettings ts;
@ -408,7 +408,7 @@ bool WINAPI devRemoveDevice(int intDeviceId){
* @sa TELLSTICK_TOGGLE * @sa TELLSTICK_TOGGLE
* @sa TELLSTICK_DIM * @sa TELLSTICK_DIM
*/ */
int WINAPI devMethods(int id){ int WINAPI tdMethods(int id){
int intMethods = 0; int intMethods = 0;
try{ try{
@ -438,7 +438,7 @@ int WINAPI devMethods(int id){
* @sa TELLSTICK_ERROR_METHOD_NOT_SUPPORTED * @sa TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
* @sa TELLSTICK_ERROR_UNKNOWN * @sa TELLSTICK_ERROR_UNKNOWN
*/ */
char * WINAPI devGetErrorString(int intErrorNo) { char * WINAPI tdGetErrorString(int intErrorNo) {
const int numResponses = 5; const int numResponses = 5;
const char *responses[numResponses] = { const char *responses[numResponses] = {
"Success", "Success",

View file

@ -24,29 +24,29 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
TELLSTICK_API int WINAPI devTurnOn(int intDeviceId); TELLSTICK_API int WINAPI tdTurnOn(int intDeviceId);
TELLSTICK_API int WINAPI devTurnOff(int intDeviceId); TELLSTICK_API int WINAPI tdTurnOff(int intDeviceId);
TELLSTICK_API int WINAPI devBell(int intDeviceId); TELLSTICK_API int WINAPI tdBell(int intDeviceId);
TELLSTICK_API int WINAPI devDim(int intDeviceId, unsigned char level); TELLSTICK_API int WINAPI tdDim(int intDeviceId, unsigned char level);
TELLSTICK_API int WINAPI devMethods(int id); TELLSTICK_API int WINAPI tdMethods(int id);
TELLSTICK_API int WINAPI devGetNumberOfDevices(); TELLSTICK_API int WINAPI tdGetNumberOfDevices();
TELLSTICK_API int WINAPI devGetDeviceId(int intDeviceIndex); TELLSTICK_API int WINAPI tdGetDeviceId(int intDeviceIndex);
TELLSTICK_API char * WINAPI devGetErrorString(int intErrorNo); TELLSTICK_API char * WINAPI tdGetErrorString(int intErrorNo);
TELLSTICK_API char * WINAPI devGetName(int intDeviceId); TELLSTICK_API char * WINAPI tdGetName(int intDeviceId);
TELLSTICK_API bool WINAPI devSetName(int intDeviceId, const char* chNewName); TELLSTICK_API bool WINAPI tdSetName(int intDeviceId, const char* chNewName);
TELLSTICK_API char * WINAPI devGetVendor(int intDeviceId); TELLSTICK_API char * WINAPI tdGetVendor(int intDeviceId);
TELLSTICK_API bool WINAPI devSetVendor(int intDeviceId, const char* chNewName); TELLSTICK_API bool WINAPI tdSetVendor(int intDeviceId, const char* chNewName);
TELLSTICK_API int WINAPI devGetModel(int intDeviceId); TELLSTICK_API int WINAPI tdGetModel(int intDeviceId);
TELLSTICK_API bool WINAPI devSetModel(int intDeviceId, int intModel); TELLSTICK_API bool WINAPI tdSetModel(int intDeviceId, int intModel);
TELLSTICK_API const char * WINAPI devGetArgument(int intDeviceId, const char *strName, const char *defaultValue); TELLSTICK_API const char * WINAPI tdGetArgument(int intDeviceId, const char *strName, const char *defaultValue);
TELLSTICK_API bool WINAPI devSetArgument(int intDeviceId, const char *strName, const char* strValue); TELLSTICK_API bool WINAPI tdSetArgument(int intDeviceId, const char *strName, const char* strValue);
TELLSTICK_API int WINAPI devAddDevice(); TELLSTICK_API int WINAPI tdAddDevice();
TELLSTICK_API bool WINAPI devRemoveDevice(int intDeviceId); TELLSTICK_API bool WINAPI tdRemoveDevice(int intDeviceId);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -3,7 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include "TellUsbD101.h" #include "../driver/libtelldus-core/telldus-core.h"
#ifdef __MINGW32__ #ifdef __MINGW32__
#define sleep(x) _sleep((x)*1000) #define sleep(x) _sleep((x)*1000)
#endif #endif
@ -61,14 +61,14 @@ void print_version() {
} }
void print_device( int index ) { void print_device( int index ) {
int intId = devGetDeviceId(index); int intId = tdGetDeviceId(index);
char *name = devGetName(intId); char *name = tdGetName(intId);
printf("%i\t%s\n", intId, name); printf("%i\t%s\n", intId, name);
free(name); free(name);
} }
void list_devices() { void list_devices() {
int intNum = devGetNumberOfDevices(); int intNum = tdGetNumberOfDevices();
printf("Number of devices: %i\n", intNum); printf("Number of devices: %i\n", intNum);
int i = 0; int i = 0;
while (i < intNum) { while (i < intNum) {
@ -80,11 +80,11 @@ void list_devices() {
int find_device( char *device ) { int find_device( char *device ) {
int deviceId = atoi(device); int deviceId = atoi(device);
if (deviceId == 0) { //Try to find the id from the name if (deviceId == 0) { //Try to find the id from the name
int intNum = devGetNumberOfDevices(); int intNum = tdGetNumberOfDevices();
int index = 0; int index = 0;
while (index < intNum) { while (index < intNum) {
int id = devGetDeviceId(index); int id = tdGetDeviceId(index);
char *name = devGetName( id ); char *name = tdGetName( id );
if (strcasecmp(name, device) == 0) { if (strcasecmp(name, device) == 0) {
deviceId = id; deviceId = id;
free(name); free(name);
@ -104,9 +104,9 @@ void switch_device( bool turnOn, char *device ) {
return; return;
} }
char *name = devGetName( deviceId ); char *name = tdGetName( deviceId );
int retval = (turnOn ? devTurnOn( deviceId ) : devTurnOff( deviceId )); int retval = (turnOn ? tdTurnOn( deviceId ) : tdTurnOff( deviceId ));
char *errorString = devGetErrorString(retval); char *errorString = tdGetErrorString(retval);
printf("Turning %s device: %i %s - %s\n", (turnOn ? "on" : "off"), deviceId, name, errorString); printf("Turning %s device: %i %s - %s\n", (turnOn ? "on" : "off"), deviceId, name, errorString);
free(name); free(name);
@ -127,9 +127,9 @@ void dim_device( char *device, int level ) {
return; return;
} }
char *name = devGetName( deviceId ); char *name = tdGetName( deviceId );
int retval = devDim( deviceId, (unsigned char)level ); int retval = tdDim( deviceId, (unsigned char)level );
char *errorString = devGetErrorString(retval); char *errorString = tdGetErrorString(retval);
printf("Dimming device: %i %s to %i - %s\n", deviceId, name, level, errorString); printf("Dimming device: %i %s to %i - %s\n", deviceId, name, level, errorString);
free(name); free(name);
free(errorString); free(errorString);
@ -145,9 +145,9 @@ void bell_device( char *device ) {
return; return;
} }
char *name = devGetName( deviceId ); char *name = tdGetName( deviceId );
int retval = devBell( deviceId ); int retval = tdBell( deviceId );
char *errorString = devGetErrorString(retval); char *errorString = tdGetErrorString(retval);
printf("Sending bell to: %i %s - %s\n", deviceId, name, errorString); printf("Sending bell to: %i %s - %s\n", deviceId, name, errorString);
free(name); free(name);
free(errorString); free(errorString);