X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fnfc.h;h=0b2c5acbee4f7add8d9190b1cd9791af454af96c;hb=64595f569932a4a86a9f3200dc848eb13d86be61;hp=58719674bdea21f6cf79f80d4904d4f4516bf6c1;hpb=1d4ce0396b95dc6f066ec70846dfaf6e35c2dc4b;p=platform%2Fcore%2Fapi%2Fnfc.git diff --git a/include/nfc.h b/include/nfc.h old mode 100755 new mode 100644 index 5871967..0b2c5ac --- a/include/nfc.h +++ b/include/nfc.h @@ -156,7 +156,7 @@ typedef enum{ 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_CARD_EMULATION_CHANGED + NFC_SE_EVENT_CARD_EMULATION_CHANGED, /**< This event notifies, changing the card emulation mode */ } nfc_se_event_e; /** @@ -170,9 +170,9 @@ typedef enum{ } nfc_se_type_e; /** - * * @brief Enumerations for NFC Card Emulation Mode type - * * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE - * */ + * @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 */ @@ -189,8 +189,49 @@ typedef enum { NFC_AC_TYPE_UNKNOWN, /* No selected preferred AC */ } nfc_ac_type_e ; +/** + * @brief Enumerations for SNEP event + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + */ +typedef enum { + NFC_SNEP_EVENT_STOP = 0x00, /**< server or client stopped */ + NFC_SNEP_EVENT_START = 0x01, /**< server started or client connected */ + NFC_SNEP_EVENT_GET = 0x02, /**< server received get request */ + NFC_SNEP_EVENT_PUT = 0x03, /**< server received put request */ + NFC_SNEP_EVENT_REGISTER = 0x04, /**< service registered */ + NFC_SNEP_EVENT_UNREGISTER = 0x05, /**< service unregistered */ +} nfc_snep_event_e; + +/** + * @brief Enumerations for SNEP request type + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + */ +typedef enum { + NFC_SNEP_GET = 0x01, /**< get request */ + NFC_SNEP_PUT = 0x02, /**< put request */ +} nfc_snep_type_e; +/** + * @brief Enumerations for PRBS technology type + * @ingroup CAPI_NETWORK_NFC_TEST_MODULE + */ +typedef enum { + NFC_PRBS_TECH_NONE = 0x00, /**< Unknown NFC technology */ + NFC_PRBS_TECH_A = 0x01, /**< NFC technology A */ + NFC_PRBS_TECH_B = 0x02, /**< NFC technology B */ + NFC_PRBS_TECH_F = 0x03, /**< NFC technology F */ +} nfc_prbs_tech_e; +/** + * @brief Enumerations for PRBS speed rate type + * @ingroup CAPI_NETWORK_NFC_TEST_MODULE + */ +typedef enum { + NFC_PRBS_RATE_NONE = 0x00, /**< Unknown NFC speed */ + NFC_PRBS_RATE_106K = 0x01, /**< 106kbps */ + NFC_PRBS_RATE_212K = 0x02, /**< 212kbps */ + NFC_PRBS_RATE_424K = 0x03, /**< 424kbps */ +} nfc_prbs_rate_e; /** * @brief The handle to the NDEF record @@ -218,6 +259,18 @@ typedef struct _net_nfc_target_info_s *nfc_tag_h; typedef void *nfc_p2p_target_h; /** + * @brief The handle to NFC p2p snep instance + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + */ +typedef struct _nfc_p2p_snep_s *nfc_p2p_snep_h; + +/** + * @brief The handle to NFC secure element instance + * @ingroup CAPI_NETWORK_NFC_TAG_MODULE + */ +typedef void *nfc_se_h; + +/** * @brief The default factory key. * @details The key is 0xff, 0xff, 0xff, 0xff, 0xff, 0xff * @ingroup CAPI_NETWORK_NFC_TAG_MIFARE_MODULE @@ -636,6 +689,24 @@ typedef void (*nfc_p2p_data_recived_cb)(nfc_p2p_target_h target, nfc_ndef_messag */ typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc_ac_type_e carrior, void * ac_data, int ac_data_size , void *user_data); + +/** + * @brief Called when SNEP event is raised + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] handle The handle of current snep instance + * @param [in] event The kind of snep event + * @param [in] result The result of snep event + * @param [in] msg The ndef message which received from client or result of get request + * @param [in] user_data The user data passed from snep apis. + * + * @see nfc_snep_start_server() + * @see nfc_snep_send_request() + */ +typedef void (*nfc_snep_event_cb)(nfc_p2p_snep_h handle, + nfc_snep_event_e event, nfc_error_e result, + nfc_ndef_message_h msg, void *user_data); + /** * @brief Gets the value that indicates whether NFC is supported. * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE @@ -646,7 +717,6 @@ typedef void (*nfc_p2p_connection_handover_completed_cb)(nfc_error_e result, nfc * * @see nfc_manager_set_activation() */ - bool nfc_manager_is_supported(void); /** @@ -864,7 +934,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] 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 * @@ -875,7 +945,7 @@ 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_type_e se_type, +int nfc_manager_set_se_transaction_event_cb(nfc_se_type_e se_type, nfc_se_transaction_event_cb callback, void *user_data); /** @@ -962,7 +1032,7 @@ int nfc_manager_get_connected_target(nfc_p2p_target_h *target); /** * @brief Enable or disable the system handling for tag and target discovered event * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE - * @remarks In default, The system handling is enabled. + * @remarks By default, The system handling is enabled. * * @param [in] enable The state of enable * @@ -975,9 +1045,24 @@ int nfc_manager_get_connected_target(nfc_p2p_target_h *target); int nfc_manager_set_system_handler_enable(bool enable); /** + * @brief Enable or disable the system handling for tag and target discovered event + * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE + * @remarks By default, The system handling is enabled. + * + * @param [in] enable The state of enable + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see nfc_manager_is_system_handler_enabled() + */ +int nfc_manager_set_system_handler_enable_force(bool enable); + +/** * @brief Gets the state of the system handler * @ingroup CAPI_NETWORK_NFC_MANAGER_MODULE - * @remarks In default, The system handling is enabled. + * @remarks By default, The system handling is enabled. * * @return true on enabled, otherwise false. * @@ -1018,6 +1103,19 @@ int nfc_manager_set_card_emulation_se_type(nfc_se_type_e type, nfc_set_card_emul 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 * @@ -2093,6 +2191,238 @@ int nfc_p2p_connection_handover(nfc_p2p_target_h target , nfc_ac_type_e type, nf bool nfc_p2p_is_supported_ac_type( nfc_ac_type_e carrior); +/** + * @brief Start peer-to-peer server using SNEP protocol + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] target The handle to peer target + * @param [in] san The name of service (service access name) + * @param [in] sap The number of service (service access point) + * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required + * @param [in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() +*/ +int nfc_snep_start_server(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data); + +/** + * @brief Start peer-to-peer client using SNEP protocol + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] target The handle to peer target + * @param [in] san The name of service (service access name) + * @param [in] sap The number of service (service access point) + * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required + * @param [in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() + * @see nfc_snep_send_client_request() + * @see nfc_snep_stop_service +*/ +int nfc_snep_start_client(nfc_p2p_target_h target, const char *san, int sap, nfc_snep_event_cb callback, void *user_data); + +/** + * @brief Send request message to peer-to-peer client using SNEP protocol + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] handle The handle to connected snep instance + * @param [in] type The request type of snep protocol + * @param [in] msg The ndef message which will be sent + * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required + * @param [in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() +*/ +int nfc_snep_send_client_request(nfc_p2p_snep_h handle, nfc_snep_type_e type, nfc_ndef_message_h msg, nfc_snep_event_cb callback, void *user_data); + +/** + * @brief Stop snep server or client + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] target The handle to peer target + * @param [in] service The handle which will be stopped + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() +*/ +int nfc_snep_stop_service(nfc_p2p_target_h target, nfc_p2p_snep_h service); + +/** + * @brief Register peer-to-peer server using SNEP protocol + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] san The name of service (service access name) + * @param [in] sap The number of service (service access point) + * @param [in] callback The callback function to invoke after this function has completed\n It can be null if notification is not required + * @param [in] user_data The user data to be passed to the callback function + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_DEVICE_BUSY Device is too busy to handle your request + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() +*/ +int nfc_snep_register_server(const char *san, int sap, nfc_snep_event_cb callback, void *user_data); + +/** + * @brief Unregister snep server or client + * @ingroup CAPI_NETWORK_NFC_P2P_MODULE + * + * @param [in] san The name of service (service access name) + * @param [in] sap The number of service (service access point) + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * + * @see nfc_snep_event_cb() +*/ +int nfc_snep_unregister_server(const char *san, int sap); + +/** + * @brief Open connection to secure element. + * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE + * + * @param [in] se_type The type you want to open + * @param [out] handle The handle of connected secure element + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message + * + * @see nfc_se_close_secure_element() + */ +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 + * + * @remarks It gets the allocated bytes array including data. @a resp must be released with free() by you. + * + * @param [in] handle The handle of connected secure element + * @param [in] cmd The bytes array of apdu command data + * @param [in] cmd_len The size of apdu command bytes array + * @param [out] resp The bytes array of response data + * @param [out] resp_len The size of response bytes array + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message + * + * @see nfc_se_open_secure_element() + * @see nfc_se_close_secure_element() + */ +int nfc_se_send_apdu(nfc_se_h handle, unsigned char *cmd, unsigned int cmd_len, unsigned char **resp, unsigned int *resp_len); + +/** + * @brief Get ATR(Answer to Reset) of connected secure element. + * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE + * + * @remarks It gets the allocated bytes array including data. @a atr must be released with free() by you. + * + * @param [in] handle The handle of connected secure element + * @param [out] atr The bytes array of atr data + * @param [out] atr_len The size of atr bytes array + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message + * + * @see nfc_se_open_secure_element() + * @see nfc_se_close_secure_element() + */ +int nfc_se_get_atr(nfc_se_h handle, unsigned char **atr, unsigned int *atr_len); + +/** + * @brief Close connection to secure element. + * @ingroup CAPI_NETWORK_NFC_NDEF_MESSAGE_MODULE + * + * @param [in] handle The handle of connected secure element + * + * @return 0 on success, otherwise a negative error value. + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #NFC_ERROR_OUT_OF_MEMORY Out of memory + * @retval #NFC_ERROR_INVALID_NDEF_MESSAGE Invalid NDEF message + * + * @see nfc_se_open_secure_element() + */ +int nfc_se_close_secure_element(nfc_se_h handle); + #ifdef __cplusplus } #endif