Enhance error handeling.
- New API functions: nfc_strerror(), nfc_strerror_r() and nfc_perror(); - Drivers now have a reference to chips callback methods; - Rename -pn53x_err2string to pn53x_strerror and add it to pn53x_callbacks_list.
This commit is contained in:
parent
30e715cff0
commit
daa178b18f
7 changed files with 96 additions and 63 deletions
|
|
@ -93,6 +93,15 @@ typedef struct {
|
|||
uint32_t uiBusIndex;
|
||||
} nfc_device_desc_t;
|
||||
|
||||
/**
|
||||
* @struct chip_callbacks
|
||||
* @brief Functions for chip specific functions.
|
||||
*/
|
||||
struct chip_callbacks {
|
||||
/** Error lookup */
|
||||
const char* (*strerror) (const nfc_device_t *pnd);
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct driver_callbacks
|
||||
* @brief Generic structure to handle NFC device functions.
|
||||
|
|
@ -100,6 +109,8 @@ typedef struct {
|
|||
struct driver_callbacks {
|
||||
/** Driver name */
|
||||
const char* acDriver;
|
||||
/** Chip specific callback functions */
|
||||
const struct chip_callbacks *pcc;
|
||||
/** Pick devices callback */
|
||||
nfc_device_desc_t *(*pick_device)(void);
|
||||
/** List devices callback */
|
||||
|
|
|
|||
|
|
@ -78,6 +78,11 @@ NFC_EXPORT bool nfc_target_send_bits(nfc_device_t* pnd, const byte_t* pbtTx, con
|
|||
NFC_EXPORT bool nfc_target_send_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
|
||||
NFC_EXPORT bool nfc_target_send_dep_bytes(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTxLen);
|
||||
|
||||
/* Error reporting */
|
||||
NFC_EXPORT const char *nfc_strerror (const nfc_device_t *pnd);
|
||||
NFC_EXPORT int nfc_strerror_r (const nfc_device_t *pnd, char *pcStrErrBuf, size_t szBufLen);
|
||||
NFC_EXPORT void nfc_perror (const nfc_device_t *pnd, const char *pcString);
|
||||
|
||||
/* Special data accessors */
|
||||
NFC_EXPORT const char* nfc_device_name(nfc_device_t* pnd);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue