NFC_SE_EVENT_FIELD_ON, /**< When the CLF(Contactless Front-end) detects a RF field, the card RF gate sends the event #NFC_SE_EVENT_FIELD_ON to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_ON on all open pipes to these gates.Next the CLF starts the initialization and anti-collision process as defined in ISO/IEC 14443-3 [6]*/
NFC_SE_EVENT_FIELD_OFF, /**< When the CLF(Contactless Front-end) detects that the RF field is off, the card RF gate shall send #NFC_SE_EVENT_FIELD_OFF to the card application gate.\nWhen there are multiple open card RF gates the CLF shall send the #NFC_SE_EVENT_FIELD_OFF to one gate only.*/
NFC_SE_EVENT_TRANSACTION, /**< This event notifies , external reader trys to access secure element */
- NFC_SE_EVENT_SE_TYPE_CHANGED /**< This event notifies, changing the emulated secure element type */
+ NFC_SE_EVENT_SE_TYPE_CHANGED, /**< This event notifies, changing the emulated secure element type */
+ NFC_SE_EVENT_SE_CARD_EMULATION_CHANGED
} nfc_se_event_e;
/**
} nfc_se_type_e;
/**
+ * * @brief Enumerations for NFC Card Emulation Mode type
+ * * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
+ * */
+typedef enum{
+ NFC_SE_CARD_EMULATION_MODE_OFF = 0x00, /**< Card Emulation mode OFF */
+ NFC_SE_CARD_EMULATION_MODE_ON = 0x01, /**< Card Emulation mode ON */
+} nfc_se_card_emulation_mode_type_e;
+
+/**
* @brief Enumerations for NFC AC(Alternative Carrier)
* @ingroup CAPI_NETWORK_NFC_P2P_MODULE
*/
* @remarks This event notifies , external reader trys to access secure element.
* @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
*
+ * @param [in] se type
* @param [in] aid Application Id, specified in ISO/IEC 7816-4
* @param [in] aid_size The size of aid (5~16)
* @param [in] param The parameter list, specified in ISO/IEC 8825-1
* @see nfc_manager_set_se_transaction_event_cb()
* @see nfc_manager_unset_se_transaction_event_cb()
*/
-typedef void (*nfc_se_transaction_event_cb)(unsigned char* aid, int aid_size , unsigned char* param, int param_size, void *user_data);
+typedef void (*nfc_se_transaction_event_cb)(nfc_se_type_e se_type, unsigned char* aid, int aid_size , unsigned char* param, int param_size, void *user_data);
*
* @see nfc_manager_set_activation()
*/
+
bool nfc_manager_is_supported(void);
/**
* @brief Registers a callback function for receiving Secure Element (SIM/UICC(Universal Integrated Circuit Card)) transaction event(#NFC_SE_EVENT_TRANSACTION) data.
* @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
*
+ * @param [in] se_type The type os secure element
* @param [in] callback The callback function called when occurred SE transaction event.
* @param [in] user_data The user data to be passed to the callback function
*
* @see nfc_se_transaction_event_cb()
* @see nfc_manager_unset_se_transaction_event_cb()
*/
-int nfc_manager_set_se_transaction_event_cb(nfc_se_transaction_event_cb callback, void *user_data);
+int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type,
+ nfc_se_transaction_event_cb callback, void *user_data);
/**
* @brief Unregisters the callback function.
* @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
*
+ * @param [in] se_type The type of secure element.
+ *
* @see nfc_se_transaction_event_cb()
* @see nfc_manager_set_se_transaction_event_cb()
*/
-void nfc_manager_unset_se_transaction_event_cb(void);
+void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type);
/**
* @brief Gets NDEF message cached when the tag is detected or when data received from NFC peer-to-peer target.
* @retval #NFC_ERROR_NONE Successful
* @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
*/
-int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, int *size);
+int nfc_ndef_record_get_payload(nfc_ndef_record_h record, unsigned char ** payload, unsigned int *size);
/**
* @brief Gets record type.
* @see nfc_ndef_message_destroy()
* @see nfc_ndef_message_get_rawdata()
*/
-int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message, const unsigned char *rawdata, int rawdata_size);
+int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h *ndef_message,
+ const unsigned char *rawdata, unsigned int rawdata_size);
/**
* @brief Destroys NDEF message handle
*
* @see nfc_ndef_message_create_from_rawdata()
*/
-int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message, unsigned char **rawdata, int *rawdata_size);
+int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message,
+ unsigned char **rawdata, unsigned int *rawdata_size);
/**
* @brief Appends a record into NDEF message
#include <vconf.h>
#include <Ecore_X.h>
#include <glib.h>
+#include "net_nfc_internal_se.h"
/**
* @brief The default factory key.
case NET_NFC_MESSAGE_SE_FIELD_ON :
case NET_NFC_MESSAGE_SE_FIELD_OFF :
case NET_NFC_MESSAGE_SE_TYPE_CHANGED :
+ case NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED :
{
nfc_se_event_e event = NFC_SE_EVENT_START_TRANSACTION;
switch( message ){
case NET_NFC_MESSAGE_SE_TYPE_CHANGED:
event = NFC_SE_EVENT_SE_TYPE_CHANGED;
break;
+ case NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED:
+ event = NFC_SE_EVENT_SE_CARD_EMULATION_CHANGED;
default:
break;
}
}
if( message == NET_NFC_MESSAGE_SE_TYPE_TRANSACTION){
net_nfc_se_event_info_s* transaction_data = (net_nfc_se_event_info_s*)data;
- if( g_nfc_context.on_se_transaction_event_cb && transaction_data != NULL){
- g_nfc_context.on_se_transaction_event_cb(transaction_data->aid.buffer,transaction_data->aid.length, transaction_data->param.buffer,transaction_data->param.length , g_nfc_context.on_se_transaction_event_user_data);
+
+ bool fg_dispatch = transaction_data->fg_dispatch;
+ net_nfc_se_type_e se_type = transaction_data->se_type;
+ pid_t focus_app_pid = transaction_data->focus_app_pid;
+
+ if(g_nfc_context.on_se_type == se_type)
+ {
+ pid_t mypid = getpid();
+
+ if(fg_dispatch == false ||
+ (fg_dispatch == true && focus_app_pid == (getpgid(mypid))))
+ {
+ if( NET_NFC_SE_TYPE_ESE == g_nfc_context.on_se_type)
+ {
+ if( g_nfc_context.on_eSE_transaction_event_cb && transaction_data != NULL)
+ {
+ g_nfc_context.on_eSE_transaction_event_cb(
+ se_type,
+ transaction_data->aid.buffer,transaction_data->aid.length,
+ transaction_data->param.buffer,transaction_data->param.length,
+ g_nfc_context.on_eSE_transaction_event_user_data);
+ }
+ }
+ else if( NET_NFC_SE_TYPE_UICC == g_nfc_context.on_se_type)
+ {
+ if( g_nfc_context.on_UICC_transaction_event_cb && transaction_data != NULL)
+ {
+ g_nfc_context.on_UICC_transaction_event_cb(
+ se_type,
+ transaction_data->aid.buffer,transaction_data->aid.length,
+ transaction_data->param.buffer,transaction_data->param.length,
+ g_nfc_context.on_UICC_transaction_event_user_data);
+ }
+ }
+ }
}
}
}
return _convert_error_code(__func__, ret);
}
+int nfc_manager_set_se_type(nfc_se_type_e type)
+{
+ int ret;
+ net_nfc_se_type_e se_type = NET_NFC_SE_TYPE_NONE;
+
+ if ((type < NFC_SE_TYPE_DISABLE) || (type > NFC_SE_TYPE_UICC))
+ {
+ return _return_invalid_param(__func__);
+ }
+
+ if (!nfc_manager_is_activated())
+ {
+ return NFC_ERROR_NOT_ACTIVATED;
+ }
+
+ switch (type)
+ {
+ case NFC_SE_TYPE_DISABLE :
+ se_type = NET_NFC_SE_TYPE_NONE;
+ break;
+ case NFC_SE_TYPE_ESE :
+ se_type = NET_NFC_SE_TYPE_ESE;
+ break;
+ case NFC_SE_TYPE_UICC :
+ se_type = NET_NFC_SE_TYPE_UICC;
+ break;
+ }
+
+ ret = net_nfc_set_secure_element_type_sync(se_type);
+
+ return _convert_error_code(__func__, ret);
+}
+
+
int nfc_manager_get_card_emulation_se_type(nfc_se_type_e* type)
{
int ret = NFC_ERROR_NONE;
return _convert_error_code(__func__, ret);
}
-int nfc_ndef_record_get_payload (nfc_ndef_record_h record, unsigned char ** payload, int *size)
+int nfc_ndef_record_get_payload (nfc_ndef_record_h record,
+ unsigned char ** payload, unsigned int *size)
{
int ret ;
return _convert_error_code(__func__, ret);
}
-int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h* ndef_message, const unsigned char* rawdata, int rawdata_size)
+int nfc_ndef_message_create_from_rawdata(nfc_ndef_message_h* ndef_message,
+ const unsigned char* rawdata, unsigned int rawdata_size)
{
int ret = 0;
return _convert_error_code(__func__, ret);
}
-int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message , unsigned char ** rawdata , int *rawdata_size)
+int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message ,
+ unsigned char ** rawdata , unsigned int *rawdata_size)
{
int ret=0;
data_s *rawdata_data = NULL;
return _convert_error_code(__func__, ret);
}
-int nfc_ndef_message_get_rawdata_size(nfc_ndef_message_h ndef_message , int *byte_size)
+int nfc_ndef_message_get_rawdata_size(nfc_ndef_message_h ndef_message,
+ unsigned int *byte_size)
{
int ret = 0;
int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg , nfc_tag_write_completed_cb callback , void *user_data)
{
+
+ int ret=0;
+ unsigned int byte_size = 0;
+ _async_callback_data * trans_data = NULL;
+ net_nfc_target_info_s *tag_info = (net_nfc_target_info_s*)tag;
+
if (tag == NULL || msg == NULL)
return _return_invalid_param(__func__);
return NFC_ERROR_SECURITY_RESTRICTED;
}
- int ret=0;
- _async_callback_data * trans_data = NULL;
- net_nfc_target_info_s *tag_info = (net_nfc_target_info_s*)tag;
if (tag_info->ndefCardState == NET_NFC_NDEF_CARD_READ_ONLY )
{
}
- int byte_size = 0;
nfc_ndef_message_get_rawdata_size(msg , &byte_size);
if(tag_info->maxDataSize < byte_size)
return NFC_ERROR_NO_SPACE_ON_NDEF;
}
-
-
if( callback != NULL ){
trans_data = (_async_callback_data*)malloc( sizeof(_async_callback_data));
if(trans_data == NULL )
g_nfc_context.on_p2p_discovered_user_data = NULL;
}
+int nfc_se_enable_card_emulation()
+{
+ net_nfc_error_e result;
+
+ result = net_nfc_set_card_emulation_mode_sync(NET_NFC_CARD_EMELATION_ENABLE);
+
+ return _convert_error_code(__func__, result);
+}
+
+int nfc_se_disable_card_emulation()
+{
+ net_nfc_error_e result;
+
+ result = net_nfc_set_card_emulation_mode_sync(NET_NFC_CARD_EMULATION_DISABLE);
+
+ return _convert_error_code(__func__, result);
+}
+
+int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type)
+{
+ int ret;
+ int se_type;
+
+ ret = vconf_get_int(VCONFKEY_NFC_SE_TYPE, &se_type);
+ if (ret == 0)
+ {
+ if(se_type == NFC_SE_TYPE_DISABLE)
+ {
+ *type = NFC_SE_CARD_EMULATION_MODE_OFF;
+ ret = NFC_ERROR_NONE;
+
+ }
+ else if(se_type >= NFC_SE_TYPE_ESE && se_type <= NFC_SE_TYPE_UICC)
+ {
+ *type = NFC_SE_CARD_EMULATION_MODE_ON;
+ ret = NFC_ERROR_NONE;
+ }
+ else
+ {
+ ret = NFC_ERROR_OPERATION_FAILED;
+ }
+ }
+ else
+ {
+ ret = NFC_ERROR_OPERATION_FAILED;
+ }
+
+ return ret;
+}
+
+
int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data)
{
if( callback == NULL )
void nfc_manager_unset_se_event_cb(void)
{
+ g_nfc_context.on_se_type = NET_NFC_SE_TYPE_NONE;
g_nfc_context.on_se_event_cb = NULL;
g_nfc_context.on_se_event_user_data = NULL;
}
-int nfc_manager_set_se_transaction_event_cb(nfc_se_transaction_event_cb callback, void *user_data)
+int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type,
+ nfc_se_transaction_event_cb callback, void *user_data)
{
if( callback == NULL )
return _return_invalid_param(__func__);
- g_nfc_context.on_se_transaction_event_cb = callback;
- g_nfc_context.on_se_transaction_event_user_data = user_data;
+ g_nfc_context.on_se_type = se_type;
+
+ if(se_type == NFC_SE_TYPE_ESE)
+ {
+ g_nfc_context.on_eSE_transaction_event_cb = callback;
+ g_nfc_context.on_eSE_transaction_event_user_data = user_data;
+ }
+ else if(se_type == NFC_SE_TYPE_UICC)
+ {
+ g_nfc_context.on_UICC_transaction_event_cb = callback;
+ g_nfc_context.on_UICC_transaction_event_user_data = user_data;
+ }
+
return 0;
}
-void nfc_manager_unset_se_transaction_event_cb(void)
+void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type)
{
- g_nfc_context.on_se_transaction_event_cb = NULL;
- g_nfc_context.on_se_transaction_event_user_data = NULL;
+ if(se_type == NFC_SE_TYPE_ESE)
+ {
+ g_nfc_context.on_eSE_transaction_event_cb = NULL;
+ g_nfc_context.on_eSE_transaction_event_user_data = NULL;
+ }
+ else if(se_type == NFC_SE_TYPE_UICC)
+ {
+ g_nfc_context.on_UICC_transaction_event_cb = NULL;
+ g_nfc_context.on_UICC_transaction_event_user_data = NULL;
+ }
}
unsigned char *type;
int type_size;
unsigned char *payload;
- int payload_size;
+ uint32_t payload_size;
nfc_ndef_record_h record;
int ret;
unsigned char *id;
int id_size;
unsigned char *payload;
- int payload_size;
+ unsigned int payload_size;
char *strp = NULL;
char *strp2 = NULL;
ecore_idler_add(handover_test, target);
}
}
+void _card_emulation_changed_cb(nfc_se_event_e event , void *user_data){
+ if(NFC_SE_EVENT_SE_CARD_EMULATION_CHANGED == event)
+ {
+ printf("CARD_EMULATION_CHANGED arrived!!!!\n");
+ }
+}
void send_ndef_to_peer(nfc_error_e error, void *user_data){
ecore_timer_add(1, timeout_handler, NULL);
}
+
+void set_card_emulation_cb_test(nfc_error_e error, void *user_data){
+ int ret ;
+ success = 0;
+ timeout_counter =30;
+
+ ret = nfc_manager_set_se_event_cb(_card_emulation_changed_cb, NULL);
+ if(0 == ret)
+ {
+ printf("card emulation cb registered. Will be tried to card emulation change\n");
+
+ }
+
+ ret = nfc_se_enable_card_emulation();
+
+ printf("card emulation result is = %d\n", ret);
+ ecore_timer_add(1, timeout_handler, NULL);
+}
+
+
+
void _p2p_recv_cb(nfc_p2p_target_h target , nfc_ndef_message_h message, void *user_data){
printf("recevie a new message!\n");
" g. ON nfc_manager_enable_system_handler\n"
" h. OFF nfc_manager_enable_system_handler\n"
-
-
+ " i. connect handover to peer\n"
"------------------\n"
">";
{
elm_init(argc, argv);
is_terminate = 0;
- char select[255];
+ char select;
int ret;
- printf( menu );
- gets(select);
+ printf("%s", menu );
+ ret = scanf("%c", &select);
- switch(select[0]){
+ switch(select){
case '0':
ret = nfc_manager_set_activation(0, set_activation_completed_cb, NULL);
elm_shutdown();
return 0;
-
+ case 'i':
+ ret = nfc_manager_initialize(set_card_emulation_cb_test,NULL);
+ print_result("nfc_manager_initialize", ret);
+ break;
default:
printf("wrong selection!\n");