Merge branch 'nfc_get_supported_baud_rate_proposal'
* nfc_get_supported_baud_rate_proposal: nfc_get_supported_baud_rate() proposal to reverse API
This commit is contained in:
commit
49dde9c28c
3 changed files with 29 additions and 9 deletions
|
@ -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_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_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 */
|
||||
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const nfc_property property, const int value);
|
||||
|
|
|
@ -3366,7 +3366,7 @@ pn53x_get_information_about(nfc_device *pnd, char **pbuf)
|
|||
}
|
||||
buflen -= res;
|
||||
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);
|
||||
return res;
|
||||
}
|
||||
|
@ -3431,7 +3431,7 @@ pn53x_get_information_about(nfc_device *pnd, char **pbuf)
|
|||
}
|
||||
buflen -= res;
|
||||
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);
|
||||
return res;
|
||||
}
|
||||
|
|
31
libnfc/nfc.c
31
libnfc/nfc.c
|
@ -1198,18 +1198,31 @@ nfc_device_get_supported_modulation(nfc_device *pnd, const nfc_mode mode, const
|
|||
}
|
||||
|
||||
/** @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)
|
||||
* @param pnd \a nfc_device struct pointer that represent currently used device
|
||||
* @param mode \a nfc_mode.
|
||||
* @param nmt \a nfc_modulation_type.
|
||||
* @param supported_br pointer of \a nfc_baud_rate array.
|
||||
*
|
||||
*/
|
||||
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
|
||||
|
@ -1231,8 +1244,14 @@ nfc_device_validate_modulation(nfc_device *pnd, const nfc_mode mode, const nfc_m
|
|||
for (int i = 0; nmt[i]; i++) {
|
||||
if (nmt[i] == nm->nmt) {
|
||||
const nfc_baud_rate *nbr;
|
||||
if ((res = nfc_device_get_supported_baud_rate(pnd, mode, nmt[i], &nbr)) < 0) {
|
||||
return res;
|
||||
if (mode == N_INITIATOR) {
|
||||
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++) {
|
||||
if (nbr[j] == nm->nbr)
|
||||
|
|
Loading…
Reference in a new issue