add GSMA api
authorJi-hoon Jung <jh8801.jung@samsung.com>
Wed, 23 Oct 2013 05:27:02 +0000 (14:27 +0900)
committerJi-hoon Jung <jh8801.jung@samsung.com>
Wed, 23 Oct 2013 10:44:02 +0000 (19:44 +0900)
Change-Id: I61a41dbd56e852ee6e505ec6606b9ee528633191

TC/testcase/utc_network_nfc_ndef_message.c
TC/testcase/utc_network_nfc_ndef_record.c
include/nfc.h
include/nfc_private.h
packaging/capi-network-nfc.spec
src/nfc.c
test/network_nfc_test.c

index 4f63a40..84d2265 100755 (executable)
@@ -110,7 +110,7 @@ static void utc_nfc_ndef_message_create_from_rawdata_p(void)
 {
        int ret ;
        unsigned char *buffer;
-       int size;
+       uint32_t size;
        nfc_ndef_message_h message;
        nfc_ndef_message_h message2;
        nfc_ndef_record_h record1;
@@ -178,7 +178,7 @@ static void utc_nfc_ndef_message_get_rawdata_p(void)
 {
        int ret ;
        unsigned char *buffer;
-       int size;
+       uint32_t size;
        nfc_ndef_message_h message;
        nfc_ndef_record_h record1;
        ret = nfc_ndef_message_create(&message);
index b45231e..8ac2ec2 100755 (executable)
@@ -257,7 +257,7 @@ static void utc_nfc_ndef_record_get_id_n(void)
 static void utc_nfc_ndef_record_get_payload_p(void)
 {
        int ret = 0;
-       int size;
+       uint32_t size;
        nfc_ndef_record_h record;
        unsigned char *payload;
        ret = nfc_ndef_record_create_text(&record, "test", "en-US", NFC_ENCODE_UTF_8 );
index e077048..5871967 100755 (executable)
@@ -155,7 +155,8 @@ typedef enum{
        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;
 
 /**
@@ -169,6 +170,15 @@ typedef enum{
 } 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
  */
@@ -566,6 +576,7 @@ typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
  * @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
@@ -575,7 +586,7 @@ typedef void (*nfc_se_event_cb)(nfc_se_event_e event , void *user_data);
  * @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);
 
 
 
@@ -635,6 +646,7 @@ typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc
  *
  * @see nfc_manager_set_activation()
  */
+
 bool nfc_manager_is_supported(void);
 
 /**
@@ -852,6 +864,7 @@ void nfc_manager_unset_se_event_cb(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
  *
@@ -862,16 +875,19 @@ void nfc_manager_unset_se_event_cb(void);
  * @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.
@@ -1193,7 +1209,7 @@ int nfc_ndef_record_get_id(nfc_ndef_record_h record, unsigned char **id, int *si
  * @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.
@@ -1361,7 +1377,8 @@ int nfc_ndef_message_create(nfc_ndef_message_h *ndef_message);
  * @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
@@ -1411,7 +1428,8 @@ int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message, int *coun
  *
  * @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
index 4d9903b..cf082ce 100755 (executable)
@@ -57,8 +57,16 @@ typedef struct {
 
        nfc_initialize_completed_cb             on_initialize_completed_cb;
 
-       nfc_se_transaction_event_cb             on_se_transaction_event_cb;
-       void *                                          on_se_transaction_event_user_data;
+       //nfc_se_transaction_event_cb           on_se_transaction_event_cb;
+       //void *                                                on_se_transaction_event_user_data;
+
+       nfc_se_transaction_event_cb             on_eSE_transaction_event_cb;
+       void *                                          on_eSE_transaction_event_user_data;
+
+       nfc_se_transaction_event_cb             on_UICC_transaction_event_cb;
+       void *                                          on_UICC_transaction_event_user_data;
+
+       net_nfc_se_type_e                                               on_se_type;
 
        nfc_activation_changed_cb       on_activation_changed_cb;
        void *                                          on_activation_changed_user_data;
index 041b0a9..d60bc6e 100644 (file)
@@ -1,7 +1,7 @@
 #sbs-git:slp/api/nfc capi-network-nfc 0.0.1 14f15050f8f6ff8217421da04fa5d66e834e2016
 Name:       capi-network-nfc
 Summary:    A NFC library in SLP C API
-Version:    0.0.10
+Version:    0.0.11
 Release:    0
 Group:      API/C API
 License:    Apache-2.0
index 991d451..5f0ba6c 100755 (executable)
--- a/src/nfc.c
+++ b/src/nfc.c
@@ -25,6 +25,7 @@
 #include <vconf.h>
 #include <Ecore_X.h>
 #include <glib.h>
+#include "net_nfc_internal_se.h"
 
 /**
  * @brief The default factory key.
@@ -599,6 +600,7 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo
        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 ){
@@ -623,6 +625,8 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo
                        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;
                        }
@@ -632,8 +636,41 @@ void _nfc_response_handler(net_nfc_message_e message, net_nfc_error_e result, vo
                        }
                        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);
+                                                       }
+                                               }
+                                       }
                                }
                        }
                }
@@ -1021,6 +1058,40 @@ int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type, nfc_set_card_emul
        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;
@@ -1152,7 +1223,8 @@ int nfc_ndef_record_set_id (nfc_ndef_record_h record, unsigned char *id , int id
        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 ;
 
@@ -1266,7 +1338,8 @@ int nfc_ndef_message_create(nfc_ndef_message_h* ndef_message)
        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;
 
@@ -1304,7 +1377,8 @@ int nfc_ndef_message_get_record_count(nfc_ndef_message_h ndef_message , int *cou
        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;
@@ -1330,7 +1404,8 @@ int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message , unsigned char
        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;
 
@@ -1514,6 +1589,12 @@ int nfc_tag_read_ndef( nfc_tag_h tag, nfc_tag_read_completed_cb callback , void
 
 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__);
 
@@ -1528,9 +1609,6 @@ int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg , nfc_tag_write_com
                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 )
        {
@@ -1538,7 +1616,6 @@ int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg , nfc_tag_write_com
 
        }
 
-       int byte_size = 0;
        nfc_ndef_message_get_rawdata_size(msg , &byte_size);
 
        if(tag_info->maxDataSize < byte_size)
@@ -1546,8 +1623,6 @@ int nfc_tag_write_ndef(nfc_tag_h tag, nfc_ndef_message_h msg , nfc_tag_write_com
                return NFC_ERROR_NO_SPACE_ON_NDEF;
        }
 
-
-
        if( callback != NULL ){
                trans_data = (_async_callback_data*)malloc( sizeof(_async_callback_data));
                if(trans_data == NULL )
@@ -2057,6 +2132,57 @@ void nfc_manager_unset_p2p_target_discovered_cb( void ){
        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 )
@@ -2069,22 +2195,43 @@ int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data)
 
 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;
+       }
 }
index d20e8de..ac64c77 100755 (executable)
@@ -76,7 +76,7 @@ void print_ndef_message(nfc_ndef_message_h message){
        unsigned char *type;
        int type_size;
        unsigned char *payload;
-       int payload_size;
+       uint32_t payload_size;
        nfc_ndef_record_h record;
        int ret;
 
@@ -133,7 +133,7 @@ void ndef_record_create_test(nfc_error_e error, void *user_data){
        unsigned char *id;
        int id_size;
        unsigned char *payload;
-       int payload_size;
+       unsigned int payload_size;
 
        char *strp = NULL;
        char *strp2 = NULL;
@@ -394,6 +394,12 @@ void _target_discovered_for_connect_handover_cb(nfc_discovered_type_e type, nfc_
                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){
 
@@ -429,6 +435,27 @@ void connect_handover_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");
@@ -511,8 +538,7 @@ char *menu =
 
        " g. ON nfc_manager_enable_system_handler\n"
        " h. OFF nfc_manager_enable_system_handler\n"
-
-
+       " i. connect handover to peer\n"
 
        "------------------\n"
        ">";
@@ -527,14 +553,14 @@ int main(int argc, char ** argv)
 {
        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);
@@ -631,7 +657,10 @@ int main(int argc, char ** argv)
                        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");