net_nfc_target_handle_s *handle;
net_nfc_error_e prev_result;
net_nfc_llcp_socket_t incomming_socket;
- ndef_message_s *requester;
- ndef_message_s *selector;
+ net_nfc_ndef_message_s *requester;
+ net_nfc_ndef_message_s *selector;
bool low_power;
void *user_data;
void *payload;
- llcp_app_protocol_e type_app_protocol;
+ net_nfc_llcp_app_protocol_e type_app_protocol;
net_nfc_conn_handover_carrier_type_e type;
} net_nfc_oem_llcp_state_t;
typedef struct _snep_msg_s {
- data_s *data;
+ net_nfc_data_s *data;
int offset;
bool isSegment;
typedef struct _emulMsg_data_s {
net_nfc_record_tnf_e tnf;
- data_s typeName;
- data_s id;
- data_s payload;
+ net_nfc_data_s typeName;
+ net_nfc_data_s id;
+ net_nfc_data_s payload;
bool realRecord;
} emulMsg_data_s;
#define NET_NFC_MAX_LLCP_SOCKET_BUFFER BUFFER_LENGTH_MAX
/* listener callback */
-static target_detection_listener_cb g_emul_controller_target_cb;
-static se_transaction_listener_cb g_emul_controller_se_cb;
-static llcp_event_listener_cb g_emul_controller_llcp_cb;
-static hce_apdu_listener_cb g_emul_controller_hce_cb;
+static net_nfc_target_detection_listener_cb g_emul_controller_target_cb;
+static net_nfc_se_transaction_listener_cb g_emul_controller_se_cb;
+static net_nfc_llcp_event_listener_cb g_emul_controller_llcp_cb;
+static net_nfc_hce_apdu_listener_cb g_emul_controller_hce_cb;
/* for emulator management */
static pthread_t gEmulThread;
static socket_info_s socket_info_array[LLCP_NB_SOCKET_MAX] = {{0}};
static snep_msg_s *Snep_Server_msg;
-static data_s *llcp_server_data = NULL;
+static net_nfc_data_s *llcp_server_data = NULL;
static pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
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)
+static bool _net_nfc_util_init_data(net_nfc_data_s * data, uint32_t length)
{
if (data == NULL || length == 0)
return false;
return true;
}
-static void _net_nfc_util_clear_data(data_s * data)
+static void _net_nfc_util_clear_data(net_nfc_data_s * data)
{
if (data == NULL)
return;
data->length = 0;
}
-static net_nfc_error_e _net_nfc_util_free_record(ndef_record_s * record)
+static net_nfc_error_e _net_nfc_util_free_record(net_nfc_ndef_record_s * record)
{
if (record == NULL)
return NET_NFC_NULL_PARAMETER;
return NET_NFC_OK;
}
-static net_nfc_error_e _net_nfc_util_free_ndef_message(ndef_message_s * msg)
+static net_nfc_error_e _net_nfc_util_free_ndef_message(net_nfc_ndef_message_s * msg)
{
int idx = 0;
- ndef_record_s *prev, *current;
+ net_nfc_ndef_record_s *prev, *current;
if (msg == NULL)
return NET_NFC_NULL_PARAMETER;
return NET_NFC_OK;
}
-static net_nfc_error_e _net_nfc_util_create_record(net_nfc_record_tnf_e recordType, data_s * typeName, data_s * id, data_s * payload, ndef_record_s ** record)
+static net_nfc_error_e _net_nfc_util_create_record(net_nfc_record_tnf_e recordType, net_nfc_data_s * typeName, net_nfc_data_s * id, net_nfc_data_s * payload, net_nfc_ndef_record_s ** record)
{
- ndef_record_s *record_temp = NULL;
+ net_nfc_ndef_record_s *record_temp = NULL;
if (record == NULL)
return NET_NFC_NULL_PARAMETER;
- if (recordType < NET_NFC_RECORD_EMPTY || recordType > NET_NFC_RECORD_UNCHAGNED)
+ if (recordType < NET_NFC_RECORD_EMPTY || recordType > NET_NFC_RECORD_UNCHANGED)
return NET_NFC_OUT_OF_BOUND;
/* empty_tag */
return NET_NFC_INVALID_PARAM;
}
- _nfc_emul_util_alloc_mem(record_temp, sizeof(ndef_record_s));
+ _nfc_emul_util_alloc_mem(record_temp, sizeof(net_nfc_ndef_record_s));
if (record_temp == NULL)
return NET_NFC_ALLOC_FAIL;
// set type name and length and TNF field
return NET_NFC_OK;
}
-static net_nfc_error_e _net_nfc_util_append_record(ndef_message_s * msg, ndef_record_s * record)
+static net_nfc_error_e _net_nfc_util_append_record(net_nfc_ndef_message_s * msg, net_nfc_ndef_record_s * record)
{
if (msg == NULL || record == NULL)
return NET_NFC_NULL_PARAMETER;
DEBUG_MSG("record is added to NDEF message :: count [%d]", msg->recordCount);
} else {
- ndef_record_s *current = NULL;
- ndef_record_s *prev = NULL;
+ net_nfc_ndef_record_s *current = NULL;
+ net_nfc_ndef_record_s *prev = NULL;
// set flag :: this record is FIRST
current = msg->records;
return NET_NFC_OK;
}
-static uint32_t _net_nfc_util_get_record_length(ndef_record_s * Record)
+static uint32_t _net_nfc_util_get_record_length(net_nfc_ndef_record_s * Record)
{
uint32_t RecordLength = 1;
return RecordLength;
}
-static uint32_t _net_nfc_util_get_ndef_message_length(ndef_message_s * message)
+static uint32_t _net_nfc_util_get_ndef_message_length(net_nfc_ndef_message_s * message)
{
- ndef_record_s *current;
+ net_nfc_ndef_record_s *current;
int total = 0;
if (message == NULL)
return total;
}
-static net_nfc_error_e _net_nfc_util_create_ndef_message(ndef_message_s ** ndef_message)
+static net_nfc_error_e _net_nfc_util_create_ndef_message(net_nfc_ndef_message_s ** ndef_message)
{
if (ndef_message == NULL)
return NET_NFC_NULL_PARAMETER;
- _nfc_emul_util_alloc_mem(*ndef_message, sizeof(ndef_message_s));
+ _nfc_emul_util_alloc_mem(*ndef_message, sizeof(net_nfc_ndef_message_s));
if (*ndef_message == NULL)
return NET_NFC_ALLOC_FAIL;
return NET_NFC_OK;
}
-static net_nfc_error_e _net_nfc_util_convert_ndef_message_to_rawdata(ndef_message_s * ndef, data_s * rawdata)
+static net_nfc_error_e _net_nfc_util_convert_ndef_message_to_rawdata(net_nfc_ndef_message_s * ndef, net_nfc_data_s * rawdata)
{
- ndef_record_s *record = NULL;
+ net_nfc_ndef_record_s *record = NULL;
uint8_t *current = NULL;
uint8_t ndef_header;
if (Snep_Server_msg == NULL)
return;
- Snep_Server_msg->data = calloc(1, sizeof(data_s));
+ Snep_Server_msg->data = calloc(1, sizeof(net_nfc_data_s));
if (Snep_Server_msg->data == NULL)
return;
}
-static inline int _create_records_well_known(emulMsg_data_s *record, char *record_payload, ndef_record_h *new_record)
+static inline int _create_records_well_known(emulMsg_data_s *record, char *record_payload, net_nfc_ndef_record_h *new_record)
{
if (!strncmp((char *)record->typeName.buffer, "U", 1)) {
DEBUG_MSG("URI Type ");
- data_s payload_data = {NULL, 0};
+ net_nfc_data_s payload_data = {NULL, 0};
if (record->payload.buffer != NULL) {
payload_data.length = strlen(record_payload) + 1;
memcpy(payload_data.buffer + 1, record->payload.buffer, payload_data.length - 1);
}
- if (_net_nfc_util_create_record(record->tnf, &record->typeName, &record->id, &payload_data, (ndef_record_s**)new_record) != NET_NFC_OK) {
+ if (_net_nfc_util_create_record(record->tnf, &record->typeName, &record->id, &payload_data, (net_nfc_ndef_record_s**)new_record) != NET_NFC_OK) {
DEBUG_ERR_MSG("net_nfc_util_create_record is failed");
return -1;
}
} else if (!strncmp((char *)record->typeName.buffer, "T", 1)) {
DEBUG_MSG("TEXT Type ");
- data_s payload_data = {NULL, 0};
+ net_nfc_data_s payload_data = {NULL, 0};
int offset = 0;
int controll_byte;
memcpy(payload_data.buffer + offset, record->payload.buffer, strlen(record_payload));
}
- if (_net_nfc_util_create_record(record->tnf, &record->typeName, &record->id, &payload_data, (ndef_record_s**)new_record) != NET_NFC_OK) {
+ if (_net_nfc_util_create_record(record->tnf, &record->typeName, &record->id, &payload_data, (net_nfc_ndef_record_s**)new_record) != NET_NFC_OK) {
DEBUG_ERR_MSG("net_nfc_util_create_record is failed");
return -1;
}
return 0;
}
-static inline int _create_records_mime(emulMsg_data_s *record, char *record_payload, ndef_record_h *new_record)
+static inline int _create_records_mime(emulMsg_data_s *record, char *record_payload, net_nfc_ndef_record_h *new_record)
{
FILE *file = NULL;
- data_s filePayload = {NULL, 0};
+ net_nfc_data_s filePayload = {NULL, 0};
/* open file : size limit? 10k? */
file = fopen(record_payload, "r");
/* create record */
int ret = _net_nfc_util_create_record(record->tnf, &record->typeName, &record->id,
- &filePayload, (ndef_record_s **)new_record);
+ &filePayload, (net_nfc_ndef_record_s **)new_record);
_nfc_emul_util_free_mem(filePayload.buffer);
if (ret != NET_NFC_OK) {
DEBUG_MSG("net_nfc_create_record failed[%d]", ret);
_nfc_emul_util_free_mem(record->payload.buffer);
}
-static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_message_s **ndef_message, int record_count)
+static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, net_nfc_ndef_message_s **ndef_message, int record_count)
{
DEBUG_EMUL_BEGIN();
#endif
/* create record */
- ndef_record_h new_record = NULL;
+ net_nfc_ndef_record_h new_record = NULL;
net_nfc_error_e result = NET_NFC_OK;
switch (record.tnf) {
case NET_NFC_RECORD_EMPTY:
result = _net_nfc_util_create_record(NET_NFC_RECORD_EMPTY, &record.typeName,
- &record.id, &record.payload, (ndef_record_s **)&new_record);
+ &record.id, &record.payload, (net_nfc_ndef_record_s **)&new_record);
if (NET_NFC_OK != result) {
DEBUG_MSG("net_nfc_create_record failed[%d]", result);
_create_records_free(&record);
break;
case NET_NFC_RECORD_UNKNOWN:
result = _net_nfc_util_create_record(NET_NFC_RECORD_UNKNOWN, &record.typeName,
- &record.id, &record.payload, (ndef_record_s **)&new_record);
+ &record.id, &record.payload, (net_nfc_ndef_record_s **)&new_record);
if (NET_NFC_OK != result) {
DEBUG_MSG("net_nfc_create_record failed[%d]", result);
_create_records_free(&record);
default:
/* NET_NFC_RECORD_URI or NET_NFC_RECORD_EXTERNAL_RTD */
result = _net_nfc_util_create_record(record.tnf, &record.typeName,
- &record.id, &record.payload, (ndef_record_s **)&new_record);
+ &record.id, &record.payload, (net_nfc_ndef_record_s **)&new_record);
if (NET_NFC_OK != result) {
DEBUG_MSG("net_nfc_create_record failed[%d]", result);
_create_records_free(&record);
}
/* append record to ndef msg */
- if ((result = _net_nfc_util_append_record((ndef_message_s*)*ndef_message, (ndef_record_s *)new_record)) != NET_NFC_OK) {
+ if ((result = _net_nfc_util_append_record((net_nfc_ndef_message_s*)*ndef_message, (net_nfc_ndef_record_s *)new_record)) != NET_NFC_OK) {
DEBUG_MSG("net_nfc_util_append_record failed[%d]", result);
_create_records_free(&record);
return create_record_count;
return true;
}
-static void _net_nfc_store_ndef_message(data_s *data)
+static void _net_nfc_store_ndef_message(net_nfc_data_s *data)
{
char file_name[1024] = {0};
FILE *fp = NULL;
}
}
-static net_nfc_error_e _net_nfc_retrieve_ndef_message(data_s *data)
+static net_nfc_error_e _net_nfc_retrieve_ndef_message(net_nfc_data_s *data)
{
char file_name[1024] = {0};
FILE *fp = NULL;
int retval = true;
net_nfc_error_e result = NET_NFC_OK;
- data_s rawdata = {NULL, 0};
+ net_nfc_data_s rawdata = {NULL, 0};
int record_count = emul_msg->record_count;
return false;
/* create ndef msg */
- ndef_message_h ndef_message = NULL;
+ net_nfc_ndef_message_h ndef_message = NULL;
int ndef_length = 0;
- if ((result = _net_nfc_util_create_ndef_message((ndef_message_s **)&ndef_message)) != NET_NFC_OK)
+ if ((result = _net_nfc_util_create_ndef_message((net_nfc_ndef_message_s **)&ndef_message)) != NET_NFC_OK)
DEBUG_MSG("failed to create ndef message [%d]", result);
/* create records and append it to ndef_msg*/
- emul_msg->record_count = _net_nfc_create_records_from_emulMsg(emul_msg, (ndef_message_s **)&ndef_message, record_count);
+ emul_msg->record_count = _net_nfc_create_records_from_emulMsg(emul_msg, (net_nfc_ndef_message_s **)&ndef_message, record_count);
/* convert ndef msg to raw data */
- ndef_length = _net_nfc_util_get_ndef_message_length((ndef_message_s *)ndef_message);
+ ndef_length = _net_nfc_util_get_ndef_message_length((net_nfc_ndef_message_s *)ndef_message);
if (!ndef_length)
DEBUG_MSG("ndef_message size is zero!");
rawdata.length = ndef_length;
_nfc_emul_util_alloc_mem(rawdata.buffer, ndef_length);
- if ((result = _net_nfc_util_convert_ndef_message_to_rawdata((ndef_message_s*)ndef_message, &rawdata)) != NET_NFC_OK)
+ if ((result = _net_nfc_util_convert_ndef_message_to_rawdata((net_nfc_ndef_message_s*)ndef_message, &rawdata)) != NET_NFC_OK)
DEBUG_MSG("net_nfc_util_convert_ndef_message_to_rawdata is failed![%d]", result);
_net_nfc_store_ndef_message(&rawdata);
target_detected->request_type = NET_NFC_MESSAGE_SERVICE_STANDALONE_TARGET_DETECTED;
target_detected->handle = handle;
- target_detected->devType = _net_nfc_emul_convert_target_type(emul_msg->target_type);
- if (!target_detected->devType) {
- DEBUG_MSG("target_detected->devType is unknown");
+ target_detected->dev_type = _net_nfc_emul_convert_target_type(emul_msg->target_type);
+ if (!target_detected->dev_type) {
+ DEBUG_MSG("target_detected->dev_type is unknown");
_nfc_emul_util_free_mem(target_detected);
return;
}
target_detected->handle->connection_id = current_connection_id++;
- if (target_detected->devType == NET_NFC_NFCIP1_TARGET) {
+ if (target_detected->dev_type == NET_NFC_NFCIP1_TARGET) {
DEBUG_MSG("set llcp connection type. remote device is target");
handle->connection_type = NET_NFC_P2P_CONNECTION_TARGET;
_net_nfc_emul_set_is_p2p_attached(true);
- } else if (target_detected->devType == NET_NFC_NFCIP1_INITIATOR) {
+ } else if (target_detected->dev_type == NET_NFC_NFCIP1_INITIATOR) {
DEBUG_MSG("set llcp connection type. remote device is initiator");
handle->connection_type = NET_NFC_P2P_CONNECTION_INITIATOR;
_net_nfc_emul_set_is_p2p_attached(true);
uint8_t response = (uint8_t)resp_field;
uint8_t version = 0;
uint32_t length_field = 0;
- data_s rawdata = {NULL, 0};
+ net_nfc_data_s rawdata = {NULL, 0};
version = SNEP_MAJOR_VER;
version = (((version << 4) & 0xf0) | (SNEP_MINOR_VER & 0x0f));
static bool _net_nfc_make_llcp_data(emulMsg_s *emul_msg)
{
DEBUG_EMUL_BEGIN();
- data_s rawdata = {NULL, 0};
+ net_nfc_data_s rawdata = {NULL, 0};
_net_nfc_retrieve_ndef_message(&rawdata);
_nfc_emul_util_free_mem(rawdata.buffer);
DEBUG_EMUL_END();
}
-static bool net_nfc_emul_controller_init(net_nfc_error_e *result)
+static int net_nfc_emul_controller_init()
{
- bool ret = true;
-
- if (result == NULL)
- return false;
-
DEBUG_EMUL_BEGIN();
DEBUG_MSG("start stack init ");
DEBUG_MSG("Stack init finished");
g_stack_init_successful = true;
- *result = NET_NFC_OK;
DEBUG_EMUL_END();
- return ret;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_deinit(void)
+static int net_nfc_emul_controller_deinit(void)
{
DEBUG_EMUL_BEGIN();
/* End thread */
if (g_stack_init_successful == false) {
DEBUG_MSG("Already statck is deinitialized");
- return true;
+ return NET_NFC_OK;
}
_net_nfc_emul_controller_stop_thread();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_register_listener(
- target_detection_listener_cb target_detection_listener,
- se_transaction_listener_cb se_transaction_listener,
- llcp_event_listener_cb llcp_event_listener,
- hce_apdu_listener_cb hce_apdu_listener,
- net_nfc_error_e *result)
-{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
+static int net_nfc_emul_controller_register_listener(
+ net_nfc_target_detection_listener_cb target_detection_listener,
+ net_nfc_se_transaction_listener_cb se_transaction_listener,
+ net_nfc_llcp_event_listener_cb llcp_event_listener,
+ net_nfc_hce_apdu_listener_cb hce_apdu_listener)
+{
DEBUG_EMUL_BEGIN();
g_emul_controller_target_cb = target_detection_listener;
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_unregister_listener()
+static int net_nfc_emul_controller_unregister_listener()
{
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_get_firmware_version(data_s **data, net_nfc_error_e *result)
+static int net_nfc_emul_controller_get_firmware_version(net_nfc_data_s **data)
{
- if (data == NULL || result == NULL)
+ if (data == NULL)
return false;
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
- *data = calloc(1, sizeof(data_s));
+ *data = calloc(1, sizeof(net_nfc_data_s));
if (*data == NULL)
return false;
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_check_firmware_version(net_nfc_error_e *result)
+static int net_nfc_emul_controller_check_firmware_version()
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_update_firmware(net_nfc_error_e *result)
+static int net_nfc_emul_controller_update_firmware()
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_get_stack_information(net_nfc_stack_information_s *stack_info, net_nfc_error_e *result)
+static int net_nfc_emul_controller_get_stack_information(net_nfc_stack_information_s *stack_info)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e *result)
+static int net_nfc_emul_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config)
{
int idx;
- bool ret = true;
-
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
+ int ret = NET_NFC_OK;
if (mode == NET_NFC_DISCOVERY_MODE_START) {
mode = NET_NFC_DISCOVERY_MODE_CONFIG;
ret = net_nfc_emul_controller_deinit();
} else if (config == NET_NFC_ALL_ENABLE) {
- net_nfc_error_e err;
-
DEBUG_MSG("Create Thread");
- ret = net_nfc_emul_controller_init(&err);
+ ret = net_nfc_emul_controller_init();
}
}
return ret;
}
-static bool net_nfc_emul_controller_get_secure_element_list(net_nfc_secure_element_info_s *list, int *count, net_nfc_error_e *result)
+static int net_nfc_emul_controller_get_secure_element_list(net_nfc_secure_element_info_s *list, int *count)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e *result)
+static int net_nfc_emul_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_check_target_presence(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_check_target_presence(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
usleep(300 * 1000);
if (_net_nfc_emul_get_is_tag_attached()) {
- return true;
+ return NET_NFC_OK;
} else {
DEBUG_MSG("TAG Detached");
return false;
}
}
-static bool net_nfc_emul_controller_connect(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_connect(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_disconnect(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_disconnect(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
-
// This handle is not useful anymore
__net_nfc_make_invalid_target_handle();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_check_ndef(net_nfc_target_handle_s *handle, uint8_t *ndef_card_state, int *max_data_size, int *real_data_size, net_nfc_error_e *result)
+static int net_nfc_emul_controller_check_ndef(net_nfc_target_handle_s *handle, uint8_t *ndef_card_state, int *max_net_nfc_data_size, int *real_net_nfc_data_size)
{
- data_s rawdata = {NULL, 0};
+ net_nfc_data_s rawdata = {NULL, 0};
- if (result == NULL)
- return false;
+ if (handle == NULL || ndef_card_state == NULL || max_net_nfc_data_size == NULL || real_net_nfc_data_size == NULL)
+ return NET_NFC_NULL_PARAMETER;
- *result = NET_NFC_OK;
-
- if (handle == NULL || ndef_card_state == NULL || max_data_size == NULL || real_data_size == NULL || result == NULL) {
- *result = NET_NFC_NULL_PARAMETER;
- return false;
- }
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
if (_net_nfc_emul_get_is_tag_attached()) {
*ndef_card_state = NET_NFC_NDEF_CARD_READ_WRITE;
- *max_data_size = BUFFER_LENGTH_MAX;
- *real_data_size = rawdata.length;
- DEBUG_MSG("Card State : [%d] MAX data size :[%d] actual data size = [%d]", *ndef_card_state, *max_data_size, *real_data_size);
+ *max_net_nfc_data_size = BUFFER_LENGTH_MAX;
+ *real_net_nfc_data_size = rawdata.length;
+ DEBUG_MSG("Card State : [%d] MAX data size :[%d] actual data size = [%d]", *ndef_card_state, *max_net_nfc_data_size, *real_net_nfc_data_size);
} else {
DEBUG_MSG("target detached");
}
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_make_read_only_ndef(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_make_read_only_ndef(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s *handle, data_s **data, net_nfc_error_e *result)
+static int net_nfc_emul_controller_read_ndef(net_nfc_target_handle_s *handle, net_nfc_data_s **data)
{
- int real_data_size = 0;
- data_s rawdata = {NULL, 0};
+ int result = NET_NFC_OK;
+ int real_net_nfc_data_size = 0;
+ net_nfc_data_s rawdata = {NULL, 0};
DEBUG_EMUL_BEGIN();
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (handle == NULL || data == NULL || result == NULL) {
+ if (handle == NULL || data == NULL) {
DEBUG_ERR_MSG("NET_NFC_NULL_PARAMETER >>>");
- *result = NET_NFC_NULL_PARAMETER;
- return false;
+ return NET_NFC_NULL_PARAMETER;
}
- if (!__net_nfc_is_valide_target_handle(handle)) {
- DEBUG_ERR_MSG("NET_NFC_INVALID_HANDLE >>>");
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
if (!_net_nfc_emul_get_is_tag_attached()) {
DEBUG_ERR_MSG("NET_NFC_NOT_ALLOWED_OPERATION >>>");
- *result = NET_NFC_NOT_ALLOWED_OPERATION;
- return false;
+ return NET_NFC_NOT_ALLOWED_OPERATION;
}
- *result = _net_nfc_retrieve_ndef_message(&rawdata);
- if (*result != NET_NFC_OK) {
+ result = _net_nfc_retrieve_ndef_message(&rawdata);
+ if (result != NET_NFC_OK) {
_nfc_emul_util_free_mem(rawdata.buffer);
return false;
}
- real_data_size = rawdata.length;
+ real_net_nfc_data_size = rawdata.length;
- if (real_data_size == 0) {
- DEBUG_ERR_MSG("read ndef_msg is failed >>> real_data_size is zero");
- *result = NET_NFC_NO_NDEF_MESSAGE;
+ if (real_net_nfc_data_size == 0) {
+ DEBUG_ERR_MSG("read ndef_msg is failed >>> real_net_nfc_data_size is zero");
_nfc_emul_util_free_mem(rawdata.buffer);
- return false;
+ return NET_NFC_NO_NDEF_MESSAGE;
}
- *data = calloc(1, sizeof(data_s));
+ *data = calloc(1, sizeof(net_nfc_data_s));
if (*data == NULL) {
- *result = NET_NFC_ALLOC_FAIL;
_nfc_emul_util_free_mem(rawdata.buffer);
- return false;
+ return NET_NFC_ALLOC_FAIL;
}
- (*data)->length = real_data_size;
- (*data)->buffer = calloc(1, real_data_size);
+ (*data)->length = real_net_nfc_data_size;
+ (*data)->buffer = calloc(1, real_net_nfc_data_size);
if ((*data)->buffer == NULL) {
free(*data);
- *result = NET_NFC_ALLOC_FAIL;
_nfc_emul_util_free_mem(rawdata.buffer);
- return false;
+ return NET_NFC_ALLOC_FAIL;
}
/* copy rawdata to data->buffer */
- memcpy((*data)->buffer, rawdata.buffer, real_data_size);
+ memcpy((*data)->buffer, rawdata.buffer, real_net_nfc_data_size);
_nfc_emul_util_free_mem(rawdata.buffer);
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_write_ndef(net_nfc_target_handle_s *handle, data_s *data, net_nfc_error_e *result)
+static int net_nfc_emul_controller_write_ndef(net_nfc_target_handle_s *handle, net_nfc_data_s *data)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_transceive(net_nfc_target_handle_s *handle,
- net_nfc_transceive_info_s *info, data_s **data, net_nfc_error_e *result)
+static int net_nfc_emul_controller_transceive(net_nfc_target_handle_s *handle,
+ net_nfc_transceive_info_s *info, net_nfc_data_s **data)
{
- bool ret = false;
-
- if (result == NULL)
- return ret;
-
if (info == NULL || info->trans_data.buffer == NULL ||
info->trans_data.length == 0) {
- *result = NET_NFC_INVALID_PARAM;
- return ret;
+ return NET_NFC_INVALID_PARAM;
}
- *result = NET_NFC_OK;
*data = NULL;
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return ret;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return ret;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_format_ndef(net_nfc_target_handle_s *handle, data_s *secure_key, net_nfc_error_e *result)
+static int net_nfc_emul_controller_format_ndef(net_nfc_target_handle_s *handle, net_nfc_data_s *secure_key)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_exception_handler(void)
+static int net_nfc_emul_controller_exception_handler(void)
{
DEBUG_EMUL_BEGIN();
- net_nfc_error_e error;
-
- if (net_nfc_emul_controller_init(&error) == false) {
+ if (net_nfc_emul_controller_init() == false) {
DEBUG_ERR_MSG("exception handler is failed!!");
exit(0xff);
}
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_is_ready(net_nfc_error_e *result)
+static int net_nfc_emul_controller_is_ready()
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return g_stack_init_successful;
+ return NET_NFC_OK;
}
* LLCP definition *
********************/
-static bool net_nfc_emul_controller_llcp_config(net_nfc_llcp_config_info_s *config, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_config(net_nfc_llcp_config_info_s *config)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_check_llcp(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_check_llcp(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_activate_llcp(net_nfc_target_handle_s *handle, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_activate_llcp(net_nfc_target_handle_s *handle)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_create_socket(net_nfc_llcp_socket_t *socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_create_socket(net_nfc_llcp_socket_t *socket, net_nfc_socket_type_e socketType, uint16_t miu, uint8_t rw, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
/* get available socket */
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_bind(net_nfc_llcp_socket_t socket, uint8_t service_access_point)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_listen(net_nfc_target_handle_s *handle, uint8_t *service_access_name, net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_listen(net_nfc_target_handle_s *handle, uint8_t *service_access_name, net_nfc_llcp_socket_t socket, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
/* below accept function does not used. */
-static bool net_nfc_emul_controller_llcp_accept(net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_accept(net_nfc_llcp_socket_t socket, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_connect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_connect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t service_access_point, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_connect_by_url(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t *service_access_name, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_connect_by_url(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, uint8_t *service_access_name, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_send(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_send(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_data_s *data, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_send_to(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, uint8_t service_access_point, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_send_to(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_data_s *data, uint8_t service_access_point, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_recv(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_recv(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_data_s *data, void *user_param)
{
- if (result == NULL || data == NULL)
+ if (data == NULL)
return false;
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_recv_from(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, data_s *data, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_recv_from(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_data_s *data, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_disconnect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_error_e *result, void *user_param)
+static int net_nfc_emul_controller_llcp_disconnect(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, void *user_param)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_socket_close(net_nfc_llcp_socket_t socket,
- net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_socket_close(net_nfc_llcp_socket_t socket)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_reject(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_reject(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket)
{
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_get_remote_config(net_nfc_target_handle_s *handle, net_nfc_llcp_config_info_s *config, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_get_remote_config(net_nfc_target_handle_s *handle, net_nfc_llcp_config_info_s *config)
{
/* In llcp specification ver 1.1, default miu size is 128 */
const uint16_t default_miu = 128;
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_llcp_get_remote_socket_info(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s *option, net_nfc_error_e *result)
+static int net_nfc_emul_controller_llcp_get_remote_socket_info(net_nfc_target_handle_s *handle, net_nfc_llcp_socket_t socket, net_nfc_llcp_socket_option_s *option)
{
/* In llcp specification ver 1.1, default miu size is 128 */
const uint16_t default_miu = 128;
- if (result == NULL)
- return false;
-
- *result = NET_NFC_OK;
-
- if (!__net_nfc_is_valide_target_handle(handle)) {
- *result = NET_NFC_INVALID_HANDLE;
- return false;
- }
+ if (!__net_nfc_is_valide_target_handle(handle))
+ return NET_NFC_INVALID_HANDLE;
DEBUG_EMUL_BEGIN();
DEBUG_EMUL_END();
- return true;
+ return NET_NFC_OK;
}
-
-static bool net_nfc_emul_controller_support_nfc(net_nfc_error_e *result)
+static int net_nfc_emul_controller_support_nfc()
{
- bool ret = false;
struct stat st = {0};
- if (stat("/dev/nfc0", &st) == -1) {
- if (result)
- *result = NET_NFC_NOT_SUPPORTED;
- return ret;
- }
-
- if (result)
- *result = NET_NFC_OK;
-
- ret = true;
-
- return ret;
+ return (stat("/dev/nfc0", &st) == -1) ? NET_NFC_NOT_SUPPORTED : NET_NFC_OK;
}
-static bool net_nfc_emul_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle, net_nfc_error_e *result)
+
+static int net_nfc_emul_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s **handle)
{
DEBUG_ERR_MSG("se open start");
- *result = NET_NFC_OK;
+
__net_nfc_make_valid_target_handle(handle);
DEBUG_ERR_MSG("se_open end");
- return true;
+
+ return NET_NFC_OK;
}
-static bool net_nfc_emul_controller_secure_element_get_atr(net_nfc_target_handle_s *handle,
- data_s **atr, net_nfc_error_e *result)
+
+static int net_nfc_emul_controller_secure_element_get_atr(net_nfc_target_handle_s *handle,
+ net_nfc_data_s **atr)
{
- bool ret = true;
+ int result = NET_NFC_OK;
char buffer[1024];
int length = sizeof(buffer);
- data_s *temp;
+ net_nfc_data_s *temp;
DEBUG_ERR_MSG("se get_atr start");
- *result = NET_NFC_OK;
+
*atr = NULL;
strncpy(buffer, "getatr", sizeof(buffer));
memcpy(temp->buffer, buffer, length);
temp->length = length;
*atr = temp;
- *result = NET_NFC_OK;
+ result = NET_NFC_OK;
} else {
free(temp);
- *result = NET_NFC_ALLOC_FAIL;
- ret = false;
+ result = NET_NFC_ALLOC_FAIL;
}
} else {
- *result = NET_NFC_ALLOC_FAIL;
- ret = false;
+ result = NET_NFC_ALLOC_FAIL;
}
+
DEBUG_ERR_MSG("se get atr end");
- return ret;
+ return result;
}
-static bool net_nfc_emul_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle,
- data_s *command, data_s **response, net_nfc_error_e *result)
+
+static int net_nfc_emul_controller_secure_element_send_apdu(net_nfc_target_handle_s *handle,
+ net_nfc_data_s *command, net_nfc_data_s **response)
{
- bool ret = true;
+ int result = NET_NFC_OK;
char buffer[1024];
int length;
- data_s *temp;
+ net_nfc_data_s *temp;
DEBUG_ERR_MSG("se send apdu start");
- *result = NET_NFC_OK;
*response = NULL;
//buffer response
temp->length = length;
*response = temp;
- *result = NET_NFC_OK;
+ result = NET_NFC_OK;
} else {
free(temp);
- *result = NET_NFC_ALLOC_FAIL;
- ret = false;
+ result = NET_NFC_ALLOC_FAIL;
}
} else {
- *result = NET_NFC_ALLOC_FAIL;
- ret = false;
+ result = NET_NFC_ALLOC_FAIL;
}
DEBUG_ERR_MSG("se send apdu end");
- return ret;
+ return result;
}
-static bool net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s *handle,
- net_nfc_error_e *result)
+
+static int net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s *handle)
{
DEBUG_ERR_MSG("se close start");
- *result = NET_NFC_OK;
- return true;
DEBUG_ERR_MSG("se close end");
+
+ return NET_NFC_OK;
}
static int nfc_backend_init(void **data)
EXPORT hal_backend hal_backend_nfc_data = {
.name = "nfc-backend",
.vendor = "Samsung",
- .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
.init = nfc_backend_init,
.exit = nfc_backend_exit,
.major_version = 1,