Conflicts:
	cmake/modules/LibnfcDrivers.cmake
This commit is contained in:
Marcos Vives Del Sol 2015-06-30 19:41:47 +02:00
commit c2fdab7f0c
4 changed files with 30 additions and 10 deletions

View File

@ -68,4 +68,4 @@ IF(LIBNFC_DRIVER_RC522_UART)
SET(UART_REQUIRED TRUE) SET(UART_REQUIRED TRUE)
ENDIF(LIBNFC_DRIVER_RC522_UART) ENDIF(LIBNFC_DRIVER_RC522_UART)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/drivers) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libnfc/drivers)

View File

@ -126,7 +126,8 @@ NFC_EXPORT int nfc_device_get_last_error(const nfc_device *pnd);
NFC_EXPORT const char *nfc_device_get_name(nfc_device *pnd); NFC_EXPORT const char *nfc_device_get_name(nfc_device *pnd);
NFC_EXPORT const char *nfc_device_get_connstring(nfc_device *pnd); NFC_EXPORT const char *nfc_device_get_connstring(nfc_device *pnd);
NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt); NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type **const supported_mt);
NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br); NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
NFC_EXPORT int nfc_device_get_supported_baud_rate_target_mode(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
/* Properties accessors */ /* Properties accessors */
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value); NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value);

View File

@ -3338,7 +3338,7 @@ pn53x_get_information_about(nfc_device *pnd, char **pbuf)
} }
buflen -= res; buflen -= res;
const nfc_baud_rate *nbr; const nfc_baud_rate *nbr;
if ((res = nfc_device_get_supported_baud_rate(pnd, N_INITIATOR, nmt[i], &nbr)) < 0) { if ((res = nfc_device_get_supported_baud_rate(pnd, nmt[i], &nbr)) < 0) {
free(*pbuf); free(*pbuf);
return res; return res;
} }
@ -3403,7 +3403,7 @@ pn53x_get_information_about(nfc_device *pnd, char **pbuf)
} }
buflen -= res; buflen -= res;
const nfc_baud_rate *nbr; const nfc_baud_rate *nbr;
if ((res = nfc_device_get_supported_baud_rate(pnd, N_TARGET, nmt[i], &nbr)) < 0) { if ((res = nfc_device_get_supported_baud_rate_target_mode(pnd, nmt[i], &nbr)) < 0) {
free(*pbuf); free(*pbuf);
return res; return res;
} }

View File

@ -1204,18 +1204,31 @@ nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const
} }
/** @ingroup data /** @ingroup data
* @brief Get supported baud rates. * @brief Get supported baud rates (initiator mode).
* @return Returns 0 on success, otherwise returns libnfc's error code (negative value) * @return Returns 0 on success, otherwise returns libnfc's error code (negative value)
* @param pnd \a nfc_device struct pointer that represent currently used device * @param pnd \a nfc_device struct pointer that represent currently used device
* @param mode \a nfc_mode.
* @param nmt \a nfc_modulation_type. * @param nmt \a nfc_modulation_type.
* @param supported_br pointer of \a nfc_baud_rate array. * @param supported_br pointer of \a nfc_baud_rate array.
* *
*/ */
int int
nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br) nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
{ {
HAL(get_supported_baud_rate, pnd, mode, nmt, supported_br); HAL(get_supported_baud_rate, pnd, N_INITIATOR, nmt, supported_br);
}
/** @ingroup data
* @brief Get supported baud rates for target mode.
* @return Returns 0 on success, otherwise returns libnfc's error code (negative value)
* @param pnd \a nfc_device struct pointer that represent currently used device
* @param nmt \a nfc_modulation_type.
* @param supported_br pointer of \a nfc_baud_rate array.
*
*/
int
nfc_device_get_supported_baud_rate_target_mode(nfc_device *pnd, const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
{
HAL(get_supported_baud_rate, pnd, N_TARGET, nmt, supported_br);
} }
/** @ingroup data /** @ingroup data
@ -1237,8 +1250,14 @@ nfc_device_validate_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
for (int i = 0; nmt[i]; i++) { for (int i = 0; nmt[i]; i++) {
if (nmt[i] == nm->nmt) { if (nmt[i] == nm->nmt) {
const nfc_baud_rate *nbr; const nfc_baud_rate *nbr;
if ((res = nfc_device_get_supported_baud_rate(pnd, mode, nmt[i], &nbr)) < 0) { if (mode == N_INITIATOR) {
return res; if ((res = nfc_device_get_supported_baud_rate(pnd, nmt[i], &nbr)) < 0) {
return res;
}
} else {
if ((res = nfc_device_get_supported_baud_rate_target_mode(pnd, nmt[i], &nbr)) < 0) {
return res;
}
} }
for (int j = 0; nbr[j]; j++) { for (int j = 0; nbr[j]; j++) {
if (nbr[j] == nm->nbr) if (nbr[j] == nm->nbr)