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_CARD_EMULATION_CHANGED, /**< This event notifies, changing the card emulation mode */
} nfc_se_event_e;
/**
NFC_SE_TYPE_UICC = 0x02 /**< UICC type card emulation */
} 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);
* @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 of 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.
*/
int nfc_manager_get_card_emulation_se_type(nfc_se_type_e* type);
+/**
+ * @brief Gets the card emulation Secure Element type
+ * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE
+ *
+ * @param [in] type The type of Secure Element
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #NFC_ERROR_NONE Successful
+ * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int nfc_manager_set_se_type(nfc_se_type_e type);
+
/**
* @brief Creates a record with given parameter value.
* @ingroup CAPI_NETWORK_NFC_NDEF_RECORD_MODULE
* @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
*/
int nfc_se_open_secure_element(nfc_se_type_e se_type, nfc_se_h *handle);
+/**
+ * @brief Enable card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @return 0 on success, otherwise a negative error value.
+ *
+ * @see nfc_se_disable_card_emulation()
+ */
+int nfc_se_enable_card_emulation();
+
+/**
+ * @brief Disable card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @return 0 on success, otherwise a negative error value.
+ *
+ * @see nfc_se_enable_card_emulation()
+ */
+int nfc_se_disable_card_emulation();
+
+/**
+ * @brief Get the current card emulation mode.
+ * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
+ *
+ * @param [out] type The current card emulation mode type
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #NFC_ERROR_NONE Successful
+ * @retval #NFC_ERROR_OPERATION_FAILED Operation failed
+ *
+ */
+int nfc_se_get_card_emulation_mode(nfc_se_card_emulation_mode_type_e *type);
+
/**
* @brief Open connection to secure element.
* @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE
gdbus_nfc_context.current_target = NULL;
}
+static void _se_event_cb(net_nfc_message_e message, void *user_data)
+{
+ if (gdbus_nfc_context.on_se_event_cb != NULL) {
+ if(message == NET_NFC_MESSAGE_SE_CARD_EMULATION_CHANGED)
+ gdbus_nfc_context.on_se_event_cb(
+ NFC_SE_EVENT_CARD_EMULATION_CHANGED,
+ gdbus_nfc_context.on_se_event_user_data);
+
+ else if(message == NET_NFC_MESSAGE_SE_TYPE_CHANGED)
+ gdbus_nfc_context.on_se_event_cb(
+ NFC_SE_EVENT_SE_TYPE_CHANGED,
+ gdbus_nfc_context.on_se_event_user_data);
+ }
+}
+
/* deprecated */
static gboolean _initialize_cb(gpointer user_data)
{
net_nfc_client_p2p_set_device_discovered(_p2p_target_discovered_cb, NULL);
net_nfc_client_p2p_set_device_detached(_p2p_device_detached, NULL);
+ net_nfc_client_se_set_event_cb(_se_event_cb, NULL);
/* invoke callback if it needs */
if (callback != NULL) {
net_nfc_client_p2p_set_device_discovered(_p2p_target_discovered_cb, NULL);
net_nfc_client_p2p_set_device_detached(_p2p_device_detached, NULL);
+ net_nfc_client_se_set_event_cb(_se_event_cb, NULL);
#if 0
ret = net_nfc_client_tag_is_tag_connected_sync(&devType);
if (ret == NET_NFC_OK)
}
int nfc_ndef_message_get_rawdata_size(nfc_ndef_message_h ndef_message,
- int *byte_size)
+ unsigned int *byte_size)
{
int ret;
nfc_tag_write_completed_cb callback, void *user_data)
{
int ret;
- int byte_size = 0;
+ unsigned int byte_size = 0;
GVariant *parameter;
if (tag == NULL)
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;
data_s *payload_data;
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;
data_s rawdata_data = { (unsigned char *)rawdata, rawdata_size };
}
int nfc_ndef_message_get_rawdata(nfc_ndef_message_h ndef_message,
- unsigned char **rawdata, int *rawdata_size)
+ unsigned char **rawdata,
+ unsigned int *rawdata_size)
{
int ret;
data_s *rawdata_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_client_se_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;
return _convert_error_code(__func__, result);
}
+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)
+{
+ net_nfc_error_e result;
+ net_nfc_se_type_e se_type;
+
+ result = net_nfc_get_card_emulation_mode(&se_type);
+
+ if(result == NET_NFC_OK)
+ {
+ if(se_type == NET_NFC_SE_TYPE_NONE)
+ {
+ *type = NFC_SE_CARD_EMULATION_MODE_OFF;
+ }
+ else if(se_type == NET_NFC_SE_TYPE_ESE || se_type == NET_NFC_SE_TYPE_UICC)
+ {
+ *type = NFC_SE_CARD_EMULATION_MODE_ON;
+ }
+ }
+ else
+ {
+ result = NET_NFC_OPERATION_FAIL;
+ }
+
+ return _convert_error_code(__func__, result);;
+}
+
int nfc_manager_set_se_event_cb(nfc_se_event_cb callback, void *user_data)
{
if (callback == NULL)
gdbus_nfc_context.on_se_transaction_event_user_data = NULL;
}
-static void _se_transaction_event_cb(data_s *aid, data_s *param, void *user_data)
+static void _se_transaction_event_cb(
+ net_nfc_se_type_e se_type,
+ data_s* aid,
+ data_s* param,
+ void *user_data)
{
if (gdbus_nfc_context.on_se_transaction_event_cb != NULL) {
gdbus_nfc_context.on_se_transaction_event_cb(
- net_nfc_get_data_buffer(aid),
- net_nfc_get_data_length(aid),
- net_nfc_get_data_buffer(param),
- net_nfc_get_data_length(param),
- gdbus_nfc_context.on_se_transaction_event_user_data);
+ se_type,
+ net_nfc_get_data_buffer(aid),
+ net_nfc_get_data_length(aid),
+ net_nfc_get_data_buffer(param),
+ net_nfc_get_data_length(param),
+ gdbus_nfc_context.on_se_transaction_event_user_data);
}
}
int nfc_manager_set_se_transaction_event_cb(
- nfc_se_transaction_event_cb callback, void *user_data)
+ nfc_se_type_e se_type,
+ nfc_se_transaction_event_cb callback,
+ void *user_data)
{
+ net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
+
if (callback == NULL)
return _return_invalid_param(__func__);
gdbus_nfc_context.on_se_transaction_event_cb = callback;
gdbus_nfc_context.on_se_transaction_event_user_data = user_data;
- net_nfc_client_se_set_transaction_event_cb(_se_transaction_event_cb,
- NULL);
+ switch(se_type)
+ {
+ case NFC_SE_TYPE_ESE:
+ type = NET_NFC_SE_TYPE_ESE;
+ break;
+
+ case NFC_SE_TYPE_UICC:
+ type = NET_NFC_SE_TYPE_UICC;
+ break;
+ default:
+ return _return_invalid_param(__func__);
+ break;
+
+ }
+
+ net_nfc_client_se_set_transaction_event_cb(type, _se_transaction_event_cb, user_data);
return NFC_ERROR_NONE;
}
-void nfc_manager_unset_se_transaction_event_cb(void)
+void nfc_manager_unset_se_transaction_event_cb(nfc_se_type_e se_type)
{
- net_nfc_client_se_unset_transaction_event_cb();
+ net_nfc_se_type_e type = NET_NFC_SE_TYPE_NONE;
+
+ switch(se_type)
+ {
+ case NFC_SE_TYPE_ESE:
+ type = NET_NFC_SE_TYPE_ESE;
+ break;
+
+ case NFC_SE_TYPE_UICC:
+ type = NET_NFC_SE_TYPE_UICC;
+ break;
+ default:
+ type = NET_NFC_SE_TYPE_NONE;
+ break;
+ }
+ net_nfc_client_se_unset_transaction_event_cb(type);
}
/************************************Raw Data- Transceive*********************/