From 562c459a44b6a2277f61494b9064642f5ff265eb Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Mon, 3 Dec 2012 10:53:11 +0100 Subject: [PATCH] add functions for manipulating the device_config --- libykpers-1.map | 5 +++++ ykpers.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ ykpers.h | 6 ++++++ 3 files changed, 60 insertions(+) diff --git a/libykpers-1.map b/libykpers-1.map index 5c887c2..56dab36 100644 --- a/libykpers-1.map +++ b/libykpers-1.map @@ -169,5 +169,10 @@ LIBYKPERS_1.10 { ykp_ndef_as_text; yk_check_firmware_version2; yk_set_usb_mode; + ykp_alloc_device_config; + ykp_free_device_config; + ykp_set_device_mode; + ykp_set_device_chalresp_timeout; + ykp_set_device_autoeject_time; # Variables: } LIBYKPERS_1.9; diff --git a/ykpers.c b/ykpers.c index f2dd875..0daf6fe 100644 --- a/ykpers.c +++ b/ykpers.c @@ -500,6 +500,55 @@ int ykp_set_ndef_access_code(YK_NDEF *ndef, unsigned char *access_code) return 1; } +YK_DEVICE_CONFIG *ykp_alloc_device_config(void) +{ + YK_DEVICE_CONFIG *cfg = malloc(sizeof(YK_DEVICE_CONFIG)); + if(cfg) { + memset(cfg, 0, sizeof(YK_DEVICE_CONFIG)); + return cfg; + } + return 0; +} + +int ykp_free_device_config(YK_DEVICE_CONFIG *device_config) +{ + if(device_config) { + free(device_config); + return 1; + } + return 0; +} + +int ykp_set_device_mode(YK_DEVICE_CONFIG *device_config, unsigned char mode) +{ + if(device_config) { + device_config->mode = mode; + return 1; + } + ykp_errno = YKP_EINVAL; + return 0; +} + +int ykp_set_device_chalresp_timeout(YK_DEVICE_CONFIG *device_config, unsigned char timeout) +{ + if(device_config) { + device_config->crTimeout = timeout; + return 1; + } + ykp_errno = YKP_EINVAL; + return 0; +} + +int ykp_set_device_autoeject_time(YK_DEVICE_CONFIG *device_config, unsigned short eject_time) +{ + if(device_config) { + device_config->autoEjectTime = eject_time; + return 1; + } + ykp_errno = YKP_EINVAL; + return 0; +} + static bool vcheck_all(const YKP_CONFIG *cfg) { return true; diff --git a/ykpers.h b/ykpers.h index 4eeec6a..8470944 100644 --- a/ykpers.h +++ b/ykpers.h @@ -74,6 +74,12 @@ int ykp_construct_ndef_text(YK_NDEF *ndef, const char *text, const char *lang, b int ykp_set_ndef_access_code(YK_NDEF *ndef, unsigned char *access_code); int ykp_ndef_as_text(YK_NDEF *ndef, char *text, size_t len); +YK_DEVICE_CONFIG *ykp_alloc_device_config(void); +int ykp_free_device_config(YK_DEVICE_CONFIG *device_config); +int ykp_set_device_mode(YK_DEVICE_CONFIG *device_config, unsigned char mode); +int ykp_set_device_chalresp_timeout(YK_DEVICE_CONFIG *device_config, unsigned char timeout); +int ykp_set_device_autoeject_time(YK_DEVICE_CONFIG *device_config, unsigned short eject_time); + int ykp_set_access_code(YKP_CONFIG *cfg, unsigned char *access_code, size_t len); int ykp_set_fixed(YKP_CONFIG *cfg, unsigned char *fixed, size_t len); int ykp_set_uid(YKP_CONFIG *cfg, unsigned char *uid, size_t len); -- 2.39.5