char url[] = "samsung.com";
ndef_record_h record = NULL;
ndef_message_h msg = NULL;
- int length = 0;
+ uint32_t length = 0;
net_nfc_create_uri_type_record(&record, url, NET_NFC_SCHEMA_HTTPS_WWW);
Name: nfc-manager
Summary: NFC framework manager
-Version: 0.0.50
+Version: 0.0.51
Release: 0
Group: libs
License: Flora Software License
*/
net_nfc_error_e net_nfc_get_atr_sync(net_nfc_target_handle_h handle, data_h *atr);
+/**
+ set card emulation mode of secure element
+
+ \par Sync (or) Async: Sync
+ This is a Synchronous API
+
+ @param[in] se_mode the mode of card emulation
+
+ @return return the result of the calling the function
+
+ @exception NET_NFC_INVALID_PARAM invalid
+
+*/
+net_nfc_error_e net_nfc_set_card_emulation_mode_sync(net_nfc_card_emulation_mode_t se_mode);
+
+
+/**
+ set type of secure element
+
+ \par Sync (or) Async: Sync
+ This is a Synchronous API
+
+ @param[in] se_type the type of secure element
+
+ @return return the result of the calling the function
+
+ @exception NET_NFC_INVALID_PARAM invalid
+
+*/
+net_nfc_error_e net_nfc_set_secure_element_type_sync(net_nfc_se_type_e se_type);
+
#ifdef __cplusplus
}
#endif
*/
-net_nfc_error_e net_nfc_get_ndef_message_byte_length(ndef_message_h ndef_message, int * length) ;
+net_nfc_error_e net_nfc_get_ndef_message_byte_length(ndef_message_h ndef_message, uint32_t *length) ;
/**
Append a record to ndef message structure.
This API help to create NDEF message and it control Record flags to follow the NDEF forum specification
}
break;
+ case NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED :
+ {
+ if (client_cb != NULL)
+ {
+ client_cb(msg->response_type, NET_NFC_OK, NULL, NULL, NULL);
+ }
+ }
+ break;
+
case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
{
DEBUG_CLIENT_MSG("handle = [0x%p]", ((net_nfc_response_open_internal_se_t *)(msg->detail_message))->handle);
info.aid = se_event->aid;
info.param = se_event->param;
+ info.se_type = se_event->se_type;
+ info.fg_dispatch = se_event->fg_dispatch;
+ info.focus_app_pid = se_event->focus_app_pid;
if (client_cb != NULL)
client_cb(msg->response_type, NET_NFC_OK, (void *)&info, client_context->register_user_param, NULL);
case NET_NFC_MESSAGE_SE_TYPE_CHANGED :
break;
+ case NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE :
+ {
+ net_nfc_response_se_change_card_emulation_t *response
+ = (net_nfc_response_se_change_card_emulation_t *)msg->detail_message;
+
+ /* return */
+ result = response->result;
+ }
+ break;
+
case NET_NFC_MESSAGE_OPEN_INTERNAL_SE :
{
net_nfc_response_open_internal_se_t *response = (net_nfc_response_open_internal_se_t *)msg->detail_message;
#define NET_NFC_EXPORT_API __attribute__((visibility("default")))
#endif
+NET_NFC_EXPORT_API
+net_nfc_error_e net_nfc_set_card_emulation_mode_sync(
+ net_nfc_card_emulation_mode_t se_mode)
+{
+ net_nfc_error_e ret = NET_NFC_OK;
+ net_nfc_request_se_change_card_emulation_t request = { 0, };
+
+ if (se_mode < NET_NFC_SE_TYPE_NONE || se_mode > NET_NFC_SE_TYPE_UICC)
+ {
+ return NET_NFC_INVALID_PARAM;
+ }
+
+ request.length = sizeof(net_nfc_request_se_change_card_emulation_t);
+ request.request_type = NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE;
+ request.se_mode = se_mode;
+
+ ret = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+
+ if (ret != NET_NFC_OK)
+ DEBUG_ERR_MSG("net_nfc_set_card_emulation_mode_sync failed [%d]", ret);
+
+ return ret;
+}
+
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type_sync(
+ net_nfc_se_type_e se_type)
+{
+ net_nfc_error_e ret = NET_NFC_OK;
+ net_nfc_request_set_se_t request = { 0, };
+
+ if (se_type < NET_NFC_SE_TYPE_NONE || se_type > NET_NFC_SE_TYPE_UICC)
+ {
+ return NET_NFC_INVALID_PARAM;
+ }
+
+ request.length = sizeof(net_nfc_request_set_se_t);
+ request.request_type = NET_NFC_MESSAGE_SET_SE;
+ request.se_type = se_type;
+
+ ret = net_nfc_client_send_request_sync((net_nfc_request_msg_t *)&request, NULL);
+ if (ret != NET_NFC_OK)
+ DEBUG_ERR_MSG("net_nfc_set_secure_element_type_sync failed [%d]", ret);
+
+ return ret;
+}
+
+
NET_NFC_EXPORT_API net_nfc_error_e net_nfc_set_secure_element_type(net_nfc_se_type_e se_type, void *trans_param)
{
net_nfc_error_e ret;
}
break;
+ case NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE :
+ {
+ net_nfc_response_se_change_card_emulation_t *resp_detail = NULL;
+ int res = 0;
+
+ DEBUG_CLIENT_MSG("Client Receive the NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE");
+
+ res = __net_nfc_client_read_util((void **)&resp_detail,
+ sizeof(net_nfc_response_se_change_card_emulation_t));
+ if (res != 1)
+ {
+ _net_nfc_util_free_mem(resp_msg);
+ return NULL;
+ }
+ resp_msg->detail_message = resp_detail;
+
+ }
+ break;
+
+ case NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED :
+ {
+ net_nfc_response_notify_t *resp_detail = NULL;
+ int res = 0;
+
+ DEBUG_CLIENT_MSG("Client Receive the NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED");
+
+ res = __net_nfc_client_read_util((void **)&resp_detail, sizeof(net_nfc_response_notify_t));
+ if (res != 1)
+ {
+ _net_nfc_util_free_mem(resp_msg);
+ return NULL;
+ }
+ resp_msg->detail_message = resp_detail;
+ }
+ break;
+
case NET_NFC_MESSAGE_TRANSCEIVE :
{
net_nfc_response_transceive_t *resp_detail = NULL;
NET_NFC_EXPORT_API net_nfc_error_e net_nfc_create_rawdata_from_ndef_message (ndef_message_h ndef_message, data_h* rawdata)
{
- int count;
+ uint32_t count;
net_nfc_error_e result;
data_h tmp_data;
}
-NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_ndef_message_byte_length(ndef_message_h ndef_message, int * length)
+NET_NFC_EXPORT_API net_nfc_error_e net_nfc_get_ndef_message_byte_length(ndef_message_h ndef_message, uint32_t *length)
{
if (ndef_message == NULL || length == NULL){
return NET_NFC_NULL_PARAMETER;
NET_NFC_MESSAGE_TAG_DETACHED, /**< Type: Notify Event, <br> When a tag or SE is disappeared, you got this event.
<br> The data contains the target info , need to cast to net_nfc_target_info_h but it does not have detail target info
<br> please, do not use "net_nfc_get_tag_info_keys" when you got this event*/
- NET_NFC_MESSAGE_FORMAT_NDEF, /**< Type: Response Event <br> After complete "net_nfc_format_ndef", this event is delivered */
+ /*10*/NET_NFC_MESSAGE_FORMAT_NDEF, /**< Type: Response Event <br> After complete "net_nfc_format_ndef", this event is delivered */
NET_NFC_MESSAGE_LLCP_DISCOVERED,/**< Type: Notify Event <br> When LLCP is discovered and remote device is support llcp, you receive this event
<br> data pointer contains the remote llcp configuration info. Cast to net_nfc_llcp_config_info_h*/
NET_NFC_MESSAGE_P2P_DETACHED, /**< Type: Notify Event <br> When LLCP is de-activated by removing the device, you receive this event*/
NET_NFC_MESSAGE_SE_START_TRANSACTION, /**< Type: Notify Event, indicates external reader start transaction*/
NET_NFC_MESSAGE_SE_END_TRANSACTION, /**< Type: Notify Event, indicates external reader end transaction*/
NET_NFC_MESSAGE_SE_TYPE_TRANSACTION, /**< Type: Notify Event, Indicates external reader trying to access secure element */
- NET_NFC_MESSAGE_SE_CONNECTIVITY, /**< Type: Notify Event, This event notifies the terminal host that it shall send a connectivity event from UICC */
+ /*20*/NET_NFC_MESSAGE_SE_CONNECTIVITY, /**< Type: Notify Event, This event notifies the terminal host that it shall send a connectivity event from UICC */
NET_NFC_MESSAGE_SE_FIELD_ON, /**< Type: Notify Event, indicates external reader field is on*/
NET_NFC_MESSAGE_SE_FIELD_OFF, /**< Type: Notify Event, indicates external reader field is off*/
NET_NFC_MESSAGE_SE_TYPE_CHANGED, /**< Type: Notify Event, indicates secure element type is changed*/
+ NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED, /**< Type: Notify Event, indicates card emulation mode is changed*/
NET_NFC_MESSAGE_CONNECTION_HANDOVER, /**< Type: Response Event. <br> The result of connection handover. If it has been completed successfully, this event will include the information of alternative carrier. */
NET_NFC_MESSAGE_GET_SE,
NET_NFC_MESSAGE_OPEN_INTERNAL_SE,
NET_NFC_MESSAGE_CLOSE_INTERNAL_SE,
- NET_NFC_MESSAGE_SEND_APDU_SE,
+ /*30*/NET_NFC_MESSAGE_SEND_APDU_SE,
NET_NFC_MESSAGE_GET_ATR_SE,
+ NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE,
NET_NFC_GET_SERVER_STATE,
NET_NFC_MESSAGE_SIM_TEST,
- NET_NFC_MESSAGE_INIT,/*31*/
+ NET_NFC_MESSAGE_INIT,
NET_NFC_MESSAGE_DEINIT,
NET_NFC_MESSAGE_PRBS_TEST,
typedef enum
{
+ NET_NFC_CARD_EMELATION_ENABLE = 0,
+ NET_NFC_CARD_EMULATION_DISABLE,
+}
+net_nfc_card_emulation_mode_t;
+
+typedef enum
+{
NET_NFC_SIGN_TYPE_NO_SIGN = 0,
NET_NFC_SIGN_TYPE_PKCS_1,
NET_NFC_SIGN_TYPE_PKCS_1_V_1_5,
data_s raw_data;
} net_nfc_target_info_s;
+typedef enum _net_nfc_secure_element_type_e
+{
+ SECURE_ELEMENT_TYPE_INVALID = 0x00, /**< Indicates SE type is Invalid */
+ SECURE_ELEMENT_TYPE_ESE = 0x01, /**< Indicates SE type is SmartMX */
+ SECURE_ELEMENT_TYPE_UICC = 0x02, /**<Indicates SE type is UICC */
+ SECURE_ELEMENT_TYPE_UNKNOWN = 0x03 /**< Indicates SE type is Unknown */
+} net_nfc_secure_element_type_e;
+
typedef struct _net_nfc_se_event_info_s
{
data_s aid;
data_s param;
+ bool fg_dispatch;
+ pid_t focus_app_pid;
+ net_nfc_secure_element_type_e se_type;
}net_nfc_se_event_info_s;
typedef struct _net_nfc_transceive_info_s
net_nfc_target_handle_s *handle;
} net_nfc_request_get_atr_t;
+typedef struct _net_nfc_request_se_change_card_emulation_t
+{
+ NET_NFC_REQUEST_MSG_HEADER
+
+ void *trans_param;
+ uint8_t se_mode;
+} net_nfc_request_se_change_card_emulation_t;
+
typedef struct _net_nfc_request_connection_handover_t
{
NET_NFC_REQUEST_MSG_HEADER
data_s aid;
data_s param;
+ bool fg_dispatch;
+ pid_t focus_app_pid;
+ net_nfc_secure_element_type_e se_type;
} net_nfc_response_se_event_t;
typedef struct _net_nfc_response_get_current_tag_info_t
void *trans_param;
} net_nfc_response_get_se_t;
+typedef struct _net_nfc_response_se_change_card_emulation_t
+{
+ NET_NFC_RESPONSE_MSG_HEADER
+
+ uint8_t se_mode;
+ void *trans_param;
+} net_nfc_response_se_change_card_emulation_t;
+
typedef struct _net_nfc_response_open_internal_se_t
{
NET_NFC_RESPONSE_MSG_HEADER
NET_NFC_DISCOVERY_MODE_RESUME,
} net_nfc_discovery_mode_e;
-typedef enum _net_nfc_secure_element_type_e
-{
- SECURE_ELEMENT_TYPE_INVALID = 0x00, /**< Indicates SE type is Invalid */
- SECURE_ELEMENT_TYPE_ESE = 0x01, /**< Indicates SE type is SmartMX */
- SECURE_ELEMENT_TYPE_UICC = 0x02, /**<Indicates SE type is UICC */
- SECURE_ELEMENT_TYPE_UNKNOWN = 0x03 /**< Indicates SE type is Unknown */
-} net_nfc_secure_element_type_e;
-
typedef enum _net_nfc_secure_element_state_e
{
SECURE_ELEMENT_ACTIVE_STATE = 0x00, /**< state of the SE is active */
void net_nfc_app_util_clean_storage(char* src_path);
bool net_nfc_app_util_is_dir(const char* path_name);
int net_nfc_app_util_appsvc_launch(const char *operation, const char *uri, const char *mime, const char *data);
-int net_nfc_app_util_launch_se_transaction_app(uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len);
+int net_nfc_app_util_launch_se_transaction_app(net_nfc_secure_element_type_e se_type,
+ uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len);
int net_nfc_app_util_encode_base64(uint8_t *buffer, uint32_t buf_len, char *result, uint32_t max_result);
int net_nfc_app_util_decode_base64(const char *buffer, uint32_t buf_len, uint8_t *result, uint32_t *res_len);
bool net_nfc_app_util_check_launch_state();
+pid_t net_nfc_app_util_get_focus_app_pid();
#endif
net_nfc_target_handle_s *current_ese_handle;
void *open_request_trans_param;
uint8_t type;
+ uint8_t return_type;
uint8_t mode;
}
net_nfc_se_setting_t;
void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg);
void net_nfc_service_se_get_se(net_nfc_request_msg_t *msg);
void net_nfc_service_se_cleanup();
+void net_nfc_service_se_change_card_emulation_mode(net_nfc_request_msg_t *req_msg);
#endif
*length = current / 2;
}
-int net_nfc_app_util_launch_se_transaction_app(uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len)
+int net_nfc_app_util_launch_se_transaction_app(net_nfc_secure_element_type_e se_type,
+ uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len)
{
int result;
bundle *bd = NULL;
char aid_string[1024] = { 0, };
_binary_to_string(aid, aid_len, temp_string, sizeof(temp_string));
- snprintf(aid_string, sizeof(aid_string), "nfc://secure/aid/%s", temp_string);
+ switch(se_type)
+ {
+ case SECURE_ELEMENT_TYPE_UICC:
+ snprintf(aid_string, sizeof(aid_string), "nfc://secure/SIM1/aid/%s", temp_string);
+ break;
+ case SECURE_ELEMENT_TYPE_ESE:
+ snprintf(aid_string, sizeof(aid_string), "nfc://secure/eSE/aid/%s", temp_string);
+ break;
+ default:
+ snprintf(aid_string, sizeof(aid_string), "nfc://secure/aid/%s", temp_string);
+ break;
+ }
DEBUG_SERVER_MSG("aid_string : %s", aid_string);
appsvc_set_uri(bd, aid_string);
}
return ret;
}
-static pid_t _net_nfc_app_util_get_focus_app_pid()
+pid_t net_nfc_app_util_get_focus_app_pid()
{
Ecore_X_Window focus;
pid_t pid;
net_nfc_launch_popup_state_e popup_state;
bool result = false;
- focus_app_pid = _net_nfc_app_util_get_focus_app_pid();
+ focus_app_pid = net_nfc_app_util_get_focus_app_pid();
popup_state = net_nfc_server_get_client_popup_state(focus_app_pid);
}
break;
+ case NET_NFC_MESSAGE_CARD_EMULATION_CHANGE_SE :
+ {
+ net_nfc_service_se_change_card_emulation_mode(req_msg);
+ }
+ break;
+
case NET_NFC_MESSAGE_P2P_SEND :
{
net_nfc_request_p2p_send_t *exchanger = (net_nfc_request_p2p_send_t *)req_msg;
void net_nfc_service_se_set_se_type(uint8_t type)
{
+ g_se_setting.return_type = g_se_setting.type;
g_se_setting.type = type;
}
+uint8_t net_nfc_service_se_get_return_se_mode()
+{
+ return g_se_setting.return_type;
+}
+
uint8_t net_nfc_service_se_get_se_mode()
{
return g_se_setting.mode;
g_se_setting.mode = mode;
}
+net_nfc_error_e net_nfc_service_se_disable_card_emulation()
+{
+ net_nfc_error_e result;
+
+ net_nfc_service_se_set_se_type(SECURE_ELEMENT_TYPE_INVALID);
+ net_nfc_service_se_set_se_mode(SECURE_ELEMENT_OFF_MODE);
+
+ /*turn off ESE*/
+ net_nfc_controller_set_secure_element_mode(
+ SECURE_ELEMENT_TYPE_ESE,
+ SECURE_ELEMENT_OFF_MODE,
+ &result);
+
+ /*turn off UICC*/
+ net_nfc_controller_set_secure_element_mode(
+ SECURE_ELEMENT_TYPE_UICC,
+ SECURE_ELEMENT_OFF_MODE,
+ &result);
+
+ return NET_NFC_OK;
+}
+
net_nfc_error_e net_nfc_service_se_change_se(uint8_t type)
{
net_nfc_error_e result = NET_NFC_OK;
bool net_nfc_service_se_transaction_receive(net_nfc_request_msg_t* msg)
{
bool res = true;
+ bool fg_dispatch;
+ pid_t focus_app_pid;
+ net_nfc_secure_element_type_e se_type;
net_nfc_request_se_event_t *se_event = (net_nfc_request_se_event_t *)msg;
if (se_event->request_type == NET_NFC_MESSAGE_SE_START_TRANSACTION)
{
DEBUG_SERVER_MSG("launch se app");
- net_nfc_app_util_launch_se_transaction_app(se_event->aid.buffer,
+ se_type = net_nfc_service_se_get_se_type();
+ fg_dispatch = net_nfc_app_util_check_launch_state();
+ focus_app_pid = net_nfc_app_util_get_focus_app_pid();
+
+ res = net_nfc_app_util_launch_se_transaction_app(se_type, se_event->aid.buffer,
se_event->aid.length, se_event->param.buffer, se_event->param.length);
DEBUG_SERVER_MSG("launch se app end");
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_se_event_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_se_event_t);
+ resp.flags = se_event->flags;
+ resp.result = res;
+ resp.aid = se_event->aid;
+ resp.param = se_event->param;
+ resp.fg_dispatch = fg_dispatch;
+ resp.focus_app_pid = focus_app_pid;
+ resp.se_type = se_type;
+
+ net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_START_TRANSACTION,
+ (void *)&resp, sizeof(net_nfc_response_se_event_t), NULL);
+ }
}
return res;
}
}
+void net_nfc_service_se_change_card_emulation_mode(net_nfc_request_msg_t *msg)
+{
+ bool isModeChange = false;
+ uint8_t current_mode, return_mode;
+ net_nfc_error_e result = NET_NFC_OK;
+ net_nfc_request_se_change_card_emulation_t *detail
+ = (net_nfc_request_se_change_card_emulation_t *)msg;
+
+ current_mode = net_nfc_service_se_get_se_mode();
+
+ if(detail->se_mode == SECURE_ELEMENT_ACTIVE_STATE
+ && current_mode == SECURE_ELEMENT_TYPE_INVALID)
+ {
+ return_mode = net_nfc_service_se_get_return_se_mode();
+ result = net_nfc_service_se_change_se(return_mode);
+ isModeChange = true;
+ }
+ else if(detail->se_mode == SECURE_ELEMENT_INACTIVE_STATE
+ && current_mode != SECURE_ELEMENT_TYPE_INVALID)
+ {
+ result = net_nfc_service_se_disable_card_emulation();
+ isModeChange = true;
+ }
+
+ if (net_nfc_server_check_client_is_running(msg->client_fd))
+ {
+ net_nfc_response_se_change_card_emulation_t resp = { 0 };
+
+ resp.length = sizeof(net_nfc_response_se_change_card_emulation_t);
+ resp.flags = detail->flags;
+ resp.user_param = detail->user_param;
+ resp.trans_param = detail->trans_param;
+ resp.result = result;
+ resp.se_mode = detail->se_mode;
+
+ net_nfc_send_response_msg(msg->client_fd, msg->request_type,
+ (void *)&resp, sizeof(net_nfc_response_se_change_card_emulation_t), NULL);
+ }
+
+ if(isModeChange)
+ {
+ net_nfc_response_notify_t noti_se = { 0, };
+
+ net_nfc_broadcast_response_msg(NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED,
+ (void *)¬i_se, sizeof(net_nfc_response_notify_t), NULL);
+ }
+}
+
void net_nfc_service_se_set_se(net_nfc_request_msg_t *msg)
{
#if 1