#include <sys/time.h>
#include <libgen.h>
-// below define should define before blog.h
-#define LOG_TAG "NFC_PLUGIN_EMUL"
-
-#include <dlog.h>
+#ifdef FEATURE_DLOG
+ #define LOG_TAG "HAL_BACKEND_NFC_PLUGIN_EMUL"
+ #include <dlog.h>
+ #define _D(fmt, args...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
+ #define _I(fmt, args...) dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
+ #define _W(fmt, args...) dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
+ #define _E(fmt, args...) dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
+#else
+ #define _D(x, ...)
+ #define _I(x, ...)
+ #define _W(x, ...)
+ #define _E(x, ...)
+#endif
#define LOG_COLOR_RED "\033[0;31m"
#define LOG_COLOR_GREEN "\033[0;32m"
#define DEBUG_MSG_PRINT_BUFFER(buffer, length) \
do {\
int i = 0;\
- LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
+ _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
for (; i < length; i++)\
- LOGE(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\
- LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
+ _D(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\
+ _D(LOG_COLOR_BLUE""LOG_COLOR_END);\
} while (0)
#define DEBUG_MSG_PRINT_BUFFER_CHAR(buffer, length) \
do {\
int i = 0;\
- LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
+ _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
for (; i < length; i++)\
- LOGE(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\
- LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
+ _D(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\
+ _D(LOG_COLOR_BLUE""LOG_COLOR_END);\
} while (0)
#define DEBUG_MSG(format, args...) \
do {\
- LOGE(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
+ _D(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
} while (0)
#define DEBUG_ERR_MSG(format, args...) \
do {\
- LOGE(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
+ _E(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
} while (0)
#define DEBUG_EMUL_BEGIN() \
do {\
- LOGE(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\
+ _D(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\
} while (0)
#define DEBUG_EMUL_END() \
do {\
- LOGE(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\
+ _D(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\
} while (0)
#define PROFILING(str) \
gettimeofday(&mytime, NULL);\
char time_string[128] = {0,};\
sprintf(time_string, "%d.%4d", mytime.tv_sec, mytime.tv_usec);\
- LOGE(str);\
- LOGE("\t time = [%s]", time_string);\
+ _D(str);\
+ _D("\t time = [%s]", time_string);\
} while (0)
#endif
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/epoll.h>
-#include <vconf.h>
+#include <string.h>
#include <arpa/inet.h>
#include <hal-nfc-interface.h>
static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int line)
{
if (mem == NULL || *mem == NULL) {
- LOGE("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line);
+ DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line);
return;
}
free(*mem);
static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsigned int line)
{
if (mem == NULL || size <= 0) {
- LOGE("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line);
+ DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line);
return;
}
DEBUG_MSG("size to malloc() = [%d]", size);
if (*mem != NULL)
- LOGE("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line);
+ DEBUG_ERR_MSG("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line);
*mem = calloc(1, size);
if (NULL == *mem)
- LOGE("FILE: %s, LINE:%d, Allocation is failed", filename, line);
+ DEBUG_ERR_MSG("FILE: %s, LINE:%d, Allocation is failed", filename, line);
}
static bool _net_nfc_util_init_data(data_s * data, uint32_t length)
memcpy(record.payload.buffer, record_payload, sizeof(record.payload.buffer) - 1);
#ifndef __EMUL_DEBUG__
- DEBUG_ERR_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>");
+ DEBUG_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>");
DEBUG_MSG("TNF >>>>[%d]", record.tnf);
- LOGE("type_name >>>>[%s]", type_name);
- LOGE("record_id >>>>[%s]", record_id);
+ DEBUG_MSG("type_name >>>>[%s]", type_name);
+ DEBUG_MSG("record_id >>>>[%s]", record_id);
DEBUG_MSG("record_payload >>>>[%s]", record_payload);
- DEBUG_ERR_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>");
+ DEBUG_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>");
#endif
/* create record */
/* make file name */
snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME);
- LOGE("file path : %s", file_name);
+ DEBUG_MSG("file path : %s", file_name);
/* open file for poll */
emulMsg_file_fd = open(file_name, O_RDONLY | O_NONBLOCK);
/* make file name */
snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME);
- LOGE("file path : %s", file_name);
+ DEBUG_MSG("file path : %s", file_name);
time(&curTime);
DEBUG_MSG("Start Current Time [%ld]", (unsigned long)curTime);
static int nfc_backend_init(void **data)
{
- hal_backend_nfc_funcs *nfc_funcs;
+ hal_backend_nfc_funcs *nfc_funcs;
- nfc_funcs = calloc(1, sizeof(hal_backend_nfc_funcs));
- if (!nfc_funcs)
- return -ENOMEM;
+ if (!data) {
+ _E("data is NULL");
+ return -EINVAL;
+ }
+
+ nfc_funcs = *(hal_backend_nfc_funcs **)data;
+ if (!nfc_funcs) {
+ _E("nfc_funcs is NULL");
+ return -EINVAL;
+ }
nfc_funcs->start = net_nfc_emul_controller_init;
nfc_funcs->stop = net_nfc_emul_controller_deinit;
EXPORT hal_backend hal_backend_nfc_data = {
.name = "nfc-backend",
- .vendor = "Emulator",
+ .vendor = "Samsung",
.abi_version = HAL_ABI_VERSION_TIZEN_6_5,
.init = nfc_backend_init,
.exit = nfc_backend_exit,
+ .major_version = 1,
+ .minor_version = 0,
};