From 4e57078986357482aa56be9ae5db7f301f6f920d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 12 Nov 2024 03:33:20 +0000 Subject: [PATCH 1/2] build(bindings): bump SDK to `1.1.2` --- crates/sys/src/bindings.rs | 4206 ++++++++++++++++++------------------ 1 file changed, 2161 insertions(+), 2045 deletions(-) diff --git a/crates/sys/src/bindings.rs b/crates/sys/src/bindings.rs index 16d3903..594adbc 100644 --- a/crates/sys/src/bindings.rs +++ b/crates/sys/src/bindings.rs @@ -110,7 +110,7 @@ impl ::core::fmt::Debug for __IncompleteArrayField { fmt.write_str("__IncompleteArrayField") } } -pub const API_VERSION: u32 = 4784128; +pub const API_VERSION: u32 = 5111809; pub type wint_t = core::ffi::c_int; pub type __uint_least8_t = core::ffi::c_uchar; pub type __uint_least16_t = core::ffi::c_ushort; @@ -1674,12 +1674,27 @@ extern "C" { ); } pub type FuriEventLoopObject = core::ffi::c_void; -#[doc = "Callback type for event loop events\n\n # Arguments\n\n* `object` - The object that triggered the event\n * `context` - The context that was provided upon subscription\n\n # Returns\n\ntrue if event was processed, false if we need to delay processing"] +#[doc = "Callback type for event loop events\n\n # Arguments\n\n* `object` - The object that triggered the event\n * `context` - The context that was provided upon subscription"] pub type FuriEventLoopEventCallback = ::core::option::Option< - unsafe extern "C" fn(object: *mut FuriEventLoopObject, context: *mut core::ffi::c_void) -> bool, + unsafe extern "C" fn(object: *mut FuriEventLoopObject, context: *mut core::ffi::c_void), >; #[repr(C)] #[derive(Debug, Copy, Clone)] +pub struct FuriEventFlag { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Subscribe to event flag events\n\n you can only have one subscription for one event type.\n\n # Arguments\n\n* `instance` - The Event Loop instance\n * `event_flag` - The event flag to add\n * `event` (direction in) - The Event Loop event to trigger on\n * `callback` (direction in) - The callback to call on event\n * `context` - The context for callback"] + pub fn furi_event_loop_subscribe_event_flag( + instance: *mut FuriEventLoop, + event_flag: *mut FuriEventFlag, + event: FuriEventLoopEvent, + callback: FuriEventLoopEventCallback, + context: *mut core::ffi::c_void, + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] pub struct FuriMessageQueue { _unused: [u8; 0], } @@ -1745,6 +1760,13 @@ extern "C" { object: *mut FuriEventLoopObject, ); } +extern "C" { + #[doc = "Checks if the loop is subscribed to an object of any kind\n\n # Arguments\n\n* `instance` - Event Loop instance\n * `object` - Object to check"] + pub fn furi_event_loop_is_subscribed( + instance: *mut FuriEventLoop, + object: *mut FuriEventLoopObject, + ) -> bool; +} #[doc = "< One-shot timer."] pub const FuriEventLoopTimerType_FuriEventLoopTimerTypeOnce: FuriEventLoopTimerType = 0; #[doc = "< Repeating timer."] @@ -1796,11 +1818,6 @@ extern "C" { #[doc = "Check if the timer is currently running.\n\n A timer is considered running if it has not expired yet.\n # Arguments\n\n* `timer` (direction in) - pointer to the timer to be queried\n # Returns\n\ntrue if the timer is running, false otherwise"] pub fn furi_event_loop_timer_is_running(timer: *const FuriEventLoopTimer) -> bool; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct FuriEventFlag { - _unused: [u8; 0], -} extern "C" { #[doc = "Allocate FuriEventFlag\n\n # Returns\n\npointer to FuriEventFlag"] pub fn furi_event_flag_alloc() -> *mut FuriEventFlag; @@ -1859,7 +1876,7 @@ extern "C" { pub fn furi_delay_tick(ticks: u32); } extern "C" { - #[doc = "Delay until tick\n\n This should never be called in interrupt request context.\n\n # Arguments\n\n* `tick` (direction in) - The tick until which kerel should delay task execution\n\n # Returns\n\nThe furi status."] + #[doc = "Delay until tick\n\n This should never be called in interrupt request context.\n\n # Arguments\n\n* `tick` (direction in) - The tick until which kernel should delay task execution\n\n # Returns\n\nThe furi status."] pub fn furi_delay_until_tick(tick: u32) -> FuriStatus; } extern "C" { @@ -2001,23 +2018,25 @@ extern "C" { #[doc = "Freed space obtained through the aligned_malloc function\n # Arguments\n\n* `p` - pointer to result of aligned_malloc"] pub fn aligned_free(p: *mut core::ffi::c_void); } -#[doc = "< Thread is stopped"] +#[doc = "< Thread is stopped and is safe to release. Event delivered from system init thread(TCB cleanup routine). It is safe to release thread instance."] pub const FuriThreadState_FuriThreadStateStopped: FuriThreadState = 0; -#[doc = "< Thread is starting"] -pub const FuriThreadState_FuriThreadStateStarting: FuriThreadState = 1; -#[doc = "< Thread is running"] -pub const FuriThreadState_FuriThreadStateRunning: FuriThreadState = 2; +#[doc = "< Thread is stopping. Event delivered from child thread."] +pub const FuriThreadState_FuriThreadStateStopping: FuriThreadState = 1; +#[doc = "< Thread is starting. Event delivered from parent(self) thread."] +pub const FuriThreadState_FuriThreadStateStarting: FuriThreadState = 2; +#[doc = "< Thread is running. Event delivered from child thread."] +pub const FuriThreadState_FuriThreadStateRunning: FuriThreadState = 3; #[doc = "Enumeration of possible FuriThread states.\n\n Many of the FuriThread functions MUST ONLY be called when the thread is STOPPED."] pub type FuriThreadState = core::ffi::c_uchar; -#[doc = "< Uninitialized, choose system default"] -pub const FuriThreadPriority_FuriThreadPriorityNone: FuriThreadPriority = 0; #[doc = "< Idle priority"] -pub const FuriThreadPriority_FuriThreadPriorityIdle: FuriThreadPriority = 1; +pub const FuriThreadPriority_FuriThreadPriorityIdle: FuriThreadPriority = 0; +#[doc = "< Init System Thread Priority"] +pub const FuriThreadPriority_FuriThreadPriorityInit: FuriThreadPriority = 4; #[doc = "< Lowest"] pub const FuriThreadPriority_FuriThreadPriorityLowest: FuriThreadPriority = 14; #[doc = "< Low"] pub const FuriThreadPriority_FuriThreadPriorityLow: FuriThreadPriority = 15; -#[doc = "< Normal"] +#[doc = "< Normal, system default"] pub const FuriThreadPriority_FuriThreadPriorityNormal: FuriThreadPriority = 16; #[doc = "< High"] pub const FuriThreadPriority_FuriThreadPriorityHigh: FuriThreadPriority = 17; @@ -2044,9 +2063,13 @@ pub type FuriThreadCallback = #[doc = "Standard output callback function pointer type.\n\n The function to be used as a standard output callback MUST follow this signature.\n\n The handler MUST process ALL of the provided data before returning.\n\n # Arguments\n\n* `data` (direction in) - pointer to the data to be written to the standard out\n * `size` (direction in) - size of the data in bytes"] pub type FuriThreadStdoutWriteCallback = ::core::option::Option; -#[doc = "State change callback function pointer type.\n\n The function to be used as a state callback MUST follow this signature.\n\n # Arguments\n\n* `state` (direction in) - identifier of the state the thread has transitioned to\n * `context` (direction in, out) - pointer to a user-specified object"] +#[doc = "State change callback function pointer type.\n\n The function to be used as a state callback MUST follow this\n signature.\n\n # Arguments\n\n* `thread` (direction in) - to the FuriThread instance that changed the state\n * `state` (direction in) - identifier of the state the thread has transitioned\n to\n * `context` (direction in, out) - pointer to a user-specified object"] pub type FuriThreadStateCallback = ::core::option::Option< - unsafe extern "C" fn(state: FuriThreadState, context: *mut core::ffi::c_void), + unsafe extern "C" fn( + thread: *mut FuriThread, + state: FuriThreadState, + context: *mut core::ffi::c_void, + ), >; #[doc = "Signal handler callback function pointer type.\n\n The function to be used as a signal handler callback MUS follow this signature.\n\n # Arguments\n\n* `signal` (direction in) - value of the signal to be handled by the recipient\n * `arg` (direction in, out) - optional argument (can be of any value, including NULL)\n * `context` (direction in, out) - pointer to a user-specified object\n # Returns\n\ntrue if the signal was handled, false otherwise"] pub type FuriThreadSignalCallback = ::core::option::Option< @@ -2613,10 +2636,6 @@ extern "C" { thread: *mut FuriThread, ) -> *mut FuriThreadListItem; } -extern "C" { - #[doc = "Process items in the FuriThreadList instance\n\n # Arguments\n\n* `instance` - The instance\n * `runtime` (direction in) - The runtime of the system since start\n * `tick` (direction in) - The tick when processing happened"] - pub fn furi_thread_list_process(instance: *mut FuriThreadList, runtime: u32, tick: u32); -} extern "C" { #[doc = "Get percent of time spent in ISR\n\n # Arguments\n\n* `instance` - The instance\n\n # Returns\n\npercent of time spent in ISR"] pub fn furi_thread_list_get_isr_time(instance: *mut FuriThreadList) -> f32; @@ -2645,6 +2664,10 @@ extern "C" { #[doc = "Free timer\n\n # Arguments\n\n* `instance` - The pointer to FuriTimer instance"] pub fn furi_timer_free(instance: *mut FuriTimer); } +extern "C" { + #[doc = "Flush timer task control message queue\n\n Ensures that all commands before this point was processed."] + pub fn furi_timer_flush(); +} extern "C" { #[doc = "Start timer\n\n This is asynchronous call, real operation will happen as soon as\n timer service process this request.\n\n # Arguments\n\n* `instance` - The pointer to FuriTimer instance\n * `ticks` (direction in) - The interval in ticks\n\n # Returns\n\nThe furi status."] pub fn furi_timer_start(instance: *mut FuriTimer, ticks: u32) -> FuriStatus; @@ -2654,7 +2677,7 @@ extern "C" { pub fn furi_timer_restart(instance: *mut FuriTimer, ticks: u32) -> FuriStatus; } extern "C" { - #[doc = "Stop timer\n\n This is asynchronous call, real operation will happen as soon as\n timer service process this request.\n\n # Arguments\n\n* `instance` - The pointer to FuriTimer instance\n\n # Returns\n\nThe furi status."] + #[doc = "Stop timer\n\n This is synchronous call that will be blocked till timer queue processed.\n\n # Arguments\n\n* `instance` - The pointer to FuriTimer instance\n\n # Returns\n\nThe furi status."] pub fn furi_timer_stop(instance: *mut FuriTimer) -> FuriStatus; } extern "C" { @@ -6609,6 +6632,14 @@ extern "C" { #[doc = "Get a corresponding external connector pin number for a gpio\n\n # Arguments\n\n* `gpio` - GpioPin\n\n # Returns\n\npin number or -1 if gpio is not on the external connector"] pub fn furi_hal_resources_get_ext_pin_number(gpio: *const GpioPin) -> i32; } +extern "C" { + #[doc = "Finds a pin by its name\n\n # Arguments\n\n* `name` - case-insensitive pin name to look for (e.g. `\"Pc3\"`, `\"pA4\"`)\n\n # Returns\n\na pointer to the corresponding `GpioPinRecord` if such a pin exists,\n `NULL` otherwise."] + pub fn furi_hal_resources_pin_by_name(name: *const core::ffi::c_char) -> *const GpioPinRecord; +} +extern "C" { + #[doc = "Finds a pin by its number\n\n # Arguments\n\n* `name` - pin number to look for (e.g. `7`, `4`)\n\n # Returns\n\na pointer to the corresponding `GpioPinRecord` if such a pin exists,\n `NULL` otherwise."] + pub fn furi_hal_resources_pin_by_number(number: u8) -> *const GpioPinRecord; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct DateTime { @@ -7480,12 +7511,13 @@ pub const FuriHalInterruptId_FuriHalInterruptIdDma2Ch6: FuriHalInterruptId = 16; pub const FuriHalInterruptId_FuriHalInterruptIdDma2Ch7: FuriHalInterruptId = 17; pub const FuriHalInterruptId_FuriHalInterruptIdRcc: FuriHalInterruptId = 18; pub const FuriHalInterruptId_FuriHalInterruptIdCOMP: FuriHalInterruptId = 19; -pub const FuriHalInterruptId_FuriHalInterruptIdHsem: FuriHalInterruptId = 20; -pub const FuriHalInterruptId_FuriHalInterruptIdLpTim1: FuriHalInterruptId = 21; -pub const FuriHalInterruptId_FuriHalInterruptIdLpTim2: FuriHalInterruptId = 22; -pub const FuriHalInterruptId_FuriHalInterruptIdUart1: FuriHalInterruptId = 23; -pub const FuriHalInterruptId_FuriHalInterruptIdLpUart1: FuriHalInterruptId = 24; -pub const FuriHalInterruptId_FuriHalInterruptIdMax: FuriHalInterruptId = 25; +pub const FuriHalInterruptId_FuriHalInterruptIdRtcAlarm: FuriHalInterruptId = 20; +pub const FuriHalInterruptId_FuriHalInterruptIdHsem: FuriHalInterruptId = 21; +pub const FuriHalInterruptId_FuriHalInterruptIdLpTim1: FuriHalInterruptId = 22; +pub const FuriHalInterruptId_FuriHalInterruptIdLpTim2: FuriHalInterruptId = 23; +pub const FuriHalInterruptId_FuriHalInterruptIdUart1: FuriHalInterruptId = 24; +pub const FuriHalInterruptId_FuriHalInterruptIdLpUart1: FuriHalInterruptId = 25; +pub const FuriHalInterruptId_FuriHalInterruptIdMax: FuriHalInterruptId = 26; pub type FuriHalInterruptId = core::ffi::c_uchar; pub const FuriHalInterruptPriority_FuriHalInterruptPriorityLowest: FuriHalInterruptPriority = -3; pub const FuriHalInterruptPriority_FuriHalInterruptPriorityLower: FuriHalInterruptPriority = -2; @@ -11687,7 +11719,7 @@ extern "C" { ); } extern "C" { - #[doc = "Move the contents of source folder to destination one and rename all conflicting files.\n\n Source folder will be deleted if the migration was successful.\n\n # Arguments\n\n* `storage` - pointer to a storage API instance.\n * `source` - pointer to a zero-terminated string containing the source path.\n * `dest` - pointer to a zero-terminated string containing the destination path.\n # Returns\n\nFSE_OK if the migration was successfull completed, any other error code on failure."] + #[doc = "Move the contents of source folder to destination one and rename all conflicting files.\n\n Source folder will be deleted if the migration was successful.\n\n # Arguments\n\n* `storage` - pointer to a storage API instance.\n * `source` - pointer to a zero-terminated string containing the source path.\n * `dest` - pointer to a zero-terminated string containing the destination path.\n # Returns\n\nFSE_OK if the migration was successfully completed, any other error code on failure."] pub fn storage_common_migrate( storage: *mut Storage, source: *const core::ffi::c_char, @@ -11699,16 +11731,23 @@ extern "C" { pub fn storage_common_exists(storage: *mut Storage, path: *const core::ffi::c_char) -> bool; } extern "C" { - #[doc = "Check whether two paths are equivalent.\n\n This function will resolve aliases and apply filesystem-specific\n rules to determine whether the two given paths are equivalent.\n\n Examples:\n - /int/text and /ext/test -> false (Different storages),\n - /int/Test and /int/test -> false (Case-sensitive storage),\n - /ext/Test and /ext/test -> true (Case-insensitive storage).\n\n If the truncate parameter is set to true, the second path will be\n truncated to be no longer than the first one. It is useful to determine\n whether path2 is a subdirectory of path1.\n\n # Arguments\n\n* `storage` - pointer to a storage API instance.\n * `path1` - pointer to a zero-terminated string containing the first path.\n * `path2` - pointer to a zero-terminated string containing the second path.\n * `truncate` - whether to truncate path2 to be no longer than path1.\n # Returns\n\ntrue if paths are equivalent, false otherwise."] + #[doc = "Check whether two paths are equivalent.\n\n This function will resolve aliases and apply filesystem-specific\n rules to determine whether the two given paths are equivalent.\n\n Examples:\n - /int/text and /ext/test -> false (Different storages),\n - /int/Test and /int/test -> false (Case-sensitive storage),\n - /ext/Test and /ext/test -> true (Case-insensitive storage).\n\n # Arguments\n\n* `storage` - pointer to a storage API instance.\n * `path1` - pointer to a zero-terminated string containing the first path.\n * `path2` - pointer to a zero-terminated string containing the second path.\n # Returns\n\ntrue if paths are equivalent, false otherwise."] pub fn storage_common_equivalent_path( storage: *mut Storage, path1: *const core::ffi::c_char, path2: *const core::ffi::c_char, - truncate: bool, ) -> bool; } extern "C" { - #[doc = "Get the textual description of a numeric error identifer.\n\n # Arguments\n\n* `error_id` - numeric identifier of the error in question.\n # Returns\n\npointer to a statically allocated zero-terminated string containing the respective error text."] + #[doc = "Check whether a path is a subpath of another path.\n\n This function respects storage-defined equivalence rules\n (see `storage_common_equivalent_path`).\n\n # Arguments\n\n* `storage` - pointer to a storage API instance.\n * `parent` - pointer to a zero-terminated string containing the parent path.\n * `child` - pointer to a zero-terminated string containing the child path.\n # Returns\n\ntrue if `child` is a subpath of `parent`, or if `child` is equivalent\n to `parent`; false otherwise."] + pub fn storage_common_is_subdir( + storage: *mut Storage, + parent: *const core::ffi::c_char, + child: *const core::ffi::c_char, + ) -> bool; +} +extern "C" { + #[doc = "Get the textual description of a numeric error identifier.\n\n # Arguments\n\n* `error_id` - numeric identifier of the error in question.\n # Returns\n\npointer to a statically allocated zero-terminated string containing the respective error text."] pub fn storage_error_get_desc(error_id: FS_Error) -> *const core::ffi::c_char; } extern "C" { @@ -12773,6 +12812,18 @@ extern "C" { bitmap: *const u8, ); } +extern "C" { + #[doc = "Draw rotated XBM bitmap\n\n # Arguments\n\n* `canvas` - Canvas instance\n * `x` - x coordinate\n * `y` - y coordinate\n * `width` (direction in) - bitmap width\n * `height` (direction in) - bitmap height\n * `rotation` (direction in) - bitmap rotation\n * `bitmap_data` - pointer to XBM bitmap data"] + pub fn canvas_draw_xbm_ex( + canvas: *mut Canvas, + x: i32, + y: i32, + width: usize, + height: usize, + rotation: IconRotation, + bitmap_data: *const u8, + ); +} extern "C" { #[doc = "Draw dot at x,y\n\n # Arguments\n\n* `canvas` - Canvas instance\n * `x` - x coordinate\n * `y` - y coordinate"] pub fn canvas_draw_dot(canvas: *mut Canvas, x: i32, y: i32); @@ -14629,6 +14680,10 @@ extern "C" { clear_default_text: bool, ); } +extern "C" { + #[doc = "Sets the minimum length of a TextInput\n # Arguments\n\n* `[in]` - text_input TextInput\n * `[in]` - minimum_length Minimum input length"] + pub fn text_input_set_minimum_length(text_input: *mut TextInput, minimum_length: usize); +} extern "C" { pub fn text_input_set_validator( text_input: *mut TextInput, @@ -15067,6 +15122,10 @@ extern "C" { #[doc = "Allocate ViewDispatcher instance\n\n # Returns\n\npointer to ViewDispatcher instance"] pub fn view_dispatcher_alloc() -> *mut ViewDispatcher; } +extern "C" { + #[doc = "Allocate ViewDispatcher instance with an externally owned event loop. If\n this constructor is used instead of `view_dispatcher_alloc`, the burden of\n freeing the event loop is placed on the caller.\n\n # Arguments\n\n* `loop` - pointer to FuriEventLoop instance\n # Returns\n\npointer to ViewDispatcher instance"] + pub fn view_dispatcher_alloc_ex(loop_: *mut FuriEventLoop) -> *mut ViewDispatcher; +} extern "C" { #[doc = "Free ViewDispatcher instance\n\n All added views MUST be removed using view_dispatcher_remove_view()\n before calling this function.\n\n # Arguments\n\n* `view_dispatcher` - pointer to ViewDispatcher"] pub fn view_dispatcher_free(view_dispatcher: *mut ViewDispatcher); @@ -15094,7 +15153,7 @@ extern "C" { ); } extern "C" { - #[doc = "Set tick event handler\n\n # Arguments\n\n* `view_dispatcher` - ViewDispatcher instance\n * `callback` - ViewDispatcherTickEventCallback\n * `tick_period` - callback call period"] + #[doc = "Set tick event handler\n\n Requires the event loop to be owned by the view dispatcher, i.e.\n it should have been instantiated with `view_dispatcher_alloc`, not\n `view_dispatcher_alloc_ex`.\n\n # Arguments\n\n* `view_dispatcher` - ViewDispatcher instance\n * `callback` - ViewDispatcherTickEventCallback\n * `tick_period` - callback call period"] pub fn view_dispatcher_set_tick_event_callback( view_dispatcher: *mut ViewDispatcher, callback: ViewDispatcherTickEventCallback, @@ -16398,6 +16457,9 @@ extern "C" { extern "C" { pub static sequence_lcd_contrast_update: NotificationSequence; } +extern "C" { + pub static sequence_empty: NotificationSequence; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Power { @@ -20724,39 +20786,39 @@ pub struct BitBuffer { _unused: [u8; 0], } extern "C" { - #[doc = "Allocate a BitBuffer instance.\n\n # Arguments\n\n* `[in]` - capacity_bytes maximum buffer capacity, in bytes\n # Returns\n\npointer to the allocated BitBuffer instance"] + #[doc = "Allocate a BitBuffer instance.\n\n # Arguments\n\n* `capacity_bytes` (direction in) - maximum buffer capacity, in bytes\n\n # Returns\n\npointer to the allocated BitBuffer instance"] pub fn bit_buffer_alloc(capacity_bytes: usize) -> *mut BitBuffer; } extern "C" { - #[doc = "Delete a BitBuffer instance.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance"] + #[doc = "Delete a BitBuffer instance.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance"] pub fn bit_buffer_free(buf: *mut BitBuffer); } extern "C" { - #[doc = "Clear all data from a BitBuffer instance.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance"] + #[doc = "Clear all data from a BitBuffer instance.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance"] pub fn bit_buffer_reset(buf: *mut BitBuffer); } extern "C" { - #[doc = "Copy another BitBuffer instance's contents to this one, replacing\n all of the original data.\n The destination capacity must be no less than the source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - other pointer to a BitBuffer instance to copy from\n > **Note:** "] + #[doc = "Copy another BitBuffer instance's contents to this one, replacing all of the\n original data.\n\n The destination capacity must be no less than the source data\n size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `other` (direction in) - pointer to a BitBuffer instance to copy from"] pub fn bit_buffer_copy(buf: *mut BitBuffer, other: *const BitBuffer); } extern "C" { - #[doc = "Copy all BitBuffer instance's contents to this one, starting from start_index,\n replacing all of the original data.\n The destination capacity must be no less than the source data size\n counting from start_index.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - other pointer to a BitBuffer instance to copy from\n * `[in]` - start_index index to begin copying source data from"] + #[doc = "Copy all BitBuffer instance's contents to this one, starting from\n start_index, replacing all of the original data.\n\n The destination capacity must be no less than the source data\n size counting from start_index.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `other` (direction in) - pointer to a BitBuffer instance to copy from\n * `start_index` (direction in) - index to begin copying source data from"] pub fn bit_buffer_copy_right(buf: *mut BitBuffer, other: *const BitBuffer, start_index: usize); } extern "C" { - #[doc = "Copy all BitBuffer instance's contents to this one, ending with end_index,\n replacing all of the original data.\n The destination capacity must be no less than the source data size\n counting to end_index.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - other pointer to a BitBuffer instance to copy from\n * `[in]` - end_index index to end copying source data at"] + #[doc = "Copy all BitBuffer instance's contents to this one, ending with end_index,\n replacing all of the original data.\n\n The destination capacity must be no less than the source data\n size counting to end_index.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `other` (direction in) - pointer to a BitBuffer instance to copy from\n * `end_index` (direction in) - index to end copying source data at"] pub fn bit_buffer_copy_left(buf: *mut BitBuffer, other: *const BitBuffer, end_index: usize); } extern "C" { - #[doc = "Copy a byte array to a BitBuffer instance, replacing all of the original data.\n The destination capacity must be no less than the source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - data pointer to the byte array to be copied\n * `[in]` - size_bytes size of the data to be copied, in bytes"] + #[doc = "Copy a byte array to a BitBuffer instance, replacing all of the original\n data.\n\n The destination capacity must be no less than the source data\n size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `data` (direction in) - pointer to the byte array to be copied\n * `size_bytes` (direction in) - size of the data to be copied, in bytes"] pub fn bit_buffer_copy_bytes(buf: *mut BitBuffer, data: *const u8, size_bytes: usize); } extern "C" { - #[doc = "Copy a byte array to a BitBuffer instance, replacing all of the original data.\n The destination capacity must be no less than the source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - data pointer to the byte array to be copied\n * `[in]` - size_bits size of the data to be copied, in bits"] + #[doc = "Copy a byte array to a BitBuffer instance, replacing all of the original\n data.\n\n The destination capacity must be no less than the source data\n size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `data` (direction in) - pointer to the byte array to be copied\n * `size_bits` (direction in) - size of the data to be copied, in bits"] pub fn bit_buffer_copy_bits(buf: *mut BitBuffer, data: *const u8, size_bits: usize); } extern "C" { - #[doc = "Copy a byte with parity array to a BitBuffer instance, replacing all of the original data.\n The destination capacity must be no less than the source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to copy into\n * `[in]` - data pointer to the byte array to be copied\n * `[in]` - size_bitss size of the data to be copied, in bits"] + #[doc = "Copy a byte with parity array to a BitBuffer instance, replacing all of the\n original data.\n\n The destination capacity must be no less than the source data\n size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to copy into\n * `data` (direction in) - pointer to the byte array to be copied\n * `size_bits` (direction in) - size of the data to be copied, in bits\n > **Note:** Parity bits are placed starting with the most significant bit\n of each byte and moving up.\n > **Note:** Example: DDDDDDDD PDDDDDDD DPDDDDDD DDP..."] pub fn bit_buffer_copy_bytes_with_parity( buf: *mut BitBuffer, data: *const u8, @@ -20764,7 +20826,7 @@ extern "C" { ); } extern "C" { - #[doc = "Write a BitBuffer instance's entire contents to an arbitrary memory location.\n The destination memory must be allocated. Additionally, the destination\n capacity must be no less than the source data size.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to write from\n * `[out]` - dest pointer to the destination memory location\n * `[in]` - size_bytes maximum destination data size, in bytes"] + #[doc = "Write a BitBuffer instance's entire contents to an arbitrary memory location.\n\n The destination memory must be allocated. Additionally, the\n destination capacity must be no less than the source data size.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to write from\n * `dest` (direction out) - pointer to the destination memory location\n * `size_bytes` (direction in) - maximum destination data size, in bytes"] pub fn bit_buffer_write_bytes( buf: *const BitBuffer, dest: *mut core::ffi::c_void, @@ -20772,7 +20834,7 @@ extern "C" { ); } extern "C" { - #[doc = "Write a BitBuffer instance's entire contents to an arbitrary memory location.\n Additionally, place a parity bit after each byte.\n The destination memory must be allocated. Additionally, the destination\n capacity must be no less than the source data size plus parity.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to write from\n * `[out]` - dest pointer to the destination memory location\n * `[in]` - size_bytes maximum destination data size, in bytes\n * `[out]` - bits_written actual number of bits writen, in bits"] + #[doc = "Write a BitBuffer instance's entire contents to an arbitrary memory location.\n\n Additionally, place a parity bit after each byte.\n\n The destination memory must be allocated. Additionally, the\n destination capacity must be no less than the source data size\n plus parity.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to write from\n * `dest` (direction out) - pointer to the destination memory location\n * `size_bytes` (direction in) - maximum destination data size, in bytes\n * `bits_written` (direction out) - actual number of bits written, in bits\n > **Note:** Parity bits are placed starting with the most significant bit of\n each byte and moving up.\n > **Note:** Example: DDDDDDDD PDDDDDDD DPDDDDDD DDP..."] pub fn bit_buffer_write_bytes_with_parity( buf: *const BitBuffer, dest: *mut core::ffi::c_void, @@ -20781,7 +20843,7 @@ extern "C" { ); } extern "C" { - #[doc = "Write a slice of BitBuffer instance's contents to an arbitrary memory location.\n The destination memory must be allocated. Additionally, the destination\n capacity must be no less than the requested slice size.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to write from\n * `[out]` - dest pointer to the destination memory location\n * `[in]` - start_index index to begin copying source data from\n * `[in]` - size_bytes data slice size, in bytes"] + #[doc = "Write a slice of BitBuffer instance's contents to an arbitrary memory\n location.\n\n The destination memory must be allocated. Additionally, the\n destination capacity must be no less than the requested slice\n size.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to write from\n * `dest` (direction out) - pointer to the destination memory location\n * `start_index` (direction in) - index to begin copying source data from\n * `size_bytes` (direction in) - data slice size, in bytes"] pub fn bit_buffer_write_bytes_mid( buf: *const BitBuffer, dest: *mut core::ffi::c_void, @@ -20790,47 +20852,47 @@ extern "C" { ); } extern "C" { - #[doc = "Check whether a BitBuffer instance contains a partial byte (i.e. the bit count\n is not divisible by 8).\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be checked\n # Returns\n\ntrue if the instance contains a partial byte, false otherwise"] + #[doc = "Check whether a BitBuffer instance contains a partial byte (i.e. the bit\n count is not divisible by 8).\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be checked\n\n # Returns\n\ntrue if the instance contains a partial byte, false otherwise"] pub fn bit_buffer_has_partial_byte(buf: *const BitBuffer) -> bool; } extern "C" { - #[doc = "Check whether a BitBuffer instance's contents start with the designated byte.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be checked\n * `[in]` - byte byte value to be checked against\n # Returns\n\ntrue if data starts with designated byte, false otherwise"] + #[doc = "Check whether a BitBuffer instance's contents start with the designated byte.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be checked\n * `byte` (direction in) - byte value to be checked against\n\n # Returns\n\ntrue if data starts with designated byte, false otherwise"] pub fn bit_buffer_starts_with_byte(buf: *const BitBuffer, byte: u8) -> bool; } extern "C" { - #[doc = "Get a BitBuffer instance's capacity (i.e. the maximum possible amount of data), in bytes.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n # Returns\n\ncapacity, in bytes"] + #[doc = "Get a BitBuffer instance's capacity (i.e. the maximum possible amount of\n data), in bytes.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n\n # Returns\n\ncapacity, in bytes"] pub fn bit_buffer_get_capacity_bytes(buf: *const BitBuffer) -> usize; } extern "C" { - #[doc = "Get a BitBuffer instance's data size (i.e. the amount of stored data), in bits.\n Might be not divisible by 8 (see bit_buffer_is_partial_byte).\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n # Returns\n\ndata size, in bits."] + #[doc = "Get a BitBuffer instance's data size (i.e. the amount of stored data), in\n bits.\n\n Might be not divisible by 8 (see bit_buffer_is_partial_byte).\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n\n # Returns\n\ndata size, in bits."] pub fn bit_buffer_get_size(buf: *const BitBuffer) -> usize; } extern "C" { - #[doc = "Get a BitBuffer instance's data size (i.e. the amount of stored data), in bytes.\n If a partial byte is present, it is also counted.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n # Returns\n\ndata size, in bytes."] + #[doc = "Get a BitBuffer instance's data size (i.e. the amount of stored data), in\n bytes.\n\n If a partial byte is present, it is also counted.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n\n # Returns\n\ndata size, in bytes."] pub fn bit_buffer_get_size_bytes(buf: *const BitBuffer) -> usize; } extern "C" { - #[doc = "Get a byte value at a specified index in a BitBuffer instance.\n The index must be valid (i.e. less than the instance's data size in bytes).\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n * `[in]` - index index of the byte in question"] + #[doc = "Get a byte value at a specified index in a BitBuffer instance.\n\n The index must be valid (i.e. less than the instance's data size\n in bytes).\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n * `index` (direction in) - index of the byte in question\n\n # Returns\n\nbyte value"] pub fn bit_buffer_get_byte(buf: *const BitBuffer, index: usize) -> u8; } extern "C" { - #[doc = "Get a byte value starting from the specified bit index in a BitBuffer instance.\n The resulting byte might correspond to a single byte (if the index is a multiple\n of 8), or two overlapping bytes combined.\n The index must be valid (i.e. less than the instance's data size in bits).\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n * `[in]` - index bit index of the byte in question"] + #[doc = "Get a byte value starting from the specified bit index in a BitBuffer\n instance.\n\n The resulting byte might correspond to a single byte (if the\n index is a multiple of 8), or two overlapping bytes combined. The\n index must be valid (i.e. less than the instance's data size in\n bits).\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n * `index_bits` (direction in) - bit index of the byte in question\n\n # Returns\n\nbyte value"] pub fn bit_buffer_get_byte_from_bit(buf: *const BitBuffer, index_bits: usize) -> u8; } extern "C" { - #[doc = "Get the pointer to a BitBuffer instance's underlying data.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n # Returns\n\npointer to the underlying data"] + #[doc = "Get the pointer to a BitBuffer instance's underlying data.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n\n # Returns\n\npointer to the underlying data"] pub fn bit_buffer_get_data(buf: *const BitBuffer) -> *const u8; } extern "C" { - #[doc = "Get the pointer to a BitBuffer instance's underlying data.\n\n # Arguments\n\n* `[in]` - buf pointer to a BitBuffer instance to be queried\n # Returns\n\npointer to the underlying data"] + #[doc = "Get the pointer to the parity data of a BitBuffer instance.\n\n # Arguments\n\n* `buf` (direction in) - pointer to a BitBuffer instance to be queried\n\n # Returns\n\npointer to the parity data"] pub fn bit_buffer_get_parity(buf: *const BitBuffer) -> *const u8; } extern "C" { - #[doc = "Set byte value at a specified index in a BitBuffer instance.\n The index must be valid (i.e. less than the instance's data size in bytes).\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be modified\n * `[in]` - index index of the byte in question\n * `[in]` - byte byte value to be set at index"] + #[doc = "Set byte value at a specified index in a BitBuffer instance.\n\n The index must be valid (i.e. less than the instance's data\n size in bytes).\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be modified\n * `index` (direction in) - index of the byte in question\n * `byte` (direction in) - byte value to be set at index"] pub fn bit_buffer_set_byte(buf: *mut BitBuffer, index: usize, byte: u8); } extern "C" { - #[doc = "Set byte and parity bit value at a specified index in a BitBuffer instance.\n The index must be valid (i.e. less than the instance's data size in bytes).\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be modified\n * `[in]` - index index of the byte in question\n * `[in]` - byte byte value to be set at index\n * `[in]` - parity parity bit value to be set at index"] + #[doc = "Set byte and parity bit value at a specified index in a BitBuffer instance.\n\n The index must be valid (i.e. less than the instance's data\n size in bytes).\n\n # Arguments\n\n* `buff` (direction in, out) - pointer to a BitBuffer instance to be modified\n * `index` (direction in) - index of the byte in question\n * `byte` (direction in) - byte value to be set at index\n * `parity` (direction in) - parity bit value to be set at index"] pub fn bit_buffer_set_byte_with_parity( buff: *mut BitBuffer, index: usize, @@ -20839,19 +20901,19 @@ extern "C" { ); } extern "C" { - #[doc = "Resize a BitBuffer instance to a new size, in bits.\n May cause bugs. Use only if absolutely necessary.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be resized\n * `[in]` - new_size the new size of the buffer, in bits"] + #[doc = "Resize a BitBuffer instance to a new size, in bits.\n\n May cause bugs. Use only if absolutely necessary.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be resized\n * `new_size` (direction in) - the new size of the buffer, in bits"] pub fn bit_buffer_set_size(buf: *mut BitBuffer, new_size: usize); } extern "C" { - #[doc = "Resize a BitBuffer instance to a new size, in bytes.\n May cause bugs. Use only if absolutely necessary.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be resized\n * `[in]` - new_size_bytes the new size of the buffer, in bytes"] + #[doc = "Resize a BitBuffer instance to a new size, in bytes.\n\n May cause bugs. Use only if absolutely necessary.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be resized\n * `new_size_bytes` (direction in) - the new size of the buffer, in bytes"] pub fn bit_buffer_set_size_bytes(buf: *mut BitBuffer, new_size_bytes: usize); } extern "C" { - #[doc = "Append all BitBuffer's instance contents to this one. The destination capacity\n must be no less than its original data size plus source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be appended to\n * `[in]` - other pointer to a BitBuffer instance to be appended"] + #[doc = "Append all BitBuffer's instance contents to this one.\n\n The destination capacity must be no less than its original\n data size plus source data size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be appended to\n * `other` (direction in) - pointer to a BitBuffer instance to be appended"] pub fn bit_buffer_append(buf: *mut BitBuffer, other: *const BitBuffer); } extern "C" { - #[doc = "Append a BitBuffer's instance contents to this one, starting from start_index.\n The destination capacity must be no less than the source data size\n counting from start_index.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be appended to\n * `[in]` - other pointer to a BitBuffer instance to be appended\n * `[in]` - start_index index to begin copying source data from"] + #[doc = "Append a BitBuffer's instance contents to this one, starting from\n start_index.\n\n The destination capacity must be no less than the source data\n size counting from start_index.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be appended to\n * `other` (direction in) - pointer to a BitBuffer instance to be appended\n * `start_index` (direction in) - index to begin copying source data from"] pub fn bit_buffer_append_right( buf: *mut BitBuffer, other: *const BitBuffer, @@ -20859,2917 +20921,2966 @@ extern "C" { ); } extern "C" { - #[doc = "Append a byte to a BitBuffer instance.\n The destination capacity must be no less its original data size plus one.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be appended to\n * `[in]` - byte byte value to be appended"] + #[doc = "Append a byte to a BitBuffer instance.\n\n The destination capacity must be no less its original data\n size plus one.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be appended to\n * `byte` (direction in) - byte value to be appended"] pub fn bit_buffer_append_byte(buf: *mut BitBuffer, byte: u8); } extern "C" { - #[doc = "Append a byte array to a BitBuffer instance.\n The destination capacity must be no less its original data size plus source data size.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be appended to\n * `[in]` - data pointer to the byte array to be appended\n * `[in]` - size_bytes size of the data to be appended, in bytes"] + #[doc = "Append a byte array to a BitBuffer instance.\n\n The destination capacity must be no less its original data\n size plus source data size.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be appended to\n * `data` (direction in) - pointer to the byte array to be appended\n * `size_bytes` (direction in) - size of the data to be appended, in bytes"] pub fn bit_buffer_append_bytes(buf: *mut BitBuffer, data: *const u8, size_bytes: usize); } extern "C" { - #[doc = "Append a bit to a BitBuffer instance.\n The destination capacity must be sufficient to accomodate the additional bit.\n\n # Arguments\n\n* `[in,out]` - buf pointer to a BitBuffer instance to be appended to\n * `[in]` - bit bit value to be appended"] + #[doc = "Append a bit to a BitBuffer instance.\n\n The destination capacity must be sufficient to accommodate the\n additional bit.\n\n # Arguments\n\n* `buf` (direction in, out) - pointer to a BitBuffer instance to be appended to\n * `bit` (direction in) - bit value to be appended"] pub fn bit_buffer_append_bit(buf: *mut BitBuffer, bit: bool); } +#[doc = "< Display full(verbose) name."] +pub const NfcDeviceNameType_NfcDeviceNameTypeFull: NfcDeviceNameType = 0; +#[doc = "< Display shortened name."] +pub const NfcDeviceNameType_NfcDeviceNameTypeShort: NfcDeviceNameType = 1; +#[doc = "Verbosity level of the displayed NFC device name."] +pub type NfcDeviceNameType = core::ffi::c_uchar; +#[doc = "Generic opaque type for protocol-specific NFC device data."] +pub type NfcDeviceData = core::ffi::c_void; +pub const Iso14443_3aError_Iso14443_3aErrorNone: Iso14443_3aError = 0; +pub const Iso14443_3aError_Iso14443_3aErrorNotPresent: Iso14443_3aError = 1; +pub const Iso14443_3aError_Iso14443_3aErrorColResFailed: Iso14443_3aError = 2; +pub const Iso14443_3aError_Iso14443_3aErrorBufferOverflow: Iso14443_3aError = 3; +pub const Iso14443_3aError_Iso14443_3aErrorCommunication: Iso14443_3aError = 4; +pub const Iso14443_3aError_Iso14443_3aErrorFieldOff: Iso14443_3aError = 5; +pub const Iso14443_3aError_Iso14443_3aErrorWrongCrc: Iso14443_3aError = 6; +pub const Iso14443_3aError_Iso14443_3aErrorTimeout: Iso14443_3aError = 7; +pub type Iso14443_3aError = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Crypto1 { - pub odd: u32, - pub even: u32, +pub struct Iso14443_3aData { + pub uid: [u8; 10usize], + pub uid_len: u8, + pub atqa: [u8; 2usize], + pub sak: u8, } #[test] -fn bindgen_test_layout_Crypto1() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_Iso14443_3aData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(Crypto1)) + ::core::mem::size_of::(), + 14usize, + concat!("Size of: ", stringify!(Iso14443_3aData)) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(Crypto1)) + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(Iso14443_3aData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).odd) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(Crypto1), + stringify!(Iso14443_3aData), "::", - stringify!(odd) + stringify!(uid) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).even) as usize - ptr as usize }, - 4usize, + unsafe { ::core::ptr::addr_of!((*ptr).uid_len) as usize - ptr as usize }, + 10usize, concat!( "Offset of field: ", - stringify!(Crypto1), + stringify!(Iso14443_3aData), "::", - stringify!(even) + stringify!(uid_len) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).atqa) as usize - ptr as usize }, + 11usize, + concat!( + "Offset of field: ", + stringify!(Iso14443_3aData), + "::", + stringify!(atqa) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sak) as usize - ptr as usize }, + 13usize, + concat!( + "Offset of field: ", + stringify!(Iso14443_3aData), + "::", + stringify!(sak) ) ); } extern "C" { - pub fn crypto1_alloc() -> *mut Crypto1; -} -extern "C" { - pub fn crypto1_free(instance: *mut Crypto1); + pub fn iso14443_3a_alloc() -> *mut Iso14443_3aData; } extern "C" { - pub fn crypto1_reset(crypto1: *mut Crypto1); + pub fn iso14443_3a_free(data: *mut Iso14443_3aData); } extern "C" { - pub fn crypto1_init(crypto1: *mut Crypto1, key: u64); + pub fn iso14443_3a_reset(data: *mut Iso14443_3aData); } extern "C" { - pub fn crypto1_bit(crypto1: *mut Crypto1, in_: u8, is_encrypted: core::ffi::c_int) -> u8; + pub fn iso14443_3a_copy(data: *mut Iso14443_3aData, other: *const Iso14443_3aData); } extern "C" { - pub fn crypto1_byte(crypto1: *mut Crypto1, in_: u8, is_encrypted: core::ffi::c_int) -> u8; + pub fn iso14443_3a_verify(data: *mut Iso14443_3aData, device_type: *const FuriString) -> bool; } extern "C" { - pub fn crypto1_word(crypto1: *mut Crypto1, in_: u32, is_encrypted: core::ffi::c_int) -> u32; + pub fn iso14443_3a_load( + data: *mut Iso14443_3aData, + ff: *mut FlipperFormat, + version: u32, + ) -> bool; } extern "C" { - pub fn crypto1_decrypt(crypto: *mut Crypto1, buff: *const BitBuffer, out: *mut BitBuffer); + pub fn iso14443_3a_save(data: *const Iso14443_3aData, ff: *mut FlipperFormat) -> bool; } extern "C" { - pub fn crypto1_encrypt( - crypto: *mut Crypto1, - keystream: *mut u8, - buff: *const BitBuffer, - out: *mut BitBuffer, - ); + pub fn iso14443_3a_is_equal( + data: *const Iso14443_3aData, + other: *const Iso14443_3aData, + ) -> bool; } extern "C" { - pub fn crypto1_encrypt_reader_nonce( - crypto: *mut Crypto1, - key: u64, - cuid: u32, - nt: *mut u8, - nr: *mut u8, - out: *mut BitBuffer, - is_nested: bool, - ); + pub fn iso14443_3a_get_device_name( + data: *const Iso14443_3aData, + name_type: NfcDeviceNameType, + ) -> *const core::ffi::c_char; } extern "C" { - pub fn prng_successor(x: u32, n: u32) -> u32; + pub fn iso14443_3a_get_uid(data: *const Iso14443_3aData, uid_len: *mut usize) -> *const u8; } -pub const Iso13239CrcType_Iso13239CrcTypeDefault: Iso13239CrcType = 0; -pub const Iso13239CrcType_Iso13239CrcTypePicopass: Iso13239CrcType = 1; -pub type Iso13239CrcType = core::ffi::c_uchar; extern "C" { - pub fn iso13239_crc_append(type_: Iso13239CrcType, buf: *mut BitBuffer); + pub fn iso14443_3a_set_uid(data: *mut Iso14443_3aData, uid: *const u8, uid_len: usize) -> bool; } extern "C" { - pub fn iso13239_crc_check(type_: Iso13239CrcType, buf: *const BitBuffer) -> bool; + pub fn iso14443_3a_get_base_data(data: *const Iso14443_3aData) -> *mut Iso14443_3aData; } extern "C" { - pub fn iso13239_crc_trim(buf: *mut BitBuffer); + pub fn iso14443_3a_get_cuid(data: *const Iso14443_3aData) -> u32; } -pub const Iso14443CrcType_Iso14443CrcTypeA: Iso14443CrcType = 0; -pub const Iso14443CrcType_Iso14443CrcTypeB: Iso14443CrcType = 1; -pub type Iso14443CrcType = core::ffi::c_uchar; extern "C" { - pub fn iso14443_crc_append(type_: Iso14443CrcType, buf: *mut BitBuffer); + pub fn iso14443_3a_supports_iso14443_4(data: *const Iso14443_3aData) -> bool; } extern "C" { - pub fn iso14443_crc_check(type_: Iso14443CrcType, buf: *const BitBuffer) -> bool; + pub fn iso14443_3a_get_sak(data: *const Iso14443_3aData) -> u8; } extern "C" { - pub fn iso14443_crc_trim(buf: *mut BitBuffer); + pub fn iso14443_3a_get_atqa(data: *const Iso14443_3aData, atqa: *mut u8); } -#[doc = "< Display full(verbose) name."] -pub const NfcDeviceNameType_NfcDeviceNameTypeFull: NfcDeviceNameType = 0; -#[doc = "< Display shortened name."] -pub const NfcDeviceNameType_NfcDeviceNameTypeShort: NfcDeviceNameType = 1; -#[doc = "Verbosity level of the displayed NFC device name."] -pub type NfcDeviceNameType = core::ffi::c_uchar; -#[doc = "Generic opaque type for protocol-specific NFC device data."] -pub type NfcDeviceData = core::ffi::c_void; -pub const NfcProtocol_NfcProtocolIso14443_3a: NfcProtocol = 0; -pub const NfcProtocol_NfcProtocolIso14443_3b: NfcProtocol = 1; -pub const NfcProtocol_NfcProtocolIso14443_4a: NfcProtocol = 2; -pub const NfcProtocol_NfcProtocolIso14443_4b: NfcProtocol = 3; -pub const NfcProtocol_NfcProtocolIso15693_3: NfcProtocol = 4; -pub const NfcProtocol_NfcProtocolFelica: NfcProtocol = 5; -pub const NfcProtocol_NfcProtocolMfUltralight: NfcProtocol = 6; -pub const NfcProtocol_NfcProtocolMfClassic: NfcProtocol = 7; -pub const NfcProtocol_NfcProtocolMfPlus: NfcProtocol = 8; -pub const NfcProtocol_NfcProtocolMfDesfire: NfcProtocol = 9; -pub const NfcProtocol_NfcProtocolSlix: NfcProtocol = 10; -pub const NfcProtocol_NfcProtocolSt25tb: NfcProtocol = 11; -#[doc = "< Special value representing the number of available protocols."] -pub const NfcProtocol_NfcProtocolNum: NfcProtocol = 12; -#[doc = "< Special value representing an invalid state."] -pub const NfcProtocol_NfcProtocolInvalid: NfcProtocol = 13; -#[doc = "Enumeration of all available NFC protocols.\n\n When implementing a new protocol, add its identifier before the\n NfcProtocolNum entry."] -pub type NfcProtocol = core::ffi::c_uchar; extern "C" { - #[doc = "Get the immediate parent of a specific protocol.\n\n # Arguments\n\n* `protocol` (direction in) - identifier of the protocol in question.\n # Returns\n\nparent protocol identifier if it has one, or NfcProtocolInvalid otherwise."] - pub fn nfc_protocol_get_parent(protocol: NfcProtocol) -> NfcProtocol; + pub fn iso14443_3a_set_sak(data: *mut Iso14443_3aData, sak: u8); } extern "C" { - #[doc = "Determine if a specific protocol has a parent on an arbitrary level.\n\n Unlike nfc_protocol_get_parent(), this function will traverse the full protocol hierarchy\n and check each parent node for the matching protocol type.\n\n # Arguments\n\n* `protocol` (direction in) - identifier of the protocol in question.\n * `parent_protocol` (direction in) - identifier of the parent protocol in question.\n # Returns\n\ntrue if the parent of given type exists, false otherwise."] - pub fn nfc_protocol_has_parent(protocol: NfcProtocol, parent_protocol: NfcProtocol) -> bool; + pub fn iso14443_3a_set_atqa(data: *mut Iso14443_3aData, atqa: *const u8); } +pub const MfClassicError_MfClassicErrorNone: MfClassicError = 0; +pub const MfClassicError_MfClassicErrorNotPresent: MfClassicError = 1; +pub const MfClassicError_MfClassicErrorProtocol: MfClassicError = 2; +pub const MfClassicError_MfClassicErrorAuth: MfClassicError = 3; +pub const MfClassicError_MfClassicErrorPartialRead: MfClassicError = 4; +pub const MfClassicError_MfClassicErrorTimeout: MfClassicError = 5; +pub type MfClassicError = core::ffi::c_uchar; +pub const MfClassicType_MfClassicTypeMini: MfClassicType = 0; +pub const MfClassicType_MfClassicType1k: MfClassicType = 1; +pub const MfClassicType_MfClassicType4k: MfClassicType = 2; +pub const MfClassicType_MfClassicTypeNum: MfClassicType = 3; +pub type MfClassicType = core::ffi::c_uchar; +pub const MfClassicAction_MfClassicActionDataRead: MfClassicAction = 0; +pub const MfClassicAction_MfClassicActionDataWrite: MfClassicAction = 1; +pub const MfClassicAction_MfClassicActionDataInc: MfClassicAction = 2; +pub const MfClassicAction_MfClassicActionDataDec: MfClassicAction = 3; +pub const MfClassicAction_MfClassicActionKeyARead: MfClassicAction = 4; +pub const MfClassicAction_MfClassicActionKeyAWrite: MfClassicAction = 5; +pub const MfClassicAction_MfClassicActionKeyBRead: MfClassicAction = 6; +pub const MfClassicAction_MfClassicActionKeyBWrite: MfClassicAction = 7; +pub const MfClassicAction_MfClassicActionACRead: MfClassicAction = 8; +pub const MfClassicAction_MfClassicActionACWrite: MfClassicAction = 9; +pub type MfClassicAction = core::ffi::c_uchar; +pub const MfClassicValueCommand_MfClassicValueCommandIncrement: MfClassicValueCommand = 0; +pub const MfClassicValueCommand_MfClassicValueCommandDecrement: MfClassicValueCommand = 1; +pub const MfClassicValueCommand_MfClassicValueCommandRestore: MfClassicValueCommand = 2; +pub const MfClassicValueCommand_MfClassicValueCommandInvalid: MfClassicValueCommand = 3; +pub type MfClassicValueCommand = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcDevice { - _unused: [u8; 0], +pub struct MfClassicBlock { + pub data: [u8; 16usize], } -#[doc = "Loading callback function signature.\n\n A function with such signature can be set as a callback to indicate\n the completion (or a failure) of nfc_device_load() and nfc_device_save() functions.\n\n This facility is commonly used to control GUI elements, such as progress dialogs.\n\n # Arguments\n\n* `context` (direction in) - user-defined context that was passed in nfc_device_set_loading_callback().\n * `state` (direction in) - true if the data was loaded successfully, false otherwise."] -pub type NfcLoadingCallback = - ::core::option::Option; -extern "C" { - #[doc = "Allocate an NfcDevice instance.\n\n A newly created instance does not hold any data and thus is considered invalid. The most common\n use case would be to set its data by calling nfc_device_set_data() right afterwards.\n\n # Returns\n\npointer to the allocated instance."] - pub fn nfc_device_alloc() -> *mut NfcDevice; -} -extern "C" { - #[doc = "Delete an NfcDevice instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] - pub fn nfc_device_free(instance: *mut NfcDevice); -} -extern "C" { - #[doc = "Clear an NfcDevice instance.\n\n All data contained in the instance will be deleted and the instance itself will become invalid\n as if it was just allocated.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be cleared."] - pub fn nfc_device_clear(instance: *mut NfcDevice); -} -extern "C" { - #[doc = "Reset an NfcDevice instance.\n\n The data contained in the instance will be reset according to the protocol-defined procedure.\n Unlike the nfc_device_clear() function, the instance will remain valid.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be reset."] - pub fn nfc_device_reset(instance: *mut NfcDevice); -} -extern "C" { - #[doc = "Get the protocol identifier from an NfcDevice instance.\n\n If the instance is invalid, the return value will be NfcProtocolInvalid.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nprotocol identifier contained in the instance."] - pub fn nfc_device_get_protocol(instance: *const NfcDevice) -> NfcProtocol; -} -extern "C" { - #[doc = "Get the protocol-specific data from an NfcDevice instance.\n\n The protocol parameter's behaviour is a bit tricky. The function will check\n whether there is such a protocol somewhere in the protocol hierarchy and return\n the data exactly from that level.\n\n Example: Call nfc_device_get_data() on an instance with Mf DESFire protocol.\n The protocol hierarchy will look like the following:\n\n `Mf DESFire --> ISO14443-4A --> ISO14443-3A`\n\n Thus, the following values of the protocol parameter are valid:\n\n * NfcProtocolIso14443_3a\n * NfcProtocolIso14443_4a\n * NfcProtocolMfDesfire\n\n and passing them to the call would result in the respective data being returned.\n\n However, supplying a protocol identifier which is not in the hierarchy will\n result in a crash. This is to improve type safety.\n\n # Arguments\n\n* `instance` - pointer to the instance to be queried\n * `protocol` - protocol identifier of the data to be retrieved.\n # Returns\n\npointer to the instance's data."] - pub fn nfc_device_get_data( - instance: *const NfcDevice, - protocol: NfcProtocol, - ) -> *const NfcDeviceData; -} -extern "C" { - #[doc = "Get the protocol name by its identifier.\n\n This function does not require an instance as its return result depends only\n the protocol identifier.\n\n # Arguments\n\n* `protocol` (direction in) - numeric identifier of the protocol in question.\n # Returns\n\npointer to a statically allocated string containing the protocol name."] - pub fn nfc_device_get_protocol_name(protocol: NfcProtocol) -> *const core::ffi::c_char; -} -extern "C" { - #[doc = "Get the name of an NfcDevice instance.\n\n The return value may change depending on the instance's internal state and the name_type parameter.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `name_type` (direction in) - type of the name to be displayed.\n # Returns\n\npointer to a statically allocated string containing the device name."] - pub fn nfc_device_get_name( - instance: *const NfcDevice, - name_type: NfcDeviceNameType, - ) -> *const core::ffi::c_char; -} -extern "C" { - #[doc = "Get the unique identifier (UID) of an NfcDevice instance.\n\n The UID length is protocol-dependent. Additionally, a particular protocol might support\n several UID lengths.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `uid_len` (direction out) - pointer to the variable to contain the UID length.\n # Returns\n\npointer to the byte array containing the instance's UID."] - pub fn nfc_device_get_uid(instance: *const NfcDevice, uid_len: *mut usize) -> *const u8; -} -extern "C" { - #[doc = "Set the unique identifier (UID) of an NfcDevice instance.\n\n The UID length must be supported by the instance's protocol.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `uid` (direction in) - pointer to the byte array containing the new UID.\n * `uid_len` (direction in) - length of the UID.\n # Returns\n\ntrue if the UID was valid and set, false otherwise."] - pub fn nfc_device_set_uid(instance: *mut NfcDevice, uid: *const u8, uid_len: usize) -> bool; -} -extern "C" { - #[doc = "Set the data and protocol of an NfcDevice instance.\n\n Any data previously contained in the instance will be deleted.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `protocol` (direction in) - numeric identifier of the data's protocol.\n * `protocol_data` (direction in) - pointer to the protocol-specific data."] - pub fn nfc_device_set_data( - instance: *mut NfcDevice, - protocol: NfcProtocol, - protocol_data: *const NfcDeviceData, +#[test] +fn bindgen_test_layout_MfClassicBlock() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(MfClassicBlock)) ); -} -extern "C" { - #[doc = "Copy (export) the data contained in an NfcDevice instance to an outside NfcDeviceData instance.\n\n This function does the inverse of nfc_device_set_data().\n\n The protocol identifier passed as the protocol parameter MUST match the one\n stored in the instance, otherwise a crash will occur.\n This is to improve type safety.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be copied from.\n * `protocol` (direction in) - numeric identifier of the instance's protocol.\n * `protocol_data` (direction out) - pointer to the destination data."] - pub fn nfc_device_copy_data( - instance: *const NfcDevice, - protocol: NfcProtocol, - protocol_data: *mut NfcDeviceData, + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicBlock)) ); -} -extern "C" { - #[doc = "Check whether an NfcDevice instance holds certain data.\n\n This function's behaviour is similar to nfc_device_is_equal(), with the difference\n that it takes NfcProtocol and NfcDeviceData* instead of the second NfcDevice*.\n\n The following code snippets [1] and [2] are equivalent:\n\n [1]\n ```c\n bool is_equal = nfc_device_is_equal(device1, device2);\n ```\n [2]\n ```c\n NfcProtocol protocol = nfc_device_get_protocol(device2);\n const NfcDeviceData* data = nfc_device_get_data(device2, protocol);\n bool is_equal = nfc_device_is_equal_data(device1, protocol, data);\n ```\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be compared.\n * `protocol` (direction in) - protocol identifier of the data to be compared.\n * `protocol_data` (direction in) - pointer to the NFC device data to be compared.\n # Returns\n\ntrue if the instance is of the right type and the data matches, false otherwise."] - pub fn nfc_device_is_equal_data( - instance: *const NfcDevice, - protocol: NfcProtocol, - protocol_data: *const NfcDeviceData, - ) -> bool; -} -extern "C" { - #[doc = "Compare two NfcDevice instances to determine whether they are equal.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the first instance to be compared.\n * `other` (direction in) - pointer to the second instance to be compared.\n # Returns\n\ntrue if both instances are considered equal, false otherwise."] - pub fn nfc_device_is_equal(instance: *const NfcDevice, other: *const NfcDevice) -> bool; -} -extern "C" { - #[doc = "Set the loading callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `callback` (direction in) - pointer to a function to be called when the load operation completes.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] - pub fn nfc_device_set_loading_callback( - instance: *mut NfcDevice, - callback: NfcLoadingCallback, - context: *mut core::ffi::c_void, + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(MfClassicBlock), + "::", + stringify!(data) + ) ); } -extern "C" { - #[doc = "Save NFC device data form an NfcDevice instance to a file.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be saved.\n * `path` (direction in) - pointer to a character string with a full file path.\n # Returns\n\ntrue if the data was successfully saved, false otherwise."] - pub fn nfc_device_save(instance: *mut NfcDevice, path: *const core::ffi::c_char) -> bool; -} -extern "C" { - #[doc = "Load NFC device data to an NfcDevice instance from a file.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be loaded into.\n * `path` (direction in) - pointer to a character string with a full file path.\n # Returns\n\ntrue if the data was successfully loaded, false otherwise."] - pub fn nfc_device_load(instance: *mut NfcDevice, path: *const core::ffi::c_char) -> bool; -} -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralight: NfcDataGeneratorType = 0; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_11: NfcDataGeneratorType = 1; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_H11: NfcDataGeneratorType = 2; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_21: NfcDataGeneratorType = 3; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_H21: NfcDataGeneratorType = 4; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG203: NfcDataGeneratorType = 5; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG213: NfcDataGeneratorType = 6; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG215: NfcDataGeneratorType = 7; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG216: NfcDataGeneratorType = 8; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2C1k: NfcDataGeneratorType = 9; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2C2k: NfcDataGeneratorType = 10; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2CPlus1k: NfcDataGeneratorType = 11; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2CPlus2k: NfcDataGeneratorType = 12; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassicMini: NfcDataGeneratorType = 13; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic1k_4b: NfcDataGeneratorType = 14; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic1k_7b: NfcDataGeneratorType = 15; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic4k_4b: NfcDataGeneratorType = 16; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic4k_7b: NfcDataGeneratorType = 17; -pub const NfcDataGeneratorType_NfcDataGeneratorTypeNum: NfcDataGeneratorType = 18; -pub type NfcDataGeneratorType = core::ffi::c_uchar; -extern "C" { - pub fn nfc_data_generator_get_name(type_: NfcDataGeneratorType) -> *const core::ffi::c_char; -} -extern "C" { - pub fn nfc_data_generator_fill_data(type_: NfcDataGeneratorType, nfc_device: *mut NfcDevice); -} -extern "C" { - pub fn nfc_util_even_parity32(data: u32) -> u8; -} -extern "C" { - pub fn nfc_util_odd_parity8(data: u8) -> u8; -} -extern "C" { - pub fn nfc_util_odd_parity(src: *const u8, dst: *mut u8, len: u8); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Nfc { - _unused: [u8; 0], -} -#[doc = "< User code explicitly aborted the current operation."] -pub const NfcEventType_NfcEventTypeUserAbort: NfcEventType = 0; -#[doc = "< Reader's field was detected by the NFC hardware."] -pub const NfcEventType_NfcEventTypeFieldOn: NfcEventType = 1; -#[doc = "< Reader's field was lost."] -pub const NfcEventType_NfcEventTypeFieldOff: NfcEventType = 2; -#[doc = "< Data transmission has started."] -pub const NfcEventType_NfcEventTypeTxStart: NfcEventType = 3; -#[doc = "< Data transmission has ended."] -pub const NfcEventType_NfcEventTypeTxEnd: NfcEventType = 4; -#[doc = "< Data reception has started."] -pub const NfcEventType_NfcEventTypeRxStart: NfcEventType = 5; -#[doc = "< Data reception has ended."] -pub const NfcEventType_NfcEventTypeRxEnd: NfcEventType = 6; -#[doc = "< The listener has been activated by the reader."] -pub const NfcEventType_NfcEventTypeListenerActivated: NfcEventType = 7; -#[doc = "< The card has been activated by the poller."] -pub const NfcEventType_NfcEventTypePollerReady: NfcEventType = 8; -#[doc = "Enumeration of possible Nfc event types.\n\n Not all technologies implement all events (this is due to hardware limitations)."] -pub type NfcEventType = core::ffi::c_uchar; -#[doc = "Nfc event data structure."] +pub const MfClassicKeyType_MfClassicKeyTypeA: MfClassicKeyType = 0; +pub const MfClassicKeyType_MfClassicKeyTypeB: MfClassicKeyType = 1; +pub type MfClassicKeyType = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcEventData { - #[doc = "< Pointer to the received data buffer."] - pub buffer: *mut BitBuffer, +pub struct MfClassicKey { + pub data: [u8; 6usize], } #[test] -fn bindgen_test_layout_NfcEventData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicKey() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(NfcEventData)) + ::core::mem::size_of::(), + 6usize, + concat!("Size of: ", stringify!(MfClassicKey)) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcEventData)) + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicKey)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).buffer) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(NfcEventData), + stringify!(MfClassicKey), "::", - stringify!(buffer) + stringify!(data) ) ); } -#[doc = "Nfc event structure.\n\n Upon emission of an event, an instance of this struct will be passed to the callback."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcEvent { - #[doc = "< Type of the emitted event."] - pub type_: NfcEventType, - #[doc = "< Event-specific data."] - pub data: NfcEventData, +pub struct MfClassicAccessBits { + pub data: [u8; 4usize], } #[test] -fn bindgen_test_layout_NfcEvent() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicAccessBits() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(NfcEvent)) + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(MfClassicAccessBits)) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcEvent)) + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicAccessBits)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(NfcEvent), + stringify!(MfClassicAccessBits), "::", - stringify!(type_) + stringify!(data) ) ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct MfClassicNt { + pub data: [u8; 4usize], +} +#[test] +fn bindgen_test_layout_MfClassicNt() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(MfClassicNt)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicNt)) + ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 4usize, + 0usize, concat!( "Offset of field: ", - stringify!(NfcEvent), + stringify!(MfClassicNt), "::", stringify!(data) ) ); } -#[doc = "< Continue operation normally."] -pub const NfcCommand_NfcCommandContinue: NfcCommand = 0; -#[doc = "< Reset the current state."] -pub const NfcCommand_NfcCommandReset: NfcCommand = 1; -#[doc = "< Stop the current operation."] -pub const NfcCommand_NfcCommandStop: NfcCommand = 2; -#[doc = "< Switch Nfc hardware to low-power mode."] -pub const NfcCommand_NfcCommandSleep: NfcCommand = 3; -#[doc = "Enumeration of possible Nfc commands.\n\n The event callback must return one of these to determine the next action."] -pub type NfcCommand = core::ffi::c_uchar; -#[doc = "Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon start of a an Nfc instance.\n\n # Arguments\n\n* `[in]` - event Nfc event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting an Nfc instance).\n # Returns\n\ncommand which the event producer must execute."] -pub type NfcEventCallback = ::core::option::Option< - unsafe extern "C" fn(event: NfcEvent, context: *mut core::ffi::c_void) -> NfcCommand, ->; -#[doc = "< Configure the Nfc instance as a poller."] -pub const NfcMode_NfcModePoller: NfcMode = 0; -#[doc = "< Configure the Nfc instance as a listener."] -pub const NfcMode_NfcModeListener: NfcMode = 1; -#[doc = "< Operating mode count. Internal use."] -pub const NfcMode_NfcModeNum: NfcMode = 2; -#[doc = "Enumeration of possible operating modes.\n\n Not all technologies implement the listener operating mode."] -pub type NfcMode = core::ffi::c_uchar; -#[doc = "< Configure the Nfc instance to use the ISO14443-3A technology."] -pub const NfcTech_NfcTechIso14443a: NfcTech = 0; -#[doc = "< Configure the Nfc instance to use the ISO14443-3B technology."] -pub const NfcTech_NfcTechIso14443b: NfcTech = 1; -#[doc = "< Configure the Nfc instance to use the ISO15693 technology."] -pub const NfcTech_NfcTechIso15693: NfcTech = 2; -#[doc = "< Configure the Nfc instance to use the FeliCa technology."] -pub const NfcTech_NfcTechFelica: NfcTech = 3; -#[doc = "< Technologies count. Internal use."] -pub const NfcTech_NfcTechNum: NfcTech = 4; -#[doc = "Enumeration of available technologies."] -pub type NfcTech = core::ffi::c_uchar; -#[doc = "< No error has occurred."] -pub const NfcError_NfcErrorNone: NfcError = 0; -#[doc = "< An unknown error has occured on the lower level."] -pub const NfcError_NfcErrorInternal: NfcError = 1; -#[doc = "< Operation is taking too long (e.g. card does not respond)."] -pub const NfcError_NfcErrorTimeout: NfcError = 2; -#[doc = "< An incomplete data frame has been received."] -pub const NfcError_NfcErrorIncompleteFrame: NfcError = 3; -#[doc = "< Data has not been parsed due to wrong/unknown format."] -pub const NfcError_NfcErrorDataFormat: NfcError = 4; -#[doc = "Enumeration of possible Nfc error codes."] -pub type NfcError = core::ffi::c_uchar; -extern "C" { - #[doc = "Allocate an Nfc instance.\n\n Will exclusively take over the NFC HAL until deleted.\n\n # Returns\n\npointer to the allocated Nfc instance."] - pub fn nfc_alloc() -> *mut Nfc; -} -extern "C" { - #[doc = "Delete an Nfc instance.\n\n Will release the NFC HAL lock, making it available for use by others.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] - pub fn nfc_free(instance: *mut Nfc); -} -extern "C" { - #[doc = "Configure the Nfc instance to work in a particular mode.\n\n Not all technologies implement the listener operating mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `mode` (direction in) - required operating mode.\n * `tech` (direction in) - required technology configuration."] - pub fn nfc_config(instance: *mut Nfc, mode: NfcMode, tech: NfcTech); -} -extern "C" { - #[doc = "Set poller frame delay time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_poll_fc` (direction in) - frame delay time, in carrier cycles."] - pub fn nfc_set_fdt_poll_fc(instance: *mut Nfc, fdt_poll_fc: u32); -} -extern "C" { - #[doc = "Set listener frame delay time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_listen_fc` (direction in) - frame delay time, in carrier cycles."] - pub fn nfc_set_fdt_listen_fc(instance: *mut Nfc, fdt_listen_fc: u32); -} -extern "C" { - #[doc = "Set mask receive time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `mask_rx_time_fc` (direction in) - mask receive time, in carrier cycles."] - pub fn nfc_set_mask_receive_time_fc(instance: *mut Nfc, mask_rx_time_fc: u32); -} -extern "C" { - #[doc = "Set frame delay time.\n\n Frame delay time is the minimum time between two consecutive poll frames.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_poll_poll_us` (direction in) - frame delay time, in microseconds."] - pub fn nfc_set_fdt_poll_poll_us(instance: *mut Nfc, fdt_poll_poll_us: u32); -} -extern "C" { - #[doc = "Set guard time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `guard_time_us` (direction in) - guard time, in microseconds."] - pub fn nfc_set_guard_time_us(instance: *mut Nfc, guard_time_us: u32); -} -extern "C" { - #[doc = "Start the Nfc instance.\n\n The instance must be configured to work with a specific technology\n in a specific operating mode with a nfc_config() call before starting.\n\n Once started, the user code will be receiving events through the provided\n callback which must handle them according to the logic required.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] - pub fn nfc_start( - instance: *mut Nfc, - callback: NfcEventCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Stop Nfc instance.\n\n The instance can only be stopped if it is running.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] - pub fn nfc_stop(instance: *mut Nfc); -} -extern "C" { - #[doc = "Transmit and receive a data frame in poller mode.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n The data being transmitted and received may be either bit- or byte-oriented.\n It shall not contain any technology-specific sequences as start or stop bits\n and/or other special symbols, as this is handled on the underlying HAL level.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_poller_trx( - instance: *mut Nfc, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> NfcError; -} -extern "C" { - #[doc = "Transmit a data frame in listener mode.\n\n Used to transmit a response to the reader request in listener mode.\n\n The data being transmitted may be either bit- or byte-oriented.\n It shall not contain any technology-specific sequences as start or stop bits\n and/or other special symbols, as this is handled on the underlying HAL level.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_listener_tx(instance: *mut Nfc, tx_buffer: *const BitBuffer) -> NfcError; -} -pub const NfcIso14443aShortFrame_NfcIso14443aShortFrameSensReq: NfcIso14443aShortFrame = 0; -pub const NfcIso14443aShortFrame_NfcIso14443aShortFrameAllReqa: NfcIso14443aShortFrame = 1; -#[doc = "Enumeration of possible ISO14443-3A short frame types."] -pub type NfcIso14443aShortFrame = core::ffi::c_uchar; -extern "C" { - #[doc = "Transmit an ISO14443-3A short frame and receive the response in poller mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `frame` (direction in) - type of short frame to be sent.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso14443a_poller_trx_short_frame( - instance: *mut Nfc, - frame: NfcIso14443aShortFrame, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> NfcError; -} -extern "C" { - #[doc = "Transmit an ISO14443-3A SDD frame and receive the response in poller mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso14443a_poller_trx_sdd_frame( - instance: *mut Nfc, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> NfcError; -} -extern "C" { - #[doc = "Transmit an ISO14443-3A data frame with custom parity bits and receive the response in poller mode.\n\n Same as nfc_poller_trx(), but uses the parity bits provided by the user code\n instead of calculating them automatically.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso14443a_poller_trx_custom_parity( - instance: *mut Nfc, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> NfcError; -} -extern "C" { - #[doc = "Transmit an ISO14443-3A frame with custom parity bits in listener mode.\n\n Same as nfc_listener_tx(), but uses the parity bits provided by the user code\n instead of calculating them automatically.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso14443a_listener_tx_custom_parity( - instance: *mut Nfc, - tx_buffer: *const BitBuffer, - ) -> NfcError; -} -extern "C" { - #[doc = "Set ISO14443-3A collision resolution parameters in listener mode.\n\n Configures the NFC hardware for automatic collision resolution.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `uid` (direction in) - pointer to a byte array containing the UID.\n * `uid_len` (direction in) - UID length in bytes (must be supported by the protocol).\n * `atqa` (direction in) - ATQA byte value.\n * `sak` (direction in) - SAK byte value.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso14443a_listener_set_col_res_data( - instance: *mut Nfc, - uid: *mut u8, - uid_len: u8, - atqa: *mut u8, - sak: u8, - ) -> NfcError; -} -extern "C" { - #[doc = "Set FeliCa collision resolution parameters in listener mode.\n\n Configures the NFC hardware for automatic collision resolution.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `idm` (direction in) - pointer to a byte array containing the IDm.\n * `idm_len` (direction in) - IDm length in bytes.\n * `pmm` (direction in) - pointer to a byte array containing the PMm.\n * `pmm_len` (direction in) - PMm length in bytes.\n * `sys_code` (direction in) - System code from SYS_C block\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_felica_listener_set_sensf_res_data( - instance: *mut Nfc, - idm: *const u8, - idm_len: u8, - pmm: *const u8, - pmm_len: u8, - sys_code: u16, - ) -> NfcError; -} -extern "C" { - #[doc = "Send ISO15693 Start of Frame pattern in listener mode\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] - pub fn nfc_iso15693_listener_tx_sof(instance: *mut Nfc) -> NfcError; -} -#[doc = "Generic Nfc instance type.\n\n Must be cast to a concrete type before use.\n Depending on the context, a pointer of this type\n may point to an object of the following types:\n - Nfc type,\n - Concrete poller type,\n - Concrete listener type."] -pub type NfcGenericInstance = core::ffi::c_void; -#[doc = "Generic Nfc event data type.\n\n Must be cast to a concrete type before use.\n Usually, it will be the protocol-specific event type."] -pub type NfcGenericEventData = core::ffi::c_void; -#[doc = "Generic Nfc event type.\n\n A generic Nfc event contains a protocol identifier, can be used to determine\n the remaing fields' type.\n\n If the value of the protocol field is NfcProtocolInvalid, then it means that\n the event was emitted from an Nfc instance, otherwise it originated from\n a concrete poller or listener instance.\n\n The event_data field is protocol-specific and should be cast to the appropriate type before use."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcGenericEvent { - #[doc = "< Protocol identifier of the instance that produced the event."] - pub protocol: NfcProtocol, - #[doc = "< Pointer to the protocol-specific instance that produced the event."] - pub instance: *mut NfcGenericInstance, - #[doc = "< Pointer to the protocol-specific event."] - pub event_data: *mut NfcGenericEventData, +pub struct MfClassicAt { + pub data: [u8; 4usize], } #[test] -fn bindgen_test_layout_NfcGenericEvent() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicAt() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(NfcGenericEvent)) + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(MfClassicAt)) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcGenericEvent)) + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicAt)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(NfcGenericEvent), + stringify!(MfClassicAt), "::", - stringify!(protocol) + stringify!(data) ) ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct MfClassicNr { + pub data: [u8; 4usize], +} +#[test] +fn bindgen_test_layout_MfClassicNr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).instance) as usize - ptr as usize }, + ::core::mem::size_of::(), 4usize, + concat!("Size of: ", stringify!(MfClassicNr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicNr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(NfcGenericEvent), + stringify!(MfClassicNr), "::", - stringify!(instance) + stringify!(data) ) ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct MfClassicAr { + pub data: [u8; 4usize], +} +#[test] +fn bindgen_test_layout_MfClassicAr() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).event_data) as usize - ptr as usize }, - 8usize, + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(MfClassicAr)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicAr)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(NfcGenericEvent), + stringify!(MfClassicAr), "::", - stringify!(event_data) + stringify!(data) ) ); } -#[doc = "Generic Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon start\n of a poller, listener or Nfc instance.\n\n # Arguments\n\n* `[in]` - event Nfc generic event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting a poller/listener instance).\n # Returns\n\nthe command which the event producer must execute."] -pub type NfcGenericCallback = ::core::option::Option< - unsafe extern "C" fn(event: NfcGenericEvent, context: *mut core::ffi::c_void) -> NfcCommand, ->; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NfcListener { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Allocate an NfcListener instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n * `protocol` (direction in) - identifier of the protocol to be used.\n * `data` (direction in) - pointer to the data to use during emulation.\n # Returns\n\npointer to an allocated instance.\n\n [`nfc.h`]"] - pub fn nfc_listener_alloc( - nfc: *mut Nfc, - protocol: NfcProtocol, - data: *const NfcDeviceData, - ) -> *mut NfcListener; -} -extern "C" { - #[doc = "Delete an NfcListener instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] - pub fn nfc_listener_free(instance: *mut NfcListener); -} -extern "C" { - #[doc = "Start an NfcListener instance.\n\n The callback logic is protocol-specific, so it cannot be described here in detail.\n However, the callback return value ALWAYS determines what the listener should do next:\n to continue whatever it was doing prior to the callback run or to stop.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] - pub fn nfc_listener_start( - instance: *mut NfcListener, - callback: NfcGenericCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Stop an NfcListener instance.\n\n The emulation process can be stopped explicitly (the other way is via the callback return value).\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] - pub fn nfc_listener_stop(instance: *mut NfcListener); -} -extern "C" { - #[doc = "Get the protocol identifier an NfcListener instance was created with.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nidentifier of the protocol used by the instance."] - pub fn nfc_listener_get_protocol(instance: *const NfcListener) -> NfcProtocol; -} -extern "C" { - #[doc = "Get the data that was that was provided for emulation.\n\n The protocol identifier passed as the protocol parameter MUST match the one\n stored in the instance, otherwise a crash will occur.\n This is to improve type safety.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `protocol` (direction in) - assumed protocol identifier of the data to be retrieved.\n # Returns\n\npointer to the NFC device data."] - pub fn nfc_listener_get_data( - instance: *const NfcListener, - protocol: NfcProtocol, - ) -> *const NfcDeviceData; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NfcPoller { - _unused: [u8; 0], -} -#[doc = "Extended generic Nfc event type.\n\n An extended generic Nfc event contains protocol poller and it's parent protocol event data.\n If protocol has no parent, then events are produced by Nfc instance.\n\n The parent_event_data field is protocol-specific and should be cast to the appropriate type before use."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcGenericEventEx { - #[doc = "< Pointer to the protocol poller."] - pub poller: *mut NfcGenericInstance, - #[doc = "< Pointer to the protocol's parent poller event data."] - pub parent_event_data: *mut NfcGenericEventData, +pub struct MfClassicAuthContext { + pub block_num: u8, + pub key: MfClassicKey, + pub key_type: MfClassicKeyType, + pub nt: MfClassicNt, + pub nr: MfClassicNr, + pub ar: MfClassicAr, + pub at: MfClassicAt, } #[test] -fn bindgen_test_layout_NfcGenericEventEx() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicAuthContext() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(NfcGenericEventEx)) + ::core::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(MfClassicAuthContext)) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcGenericEventEx)) + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(MfClassicAuthContext)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).poller) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).block_num) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(NfcGenericEventEx), + stringify!(MfClassicAuthContext), "::", - stringify!(poller) + stringify!(block_num) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).parent_event_data) as usize - ptr as usize }, - 4usize, + unsafe { ::core::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(NfcGenericEventEx), + stringify!(MfClassicAuthContext), "::", - stringify!(parent_event_data) + stringify!(key) ) ); -} -#[doc = "Extended generic Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon extended start of a poller.\n\n # Arguments\n\n* `[in]` - event Nfc extended generic event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting a poller/listener instance).\n # Returns\n\nthe command which the event producer must execute."] -pub type NfcGenericCallbackEx = ::core::option::Option< - unsafe extern "C" fn(event: NfcGenericEventEx, context: *mut core::ffi::c_void) -> NfcCommand, ->; -extern "C" { - #[doc = "Allocate an NfcPoller instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n * `protocol` (direction in) - identifier of the protocol to be used.\n # Returns\n\npointer to an allocated instance.\n\n [`nfc.h`]"] - pub fn nfc_poller_alloc(nfc: *mut Nfc, protocol: NfcProtocol) -> *mut NfcPoller; -} -extern "C" { - #[doc = "Delete an NfcPoller instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] - pub fn nfc_poller_free(instance: *mut NfcPoller); -} -extern "C" { - #[doc = "Start an NfcPoller instance.\n\n The callback logic is protocol-specific, so it cannot be described here in detail.\n However, the callback return value ALWAYS determines what the poller should do next:\n to continue whatever it was doing prior to the callback run or to stop.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] - pub fn nfc_poller_start( - instance: *mut NfcPoller, - callback: NfcGenericCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Start an NfcPoller instance in extended mode.\n\n When nfc poller is started in extended mode, callback will be called with parent protocol events\n and protocol instance. This mode enables to make custom poller state machines.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] - pub fn nfc_poller_start_ex( - instance: *mut NfcPoller, - callback: NfcGenericCallbackEx, - context: *mut core::ffi::c_void, + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).key_type) as usize - ptr as usize }, + 7usize, + concat!( + "Offset of field: ", + stringify!(MfClassicAuthContext), + "::", + stringify!(key_type) + ) ); -} -extern "C" { - #[doc = "Stop an NfcPoller instance.\n\n The reading process can be stopped explicitly (the other way is via the callback return value).\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] - pub fn nfc_poller_stop(instance: *mut NfcPoller); -} -extern "C" { - #[doc = "Detect whether there is a card supporting a particular protocol in the vicinity.\n\n The behaviour of this function is protocol-defined, in general, it will do whatever is\n necessary to determine whether a card supporting the current protocol is in the vicinity\n and whether it is functioning normally.\n\n It is used automatically inside NfcScanner, so there is usually no need\n to call it explicitly.\n\n [`nfc_scanner.h`]\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to perform the detection with.\n # Returns\n\ntrue if a supported card was detected, false otherwise."] - pub fn nfc_poller_detect(instance: *mut NfcPoller) -> bool; -} -extern "C" { - #[doc = "Get the protocol identifier an NfcPoller instance was created with.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nidentifier of the protocol used by the instance."] - pub fn nfc_poller_get_protocol(instance: *const NfcPoller) -> NfcProtocol; -} -extern "C" { - #[doc = "Get the data that was that was gathered during the reading process.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\npointer to the NFC device data."] - pub fn nfc_poller_get_data(instance: *const NfcPoller) -> *const NfcDeviceData; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NfcScanner { - _unused: [u8; 0], -} -#[doc = "< One or more protocols have been detected."] -pub const NfcScannerEventType_NfcScannerEventTypeDetected: NfcScannerEventType = 0; -#[doc = "Event type passed to the user callback."] -pub type NfcScannerEventType = core::ffi::c_uchar; -#[doc = "Event data passed to the user callback."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct NfcScannerEventData { - #[doc = "< Number of detected protocols (one or more)."] - pub protocol_num: usize, - #[doc = "< Pointer to the array of detected protocol identifiers."] - pub protocols: *mut NfcProtocol, -} -#[test] -fn bindgen_test_layout_NfcScannerEventData() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), + unsafe { ::core::ptr::addr_of!((*ptr).nt) as usize - ptr as usize }, 8usize, - concat!("Size of: ", stringify!(NfcScannerEventData)) + concat!( + "Offset of field: ", + stringify!(MfClassicAuthContext), + "::", + stringify!(nt) + ) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcScannerEventData)) + unsafe { ::core::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(MfClassicAuthContext), + "::", + stringify!(nr) + ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).protocol_num) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).ar) as usize - ptr as usize }, + 16usize, concat!( "Offset of field: ", - stringify!(NfcScannerEventData), + stringify!(MfClassicAuthContext), "::", - stringify!(protocol_num) + stringify!(ar) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).protocols) as usize - ptr as usize }, - 4usize, + unsafe { ::core::ptr::addr_of!((*ptr).at) as usize - ptr as usize }, + 20usize, concat!( "Offset of field: ", - stringify!(NfcScannerEventData), + stringify!(MfClassicAuthContext), "::", - stringify!(protocols) + stringify!(at) ) ); } -#[doc = "Event passed to the user callback."] +#[repr(C)] +#[derive(Copy, Clone)] +pub union MfClassicSectorTrailer { + pub block: MfClassicBlock, + pub __bindgen_anon_1: MfClassicSectorTrailer__bindgen_ty_1, +} #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct NfcScannerEvent { - #[doc = "< Type of event. Determines how the data must be handled."] - pub type_: NfcScannerEventType, - #[doc = "< Event-specific data. Handled accordingly to the even type."] - pub data: NfcScannerEventData, +pub struct MfClassicSectorTrailer__bindgen_ty_1 { + pub key_a: MfClassicKey, + pub access_bits: MfClassicAccessBits, + pub key_b: MfClassicKey, } #[test] -fn bindgen_test_layout_NfcScannerEvent() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicSectorTrailer__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(NfcScannerEvent)) + ::core::mem::size_of::(), + 16usize, + concat!( + "Size of: ", + stringify!(MfClassicSectorTrailer__bindgen_ty_1) + ) ); assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(NfcScannerEvent)) + ::core::mem::align_of::(), + 1usize, + concat!( + "Alignment of ", + stringify!(MfClassicSectorTrailer__bindgen_ty_1) + ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).key_a) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(NfcScannerEvent), + stringify!(MfClassicSectorTrailer__bindgen_ty_1), "::", - stringify!(type_) + stringify!(key_a) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 4usize, + unsafe { ::core::ptr::addr_of!((*ptr).access_bits) as usize - ptr as usize }, + 6usize, concat!( "Offset of field: ", - stringify!(NfcScannerEvent), + stringify!(MfClassicSectorTrailer__bindgen_ty_1), "::", - stringify!(data) + stringify!(access_bits) ) ); -} -#[doc = "User callback function signature.\n\n A function with such signature must be provided by the user upon calling nfc_scanner_start().\n\n # Arguments\n\n* `event` (direction in) - occurred event, complete with type and data.\n * `context` (direction in) - pointer to the context data provided in nfc_scanner_start() call."] -pub type NfcScannerCallback = ::core::option::Option< - unsafe extern "C" fn(event: NfcScannerEvent, context: *mut core::ffi::c_void), ->; -extern "C" { - #[doc = "Allocate an NfcScanner instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n # Returns\n\npointer to the allocated NfcScanner instance.\n\n [`nfc.h`]"] - pub fn nfc_scanner_alloc(nfc: *mut Nfc) -> *mut NfcScanner; -} -extern "C" { - #[doc = "Delete an NfcScanner instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] - pub fn nfc_scanner_free(instance: *mut NfcScanner); -} -extern "C" { - #[doc = "Start an NfcScanner.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to the callback function (will be called upon a detection event).\n * `context` (direction in) - pointer to the caller-specific context (will be passed to the callback)."] - pub fn nfc_scanner_start( - instance: *mut NfcScanner, - callback: NfcScannerCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Stop an NfcScanner.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] - pub fn nfc_scanner_stop(instance: *mut NfcScanner); -} -pub const FelicaError_FelicaErrorNone: FelicaError = 0; -pub const FelicaError_FelicaErrorNotPresent: FelicaError = 1; -pub const FelicaError_FelicaErrorColResFailed: FelicaError = 2; -pub const FelicaError_FelicaErrorBufferOverflow: FelicaError = 3; -pub const FelicaError_FelicaErrorCommunication: FelicaError = 4; -pub const FelicaError_FelicaErrorFieldOff: FelicaError = 5; -pub const FelicaError_FelicaErrorWrongCrc: FelicaError = 6; -pub const FelicaError_FelicaErrorProtocol: FelicaError = 7; -pub const FelicaError_FelicaErrorTimeout: FelicaError = 8; -#[doc = "Type of possible Felica errors"] -pub type FelicaError = core::ffi::c_uchar; -#[doc = "Separate type for card key block. Used in authentication process"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct FelicaCardKey { - pub data: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_FelicaCardKey() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(FelicaCardKey)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaCardKey)) - ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_b) as usize - ptr as usize }, + 10usize, concat!( "Offset of field: ", - stringify!(FelicaCardKey), + stringify!(MfClassicSectorTrailer__bindgen_ty_1), "::", - stringify!(data) + stringify!(key_b) ) ); } -#[doc = "Felica ID block"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct FelicaIDm { - pub data: [u8; 8usize], -} #[test] -fn bindgen_test_layout_FelicaIDm() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicSectorTrailer() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(FelicaIDm)) + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(MfClassicSectorTrailer)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(FelicaIDm)) + concat!("Alignment of ", stringify!(MfClassicSectorTrailer)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).block) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(FelicaIDm), + stringify!(MfClassicSectorTrailer), "::", - stringify!(data) + stringify!(block) ) ); } -#[doc = "Felica PMm block"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct FelicaPMm { - pub data: [u8; 8usize], +pub struct MfClassicDeviceKeys { + pub key_a_mask: u64, + pub key_a: [MfClassicKey; 40usize], + pub key_b_mask: u64, + pub key_b: [MfClassicKey; 40usize], } #[test] -fn bindgen_test_layout_FelicaPMm() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicDeviceKeys() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(FelicaPMm)) + ::core::mem::size_of::(), + 496usize, + concat!("Size of: ", stringify!(MfClassicDeviceKeys)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaPMm)) + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(MfClassicDeviceKeys)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).key_a_mask) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(FelicaPMm), + stringify!(MfClassicDeviceKeys), "::", - stringify!(data) + stringify!(key_a_mask) ) ); -} -#[doc = "Felica block with status flags indicating last operation with it.\n See Felica manual for more details on status codes."] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct FelicaBlock { - #[doc = "< Status flag 1, equals to 0 when success"] - pub SF1: u8, - #[doc = "< Status flag 2, equals to 0 when success"] - pub SF2: u8, - #[doc = "< Block data"] - pub data: [u8; 16usize], -} -#[test] -fn bindgen_test_layout_FelicaBlock() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 18usize, - concat!("Size of: ", stringify!(FelicaBlock)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaBlock)) - ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).SF1) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_a) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(FelicaBlock), + stringify!(MfClassicDeviceKeys), "::", - stringify!(SF1) + stringify!(key_a) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).SF2) as usize - ptr as usize }, - 1usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_b_mask) as usize - ptr as usize }, + 248usize, concat!( "Offset of field: ", - stringify!(FelicaBlock), + stringify!(MfClassicDeviceKeys), "::", - stringify!(SF2) + stringify!(key_b_mask) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 2usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_b) as usize - ptr as usize }, + 256usize, concat!( "Offset of field: ", - stringify!(FelicaBlock), + stringify!(MfClassicDeviceKeys), "::", - stringify!(data) + stringify!(key_b) ) ); } -#[doc = "Felica filesystem structure"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct FelicaFileSystem { - pub spad: [FelicaBlock; 14usize], - pub reg: FelicaBlock, - pub rc: FelicaBlock, - pub mac: FelicaBlock, - pub id: FelicaBlock, - pub d_id: FelicaBlock, - pub ser_c: FelicaBlock, - pub sys_c: FelicaBlock, - pub ckv: FelicaBlock, - pub ck: FelicaBlock, - pub mc: FelicaBlock, - pub wcnt: FelicaBlock, - pub mac_a: FelicaBlock, - pub state: FelicaBlock, - pub crc_check: FelicaBlock, +pub struct MfClassicData { + pub iso14443_3a_data: *mut Iso14443_3aData, + pub type_: MfClassicType, + pub block_read_mask: [u32; 8usize], + pub key_a_mask: u64, + pub key_b_mask: u64, + pub block: [MfClassicBlock; 256usize], } #[test] -fn bindgen_test_layout_FelicaFileSystem() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_MfClassicData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 504usize, - concat!("Size of: ", stringify!(FelicaFileSystem)) + ::core::mem::size_of::(), + 4152usize, + concat!("Size of: ", stringify!(MfClassicData)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaFileSystem)) + ::core::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(MfClassicData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).spad) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).iso14443_3a_data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), + stringify!(MfClassicData), "::", - stringify!(spad) + stringify!(iso14443_3a_data) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).reg) as usize - ptr as usize }, - 252usize, + unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), + stringify!(MfClassicData), "::", - stringify!(reg) + stringify!(type_) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).rc) as usize - ptr as usize }, - 270usize, + unsafe { ::core::ptr::addr_of!((*ptr).block_read_mask) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), + stringify!(MfClassicData), "::", - stringify!(rc) + stringify!(block_read_mask) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).mac) as usize - ptr as usize }, - 288usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_a_mask) as usize - ptr as usize }, + 40usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), + stringify!(MfClassicData), "::", - stringify!(mac) + stringify!(key_a_mask) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, - 306usize, + unsafe { ::core::ptr::addr_of!((*ptr).key_b_mask) as usize - ptr as usize }, + 48usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), + stringify!(MfClassicData), "::", - stringify!(id) + stringify!(key_b_mask) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).d_id) as usize - ptr as usize }, - 324usize, + unsafe { ::core::ptr::addr_of!((*ptr).block) as usize - ptr as usize }, + 56usize, concat!( "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(d_id) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ser_c) as usize - ptr as usize }, - 342usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(ser_c) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sys_c) as usize - ptr as usize }, - 360usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(sys_c) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ckv) as usize - ptr as usize }, - 378usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(ckv) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ck) as usize - ptr as usize }, - 396usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(ck) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).mc) as usize - ptr as usize }, - 414usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(mc) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).wcnt) as usize - ptr as usize }, - 432usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(wcnt) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).mac_a) as usize - ptr as usize }, - 450usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(mac_a) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, - 468usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(state) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).crc_check) as usize - ptr as usize }, - 486usize, - concat!( - "Offset of field: ", - stringify!(FelicaFileSystem), - "::", - stringify!(crc_check) - ) - ); -} -#[doc = "Union which represents filesystem in junction with plain data dump"] -#[repr(C)] -#[derive(Copy, Clone)] -pub union FelicaFSUnion { - pub fs: FelicaFileSystem, - pub dump: [u8; 504usize], -} -#[test] -fn bindgen_test_layout_FelicaFSUnion() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 504usize, - concat!("Size of: ", stringify!(FelicaFSUnion)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaFSUnion)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).fs) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(FelicaFSUnion), - "::", - stringify!(fs) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).dump) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(FelicaFSUnion), - "::", - stringify!(dump) - ) - ); -} -#[doc = "Structure used to store Felica data and additional values about reading"] -#[repr(C)] -#[derive(Copy, Clone)] -pub struct FelicaData { - pub idm: FelicaIDm, - pub pmm: FelicaPMm, - pub blocks_total: u8, - pub blocks_read: u8, - pub data: FelicaFSUnion, -} -#[test] -fn bindgen_test_layout_FelicaData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 522usize, - concat!("Size of: ", stringify!(FelicaData)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(FelicaData)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).idm) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(FelicaData), - "::", - stringify!(idm) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).pmm) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(FelicaData), - "::", - stringify!(pmm) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).blocks_total) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(FelicaData), - "::", - stringify!(blocks_total) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).blocks_read) as usize - ptr as usize }, - 17usize, - concat!( - "Offset of field: ", - stringify!(FelicaData), - "::", - stringify!(blocks_read) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 18usize, - concat!( - "Offset of field: ", - stringify!(FelicaData), + stringify!(MfClassicData), "::", - stringify!(data) + stringify!(block) ) ); } extern "C" { - pub fn felica_alloc() -> *mut FelicaData; + pub fn mf_classic_alloc() -> *mut MfClassicData; } extern "C" { - pub fn felica_free(data: *mut FelicaData); + pub fn mf_classic_free(data: *mut MfClassicData); } extern "C" { - pub fn felica_reset(data: *mut FelicaData); + pub fn mf_classic_reset(data: *mut MfClassicData); } extern "C" { - pub fn felica_copy(data: *mut FelicaData, other: *const FelicaData); + pub fn mf_classic_copy(data: *mut MfClassicData, other: *const MfClassicData); } extern "C" { - pub fn felica_verify(data: *mut FelicaData, device_type: *const FuriString) -> bool; + pub fn mf_classic_verify(data: *mut MfClassicData, device_type: *const FuriString) -> bool; } extern "C" { - pub fn felica_load(data: *mut FelicaData, ff: *mut FlipperFormat, version: u32) -> bool; + pub fn mf_classic_load(data: *mut MfClassicData, ff: *mut FlipperFormat, version: u32) -> bool; } extern "C" { - pub fn felica_save(data: *const FelicaData, ff: *mut FlipperFormat) -> bool; + pub fn mf_classic_save(data: *const MfClassicData, ff: *mut FlipperFormat) -> bool; } extern "C" { - pub fn felica_is_equal(data: *const FelicaData, other: *const FelicaData) -> bool; + pub fn mf_classic_is_equal(data: *const MfClassicData, other: *const MfClassicData) -> bool; } extern "C" { - pub fn felica_get_device_name( - data: *const FelicaData, + pub fn mf_classic_get_device_name( + data: *const MfClassicData, name_type: NfcDeviceNameType, ) -> *const core::ffi::c_char; } extern "C" { - pub fn felica_get_uid(data: *const FelicaData, uid_len: *mut usize) -> *const u8; + pub fn mf_classic_get_uid(data: *const MfClassicData, uid_len: *mut usize) -> *const u8; } extern "C" { - pub fn felica_set_uid(data: *mut FelicaData, uid: *const u8, uid_len: usize) -> bool; + pub fn mf_classic_set_uid(data: *mut MfClassicData, uid: *const u8, uid_len: usize) -> bool; } extern "C" { - pub fn felica_get_base_data(data: *const FelicaData) -> *mut FelicaData; + pub fn mf_classic_get_base_data(data: *const MfClassicData) -> *mut Iso14443_3aData; } extern "C" { - pub fn felica_calculate_session_key( - ctx: *mut mbedtls_des3_context, - ck: *const u8, - rc: *const u8, - out: *mut u8, - ); + pub fn mf_classic_get_total_sectors_num(type_: MfClassicType) -> u8; } extern "C" { - pub fn felica_check_mac( - ctx: *mut mbedtls_des3_context, - session_key: *const u8, - rc: *const u8, - blocks: *const u8, - block_count: u8, - data: *mut u8, - ) -> bool; + pub fn mf_classic_get_total_block_num(type_: MfClassicType) -> u16; } extern "C" { - pub fn felica_calculate_mac_read( - ctx: *mut mbedtls_des3_context, - session_key: *const u8, - rc: *const u8, - blocks: *const u8, - block_count: u8, - data: *const u8, - mac: *mut u8, + pub fn mf_classic_get_first_block_num_of_sector(sector: u8) -> u8; +} +extern "C" { + pub fn mf_classic_get_blocks_num_in_sector(sector: u8) -> u8; +} +extern "C" { + pub fn mf_classic_get_sector_trailer_num_by_sector(sector: u8) -> u8; +} +extern "C" { + pub fn mf_classic_get_sector_trailer_num_by_block(block: u8) -> u8; +} +extern "C" { + pub fn mf_classic_get_sector_trailer_by_sector( + data: *const MfClassicData, + sector_num: u8, + ) -> *mut MfClassicSectorTrailer; +} +extern "C" { + pub fn mf_classic_is_sector_trailer(block: u8) -> bool; +} +extern "C" { + pub fn mf_classic_set_sector_trailer_read( + data: *mut MfClassicData, + block_num: u8, + sec_tr: *mut MfClassicSectorTrailer, ); } extern "C" { - pub fn felica_calculate_mac_write( - ctx: *mut mbedtls_des3_context, - session_key: *const u8, - rc: *const u8, - wcnt: *const u8, - data: *const u8, - mac: *mut u8, + pub fn mf_classic_get_sector_by_block(block: u8) -> u8; +} +extern "C" { + pub fn mf_classic_block_to_value( + block: *const MfClassicBlock, + value: *mut i32, + addr: *mut u8, + ) -> bool; +} +extern "C" { + pub fn mf_classic_value_to_block(value: i32, addr: u8, block: *mut MfClassicBlock); +} +extern "C" { + pub fn mf_classic_is_key_found( + data: *const MfClassicData, + sector_num: u8, + key_type: MfClassicKeyType, + ) -> bool; +} +extern "C" { + pub fn mf_classic_set_key_found( + data: *mut MfClassicData, + sector_num: u8, + key_type: MfClassicKeyType, + key: u64, ); } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct FelicaPoller { - _unused: [u8; 0], +extern "C" { + pub fn mf_classic_set_key_not_found( + data: *mut MfClassicData, + sector_num: u8, + key_type: MfClassicKeyType, + ); } extern "C" { - #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in FeliCa standars. The data\n field will be filled with Felica data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the Felica data structure to be filled.\n # Returns\n\nFelicaErrorNone on success, an error code on failure."] - pub fn felica_poller_activate( - instance: *mut FelicaPoller, - data: *mut FelicaData, - ) -> FelicaError; + pub fn mf_classic_get_key( + data: *const MfClassicData, + sector_num: u8, + key_type: MfClassicKeyType, + ) -> MfClassicKey; } extern "C" { - pub fn felica_poller_sync_read( - nfc: *mut Nfc, - data: *mut FelicaData, - card_key: *const FelicaCardKey, - ) -> FelicaError; + pub fn mf_classic_is_block_read(data: *const MfClassicData, block_num: u8) -> bool; +} +extern "C" { + pub fn mf_classic_set_block_read( + data: *mut MfClassicData, + block_num: u8, + block_data: *mut MfClassicBlock, + ); +} +extern "C" { + pub fn mf_classic_is_sector_read(data: *const MfClassicData, sector_num: u8) -> bool; +} +extern "C" { + pub fn mf_classic_get_read_sectors_and_keys( + data: *const MfClassicData, + sectors_read: *mut u8, + keys_found: *mut u8, + ); +} +extern "C" { + pub fn mf_classic_is_card_read(data: *const MfClassicData) -> bool; +} +extern "C" { + pub fn mf_classic_is_value_block(sec_tr: *mut MfClassicSectorTrailer, block_num: u8) -> bool; +} +extern "C" { + pub fn mf_classic_is_allowed_access_data_block( + sec_tr: *mut MfClassicSectorTrailer, + block_num: u8, + key_type: MfClassicKeyType, + action: MfClassicAction, + ) -> bool; +} +extern "C" { + pub fn mf_classic_is_allowed_access( + data: *mut MfClassicData, + block_num: u8, + key_type: MfClassicKeyType, + action: MfClassicAction, + ) -> bool; } -pub const Iso14443_3aError_Iso14443_3aErrorNone: Iso14443_3aError = 0; -pub const Iso14443_3aError_Iso14443_3aErrorNotPresent: Iso14443_3aError = 1; -pub const Iso14443_3aError_Iso14443_3aErrorColResFailed: Iso14443_3aError = 2; -pub const Iso14443_3aError_Iso14443_3aErrorBufferOverflow: Iso14443_3aError = 3; -pub const Iso14443_3aError_Iso14443_3aErrorCommunication: Iso14443_3aError = 4; -pub const Iso14443_3aError_Iso14443_3aErrorFieldOff: Iso14443_3aError = 5; -pub const Iso14443_3aError_Iso14443_3aErrorWrongCrc: Iso14443_3aError = 6; -pub const Iso14443_3aError_Iso14443_3aErrorTimeout: Iso14443_3aError = 7; -pub type Iso14443_3aError = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Iso14443_3aData { - pub uid: [u8; 10usize], - pub uid_len: u8, - pub atqa: [u8; 2usize], - pub sak: u8, +pub struct Crypto1 { + pub odd: u32, + pub even: u32, } #[test] -fn bindgen_test_layout_Iso14443_3aData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_Crypto1() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 14usize, - concat!("Size of: ", stringify!(Iso14443_3aData)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(Crypto1)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(Iso14443_3aData)) + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(Crypto1)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).uid) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).odd) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(Iso14443_3aData), - "::", - stringify!(uid) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).uid_len) as usize - ptr as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(Iso14443_3aData), - "::", - stringify!(uid_len) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).atqa) as usize - ptr as usize }, - 11usize, - concat!( - "Offset of field: ", - stringify!(Iso14443_3aData), + stringify!(Crypto1), "::", - stringify!(atqa) + stringify!(odd) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sak) as usize - ptr as usize }, - 13usize, + unsafe { ::core::ptr::addr_of!((*ptr).even) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(Iso14443_3aData), + stringify!(Crypto1), "::", - stringify!(sak) + stringify!(even) ) ); } extern "C" { - pub fn iso14443_3a_alloc() -> *mut Iso14443_3aData; + pub fn crypto1_alloc() -> *mut Crypto1; } extern "C" { - pub fn iso14443_3a_free(data: *mut Iso14443_3aData); + pub fn crypto1_free(instance: *mut Crypto1); } extern "C" { - pub fn iso14443_3a_reset(data: *mut Iso14443_3aData); + pub fn crypto1_reset(crypto1: *mut Crypto1); } extern "C" { - pub fn iso14443_3a_copy(data: *mut Iso14443_3aData, other: *const Iso14443_3aData); + pub fn crypto1_init(crypto1: *mut Crypto1, key: u64); } extern "C" { - pub fn iso14443_3a_verify(data: *mut Iso14443_3aData, device_type: *const FuriString) -> bool; + pub fn crypto1_bit(crypto1: *mut Crypto1, in_: u8, is_encrypted: core::ffi::c_int) -> u8; } extern "C" { - pub fn iso14443_3a_load( - data: *mut Iso14443_3aData, - ff: *mut FlipperFormat, - version: u32, - ) -> bool; + pub fn crypto1_byte(crypto1: *mut Crypto1, in_: u8, is_encrypted: core::ffi::c_int) -> u8; } extern "C" { - pub fn iso14443_3a_save(data: *const Iso14443_3aData, ff: *mut FlipperFormat) -> bool; + pub fn crypto1_word(crypto1: *mut Crypto1, in_: u32, is_encrypted: core::ffi::c_int) -> u32; } extern "C" { - pub fn iso14443_3a_is_equal( - data: *const Iso14443_3aData, - other: *const Iso14443_3aData, - ) -> bool; + pub fn crypto1_decrypt(crypto: *mut Crypto1, buff: *const BitBuffer, out: *mut BitBuffer); } extern "C" { - pub fn iso14443_3a_get_device_name( - data: *const Iso14443_3aData, - name_type: NfcDeviceNameType, - ) -> *const core::ffi::c_char; + pub fn crypto1_encrypt( + crypto: *mut Crypto1, + keystream: *mut u8, + buff: *const BitBuffer, + out: *mut BitBuffer, + ); } extern "C" { - pub fn iso14443_3a_get_uid(data: *const Iso14443_3aData, uid_len: *mut usize) -> *const u8; + pub fn crypto1_encrypt_reader_nonce( + crypto: *mut Crypto1, + key: u64, + cuid: u32, + nt: *mut u8, + nr: *mut u8, + out: *mut BitBuffer, + is_nested: bool, + ); } extern "C" { - pub fn iso14443_3a_set_uid(data: *mut Iso14443_3aData, uid: *const u8, uid_len: usize) -> bool; + pub fn crypto1_lfsr_rollback_word(crypto1: *mut Crypto1, in_: u32, fb: core::ffi::c_int) + -> u32; } extern "C" { - pub fn iso14443_3a_get_base_data(data: *const Iso14443_3aData) -> *mut Iso14443_3aData; + pub fn crypto1_nonce_matches_encrypted_parity_bits(nt: u32, ks: u32, nt_par_enc: u8) -> bool; } extern "C" { - pub fn iso14443_3a_get_cuid(data: *const Iso14443_3aData) -> u32; + pub fn crypto1_is_weak_prng_nonce(nonce: u32) -> bool; } extern "C" { - pub fn iso14443_3a_supports_iso14443_4(data: *const Iso14443_3aData) -> bool; + pub fn crypto1_decrypt_nt_enc(cuid: u32, nt_enc: u32, known_key: MfClassicKey) -> u32; } extern "C" { - pub fn iso14443_3a_get_sak(data: *const Iso14443_3aData) -> u8; + pub fn crypto1_prng_successor(x: u32, n: u32) -> u32; } +pub const Iso13239CrcType_Iso13239CrcTypeDefault: Iso13239CrcType = 0; +pub const Iso13239CrcType_Iso13239CrcTypePicopass: Iso13239CrcType = 1; +pub type Iso13239CrcType = core::ffi::c_uchar; extern "C" { - pub fn iso14443_3a_get_atqa(data: *const Iso14443_3aData, atqa: *mut u8); + pub fn iso13239_crc_append(type_: Iso13239CrcType, buf: *mut BitBuffer); } extern "C" { - pub fn iso14443_3a_set_sak(data: *mut Iso14443_3aData, sak: u8); + pub fn iso13239_crc_check(type_: Iso13239CrcType, buf: *const BitBuffer) -> bool; } extern "C" { - pub fn iso14443_3a_set_atqa(data: *mut Iso14443_3aData, atqa: *const u8); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_3aPoller { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Transmit and receive Iso14443_3a frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] - pub fn iso14443_3a_poller_txrx( - instance: *mut Iso14443_3aPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> Iso14443_3aError; -} -extern "C" { - #[doc = "Transmit and receive Iso14443_3a standard frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] - pub fn iso14443_3a_poller_send_standard_frame( - instance: *mut Iso14443_3aPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> Iso14443_3aError; + pub fn iso13239_crc_trim(buf: *mut BitBuffer); } +pub const Iso14443CrcType_Iso14443CrcTypeA: Iso14443CrcType = 0; +pub const Iso14443CrcType_Iso14443CrcTypeB: Iso14443CrcType = 1; +pub type Iso14443CrcType = core::ffi::c_uchar; extern "C" { - #[doc = "Transmit and receive Iso14443_3a frames with custom parity bits in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n Custom parity bits must be set in the tx_buffer. The rx_buffer will contain\n the received data with the parity bits.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] - pub fn iso14443_3a_poller_txrx_custom_parity( - instance: *mut Iso14443_3aPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - fwt: u32, - ) -> Iso14443_3aError; + pub fn iso14443_crc_append(type_: Iso14443CrcType, buf: *mut BitBuffer); } extern "C" { - #[doc = "Checks presence of Iso14443_3a complient card.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3aErrorNone if card is present, an error code otherwise."] - pub fn iso14443_3a_poller_check_presence(instance: *mut Iso14443_3aPoller) -> Iso14443_3aError; + pub fn iso14443_crc_check(type_: Iso14443CrcType, buf: *const BitBuffer) -> bool; } extern "C" { - #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in Iso14443-3a. The iso14443_3a_data\n field will be filled with Iso14443-3a data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `iso14443_3a_data` (direction out) - pointer to the Iso14443_3a data structure to be filled.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] - pub fn iso14443_3a_poller_activate( - instance: *mut Iso14443_3aPoller, - iso14443_3a_data: *mut Iso14443_3aData, - ) -> Iso14443_3aError; + pub fn iso14443_crc_trim(buf: *mut BitBuffer); } +pub const NfcProtocol_NfcProtocolIso14443_3a: NfcProtocol = 0; +pub const NfcProtocol_NfcProtocolIso14443_3b: NfcProtocol = 1; +pub const NfcProtocol_NfcProtocolIso14443_4a: NfcProtocol = 2; +pub const NfcProtocol_NfcProtocolIso14443_4b: NfcProtocol = 3; +pub const NfcProtocol_NfcProtocolIso15693_3: NfcProtocol = 4; +pub const NfcProtocol_NfcProtocolFelica: NfcProtocol = 5; +pub const NfcProtocol_NfcProtocolMfUltralight: NfcProtocol = 6; +pub const NfcProtocol_NfcProtocolMfClassic: NfcProtocol = 7; +pub const NfcProtocol_NfcProtocolMfPlus: NfcProtocol = 8; +pub const NfcProtocol_NfcProtocolMfDesfire: NfcProtocol = 9; +pub const NfcProtocol_NfcProtocolSlix: NfcProtocol = 10; +pub const NfcProtocol_NfcProtocolSt25tb: NfcProtocol = 11; +#[doc = "< Special value representing the number of available protocols."] +pub const NfcProtocol_NfcProtocolNum: NfcProtocol = 12; +#[doc = "< Special value representing an invalid state."] +pub const NfcProtocol_NfcProtocolInvalid: NfcProtocol = 13; +#[doc = "Enumeration of all available NFC protocols.\n\n When implementing a new protocol, add its identifier before the\n NfcProtocolNum entry."] +pub type NfcProtocol = core::ffi::c_uchar; extern "C" { - #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_3aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] - pub fn iso14443_3a_poller_halt(instance: *mut Iso14443_3aPoller) -> Iso14443_3aError; + #[doc = "Get the immediate parent of a specific protocol.\n\n # Arguments\n\n* `protocol` (direction in) - identifier of the protocol in question.\n # Returns\n\nparent protocol identifier if it has one, or NfcProtocolInvalid otherwise."] + pub fn nfc_protocol_get_parent(protocol: NfcProtocol) -> NfcProtocol; } extern "C" { - pub fn iso14443_3a_poller_sync_read( - nfc: *mut Nfc, - iso14443_3a_data: *mut Iso14443_3aData, - ) -> Iso14443_3aError; + #[doc = "Determine if a specific protocol has a parent on an arbitrary level.\n\n Unlike nfc_protocol_get_parent(), this function will traverse the full protocol hierarchy\n and check each parent node for the matching protocol type.\n\n # Arguments\n\n* `protocol` (direction in) - identifier of the protocol in question.\n * `parent_protocol` (direction in) - identifier of the parent protocol in question.\n # Returns\n\ntrue if the parent of given type exists, false otherwise."] + pub fn nfc_protocol_has_parent(protocol: NfcProtocol, parent_protocol: NfcProtocol) -> bool; } -pub const Iso14443_3bError_Iso14443_3bErrorNone: Iso14443_3bError = 0; -pub const Iso14443_3bError_Iso14443_3bErrorNotPresent: Iso14443_3bError = 1; -pub const Iso14443_3bError_Iso14443_3bErrorColResFailed: Iso14443_3bError = 2; -pub const Iso14443_3bError_Iso14443_3bErrorBufferOverflow: Iso14443_3bError = 3; -pub const Iso14443_3bError_Iso14443_3bErrorCommunication: Iso14443_3bError = 4; -pub const Iso14443_3bError_Iso14443_3bErrorFieldOff: Iso14443_3bError = 5; -pub const Iso14443_3bError_Iso14443_3bErrorWrongCrc: Iso14443_3bError = 6; -pub const Iso14443_3bError_Iso14443_3bErrorTimeout: Iso14443_3bError = 7; -pub type Iso14443_3bError = core::ffi::c_uchar; -pub const Iso14443_3bBitRate_Iso14443_3bBitRateBoth106Kbit: Iso14443_3bBitRate = 0; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd212Kbit: Iso14443_3bBitRate = 1; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd424Kbit: Iso14443_3bBitRate = 2; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd848Kbit: Iso14443_3bBitRate = 3; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc212Kbit: Iso14443_3bBitRate = 4; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc424Kbit: Iso14443_3bBitRate = 5; -pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc848Kbit: Iso14443_3bBitRate = 6; -pub type Iso14443_3bBitRate = core::ffi::c_uchar; -pub const Iso14443_3bFrameOption_Iso14443_3bFrameOptionNad: Iso14443_3bFrameOption = 0; -pub const Iso14443_3bFrameOption_Iso14443_3bFrameOptionCid: Iso14443_3bFrameOption = 1; -pub type Iso14443_3bFrameOption = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Iso14443_3bData { +pub struct NfcDevice { _unused: [u8; 0], } +#[doc = "Loading callback function signature.\n\n A function with such signature can be set as a callback to indicate\n the completion (or a failure) of nfc_device_load() and nfc_device_save() functions.\n\n This facility is commonly used to control GUI elements, such as progress dialogs.\n\n # Arguments\n\n* `context` (direction in) - user-defined context that was passed in nfc_device_set_loading_callback().\n * `state` (direction in) - true if the data was loaded successfully, false otherwise."] +pub type NfcLoadingCallback = + ::core::option::Option; extern "C" { - pub fn iso14443_3b_alloc() -> *mut Iso14443_3bData; -} -extern "C" { - pub fn iso14443_3b_free(data: *mut Iso14443_3bData); + #[doc = "Allocate an NfcDevice instance.\n\n A newly created instance does not hold any data and thus is considered invalid. The most common\n use case would be to set its data by calling nfc_device_set_data() right afterwards.\n\n # Returns\n\npointer to the allocated instance."] + pub fn nfc_device_alloc() -> *mut NfcDevice; } extern "C" { - pub fn iso14443_3b_reset(data: *mut Iso14443_3bData); + #[doc = "Delete an NfcDevice instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] + pub fn nfc_device_free(instance: *mut NfcDevice); } extern "C" { - pub fn iso14443_3b_copy(data: *mut Iso14443_3bData, other: *const Iso14443_3bData); + #[doc = "Clear an NfcDevice instance.\n\n All data contained in the instance will be deleted and the instance itself will become invalid\n as if it was just allocated.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be cleared."] + pub fn nfc_device_clear(instance: *mut NfcDevice); } extern "C" { - pub fn iso14443_3b_verify(data: *mut Iso14443_3bData, device_type: *const FuriString) -> bool; + #[doc = "Reset an NfcDevice instance.\n\n The data contained in the instance will be reset according to the protocol-defined procedure.\n Unlike the nfc_device_clear() function, the instance will remain valid.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be reset."] + pub fn nfc_device_reset(instance: *mut NfcDevice); } extern "C" { - pub fn iso14443_3b_load( - data: *mut Iso14443_3bData, - ff: *mut FlipperFormat, - version: u32, - ) -> bool; + #[doc = "Get the protocol identifier from an NfcDevice instance.\n\n If the instance is invalid, the return value will be NfcProtocolInvalid.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nprotocol identifier contained in the instance."] + pub fn nfc_device_get_protocol(instance: *const NfcDevice) -> NfcProtocol; } extern "C" { - pub fn iso14443_3b_save(data: *const Iso14443_3bData, ff: *mut FlipperFormat) -> bool; + #[doc = "Get the protocol-specific data from an NfcDevice instance.\n\n The protocol parameter's behaviour is a bit tricky. The function will check\n whether there is such a protocol somewhere in the protocol hierarchy and return\n the data exactly from that level.\n\n Example: Call nfc_device_get_data() on an instance with Mf DESFire protocol.\n The protocol hierarchy will look like the following:\n\n `Mf DESFire --> ISO14443-4A --> ISO14443-3A`\n\n Thus, the following values of the protocol parameter are valid:\n\n * NfcProtocolIso14443_3a\n * NfcProtocolIso14443_4a\n * NfcProtocolMfDesfire\n\n and passing them to the call would result in the respective data being returned.\n\n However, supplying a protocol identifier which is not in the hierarchy will\n result in a crash. This is to improve type safety.\n\n # Arguments\n\n* `instance` - pointer to the instance to be queried\n * `protocol` - protocol identifier of the data to be retrieved.\n # Returns\n\npointer to the instance's data."] + pub fn nfc_device_get_data( + instance: *const NfcDevice, + protocol: NfcProtocol, + ) -> *const NfcDeviceData; } extern "C" { - pub fn iso14443_3b_is_equal( - data: *const Iso14443_3bData, - other: *const Iso14443_3bData, - ) -> bool; + #[doc = "Get the protocol name by its identifier.\n\n This function does not require an instance as its return result depends only\n the protocol identifier.\n\n # Arguments\n\n* `protocol` (direction in) - numeric identifier of the protocol in question.\n # Returns\n\npointer to a statically allocated string containing the protocol name."] + pub fn nfc_device_get_protocol_name(protocol: NfcProtocol) -> *const core::ffi::c_char; } extern "C" { - pub fn iso14443_3b_get_device_name( - data: *const Iso14443_3bData, + #[doc = "Get the name of an NfcDevice instance.\n\n The return value may change depending on the instance's internal state and the name_type parameter.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `name_type` (direction in) - type of the name to be displayed.\n # Returns\n\npointer to a statically allocated string containing the device name."] + pub fn nfc_device_get_name( + instance: *const NfcDevice, name_type: NfcDeviceNameType, ) -> *const core::ffi::c_char; } extern "C" { - pub fn iso14443_3b_get_uid(data: *const Iso14443_3bData, uid_len: *mut usize) -> *const u8; + #[doc = "Get the unique identifier (UID) of an NfcDevice instance.\n\n The UID length is protocol-dependent. Additionally, a particular protocol might support\n several UID lengths.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `uid_len` (direction out) - pointer to the variable to contain the UID length.\n # Returns\n\npointer to the byte array containing the instance's UID."] + pub fn nfc_device_get_uid(instance: *const NfcDevice, uid_len: *mut usize) -> *const u8; } extern "C" { - pub fn iso14443_3b_set_uid(data: *mut Iso14443_3bData, uid: *const u8, uid_len: usize) -> bool; + #[doc = "Set the unique identifier (UID) of an NfcDevice instance.\n\n The UID length must be supported by the instance's protocol.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `uid` (direction in) - pointer to the byte array containing the new UID.\n * `uid_len` (direction in) - length of the UID.\n # Returns\n\ntrue if the UID was valid and set, false otherwise."] + pub fn nfc_device_set_uid(instance: *mut NfcDevice, uid: *const u8, uid_len: usize) -> bool; } extern "C" { - pub fn iso14443_3b_get_base_data(data: *const Iso14443_3bData) -> *mut Iso14443_3bData; + #[doc = "Set the data and protocol of an NfcDevice instance.\n\n Any data previously contained in the instance will be deleted.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `protocol` (direction in) - numeric identifier of the data's protocol.\n * `protocol_data` (direction in) - pointer to the protocol-specific data."] + pub fn nfc_device_set_data( + instance: *mut NfcDevice, + protocol: NfcProtocol, + protocol_data: *const NfcDeviceData, + ); } extern "C" { - pub fn iso14443_3b_supports_iso14443_4(data: *const Iso14443_3bData) -> bool; + #[doc = "Copy (export) the data contained in an NfcDevice instance to an outside NfcDeviceData instance.\n\n This function does the inverse of nfc_device_set_data().\n\n The protocol identifier passed as the protocol parameter MUST match the one\n stored in the instance, otherwise a crash will occur.\n This is to improve type safety.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be copied from.\n * `protocol` (direction in) - numeric identifier of the instance's protocol.\n * `protocol_data` (direction out) - pointer to the destination data."] + pub fn nfc_device_copy_data( + instance: *const NfcDevice, + protocol: NfcProtocol, + protocol_data: *mut NfcDeviceData, + ); } extern "C" { - pub fn iso14443_3b_supports_bit_rate( - data: *const Iso14443_3bData, - bit_rate: Iso14443_3bBitRate, + #[doc = "Check whether an NfcDevice instance holds certain data.\n\n This function's behaviour is similar to nfc_device_is_equal(), with the difference\n that it takes NfcProtocol and NfcDeviceData* instead of the second NfcDevice*.\n\n The following code snippets [1] and [2] are equivalent:\n\n [1]\n ```c\n bool is_equal = nfc_device_is_equal(device1, device2);\n ```\n [2]\n ```c\n NfcProtocol protocol = nfc_device_get_protocol(device2);\n const NfcDeviceData* data = nfc_device_get_data(device2, protocol);\n bool is_equal = nfc_device_is_equal_data(device1, protocol, data);\n ```\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be compared.\n * `protocol` (direction in) - protocol identifier of the data to be compared.\n * `protocol_data` (direction in) - pointer to the NFC device data to be compared.\n # Returns\n\ntrue if the instance is of the right type and the data matches, false otherwise."] + pub fn nfc_device_is_equal_data( + instance: *const NfcDevice, + protocol: NfcProtocol, + protocol_data: *const NfcDeviceData, ) -> bool; } extern "C" { - pub fn iso14443_3b_supports_frame_option( - data: *const Iso14443_3bData, - option: Iso14443_3bFrameOption, - ) -> bool; + #[doc = "Compare two NfcDevice instances to determine whether they are equal.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the first instance to be compared.\n * `other` (direction in) - pointer to the second instance to be compared.\n # Returns\n\ntrue if both instances are considered equal, false otherwise."] + pub fn nfc_device_is_equal(instance: *const NfcDevice, other: *const NfcDevice) -> bool; } extern "C" { - pub fn iso14443_3b_get_application_data( - data: *const Iso14443_3bData, - data_size: *mut usize, - ) -> *const u8; + #[doc = "Set the loading callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `callback` (direction in) - pointer to a function to be called when the load operation completes.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] + pub fn nfc_device_set_loading_callback( + instance: *mut NfcDevice, + callback: NfcLoadingCallback, + context: *mut core::ffi::c_void, + ); } extern "C" { - pub fn iso14443_3b_get_frame_size_max(data: *const Iso14443_3bData) -> u16; + #[doc = "Save NFC device data form an NfcDevice instance to a file.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be saved.\n * `path` (direction in) - pointer to a character string with a full file path.\n # Returns\n\ntrue if the data was successfully saved, false otherwise."] + pub fn nfc_device_save(instance: *mut NfcDevice, path: *const core::ffi::c_char) -> bool; } extern "C" { - pub fn iso14443_3b_get_fwt_fc_max(data: *const Iso14443_3bData) -> u32; + #[doc = "Load NFC device data to an NfcDevice instance from a file.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be loaded into.\n * `path` (direction in) - pointer to a character string with a full file path.\n # Returns\n\ntrue if the data was successfully loaded, false otherwise."] + pub fn nfc_device_load(instance: *mut NfcDevice, path: *const core::ffi::c_char) -> bool; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_3bPoller { - _unused: [u8; 0], +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralight: NfcDataGeneratorType = 0; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_11: NfcDataGeneratorType = 1; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_H11: NfcDataGeneratorType = 2; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_21: NfcDataGeneratorType = 3; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfUltralightEV1_H21: NfcDataGeneratorType = 4; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG203: NfcDataGeneratorType = 5; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG213: NfcDataGeneratorType = 6; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG215: NfcDataGeneratorType = 7; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAG216: NfcDataGeneratorType = 8; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2C1k: NfcDataGeneratorType = 9; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2C2k: NfcDataGeneratorType = 10; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2CPlus1k: NfcDataGeneratorType = 11; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNTAGI2CPlus2k: NfcDataGeneratorType = 12; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassicMini: NfcDataGeneratorType = 13; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic1k_4b: NfcDataGeneratorType = 14; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic1k_7b: NfcDataGeneratorType = 15; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic4k_4b: NfcDataGeneratorType = 16; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeMfClassic4k_7b: NfcDataGeneratorType = 17; +pub const NfcDataGeneratorType_NfcDataGeneratorTypeNum: NfcDataGeneratorType = 18; +pub type NfcDataGeneratorType = core::ffi::c_uchar; +extern "C" { + pub fn nfc_data_generator_get_name(type_: NfcDataGeneratorType) -> *const core::ffi::c_char; } extern "C" { - #[doc = "Transmit and receive Iso14443_3b frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] - pub fn iso14443_3b_poller_send_frame( - instance: *mut Iso14443_3bPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - ) -> Iso14443_3bError; + pub fn nfc_data_generator_fill_data(type_: NfcDataGeneratorType, nfc_device: *mut NfcDevice); } extern "C" { - #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in Iso14443-3b. The data\n field will be filled with Iso14443-3b data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the Iso14443_3b data structure to be filled.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] - pub fn iso14443_3b_poller_activate( - instance: *mut Iso14443_3bPoller, - data: *mut Iso14443_3bData, - ) -> Iso14443_3bError; + pub fn nfc_util_even_parity8(data: u8) -> u8; } extern "C" { - #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_3bPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] - pub fn iso14443_3b_poller_halt(instance: *mut Iso14443_3bPoller) -> Iso14443_3bError; + pub fn nfc_util_even_parity32(data: u32) -> u8; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct SimpleArray { - _unused: [u8; 0], +extern "C" { + pub fn nfc_util_odd_parity8(data: u8) -> u8; +} +extern "C" { + pub fn nfc_util_odd_parity(src: *const u8, dst: *mut u8, len: u8); } -pub type SimpleArrayData = core::ffi::c_void; -pub type SimpleArrayElement = core::ffi::c_void; -pub type SimpleArrayInit = - ::core::option::Option; -pub type SimpleArrayReset = - ::core::option::Option; -pub type SimpleArrayCopy = ::core::option::Option< - unsafe extern "C" fn(elem: *mut SimpleArrayElement, other: *const SimpleArrayElement), ->; -#[doc = "Simple Array configuration structure. Defined per type."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct SimpleArrayConfig { - #[doc = "< Initialisation (in-place constructor) method."] - pub init: SimpleArrayInit, - #[doc = "< Reset (custom destructor) method."] - pub reset: SimpleArrayReset, - #[doc = "< Copy (custom copy-constructor) method."] - pub copy: SimpleArrayCopy, - pub type_size: usize, +pub struct Nfc { + _unused: [u8; 0], } -#[test] -fn bindgen_test_layout_SimpleArrayConfig() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(SimpleArrayConfig)) +#[doc = "< User code explicitly aborted the current operation."] +pub const NfcEventType_NfcEventTypeUserAbort: NfcEventType = 0; +#[doc = "< Reader's field was detected by the NFC hardware."] +pub const NfcEventType_NfcEventTypeFieldOn: NfcEventType = 1; +#[doc = "< Reader's field was lost."] +pub const NfcEventType_NfcEventTypeFieldOff: NfcEventType = 2; +#[doc = "< Data transmission has started."] +pub const NfcEventType_NfcEventTypeTxStart: NfcEventType = 3; +#[doc = "< Data transmission has ended."] +pub const NfcEventType_NfcEventTypeTxEnd: NfcEventType = 4; +#[doc = "< Data reception has started."] +pub const NfcEventType_NfcEventTypeRxStart: NfcEventType = 5; +#[doc = "< Data reception has ended."] +pub const NfcEventType_NfcEventTypeRxEnd: NfcEventType = 6; +#[doc = "< The listener has been activated by the reader."] +pub const NfcEventType_NfcEventTypeListenerActivated: NfcEventType = 7; +#[doc = "< The card has been activated by the poller."] +pub const NfcEventType_NfcEventTypePollerReady: NfcEventType = 8; +#[doc = "Enumeration of possible Nfc event types.\n\n Not all technologies implement all events (this is due to hardware limitations)."] +pub type NfcEventType = core::ffi::c_uchar; +#[doc = "Nfc event data structure."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcEventData { + #[doc = "< Pointer to the received data buffer."] + pub buffer: *mut BitBuffer, +} +#[test] +fn bindgen_test_layout_NfcEventData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(NfcEventData)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(SimpleArrayConfig)) + concat!("Alignment of ", stringify!(NfcEventData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).init) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).buffer) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(SimpleArrayConfig), + stringify!(NfcEventData), "::", - stringify!(init) + stringify!(buffer) ) ); +} +#[doc = "Nfc event structure.\n\n Upon emission of an event, an instance of this struct will be passed to the callback."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcEvent { + #[doc = "< Type of the emitted event."] + pub type_: NfcEventType, + #[doc = "< Event-specific data."] + pub data: NfcEventData, +} +#[test] +fn bindgen_test_layout_NfcEvent() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).reset) as usize - ptr as usize }, + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(NfcEvent)) + ); + assert_eq!( + ::core::mem::align_of::(), 4usize, - concat!( - "Offset of field: ", - stringify!(SimpleArrayConfig), - "::", - stringify!(reset) - ) + concat!("Alignment of ", stringify!(NfcEvent)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).copy) as usize - ptr as usize }, - 8usize, + unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(SimpleArrayConfig), + stringify!(NfcEvent), "::", - stringify!(copy) + stringify!(type_) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).type_size) as usize - ptr as usize }, - 12usize, + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(SimpleArrayConfig), + stringify!(NfcEvent), "::", - stringify!(type_size) + stringify!(data) ) ); } +#[doc = "< Continue operation normally."] +pub const NfcCommand_NfcCommandContinue: NfcCommand = 0; +#[doc = "< Reset the current state."] +pub const NfcCommand_NfcCommandReset: NfcCommand = 1; +#[doc = "< Stop the current operation."] +pub const NfcCommand_NfcCommandStop: NfcCommand = 2; +#[doc = "< Switch Nfc hardware to low-power mode."] +pub const NfcCommand_NfcCommandSleep: NfcCommand = 3; +#[doc = "Enumeration of possible Nfc commands.\n\n The event callback must return one of these to determine the next action."] +pub type NfcCommand = core::ffi::c_uchar; +#[doc = "Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon start of a an Nfc instance.\n\n # Arguments\n\n* `[in]` - event Nfc event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting an Nfc instance).\n # Returns\n\ncommand which the event producer must execute."] +pub type NfcEventCallback = ::core::option::Option< + unsafe extern "C" fn(event: NfcEvent, context: *mut core::ffi::c_void) -> NfcCommand, +>; +#[doc = "< Configure the Nfc instance as a poller."] +pub const NfcMode_NfcModePoller: NfcMode = 0; +#[doc = "< Configure the Nfc instance as a listener."] +pub const NfcMode_NfcModeListener: NfcMode = 1; +#[doc = "< Operating mode count. Internal use."] +pub const NfcMode_NfcModeNum: NfcMode = 2; +#[doc = "Enumeration of possible operating modes.\n\n Not all technologies implement the listener operating mode."] +pub type NfcMode = core::ffi::c_uchar; +#[doc = "< Configure the Nfc instance to use the ISO14443-3A technology."] +pub const NfcTech_NfcTechIso14443a: NfcTech = 0; +#[doc = "< Configure the Nfc instance to use the ISO14443-3B technology."] +pub const NfcTech_NfcTechIso14443b: NfcTech = 1; +#[doc = "< Configure the Nfc instance to use the ISO15693 technology."] +pub const NfcTech_NfcTechIso15693: NfcTech = 2; +#[doc = "< Configure the Nfc instance to use the FeliCa technology."] +pub const NfcTech_NfcTechFelica: NfcTech = 3; +#[doc = "< Technologies count. Internal use."] +pub const NfcTech_NfcTechNum: NfcTech = 4; +#[doc = "Enumeration of available technologies."] +pub type NfcTech = core::ffi::c_uchar; +#[doc = "< No error has occurred."] +pub const NfcError_NfcErrorNone: NfcError = 0; +#[doc = "< An unknown error has occured on the lower level."] +pub const NfcError_NfcErrorInternal: NfcError = 1; +#[doc = "< Operation is taking too long (e.g. card does not respond)."] +pub const NfcError_NfcErrorTimeout: NfcError = 2; +#[doc = "< An incomplete data frame has been received."] +pub const NfcError_NfcErrorIncompleteFrame: NfcError = 3; +#[doc = "< Data has not been parsed due to wrong/unknown format."] +pub const NfcError_NfcErrorDataFormat: NfcError = 4; +#[doc = "Enumeration of possible Nfc error codes."] +pub type NfcError = core::ffi::c_uchar; extern "C" { - #[doc = "Allocate a SimpleArray instance with the given configuration.\n\n # Arguments\n\n* `[in]` - config Pointer to the type-specific configuration\n # Returns\n\nPointer to the allocated SimpleArray instance"] - pub fn simple_array_alloc(config: *const SimpleArrayConfig) -> *mut SimpleArray; + #[doc = "Allocate an Nfc instance.\n\n Will exclusively take over the NFC HAL until deleted.\n\n # Returns\n\npointer to the allocated Nfc instance."] + pub fn nfc_alloc() -> *mut Nfc; } extern "C" { - #[doc = "Free a SimpleArray instance and release its contents.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be freed"] - pub fn simple_array_free(instance: *mut SimpleArray); + #[doc = "Delete an Nfc instance.\n\n Will release the NFC HAL lock, making it available for use by others.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] + pub fn nfc_free(instance: *mut Nfc); } extern "C" { - #[doc = "Initialise a SimpleArray instance by allocating additional space to contain\n the requested number of elements.\n If init() is specified in the config, then it is called for each element,\n otherwise the data is filled with zeroes.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be init'd\n * `[in]` - count Number of elements to be allocated and init'd"] - pub fn simple_array_init(instance: *mut SimpleArray, count: u32); + #[doc = "Configure the Nfc instance to work in a particular mode.\n\n Not all technologies implement the listener operating mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `mode` (direction in) - required operating mode.\n * `tech` (direction in) - required technology configuration."] + pub fn nfc_config(instance: *mut Nfc, mode: NfcMode, tech: NfcTech); } extern "C" { - #[doc = "Reset a SimpleArray instance and delete all of its elements.\n If reset() is specified in the config, then it is called for each element,\n otherwise the data is simply free()'d.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be reset"] - pub fn simple_array_reset(instance: *mut SimpleArray); + #[doc = "Set poller frame delay time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_poll_fc` (direction in) - frame delay time, in carrier cycles."] + pub fn nfc_set_fdt_poll_fc(instance: *mut Nfc, fdt_poll_fc: u32); } extern "C" { - #[doc = "Copy (duplicate) another SimpleArray instance to this one.\n If copy() is specified in the config, then it is called for each element,\n otherwise the data is simply memcpy()'d.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to copy to\n * `[in]` - other Pointer to the SimpleArray instance to copy from"] - pub fn simple_array_copy(instance: *mut SimpleArray, other: *const SimpleArray); + #[doc = "Set listener frame delay time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_listen_fc` (direction in) - frame delay time, in carrier cycles."] + pub fn nfc_set_fdt_listen_fc(instance: *mut Nfc, fdt_listen_fc: u32); } extern "C" { - #[doc = "Check if another SimpleArray instance is equal (the same object or holds the\n same data) to this one.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be compared\n * `[in]` - other Pointer to the SimpleArray instance to be compared\n # Returns\n\nTrue if instances are considered equal, false otherwise"] - pub fn simple_array_is_equal(instance: *const SimpleArray, other: *const SimpleArray) -> bool; + #[doc = "Set mask receive time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `mask_rx_time_fc` (direction in) - mask receive time, in carrier cycles."] + pub fn nfc_set_mask_receive_time_fc(instance: *mut Nfc, mask_rx_time_fc: u32); } extern "C" { - #[doc = "Get the count of elements currently contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to query the count from\n # Returns\n\nCount of elements contained in the instance"] - pub fn simple_array_get_count(instance: *const SimpleArray) -> u32; + #[doc = "Set frame delay time.\n\n Frame delay time is the minimum time between two consecutive poll frames.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `fdt_poll_poll_us` (direction in) - frame delay time, in microseconds."] + pub fn nfc_set_fdt_poll_poll_us(instance: *mut Nfc, fdt_poll_poll_us: u32); } extern "C" { - #[doc = "Get a pointer to an element contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get an element from\n * `[in]` - index Index of the element in question. MUST be less than total element count\n # Returns\n\nPointer to the element specified by index"] - pub fn simple_array_get(instance: *mut SimpleArray, index: u32) -> *mut SimpleArrayElement; + #[doc = "Set guard time.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be modified.\n * `guard_time_us` (direction in) - guard time, in microseconds."] + pub fn nfc_set_guard_time_us(instance: *mut Nfc, guard_time_us: u32); } extern "C" { - #[doc = "Get a const pointer to an element contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get an element from\n * `[in]` - index Index of the element in question. MUST be less than total element count\n # Returns\n\nConst pointer to the element specified by index"] - pub fn simple_array_cget(instance: *const SimpleArray, index: u32) - -> *const SimpleArrayElement; + #[doc = "Start the Nfc instance.\n\n The instance must be configured to work with a specific technology\n in a specific operating mode with a nfc_config() call before starting.\n\n Once started, the user code will be receiving events through the provided\n callback which must handle them according to the logic required.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] + pub fn nfc_start( + instance: *mut Nfc, + callback: NfcEventCallback, + context: *mut core::ffi::c_void, + ); } extern "C" { - #[doc = "Get a pointer to the internal data of a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get the data of\n # Returns\n\nPointer to the instance's internal data"] - pub fn simple_array_get_data(instance: *mut SimpleArray) -> *mut SimpleArrayData; + #[doc = "Stop Nfc instance.\n\n The instance can only be stopped if it is running.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] + pub fn nfc_stop(instance: *mut Nfc); } extern "C" { - #[doc = "Get a constant pointer to the internal data of a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get the data of\n # Returns\n\nConstant pointer to the instance's internal data"] - pub fn simple_array_cget_data(instance: *const SimpleArray) -> *const SimpleArrayData; + #[doc = "Transmit and receive a data frame in poller mode.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n The data being transmitted and received may be either bit- or byte-oriented.\n It shall not contain any technology-specific sequences as start or stop bits\n and/or other special symbols, as this is handled on the underlying HAL level.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_poller_trx( + instance: *mut Nfc, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> NfcError; } extern "C" { - pub static simple_array_config_uint8_t: SimpleArrayConfig; + #[doc = "Transmit a data frame in listener mode.\n\n Used to transmit a response to the reader request in listener mode.\n\n The data being transmitted may be either bit- or byte-oriented.\n It shall not contain any technology-specific sequences as start or stop bits\n and/or other special symbols, as this is handled on the underlying HAL level.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_listener_tx(instance: *mut Nfc, tx_buffer: *const BitBuffer) -> NfcError; } -pub const Iso14443_4aError_Iso14443_4aErrorNone: Iso14443_4aError = 0; -pub const Iso14443_4aError_Iso14443_4aErrorNotPresent: Iso14443_4aError = 1; -pub const Iso14443_4aError_Iso14443_4aErrorProtocol: Iso14443_4aError = 2; -pub const Iso14443_4aError_Iso14443_4aErrorTimeout: Iso14443_4aError = 3; -pub type Iso14443_4aError = core::ffi::c_uchar; -pub const Iso14443_4aBitRate_Iso14443_4aBitRateBoth106Kbit: Iso14443_4aBitRate = 0; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd212Kbit: Iso14443_4aBitRate = 1; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd424Kbit: Iso14443_4aBitRate = 2; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd848Kbit: Iso14443_4aBitRate = 3; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc212Kbit: Iso14443_4aBitRate = 4; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc424Kbit: Iso14443_4aBitRate = 5; -pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc848Kbit: Iso14443_4aBitRate = 6; -pub type Iso14443_4aBitRate = core::ffi::c_uchar; -pub const Iso14443_4aFrameOption_Iso14443_4aFrameOptionNad: Iso14443_4aFrameOption = 0; -pub const Iso14443_4aFrameOption_Iso14443_4aFrameOptionCid: Iso14443_4aFrameOption = 1; -pub type Iso14443_4aFrameOption = core::ffi::c_uchar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_4aAtsData { - pub tl: u8, - pub t0: u8, - pub ta_1: u8, - pub tb_1: u8, - pub tc_1: u8, - pub t1_tk: *mut SimpleArray, +pub const NfcIso14443aShortFrame_NfcIso14443aShortFrameSensReq: NfcIso14443aShortFrame = 0; +pub const NfcIso14443aShortFrame_NfcIso14443aShortFrameAllReqa: NfcIso14443aShortFrame = 1; +#[doc = "Enumeration of possible ISO14443-3A short frame types."] +pub type NfcIso14443aShortFrame = core::ffi::c_uchar; +extern "C" { + #[doc = "Transmit an ISO14443-3A short frame and receive the response in poller mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `frame` (direction in) - type of short frame to be sent.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso14443a_poller_trx_short_frame( + instance: *mut Nfc, + frame: NfcIso14443aShortFrame, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> NfcError; } -#[test] -fn bindgen_test_layout_Iso14443_4aAtsData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 12usize, - concat!("Size of: ", stringify!(Iso14443_4aAtsData)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(Iso14443_4aAtsData)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tl) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(Iso14443_4aAtsData), - "::", - stringify!(tl) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).t0) as usize - ptr as usize }, - 1usize, - concat!( - "Offset of field: ", - stringify!(Iso14443_4aAtsData), - "::", - stringify!(t0) - ) +extern "C" { + #[doc = "Transmit an ISO14443-3A SDD frame and receive the response in poller mode.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso14443a_poller_trx_sdd_frame( + instance: *mut Nfc, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> NfcError; +} +extern "C" { + #[doc = "Transmit an ISO14443-3A data frame with custom parity bits and receive the response in poller mode.\n\n Same as nfc_poller_trx(), but uses the parity bits provided by the user code\n instead of calculating them automatically.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso14443a_poller_trx_custom_parity( + instance: *mut Nfc, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> NfcError; +} +extern "C" { + #[doc = "Transmit an ISO14443-3A frame with custom parity bits in listener mode.\n\n Same as nfc_listener_tx(), but uses the parity bits provided by the user code\n instead of calculating them automatically.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso14443a_listener_tx_custom_parity( + instance: *mut Nfc, + tx_buffer: *const BitBuffer, + ) -> NfcError; +} +extern "C" { + #[doc = "Set ISO14443-3A collision resolution parameters in listener mode.\n\n Configures the NFC hardware for automatic collision resolution.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `uid` (direction in) - pointer to a byte array containing the UID.\n * `uid_len` (direction in) - UID length in bytes (must be supported by the protocol).\n * `atqa` (direction in) - ATQA byte value.\n * `sak` (direction in) - SAK byte value.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso14443a_listener_set_col_res_data( + instance: *mut Nfc, + uid: *mut u8, + uid_len: u8, + atqa: *mut u8, + sak: u8, + ) -> NfcError; +} +extern "C" { + #[doc = "Set FeliCa collision resolution parameters in listener mode.\n\n Configures the NFC hardware for automatic collision resolution.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n * `idm` (direction in) - pointer to a byte array containing the IDm.\n * `idm_len` (direction in) - IDm length in bytes.\n * `pmm` (direction in) - pointer to a byte array containing the PMm.\n * `pmm_len` (direction in) - PMm length in bytes.\n * `sys_code` (direction in) - System code from SYS_C block\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_felica_listener_set_sensf_res_data( + instance: *mut Nfc, + idm: *const u8, + idm_len: u8, + pmm: *const u8, + pmm_len: u8, + sys_code: u16, + ) -> NfcError; +} +extern "C" { + #[doc = "Send ISO15693 Start of Frame pattern in listener mode\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be configured.\n # Returns\n\nNfcErrorNone on success, any other error code on failure."] + pub fn nfc_iso15693_listener_tx_sof(instance: *mut Nfc) -> NfcError; +} +#[doc = "Generic Nfc instance type.\n\n Must be cast to a concrete type before use.\n Depending on the context, a pointer of this type\n may point to an object of the following types:\n - Nfc type,\n - Concrete poller type,\n - Concrete listener type."] +pub type NfcGenericInstance = core::ffi::c_void; +#[doc = "Generic Nfc event data type.\n\n Must be cast to a concrete type before use.\n Usually, it will be the protocol-specific event type."] +pub type NfcGenericEventData = core::ffi::c_void; +#[doc = "Generic Nfc event type.\n\n A generic Nfc event contains a protocol identifier, can be used to determine\n the remaing fields' type.\n\n If the value of the protocol field is NfcProtocolInvalid, then it means that\n the event was emitted from an Nfc instance, otherwise it originated from\n a concrete poller or listener instance.\n\n The event_data field is protocol-specific and should be cast to the appropriate type before use."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcGenericEvent { + #[doc = "< Protocol identifier of the instance that produced the event."] + pub protocol: NfcProtocol, + #[doc = "< Pointer to the protocol-specific instance that produced the event."] + pub instance: *mut NfcGenericInstance, + #[doc = "< Pointer to the protocol-specific event."] + pub event_data: *mut NfcGenericEventData, +} +#[test] +fn bindgen_test_layout_NfcGenericEvent() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(NfcGenericEvent)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ta_1) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(Iso14443_4aAtsData), - "::", - stringify!(ta_1) - ) + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(NfcGenericEvent)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tb_1) as usize - ptr as usize }, - 3usize, + unsafe { ::core::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(Iso14443_4aAtsData), + stringify!(NfcGenericEvent), "::", - stringify!(tb_1) + stringify!(protocol) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tc_1) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).instance) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(Iso14443_4aAtsData), + stringify!(NfcGenericEvent), "::", - stringify!(tc_1) + stringify!(instance) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).t1_tk) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).event_data) as usize - ptr as usize }, 8usize, concat!( "Offset of field: ", - stringify!(Iso14443_4aAtsData), + stringify!(NfcGenericEvent), "::", - stringify!(t1_tk) + stringify!(event_data) ) ); } +#[doc = "Generic Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon start\n of a poller, listener or Nfc instance.\n\n # Arguments\n\n* `[in]` - event Nfc generic event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting a poller/listener instance).\n # Returns\n\nthe command which the event producer must execute."] +pub type NfcGenericCallback = ::core::option::Option< + unsafe extern "C" fn(event: NfcGenericEvent, context: *mut core::ffi::c_void) -> NfcCommand, +>; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct Iso14443_4aData { - pub iso14443_3a_data: *mut Iso14443_3aData, - pub ats_data: Iso14443_4aAtsData, +pub struct NfcListener { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Allocate an NfcListener instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n * `protocol` (direction in) - identifier of the protocol to be used.\n * `data` (direction in) - pointer to the data to use during emulation.\n # Returns\n\npointer to an allocated instance.\n\n [`nfc.h`]"] + pub fn nfc_listener_alloc( + nfc: *mut Nfc, + protocol: NfcProtocol, + data: *const NfcDeviceData, + ) -> *mut NfcListener; +} +extern "C" { + #[doc = "Delete an NfcListener instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] + pub fn nfc_listener_free(instance: *mut NfcListener); +} +extern "C" { + #[doc = "Start an NfcListener instance.\n\n The callback logic is protocol-specific, so it cannot be described here in detail.\n However, the callback return value ALWAYS determines what the listener should do next:\n to continue whatever it was doing prior to the callback run or to stop.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] + pub fn nfc_listener_start( + instance: *mut NfcListener, + callback: NfcGenericCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Stop an NfcListener instance.\n\n The emulation process can be stopped explicitly (the other way is via the callback return value).\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] + pub fn nfc_listener_stop(instance: *mut NfcListener); +} +extern "C" { + #[doc = "Get the protocol identifier an NfcListener instance was created with.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nidentifier of the protocol used by the instance."] + pub fn nfc_listener_get_protocol(instance: *const NfcListener) -> NfcProtocol; +} +extern "C" { + #[doc = "Get the data that was that was provided for emulation.\n\n The protocol identifier passed as the protocol parameter MUST match the one\n stored in the instance, otherwise a crash will occur.\n This is to improve type safety.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n * `protocol` (direction in) - assumed protocol identifier of the data to be retrieved.\n # Returns\n\npointer to the NFC device data."] + pub fn nfc_listener_get_data( + instance: *const NfcListener, + protocol: NfcProtocol, + ) -> *const NfcDeviceData; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcPoller { + _unused: [u8; 0], +} +#[doc = "Extended generic Nfc event type.\n\n An extended generic Nfc event contains protocol poller and it's parent protocol event data.\n If protocol has no parent, then events are produced by Nfc instance.\n\n The parent_event_data field is protocol-specific and should be cast to the appropriate type before use."] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcGenericEventEx { + #[doc = "< Pointer to the protocol poller."] + pub poller: *mut NfcGenericInstance, + #[doc = "< Pointer to the protocol's parent poller event data."] + pub parent_event_data: *mut NfcGenericEventData, } #[test] -fn bindgen_test_layout_Iso14443_4aData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_NfcGenericEventEx() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(Iso14443_4aData)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(NfcGenericEventEx)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(Iso14443_4aData)) + concat!("Alignment of ", stringify!(NfcGenericEventEx)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).iso14443_3a_data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).poller) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(Iso14443_4aData), + stringify!(NfcGenericEventEx), "::", - stringify!(iso14443_3a_data) + stringify!(poller) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ats_data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).parent_event_data) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(Iso14443_4aData), + stringify!(NfcGenericEventEx), "::", - stringify!(ats_data) + stringify!(parent_event_data) ) ); } +#[doc = "Extended generic Nfc event callback type.\n\n A function of this type must be passed as the callback parameter upon extended start of a poller.\n\n # Arguments\n\n* `[in]` - event Nfc extended generic event, passed by value, complete with protocol type and data.\n * `[in,out]` - context pointer to the user-specific context (set when starting a poller/listener instance).\n # Returns\n\nthe command which the event producer must execute."] +pub type NfcGenericCallbackEx = ::core::option::Option< + unsafe extern "C" fn(event: NfcGenericEventEx, context: *mut core::ffi::c_void) -> NfcCommand, +>; extern "C" { - pub fn iso14443_4a_alloc() -> *mut Iso14443_4aData; -} -extern "C" { - pub fn iso14443_4a_free(data: *mut Iso14443_4aData); -} -extern "C" { - pub fn iso14443_4a_reset(data: *mut Iso14443_4aData); -} -extern "C" { - pub fn iso14443_4a_copy(data: *mut Iso14443_4aData, other: *const Iso14443_4aData); + #[doc = "Allocate an NfcPoller instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n * `protocol` (direction in) - identifier of the protocol to be used.\n # Returns\n\npointer to an allocated instance.\n\n [`nfc.h`]"] + pub fn nfc_poller_alloc(nfc: *mut Nfc, protocol: NfcProtocol) -> *mut NfcPoller; } extern "C" { - pub fn iso14443_4a_verify(data: *mut Iso14443_4aData, device_type: *const FuriString) -> bool; + #[doc = "Delete an NfcPoller instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] + pub fn nfc_poller_free(instance: *mut NfcPoller); } extern "C" { - pub fn iso14443_4a_load( - data: *mut Iso14443_4aData, - ff: *mut FlipperFormat, - version: u32, - ) -> bool; + #[doc = "Start an NfcPoller instance.\n\n The callback logic is protocol-specific, so it cannot be described here in detail.\n However, the callback return value ALWAYS determines what the poller should do next:\n to continue whatever it was doing prior to the callback run or to stop.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] + pub fn nfc_poller_start( + instance: *mut NfcPoller, + callback: NfcGenericCallback, + context: *mut core::ffi::c_void, + ); } extern "C" { - pub fn iso14443_4a_save(data: *const Iso14443_4aData, ff: *mut FlipperFormat) -> bool; + #[doc = "Start an NfcPoller instance in extended mode.\n\n When nfc poller is started in extended mode, callback will be called with parent protocol events\n and protocol instance. This mode enables to make custom poller state machines.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to a user-defined callback function which will receive events.\n * `context` (direction in) - pointer to a user-specific context (will be passed to the callback)."] + pub fn nfc_poller_start_ex( + instance: *mut NfcPoller, + callback: NfcGenericCallbackEx, + context: *mut core::ffi::c_void, + ); } extern "C" { - pub fn iso14443_4a_is_equal( - data: *const Iso14443_4aData, - other: *const Iso14443_4aData, - ) -> bool; + #[doc = "Stop an NfcPoller instance.\n\n The reading process can be stopped explicitly (the other way is via the callback return value).\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] + pub fn nfc_poller_stop(instance: *mut NfcPoller); } extern "C" { - pub fn iso14443_4a_get_device_name( - data: *const Iso14443_4aData, - name_type: NfcDeviceNameType, - ) -> *const core::ffi::c_char; + #[doc = "Detect whether there is a card supporting a particular protocol in the vicinity.\n\n The behaviour of this function is protocol-defined, in general, it will do whatever is\n necessary to determine whether a card supporting the current protocol is in the vicinity\n and whether it is functioning normally.\n\n It is used automatically inside NfcScanner, so there is usually no need\n to call it explicitly.\n\n [`nfc_scanner.h`]\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to perform the detection with.\n # Returns\n\ntrue if a supported card was detected, false otherwise."] + pub fn nfc_poller_detect(instance: *mut NfcPoller) -> bool; } extern "C" { - pub fn iso14443_4a_get_uid(data: *const Iso14443_4aData, uid_len: *mut usize) -> *const u8; + #[doc = "Get the protocol identifier an NfcPoller instance was created with.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\nidentifier of the protocol used by the instance."] + pub fn nfc_poller_get_protocol(instance: *const NfcPoller) -> NfcProtocol; } extern "C" { - pub fn iso14443_4a_set_uid(data: *mut Iso14443_4aData, uid: *const u8, uid_len: usize) -> bool; + #[doc = "Get the data that was that was gathered during the reading process.\n\n # Arguments\n\n* `instance` (direction in) - pointer to the instance to be queried.\n # Returns\n\npointer to the NFC device data."] + pub fn nfc_poller_get_data(instance: *const NfcPoller) -> *const NfcDeviceData; } -extern "C" { - pub fn iso14443_4a_get_base_data(data: *const Iso14443_4aData) -> *mut Iso14443_3aData; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct NfcScanner { + _unused: [u8; 0], } -extern "C" { - pub fn iso14443_4a_get_frame_size_max(data: *const Iso14443_4aData) -> u16; -} -extern "C" { - pub fn iso14443_4a_get_fwt_fc_max(data: *const Iso14443_4aData) -> u32; -} -extern "C" { - pub fn iso14443_4a_get_historical_bytes( - data: *const Iso14443_4aData, - count: *mut u32, - ) -> *const u8; -} -extern "C" { - pub fn iso14443_4a_supports_bit_rate( - data: *const Iso14443_4aData, - bit_rate: Iso14443_4aBitRate, - ) -> bool; -} -extern "C" { - pub fn iso14443_4a_supports_frame_option( - data: *const Iso14443_4aData, - option: Iso14443_4aFrameOption, - ) -> bool; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_4aPoller { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Transmit and receive Iso14443_4a blocks in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer. The fwt parameter is calculated during activation procedure.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] - pub fn iso14443_4a_poller_send_block( - instance: *mut Iso14443_4aPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - ) -> Iso14443_4aError; -} -extern "C" { - #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_4aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] - pub fn iso14443_4a_poller_halt(instance: *mut Iso14443_4aPoller) -> Iso14443_4aError; -} -extern "C" { - #[doc = "Read Answer To Select (ATS) from the card.\n\n Must ONLY be used inside the callback function.\n\n Send Request Answer To Select (RATS) command to the card and parse the response.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the buffer to be filled with ATS data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] - pub fn iso14443_4a_poller_read_ats( - instance: *mut Iso14443_4aPoller, - data: *mut Iso14443_4aAtsData, - ) -> Iso14443_4aError; -} -pub const Iso14443_4bError_Iso14443_4bErrorNone: Iso14443_4bError = 0; -pub const Iso14443_4bError_Iso14443_4bErrorNotPresent: Iso14443_4bError = 1; -pub const Iso14443_4bError_Iso14443_4bErrorProtocol: Iso14443_4bError = 2; -pub const Iso14443_4bError_Iso14443_4bErrorTimeout: Iso14443_4bError = 3; -pub type Iso14443_4bError = core::ffi::c_uchar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_4bData { - _unused: [u8; 0], -} -extern "C" { - pub fn iso14443_4b_alloc() -> *mut Iso14443_4bData; -} -extern "C" { - pub fn iso14443_4b_free(data: *mut Iso14443_4bData); -} -extern "C" { - pub fn iso14443_4b_reset(data: *mut Iso14443_4bData); -} -extern "C" { - pub fn iso14443_4b_copy(data: *mut Iso14443_4bData, other: *const Iso14443_4bData); -} -extern "C" { - pub fn iso14443_4b_verify(data: *mut Iso14443_4bData, device_type: *const FuriString) -> bool; -} -extern "C" { - pub fn iso14443_4b_load( - data: *mut Iso14443_4bData, - ff: *mut FlipperFormat, - version: u32, - ) -> bool; -} -extern "C" { - pub fn iso14443_4b_save(data: *const Iso14443_4bData, ff: *mut FlipperFormat) -> bool; -} -extern "C" { - pub fn iso14443_4b_is_equal( - data: *const Iso14443_4bData, - other: *const Iso14443_4bData, - ) -> bool; -} -extern "C" { - pub fn iso14443_4b_get_device_name( - data: *const Iso14443_4bData, - name_type: NfcDeviceNameType, - ) -> *const core::ffi::c_char; -} -extern "C" { - pub fn iso14443_4b_get_uid(data: *const Iso14443_4bData, uid_len: *mut usize) -> *const u8; -} -extern "C" { - pub fn iso14443_4b_set_uid(data: *mut Iso14443_4bData, uid: *const u8, uid_len: usize) -> bool; -} -extern "C" { - pub fn iso14443_4b_get_base_data(data: *const Iso14443_4bData) -> *mut Iso14443_3bData; -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct Iso14443_4bPoller { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Transmit and receive Iso14443_4b blocks in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer. The fwt parameter is calculated during activation procedure.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4bErrorNone on success, an error code on failure."] - pub fn iso14443_4b_poller_send_block( - instance: *mut Iso14443_4bPoller, - tx_buffer: *const BitBuffer, - rx_buffer: *mut BitBuffer, - ) -> Iso14443_4bError; -} -extern "C" { - #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_4aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_4bErrorNone on success, an error code on failure."] - pub fn iso14443_4b_poller_halt(instance: *mut Iso14443_4bPoller) -> Iso14443_4bError; -} -pub const MfClassicError_MfClassicErrorNone: MfClassicError = 0; -pub const MfClassicError_MfClassicErrorNotPresent: MfClassicError = 1; -pub const MfClassicError_MfClassicErrorProtocol: MfClassicError = 2; -pub const MfClassicError_MfClassicErrorAuth: MfClassicError = 3; -pub const MfClassicError_MfClassicErrorPartialRead: MfClassicError = 4; -pub const MfClassicError_MfClassicErrorTimeout: MfClassicError = 5; -pub type MfClassicError = core::ffi::c_uchar; -pub const MfClassicType_MfClassicTypeMini: MfClassicType = 0; -pub const MfClassicType_MfClassicType1k: MfClassicType = 1; -pub const MfClassicType_MfClassicType4k: MfClassicType = 2; -pub const MfClassicType_MfClassicTypeNum: MfClassicType = 3; -pub type MfClassicType = core::ffi::c_uchar; -pub const MfClassicAction_MfClassicActionDataRead: MfClassicAction = 0; -pub const MfClassicAction_MfClassicActionDataWrite: MfClassicAction = 1; -pub const MfClassicAction_MfClassicActionDataInc: MfClassicAction = 2; -pub const MfClassicAction_MfClassicActionDataDec: MfClassicAction = 3; -pub const MfClassicAction_MfClassicActionKeyARead: MfClassicAction = 4; -pub const MfClassicAction_MfClassicActionKeyAWrite: MfClassicAction = 5; -pub const MfClassicAction_MfClassicActionKeyBRead: MfClassicAction = 6; -pub const MfClassicAction_MfClassicActionKeyBWrite: MfClassicAction = 7; -pub const MfClassicAction_MfClassicActionACRead: MfClassicAction = 8; -pub const MfClassicAction_MfClassicActionACWrite: MfClassicAction = 9; -pub type MfClassicAction = core::ffi::c_uchar; -pub const MfClassicValueCommand_MfClassicValueCommandIncrement: MfClassicValueCommand = 0; -pub const MfClassicValueCommand_MfClassicValueCommandDecrement: MfClassicValueCommand = 1; -pub const MfClassicValueCommand_MfClassicValueCommandRestore: MfClassicValueCommand = 2; -pub const MfClassicValueCommand_MfClassicValueCommandInvalid: MfClassicValueCommand = 3; -pub type MfClassicValueCommand = core::ffi::c_uchar; +#[doc = "< One or more protocols have been detected."] +pub const NfcScannerEventType_NfcScannerEventTypeDetected: NfcScannerEventType = 0; +#[doc = "Event type passed to the user callback."] +pub type NfcScannerEventType = core::ffi::c_uchar; +#[doc = "Event data passed to the user callback."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicBlock { - pub data: [u8; 16usize], +pub struct NfcScannerEventData { + #[doc = "< Number of detected protocols (one or more)."] + pub protocol_num: usize, + #[doc = "< Pointer to the array of detected protocol identifiers."] + pub protocols: *mut NfcProtocol, } #[test] -fn bindgen_test_layout_MfClassicBlock() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_NfcScannerEventData() { + const UNINIT: ::core::mem::MaybeUninit = + ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(MfClassicBlock)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(NfcScannerEventData)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(MfClassicBlock)) + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(NfcScannerEventData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).protocol_num) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicBlock), + stringify!(NfcScannerEventData), "::", - stringify!(data) + stringify!(protocol_num) ) ); -} -pub const MfClassicKeyType_MfClassicKeyTypeA: MfClassicKeyType = 0; -pub const MfClassicKeyType_MfClassicKeyTypeB: MfClassicKeyType = 1; -pub type MfClassicKeyType = core::ffi::c_uchar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct MfClassicKey { - pub data: [u8; 6usize], -} -#[test] -fn bindgen_test_layout_MfClassicKey() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 6usize, - concat!("Size of: ", stringify!(MfClassicKey)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(MfClassicKey)) - ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).protocols) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(MfClassicKey), + stringify!(NfcScannerEventData), "::", - stringify!(data) + stringify!(protocols) ) ); } +#[doc = "Event passed to the user callback."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicAccessBits { - pub data: [u8; 4usize], +pub struct NfcScannerEvent { + #[doc = "< Type of event. Determines how the data must be handled."] + pub type_: NfcScannerEventType, + #[doc = "< Event-specific data. Handled accordingly to the even type."] + pub data: NfcScannerEventData, } #[test] -fn bindgen_test_layout_MfClassicAccessBits() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_NfcScannerEvent() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(NfcScannerEvent)) + ); + assert_eq!( + ::core::mem::align_of::(), 4usize, - concat!("Size of: ", stringify!(MfClassicAccessBits)) + concat!("Alignment of ", stringify!(NfcScannerEvent)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(MfClassicAccessBits)) + unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(NfcScannerEvent), + "::", + stringify!(type_) + ) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, - 0usize, + 4usize, concat!( "Offset of field: ", - stringify!(MfClassicAccessBits), + stringify!(NfcScannerEvent), "::", stringify!(data) ) ); } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct MfClassicNt { - pub data: [u8; 4usize], -} +#[doc = "User callback function signature.\n\n A function with such signature must be provided by the user upon calling nfc_scanner_start().\n\n # Arguments\n\n* `event` (direction in) - occurred event, complete with type and data.\n * `context` (direction in) - pointer to the context data provided in nfc_scanner_start() call."] +pub type NfcScannerCallback = ::core::option::Option< + unsafe extern "C" fn(event: NfcScannerEvent, context: *mut core::ffi::c_void), +>; +extern "C" { + #[doc = "Allocate an NfcScanner instance.\n\n # Arguments\n\n* `nfc` (direction in) - pointer to an Nfc instance.\n # Returns\n\npointer to the allocated NfcScanner instance.\n\n [`nfc.h`]"] + pub fn nfc_scanner_alloc(nfc: *mut Nfc) -> *mut NfcScanner; +} +extern "C" { + #[doc = "Delete an NfcScanner instance.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be deleted."] + pub fn nfc_scanner_free(instance: *mut NfcScanner); +} +extern "C" { + #[doc = "Start an NfcScanner.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be started.\n * `callback` (direction in) - pointer to the callback function (will be called upon a detection event).\n * `context` (direction in) - pointer to the caller-specific context (will be passed to the callback)."] + pub fn nfc_scanner_start( + instance: *mut NfcScanner, + callback: NfcScannerCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Stop an NfcScanner.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be stopped."] + pub fn nfc_scanner_stop(instance: *mut NfcScanner); +} +pub const FelicaError_FelicaErrorNone: FelicaError = 0; +pub const FelicaError_FelicaErrorNotPresent: FelicaError = 1; +pub const FelicaError_FelicaErrorColResFailed: FelicaError = 2; +pub const FelicaError_FelicaErrorBufferOverflow: FelicaError = 3; +pub const FelicaError_FelicaErrorCommunication: FelicaError = 4; +pub const FelicaError_FelicaErrorFieldOff: FelicaError = 5; +pub const FelicaError_FelicaErrorWrongCrc: FelicaError = 6; +pub const FelicaError_FelicaErrorProtocol: FelicaError = 7; +pub const FelicaError_FelicaErrorTimeout: FelicaError = 8; +#[doc = "Type of possible Felica errors"] +pub type FelicaError = core::ffi::c_uchar; +#[doc = "Separate type for card key block. Used in authentication process"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FelicaCardKey { + pub data: [u8; 16usize], +} #[test] -fn bindgen_test_layout_MfClassicNt() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FelicaCardKey() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(MfClassicNt)) + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(FelicaCardKey)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(MfClassicNt)) + concat!("Alignment of ", stringify!(FelicaCardKey)) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicNt), + stringify!(FelicaCardKey), "::", stringify!(data) ) ); } +#[doc = "Felica ID block"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicAt { - pub data: [u8; 4usize], +pub struct FelicaIDm { + pub data: [u8; 8usize], } #[test] -fn bindgen_test_layout_MfClassicAt() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FelicaIDm() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(MfClassicAt)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(FelicaIDm)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(MfClassicAt)) + concat!("Alignment of ", stringify!(FelicaIDm)) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicAt), + stringify!(FelicaIDm), "::", stringify!(data) ) ); } +#[doc = "Felica PMm block"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicNr { - pub data: [u8; 4usize], +pub struct FelicaPMm { + pub data: [u8; 8usize], } #[test] -fn bindgen_test_layout_MfClassicNr() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FelicaPMm() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(MfClassicNr)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(FelicaPMm)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(MfClassicNr)) + concat!("Alignment of ", stringify!(FelicaPMm)) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicNr), + stringify!(FelicaPMm), "::", stringify!(data) ) ); } +#[doc = "Felica block with status flags indicating last operation with it.\n See Felica manual for more details on status codes."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicAr { - pub data: [u8; 4usize], +pub struct FelicaBlock { + #[doc = "< Status flag 1, equals to 0 when success"] + pub SF1: u8, + #[doc = "< Status flag 2, equals to 0 when success"] + pub SF2: u8, + #[doc = "< Block data"] + pub data: [u8; 16usize], } #[test] -fn bindgen_test_layout_MfClassicAr() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FelicaBlock() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!("Size of: ", stringify!(MfClassicAr)) + ::core::mem::size_of::(), + 18usize, + concat!("Size of: ", stringify!(FelicaBlock)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(MfClassicAr)) + concat!("Alignment of ", stringify!(FelicaBlock)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).SF1) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicAr), + stringify!(FelicaBlock), + "::", + stringify!(SF1) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).SF2) as usize - ptr as usize }, + 1usize, + concat!( + "Offset of field: ", + stringify!(FelicaBlock), + "::", + stringify!(SF2) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(FelicaBlock), "::", stringify!(data) ) ); } +#[doc = "Felica filesystem structure"] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicAuthContext { - pub block_num: u8, - pub key: MfClassicKey, - pub key_type: MfClassicKeyType, - pub nt: MfClassicNt, - pub nr: MfClassicNr, - pub ar: MfClassicAr, - pub at: MfClassicAt, +pub struct FelicaFileSystem { + pub spad: [FelicaBlock; 14usize], + pub reg: FelicaBlock, + pub rc: FelicaBlock, + pub mac: FelicaBlock, + pub id: FelicaBlock, + pub d_id: FelicaBlock, + pub ser_c: FelicaBlock, + pub sys_c: FelicaBlock, + pub ckv: FelicaBlock, + pub ck: FelicaBlock, + pub mc: FelicaBlock, + pub wcnt: FelicaBlock, + pub mac_a: FelicaBlock, + pub state: FelicaBlock, + pub crc_check: FelicaBlock, } #[test] -fn bindgen_test_layout_MfClassicAuthContext() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FelicaFileSystem() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(MfClassicAuthContext)) + ::core::mem::size_of::(), + 504usize, + concat!("Size of: ", stringify!(FelicaFileSystem)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 1usize, - concat!("Alignment of ", stringify!(MfClassicAuthContext)) + concat!("Alignment of ", stringify!(FelicaFileSystem)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).block_num) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).spad) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(block_num) + stringify!(spad) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, - 1usize, + unsafe { ::core::ptr::addr_of!((*ptr).reg) as usize - ptr as usize }, + 252usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(key) + stringify!(reg) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_type) as usize - ptr as usize }, - 7usize, + unsafe { ::core::ptr::addr_of!((*ptr).rc) as usize - ptr as usize }, + 270usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(key_type) + stringify!(rc) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).nt) as usize - ptr as usize }, - 8usize, + unsafe { ::core::ptr::addr_of!((*ptr).mac) as usize - ptr as usize }, + 288usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(nt) + stringify!(mac) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).nr) as usize - ptr as usize }, - 12usize, + unsafe { ::core::ptr::addr_of!((*ptr).id) as usize - ptr as usize }, + 306usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(nr) + stringify!(id) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).ar) as usize - ptr as usize }, - 16usize, + unsafe { ::core::ptr::addr_of!((*ptr).d_id) as usize - ptr as usize }, + 324usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(ar) + stringify!(d_id) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).at) as usize - ptr as usize }, - 20usize, + unsafe { ::core::ptr::addr_of!((*ptr).ser_c) as usize - ptr as usize }, + 342usize, concat!( "Offset of field: ", - stringify!(MfClassicAuthContext), + stringify!(FelicaFileSystem), "::", - stringify!(at) + stringify!(ser_c) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).sys_c) as usize - ptr as usize }, + 360usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(sys_c) ) ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ckv) as usize - ptr as usize }, + 378usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(ckv) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ck) as usize - ptr as usize }, + 396usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(ck) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).mc) as usize - ptr as usize }, + 414usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(mc) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).wcnt) as usize - ptr as usize }, + 432usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(wcnt) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).mac_a) as usize - ptr as usize }, + 450usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(mac_a) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 468usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).crc_check) as usize - ptr as usize }, + 486usize, + concat!( + "Offset of field: ", + stringify!(FelicaFileSystem), + "::", + stringify!(crc_check) + ) + ); +} +#[doc = "Union which represents filesystem in junction with plain data dump"] +#[repr(C)] +#[derive(Copy, Clone)] +pub union FelicaFSUnion { + pub fs: FelicaFileSystem, + pub dump: [u8; 504usize], +} +#[test] +fn bindgen_test_layout_FelicaFSUnion() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 504usize, + concat!("Size of: ", stringify!(FelicaFSUnion)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(FelicaFSUnion)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).fs) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(FelicaFSUnion), + "::", + stringify!(fs) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).dump) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(FelicaFSUnion), + "::", + stringify!(dump) + ) + ); +} +#[doc = "Structure used to store Felica data and additional values about reading"] +#[repr(C)] +#[derive(Copy, Clone)] +pub struct FelicaData { + pub idm: FelicaIDm, + pub pmm: FelicaPMm, + pub blocks_total: u8, + pub blocks_read: u8, + pub data: FelicaFSUnion, +} +#[test] +fn bindgen_test_layout_FelicaData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 522usize, + concat!("Size of: ", stringify!(FelicaData)) + ); + assert_eq!( + ::core::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(FelicaData)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).idm) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(FelicaData), + "::", + stringify!(idm) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).pmm) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(FelicaData), + "::", + stringify!(pmm) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).blocks_total) as usize - ptr as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(FelicaData), + "::", + stringify!(blocks_total) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).blocks_read) as usize - ptr as usize }, + 17usize, + concat!( + "Offset of field: ", + stringify!(FelicaData), + "::", + stringify!(blocks_read) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).data) as usize - ptr as usize }, + 18usize, + concat!( + "Offset of field: ", + stringify!(FelicaData), + "::", + stringify!(data) + ) + ); +} +extern "C" { + pub fn felica_alloc() -> *mut FelicaData; +} +extern "C" { + pub fn felica_free(data: *mut FelicaData); +} +extern "C" { + pub fn felica_reset(data: *mut FelicaData); +} +extern "C" { + pub fn felica_copy(data: *mut FelicaData, other: *const FelicaData); +} +extern "C" { + pub fn felica_verify(data: *mut FelicaData, device_type: *const FuriString) -> bool; +} +extern "C" { + pub fn felica_load(data: *mut FelicaData, ff: *mut FlipperFormat, version: u32) -> bool; +} +extern "C" { + pub fn felica_save(data: *const FelicaData, ff: *mut FlipperFormat) -> bool; +} +extern "C" { + pub fn felica_is_equal(data: *const FelicaData, other: *const FelicaData) -> bool; +} +extern "C" { + pub fn felica_get_device_name( + data: *const FelicaData, + name_type: NfcDeviceNameType, + ) -> *const core::ffi::c_char; +} +extern "C" { + pub fn felica_get_uid(data: *const FelicaData, uid_len: *mut usize) -> *const u8; +} +extern "C" { + pub fn felica_set_uid(data: *mut FelicaData, uid: *const u8, uid_len: usize) -> bool; +} +extern "C" { + pub fn felica_get_base_data(data: *const FelicaData) -> *mut FelicaData; +} +extern "C" { + pub fn felica_calculate_session_key( + ctx: *mut mbedtls_des3_context, + ck: *const u8, + rc: *const u8, + out: *mut u8, + ); +} +extern "C" { + pub fn felica_check_mac( + ctx: *mut mbedtls_des3_context, + session_key: *const u8, + rc: *const u8, + blocks: *const u8, + block_count: u8, + data: *mut u8, + ) -> bool; +} +extern "C" { + pub fn felica_calculate_mac_read( + ctx: *mut mbedtls_des3_context, + session_key: *const u8, + rc: *const u8, + blocks: *const u8, + block_count: u8, + data: *const u8, + mac: *mut u8, + ); +} +extern "C" { + pub fn felica_calculate_mac_write( + ctx: *mut mbedtls_des3_context, + session_key: *const u8, + rc: *const u8, + wcnt: *const u8, + data: *const u8, + mac: *mut u8, + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FelicaPoller { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in FeliCa standars. The data\n field will be filled with Felica data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the Felica data structure to be filled.\n # Returns\n\nFelicaErrorNone on success, an error code on failure."] + pub fn felica_poller_activate( + instance: *mut FelicaPoller, + data: *mut FelicaData, + ) -> FelicaError; +} +extern "C" { + pub fn felica_poller_sync_read( + nfc: *mut Nfc, + data: *mut FelicaData, + card_key: *const FelicaCardKey, + ) -> FelicaError; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_3aPoller { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Transmit and receive Iso14443_3a frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] + pub fn iso14443_3a_poller_txrx( + instance: *mut Iso14443_3aPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> Iso14443_3aError; +} +extern "C" { + #[doc = "Transmit and receive Iso14443_3a standard frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] + pub fn iso14443_3a_poller_send_standard_frame( + instance: *mut Iso14443_3aPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> Iso14443_3aError; +} +extern "C" { + #[doc = "Transmit and receive Iso14443_3a frames with custom parity bits in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n Custom parity bits must be set in the tx_buffer. The rx_buffer will contain\n the received data with the parity bits.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] + pub fn iso14443_3a_poller_txrx_custom_parity( + instance: *mut Iso14443_3aPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + fwt: u32, + ) -> Iso14443_3aError; +} +extern "C" { + #[doc = "Checks presence of Iso14443_3a complient card.\n\n Must ONLY be used inside the callback function.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3aErrorNone if card is present, an error code otherwise."] + pub fn iso14443_3a_poller_check_presence(instance: *mut Iso14443_3aPoller) -> Iso14443_3aError; +} +extern "C" { + #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in Iso14443-3a. The iso14443_3a_data\n field will be filled with Iso14443-3a data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `iso14443_3a_data` (direction out) - pointer to the Iso14443_3a data structure to be filled.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] + pub fn iso14443_3a_poller_activate( + instance: *mut Iso14443_3aPoller, + iso14443_3a_data: *mut Iso14443_3aData, + ) -> Iso14443_3aError; +} +extern "C" { + #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_3aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3aErrorNone on success, an error code on failure."] + pub fn iso14443_3a_poller_halt(instance: *mut Iso14443_3aPoller) -> Iso14443_3aError; +} +extern "C" { + pub fn iso14443_3a_poller_sync_read( + nfc: *mut Nfc, + iso14443_3a_data: *mut Iso14443_3aData, + ) -> Iso14443_3aError; +} +pub const Iso14443_3bError_Iso14443_3bErrorNone: Iso14443_3bError = 0; +pub const Iso14443_3bError_Iso14443_3bErrorNotPresent: Iso14443_3bError = 1; +pub const Iso14443_3bError_Iso14443_3bErrorColResFailed: Iso14443_3bError = 2; +pub const Iso14443_3bError_Iso14443_3bErrorBufferOverflow: Iso14443_3bError = 3; +pub const Iso14443_3bError_Iso14443_3bErrorCommunication: Iso14443_3bError = 4; +pub const Iso14443_3bError_Iso14443_3bErrorFieldOff: Iso14443_3bError = 5; +pub const Iso14443_3bError_Iso14443_3bErrorWrongCrc: Iso14443_3bError = 6; +pub const Iso14443_3bError_Iso14443_3bErrorTimeout: Iso14443_3bError = 7; +pub type Iso14443_3bError = core::ffi::c_uchar; +pub const Iso14443_3bBitRate_Iso14443_3bBitRateBoth106Kbit: Iso14443_3bBitRate = 0; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd212Kbit: Iso14443_3bBitRate = 1; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd424Kbit: Iso14443_3bBitRate = 2; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePiccToPcd848Kbit: Iso14443_3bBitRate = 3; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc212Kbit: Iso14443_3bBitRate = 4; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc424Kbit: Iso14443_3bBitRate = 5; +pub const Iso14443_3bBitRate_Iso14443_3bBitRatePcdToPicc848Kbit: Iso14443_3bBitRate = 6; +pub type Iso14443_3bBitRate = core::ffi::c_uchar; +pub const Iso14443_3bFrameOption_Iso14443_3bFrameOptionNad: Iso14443_3bFrameOption = 0; +pub const Iso14443_3bFrameOption_Iso14443_3bFrameOptionCid: Iso14443_3bFrameOption = 1; +pub type Iso14443_3bFrameOption = core::ffi::c_uchar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_3bData { + _unused: [u8; 0], +} +extern "C" { + pub fn iso14443_3b_alloc() -> *mut Iso14443_3bData; +} +extern "C" { + pub fn iso14443_3b_free(data: *mut Iso14443_3bData); +} +extern "C" { + pub fn iso14443_3b_reset(data: *mut Iso14443_3bData); +} +extern "C" { + pub fn iso14443_3b_copy(data: *mut Iso14443_3bData, other: *const Iso14443_3bData); +} +extern "C" { + pub fn iso14443_3b_verify(data: *mut Iso14443_3bData, device_type: *const FuriString) -> bool; +} +extern "C" { + pub fn iso14443_3b_load( + data: *mut Iso14443_3bData, + ff: *mut FlipperFormat, + version: u32, + ) -> bool; +} +extern "C" { + pub fn iso14443_3b_save(data: *const Iso14443_3bData, ff: *mut FlipperFormat) -> bool; +} +extern "C" { + pub fn iso14443_3b_is_equal( + data: *const Iso14443_3bData, + other: *const Iso14443_3bData, + ) -> bool; +} +extern "C" { + pub fn iso14443_3b_get_device_name( + data: *const Iso14443_3bData, + name_type: NfcDeviceNameType, + ) -> *const core::ffi::c_char; +} +extern "C" { + pub fn iso14443_3b_get_uid(data: *const Iso14443_3bData, uid_len: *mut usize) -> *const u8; +} +extern "C" { + pub fn iso14443_3b_set_uid(data: *mut Iso14443_3bData, uid: *const u8, uid_len: usize) -> bool; +} +extern "C" { + pub fn iso14443_3b_get_base_data(data: *const Iso14443_3bData) -> *mut Iso14443_3bData; +} +extern "C" { + pub fn iso14443_3b_supports_iso14443_4(data: *const Iso14443_3bData) -> bool; +} +extern "C" { + pub fn iso14443_3b_supports_bit_rate( + data: *const Iso14443_3bData, + bit_rate: Iso14443_3bBitRate, + ) -> bool; +} +extern "C" { + pub fn iso14443_3b_supports_frame_option( + data: *const Iso14443_3bData, + option: Iso14443_3bFrameOption, + ) -> bool; +} +extern "C" { + pub fn iso14443_3b_get_application_data( + data: *const Iso14443_3bData, + data_size: *mut usize, + ) -> *const u8; +} +extern "C" { + pub fn iso14443_3b_get_frame_size_max(data: *const Iso14443_3bData) -> u16; +} +extern "C" { + pub fn iso14443_3b_get_fwt_fc_max(data: *const Iso14443_3bData) -> u32; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_3bPoller { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Transmit and receive Iso14443_3b frames in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer, with a timeout defined by the fwt parameter.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n * `fwt` (direction in) - frame wait time (response timeout), in carrier cycles.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] + pub fn iso14443_3b_poller_send_frame( + instance: *mut Iso14443_3bPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_3bError; +} +extern "C" { + #[doc = "Perform collision resolution procedure.\n\n Must ONLY be used inside the callback function.\n\n Perfoms the collision resolution procedure as defined in Iso14443-3b. The data\n field will be filled with Iso14443-3b data on success.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the Iso14443_3b data structure to be filled.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] + pub fn iso14443_3b_poller_activate( + instance: *mut Iso14443_3bPoller, + data: *mut Iso14443_3bData, + ) -> Iso14443_3bError; +} +extern "C" { + #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_3bPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_3bErrorNone on success, an error code on failure."] + pub fn iso14443_3b_poller_halt(instance: *mut Iso14443_3bPoller) -> Iso14443_3bError; } #[repr(C)] -#[derive(Copy, Clone)] -pub union MfClassicSectorTrailer { - pub block: MfClassicBlock, - pub __bindgen_anon_1: MfClassicSectorTrailer__bindgen_ty_1, +#[derive(Debug, Copy, Clone)] +pub struct SimpleArray { + _unused: [u8; 0], } +pub type SimpleArrayData = core::ffi::c_void; +pub type SimpleArrayElement = core::ffi::c_void; +pub type SimpleArrayInit = + ::core::option::Option; +pub type SimpleArrayReset = + ::core::option::Option; +pub type SimpleArrayCopy = ::core::option::Option< + unsafe extern "C" fn(elem: *mut SimpleArrayElement, other: *const SimpleArrayElement), +>; +#[doc = "Simple Array configuration structure. Defined per type."] #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicSectorTrailer__bindgen_ty_1 { - pub key_a: MfClassicKey, - pub access_bits: MfClassicAccessBits, - pub key_b: MfClassicKey, +pub struct SimpleArrayConfig { + #[doc = "< Initialisation (in-place constructor) method."] + pub init: SimpleArrayInit, + #[doc = "< Reset (custom destructor) method."] + pub reset: SimpleArrayReset, + #[doc = "< Copy (custom copy-constructor) method."] + pub copy: SimpleArrayCopy, + pub type_size: usize, } #[test] -fn bindgen_test_layout_MfClassicSectorTrailer__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_SimpleArrayConfig() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), + ::core::mem::size_of::(), 16usize, - concat!( - "Size of: ", - stringify!(MfClassicSectorTrailer__bindgen_ty_1) - ) + concat!("Size of: ", stringify!(SimpleArrayConfig)) ); assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!( - "Alignment of ", - stringify!(MfClassicSectorTrailer__bindgen_ty_1) - ) + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(SimpleArrayConfig)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_a) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).init) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicSectorTrailer__bindgen_ty_1), + stringify!(SimpleArrayConfig), "::", - stringify!(key_a) + stringify!(init) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).access_bits) as usize - ptr as usize }, - 6usize, + unsafe { ::core::ptr::addr_of!((*ptr).reset) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(MfClassicSectorTrailer__bindgen_ty_1), + stringify!(SimpleArrayConfig), "::", - stringify!(access_bits) + stringify!(reset) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_b) as usize - ptr as usize }, - 10usize, + unsafe { ::core::ptr::addr_of!((*ptr).copy) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(MfClassicSectorTrailer__bindgen_ty_1), + stringify!(SimpleArrayConfig), "::", - stringify!(key_b) + stringify!(copy) ) ); -} -#[test] -fn bindgen_test_layout_MfClassicSectorTrailer() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(MfClassicSectorTrailer)) - ); - assert_eq!( - ::core::mem::align_of::(), - 1usize, - concat!("Alignment of ", stringify!(MfClassicSectorTrailer)) - ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).block) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).type_size) as usize - ptr as usize }, + 12usize, concat!( "Offset of field: ", - stringify!(MfClassicSectorTrailer), + stringify!(SimpleArrayConfig), "::", - stringify!(block) + stringify!(type_size) ) ); } +extern "C" { + #[doc = "Allocate a SimpleArray instance with the given configuration.\n\n # Arguments\n\n* `[in]` - config Pointer to the type-specific configuration\n # Returns\n\nPointer to the allocated SimpleArray instance"] + pub fn simple_array_alloc(config: *const SimpleArrayConfig) -> *mut SimpleArray; +} +extern "C" { + #[doc = "Free a SimpleArray instance and release its contents.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be freed"] + pub fn simple_array_free(instance: *mut SimpleArray); +} +extern "C" { + #[doc = "Initialise a SimpleArray instance by allocating additional space to contain\n the requested number of elements.\n If init() is specified in the config, then it is called for each element,\n otherwise the data is filled with zeroes.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be init'd\n * `[in]` - count Number of elements to be allocated and init'd"] + pub fn simple_array_init(instance: *mut SimpleArray, count: u32); +} +extern "C" { + #[doc = "Reset a SimpleArray instance and delete all of its elements.\n If reset() is specified in the config, then it is called for each element,\n otherwise the data is simply free()'d.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be reset"] + pub fn simple_array_reset(instance: *mut SimpleArray); +} +extern "C" { + #[doc = "Copy (duplicate) another SimpleArray instance to this one.\n If copy() is specified in the config, then it is called for each element,\n otherwise the data is simply memcpy()'d.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to copy to\n * `[in]` - other Pointer to the SimpleArray instance to copy from"] + pub fn simple_array_copy(instance: *mut SimpleArray, other: *const SimpleArray); +} +extern "C" { + #[doc = "Check if another SimpleArray instance is equal (the same object or holds the\n same data) to this one.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to be compared\n * `[in]` - other Pointer to the SimpleArray instance to be compared\n # Returns\n\nTrue if instances are considered equal, false otherwise"] + pub fn simple_array_is_equal(instance: *const SimpleArray, other: *const SimpleArray) -> bool; +} +extern "C" { + #[doc = "Get the count of elements currently contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to query the count from\n # Returns\n\nCount of elements contained in the instance"] + pub fn simple_array_get_count(instance: *const SimpleArray) -> u32; +} +extern "C" { + #[doc = "Get a pointer to an element contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get an element from\n * `[in]` - index Index of the element in question. MUST be less than total element count\n # Returns\n\nPointer to the element specified by index"] + pub fn simple_array_get(instance: *mut SimpleArray, index: u32) -> *mut SimpleArrayElement; +} +extern "C" { + #[doc = "Get a const pointer to an element contained in a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get an element from\n * `[in]` - index Index of the element in question. MUST be less than total element count\n # Returns\n\nConst pointer to the element specified by index"] + pub fn simple_array_cget(instance: *const SimpleArray, index: u32) + -> *const SimpleArrayElement; +} +extern "C" { + #[doc = "Get a pointer to the internal data of a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get the data of\n # Returns\n\nPointer to the instance's internal data"] + pub fn simple_array_get_data(instance: *mut SimpleArray) -> *mut SimpleArrayData; +} +extern "C" { + #[doc = "Get a constant pointer to the internal data of a SimpleArray instance.\n\n # Arguments\n\n* `[in]` - instance Pointer to the SimpleArray instance to get the data of\n # Returns\n\nConstant pointer to the instance's internal data"] + pub fn simple_array_cget_data(instance: *const SimpleArray) -> *const SimpleArrayData; +} +extern "C" { + pub static simple_array_config_uint8_t: SimpleArrayConfig; +} +pub const Iso14443_4aError_Iso14443_4aErrorNone: Iso14443_4aError = 0; +pub const Iso14443_4aError_Iso14443_4aErrorNotPresent: Iso14443_4aError = 1; +pub const Iso14443_4aError_Iso14443_4aErrorProtocol: Iso14443_4aError = 2; +pub const Iso14443_4aError_Iso14443_4aErrorTimeout: Iso14443_4aError = 3; +pub type Iso14443_4aError = core::ffi::c_uchar; +pub const Iso14443_4aBitRate_Iso14443_4aBitRateBoth106Kbit: Iso14443_4aBitRate = 0; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd212Kbit: Iso14443_4aBitRate = 1; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd424Kbit: Iso14443_4aBitRate = 2; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePiccToPcd848Kbit: Iso14443_4aBitRate = 3; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc212Kbit: Iso14443_4aBitRate = 4; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc424Kbit: Iso14443_4aBitRate = 5; +pub const Iso14443_4aBitRate_Iso14443_4aBitRatePcdToPicc848Kbit: Iso14443_4aBitRate = 6; +pub type Iso14443_4aBitRate = core::ffi::c_uchar; +pub const Iso14443_4aFrameOption_Iso14443_4aFrameOptionNad: Iso14443_4aFrameOption = 0; +pub const Iso14443_4aFrameOption_Iso14443_4aFrameOptionCid: Iso14443_4aFrameOption = 1; +pub type Iso14443_4aFrameOption = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct MfClassicDeviceKeys { - pub key_a_mask: u64, - pub key_a: [MfClassicKey; 40usize], - pub key_b_mask: u64, - pub key_b: [MfClassicKey; 40usize], +pub struct Iso14443_4aAtsData { + pub tl: u8, + pub t0: u8, + pub ta_1: u8, + pub tb_1: u8, + pub tc_1: u8, + pub t1_tk: *mut SimpleArray, } #[test] -fn bindgen_test_layout_MfClassicDeviceKeys() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_Iso14443_4aAtsData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 496usize, - concat!("Size of: ", stringify!(MfClassicDeviceKeys)) + ::core::mem::size_of::(), + 12usize, + concat!("Size of: ", stringify!(Iso14443_4aAtsData)) ); assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(MfClassicDeviceKeys)) + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(Iso14443_4aAtsData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_a_mask) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).tl) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(MfClassicDeviceKeys), - "::", - stringify!(key_a_mask) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_a) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(MfClassicDeviceKeys), - "::", - stringify!(key_a) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_b_mask) as usize - ptr as usize }, - 248usize, - concat!( - "Offset of field: ", - stringify!(MfClassicDeviceKeys), + stringify!(Iso14443_4aAtsData), "::", - stringify!(key_b_mask) + stringify!(tl) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_b) as usize - ptr as usize }, - 256usize, + unsafe { ::core::ptr::addr_of!((*ptr).t0) as usize - ptr as usize }, + 1usize, concat!( "Offset of field: ", - stringify!(MfClassicDeviceKeys), + stringify!(Iso14443_4aAtsData), "::", - stringify!(key_b) + stringify!(t0) ) ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct MfClassicData { - pub iso14443_3a_data: *mut Iso14443_3aData, - pub type_: MfClassicType, - pub block_read_mask: [u32; 8usize], - pub key_a_mask: u64, - pub key_b_mask: u64, - pub block: [MfClassicBlock; 256usize], -} -#[test] -fn bindgen_test_layout_MfClassicData() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4152usize, - concat!("Size of: ", stringify!(MfClassicData)) - ); - assert_eq!( - ::core::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(MfClassicData)) - ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).iso14443_3a_data) as usize - ptr as usize }, - 0usize, + unsafe { ::core::ptr::addr_of!((*ptr).ta_1) as usize - ptr as usize }, + 2usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aAtsData), "::", - stringify!(iso14443_3a_data) + stringify!(ta_1) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).type_) as usize - ptr as usize }, - 4usize, + unsafe { ::core::ptr::addr_of!((*ptr).tb_1) as usize - ptr as usize }, + 3usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aAtsData), "::", - stringify!(type_) + stringify!(tb_1) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).block_read_mask) as usize - ptr as usize }, - 8usize, + unsafe { ::core::ptr::addr_of!((*ptr).tc_1) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aAtsData), "::", - stringify!(block_read_mask) + stringify!(tc_1) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_a_mask) as usize - ptr as usize }, - 40usize, + unsafe { ::core::ptr::addr_of!((*ptr).t1_tk) as usize - ptr as usize }, + 8usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aAtsData), "::", - stringify!(key_a_mask) + stringify!(t1_tk) ) ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_4aData { + pub iso14443_3a_data: *mut Iso14443_3aData, + pub ats_data: Iso14443_4aAtsData, +} +#[test] +fn bindgen_test_layout_Iso14443_4aData() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(Iso14443_4aData)) + ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).key_b_mask) as usize - ptr as usize }, - 48usize, + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(Iso14443_4aData)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).iso14443_3a_data) as usize - ptr as usize }, + 0usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aData), "::", - stringify!(key_b_mask) + stringify!(iso14443_3a_data) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).block) as usize - ptr as usize }, - 56usize, + unsafe { ::core::ptr::addr_of!((*ptr).ats_data) as usize - ptr as usize }, + 4usize, concat!( "Offset of field: ", - stringify!(MfClassicData), + stringify!(Iso14443_4aData), "::", - stringify!(block) + stringify!(ats_data) ) ); } extern "C" { - pub fn mf_classic_alloc() -> *mut MfClassicData; + pub fn iso14443_4a_alloc() -> *mut Iso14443_4aData; } extern "C" { - pub fn mf_classic_free(data: *mut MfClassicData); + pub fn iso14443_4a_free(data: *mut Iso14443_4aData); } extern "C" { - pub fn mf_classic_reset(data: *mut MfClassicData); + pub fn iso14443_4a_reset(data: *mut Iso14443_4aData); } extern "C" { - pub fn mf_classic_copy(data: *mut MfClassicData, other: *const MfClassicData); + pub fn iso14443_4a_copy(data: *mut Iso14443_4aData, other: *const Iso14443_4aData); } extern "C" { - pub fn mf_classic_verify(data: *mut MfClassicData, device_type: *const FuriString) -> bool; + pub fn iso14443_4a_verify(data: *mut Iso14443_4aData, device_type: *const FuriString) -> bool; } extern "C" { - pub fn mf_classic_load(data: *mut MfClassicData, ff: *mut FlipperFormat, version: u32) -> bool; + pub fn iso14443_4a_load( + data: *mut Iso14443_4aData, + ff: *mut FlipperFormat, + version: u32, + ) -> bool; } extern "C" { - pub fn mf_classic_save(data: *const MfClassicData, ff: *mut FlipperFormat) -> bool; + pub fn iso14443_4a_save(data: *const Iso14443_4aData, ff: *mut FlipperFormat) -> bool; } extern "C" { - pub fn mf_classic_is_equal(data: *const MfClassicData, other: *const MfClassicData) -> bool; + pub fn iso14443_4a_is_equal( + data: *const Iso14443_4aData, + other: *const Iso14443_4aData, + ) -> bool; } extern "C" { - pub fn mf_classic_get_device_name( - data: *const MfClassicData, + pub fn iso14443_4a_get_device_name( + data: *const Iso14443_4aData, name_type: NfcDeviceNameType, ) -> *const core::ffi::c_char; } extern "C" { - pub fn mf_classic_get_uid(data: *const MfClassicData, uid_len: *mut usize) -> *const u8; + pub fn iso14443_4a_get_uid(data: *const Iso14443_4aData, uid_len: *mut usize) -> *const u8; } extern "C" { - pub fn mf_classic_set_uid(data: *mut MfClassicData, uid: *const u8, uid_len: usize) -> bool; + pub fn iso14443_4a_set_uid(data: *mut Iso14443_4aData, uid: *const u8, uid_len: usize) -> bool; } extern "C" { - pub fn mf_classic_get_base_data(data: *const MfClassicData) -> *mut Iso14443_3aData; + pub fn iso14443_4a_get_base_data(data: *const Iso14443_4aData) -> *mut Iso14443_3aData; } extern "C" { - pub fn mf_classic_get_total_sectors_num(type_: MfClassicType) -> u8; + pub fn iso14443_4a_get_frame_size_max(data: *const Iso14443_4aData) -> u16; } extern "C" { - pub fn mf_classic_get_total_block_num(type_: MfClassicType) -> u16; + pub fn iso14443_4a_get_fwt_fc_max(data: *const Iso14443_4aData) -> u32; } extern "C" { - pub fn mf_classic_get_first_block_num_of_sector(sector: u8) -> u8; + pub fn iso14443_4a_get_historical_bytes( + data: *const Iso14443_4aData, + count: *mut u32, + ) -> *const u8; } extern "C" { - pub fn mf_classic_get_blocks_num_in_sector(sector: u8) -> u8; + pub fn iso14443_4a_supports_bit_rate( + data: *const Iso14443_4aData, + bit_rate: Iso14443_4aBitRate, + ) -> bool; } extern "C" { - pub fn mf_classic_get_sector_trailer_num_by_sector(sector: u8) -> u8; + pub fn iso14443_4a_supports_frame_option( + data: *const Iso14443_4aData, + option: Iso14443_4aFrameOption, + ) -> bool; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_4aPoller { + _unused: [u8; 0], } extern "C" { - pub fn mf_classic_get_sector_trailer_num_by_block(block: u8) -> u8; + #[doc = "Transmit and receive Iso14443_4a blocks in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer. The fwt parameter is calculated during activation procedure.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_send_block( + instance: *mut Iso14443_4aPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_4aError; } extern "C" { - pub fn mf_classic_get_sector_trailer_by_sector( - data: *const MfClassicData, - sector_num: u8, - ) -> *mut MfClassicSectorTrailer; + #[doc = "Transmit and receive Iso14443_4a chained block in poller mode. Also it\n automatically modifies PCB packet byte with appropriate bits then resets them back\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer. The fwt parameter is calculated during activation procedure.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_send_chain_block( + instance: *mut Iso14443_4aPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_4aError; } extern "C" { - pub fn mf_classic_is_sector_trailer(block: u8) -> bool; + #[doc = "Transmit Iso14443_4a R-block in poller mode. This block never contains\n data, but can contain CID and NAD, therefore in tx_buffer only two bytes can be added.\n The first one will represent CID, the second one will represent NAD.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with R-block repsonse\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `acknowledged` (direction in) - Sets appropriate bit in PCB byte. True - ACK, false - NAK\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_send_receive_ready_block( + instance: *mut Iso14443_4aPoller, + acknowledged: bool, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_4aError; } extern "C" { - pub fn mf_classic_set_sector_trailer_read( - data: *mut MfClassicData, - block_num: u8, - sec_tr: *mut MfClassicSectorTrailer, - ); + #[doc = "Transmit Iso14443_4a S-block in poller mode. S-block used to exchange control\n information between the card and the reader. Two different types of S-blocks\n are defined:\n - Waiting time extension containing a 1 byte long INF field and (deselect = false)\n - DESELECT containing no INF field (deselect = true)\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with R-block repsonse\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `deselect` (direction in) - Sets appropriate bit in PCB byte.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_send_supervisory_block( + instance: *mut Iso14443_4aPoller, + deselect: bool, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_4aError; } extern "C" { - pub fn mf_classic_get_sector_by_block(block: u8) -> u8; + #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_4aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_halt(instance: *mut Iso14443_4aPoller) -> Iso14443_4aError; } extern "C" { - pub fn mf_classic_block_to_value( - block: *const MfClassicBlock, - value: *mut i32, - addr: *mut u8, - ) -> bool; + #[doc = "Read Answer To Select (ATS) from the card.\n\n Must ONLY be used inside the callback function.\n\n Send Request Answer To Select (RATS) command to the card and parse the response.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `data` (direction out) - pointer to the buffer to be filled with ATS data.\n # Returns\n\nIso14443_4aErrorNone on success, an error code on failure."] + pub fn iso14443_4a_poller_read_ats( + instance: *mut Iso14443_4aPoller, + data: *mut Iso14443_4aAtsData, + ) -> Iso14443_4aError; +} +pub const Iso14443_4bError_Iso14443_4bErrorNone: Iso14443_4bError = 0; +pub const Iso14443_4bError_Iso14443_4bErrorNotPresent: Iso14443_4bError = 1; +pub const Iso14443_4bError_Iso14443_4bErrorProtocol: Iso14443_4bError = 2; +pub const Iso14443_4bError_Iso14443_4bErrorTimeout: Iso14443_4bError = 3; +pub type Iso14443_4bError = core::ffi::c_uchar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_4bData { + _unused: [u8; 0], } extern "C" { - pub fn mf_classic_value_to_block(value: i32, addr: u8, block: *mut MfClassicBlock); + pub fn iso14443_4b_alloc() -> *mut Iso14443_4bData; } extern "C" { - pub fn mf_classic_is_key_found( - data: *const MfClassicData, - sector_num: u8, - key_type: MfClassicKeyType, - ) -> bool; + pub fn iso14443_4b_free(data: *mut Iso14443_4bData); } extern "C" { - pub fn mf_classic_set_key_found( - data: *mut MfClassicData, - sector_num: u8, - key_type: MfClassicKeyType, - key: u64, - ); + pub fn iso14443_4b_reset(data: *mut Iso14443_4bData); } extern "C" { - pub fn mf_classic_set_key_not_found( - data: *mut MfClassicData, - sector_num: u8, - key_type: MfClassicKeyType, - ); + pub fn iso14443_4b_copy(data: *mut Iso14443_4bData, other: *const Iso14443_4bData); } extern "C" { - pub fn mf_classic_is_block_read(data: *const MfClassicData, block_num: u8) -> bool; + pub fn iso14443_4b_verify(data: *mut Iso14443_4bData, device_type: *const FuriString) -> bool; } extern "C" { - pub fn mf_classic_set_block_read( - data: *mut MfClassicData, - block_num: u8, - block_data: *mut MfClassicBlock, - ); + pub fn iso14443_4b_load( + data: *mut Iso14443_4bData, + ff: *mut FlipperFormat, + version: u32, + ) -> bool; } extern "C" { - pub fn mf_classic_is_sector_read(data: *const MfClassicData, sector_num: u8) -> bool; + pub fn iso14443_4b_save(data: *const Iso14443_4bData, ff: *mut FlipperFormat) -> bool; } extern "C" { - pub fn mf_classic_get_read_sectors_and_keys( - data: *const MfClassicData, - sectors_read: *mut u8, - keys_found: *mut u8, - ); + pub fn iso14443_4b_is_equal( + data: *const Iso14443_4bData, + other: *const Iso14443_4bData, + ) -> bool; } extern "C" { - pub fn mf_classic_is_card_read(data: *const MfClassicData) -> bool; + pub fn iso14443_4b_get_device_name( + data: *const Iso14443_4bData, + name_type: NfcDeviceNameType, + ) -> *const core::ffi::c_char; } extern "C" { - pub fn mf_classic_is_value_block(sec_tr: *mut MfClassicSectorTrailer, block_num: u8) -> bool; + pub fn iso14443_4b_get_uid(data: *const Iso14443_4bData, uid_len: *mut usize) -> *const u8; } extern "C" { - pub fn mf_classic_is_allowed_access_data_block( - sec_tr: *mut MfClassicSectorTrailer, - block_num: u8, - key_type: MfClassicKeyType, - action: MfClassicAction, - ) -> bool; + pub fn iso14443_4b_set_uid(data: *mut Iso14443_4bData, uid: *const u8, uid_len: usize) -> bool; } extern "C" { - pub fn mf_classic_is_allowed_access( - data: *mut MfClassicData, - block_num: u8, - key_type: MfClassicKeyType, - action: MfClassicAction, - ) -> bool; + pub fn iso14443_4b_get_base_data(data: *const Iso14443_4bData) -> *mut Iso14443_3bData; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Iso14443_4bPoller { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Transmit and receive Iso14443_4b blocks in poller mode.\n\n Must ONLY be used inside the callback function.\n\n The rx_buffer will be filled with any data received as a response to data\n sent from tx_buffer. The fwt parameter is calculated during activation procedure.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `tx_buffer` (direction in) - pointer to the buffer containing the data to be transmitted.\n * `rx_buffer` (direction out) - pointer to the buffer to be filled with received data.\n # Returns\n\nIso14443_4bErrorNone on success, an error code on failure."] + pub fn iso14443_4b_poller_send_block( + instance: *mut Iso14443_4bPoller, + tx_buffer: *const BitBuffer, + rx_buffer: *mut BitBuffer, + ) -> Iso14443_4bError; +} +extern "C" { + #[doc = "Send HALT command to the card.\n\n Must ONLY be used inside the callback function.\n\n Halts card and changes internal Iso14443_4aPoller state to Idle.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n # Returns\n\nIso14443_4bErrorNone on success, an error code on failure."] + pub fn iso14443_4b_poller_halt(instance: *mut Iso14443_4bPoller) -> Iso14443_4bError; } #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -23777,41 +23888,46 @@ pub struct MfClassicPoller { _unused: [u8; 0], } extern "C" { - #[doc = "Collect tag nonce during authentication.\n\n Must ONLY be used inside the callback function.\n\n Starts authentication procedure and collects tag nonce.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `nt` (direction out) - pointer to the MfClassicNt structure to be filled with nonce data.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] + #[doc = "Collect tag nonce during authentication.\n\n Must ONLY be used inside the callback function.\n\n Starts authentication procedure and collects tag nonce.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `nt` (direction out) - pointer to the MfClassicNt structure to be filled with nonce data.\n * `backdoor_auth` (direction in) - flag indicating if backdoor authentication is used.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] pub fn mf_classic_poller_get_nt( instance: *mut MfClassicPoller, block_num: u8, key_type: MfClassicKeyType, nt: *mut MfClassicNt, + backdoor_auth: bool, ) -> MfClassicError; } extern "C" { - #[doc = "Collect tag nonce during nested authentication.\n\n Must ONLY be used inside the callback function.\n\n Starts nested authentication procedure and collects tag nonce.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `nt` (direction out) - pointer to the MfClassicNt structure to be filled with nonce data.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] + #[doc = "Collect tag nonce during nested authentication.\n\n Must ONLY be used inside the callback function.\n\n Starts nested authentication procedure and collects tag nonce.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `nt` (direction out) - pointer to the MfClassicNt structure to be filled with nonce data.\n * `backdoor_auth` (direction in) - flag indicating if backdoor authentication is used.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] pub fn mf_classic_poller_get_nt_nested( instance: *mut MfClassicPoller, block_num: u8, key_type: MfClassicKeyType, nt: *mut MfClassicNt, + backdoor_auth: bool, ) -> MfClassicError; } extern "C" { - #[doc = "Perform authentication.\n\n Must ONLY be used inside the callback function.\n\n Perform authentication as specified in Mf Classic protocol. Initialize crypto state for futher\n communication with the tag.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key` (direction in) - key to be used for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `data` (direction out) - pointer to MfClassicAuthContext structure to be filled with authentication data.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] + #[doc = "Perform authentication.\n\n Must ONLY be used inside the callback function.\n\n Perform authentication as specified in Mf Classic protocol. Initialize crypto state for futher\n communication with the tag.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key` (direction in) - key to be used for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `data` (direction out) - pointer to MfClassicAuthContext structure to be filled with authentication data.\n * `backdoor_auth` (direction in) - flag indicating if backdoor authentication is used.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] pub fn mf_classic_poller_auth( instance: *mut MfClassicPoller, block_num: u8, key: *mut MfClassicKey, key_type: MfClassicKeyType, data: *mut MfClassicAuthContext, + backdoor_auth: bool, ) -> MfClassicError; } extern "C" { - #[doc = "Perform nested authentication.\n\n Must ONLY be used inside the callback function.\n\n Perform nested authentication as specified in Mf Classic protocol.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key` (direction in) - key to be used for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `data` (direction out) - pointer to MfClassicAuthContext structure to be filled with authentication data.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] + #[doc = "Perform nested authentication.\n\n Must ONLY be used inside the callback function.\n\n Perform nested authentication as specified in Mf Classic protocol.\n\n # Arguments\n\n* `instance` (direction in, out) - pointer to the instance to be used in the transaction.\n * `block_num` (direction in) - block number for authentication.\n * `key` (direction in) - key to be used for authentication.\n * `key_type` (direction in) - key type to be used for authentication.\n * `data` (direction out) - pointer to MfClassicAuthContext structure to be filled with authentication data.\n * `backdoor_auth` (direction in) - flag indicating if backdoor authentication is used.\n * `early_ret` (direction in) - return immediately after receiving encrypted nonce.\n # Returns\n\nMfClassicErrorNone on success, an error code on failure."] pub fn mf_classic_poller_auth_nested( instance: *mut MfClassicPoller, block_num: u8, key: *mut MfClassicKey, key_type: MfClassicKeyType, data: *mut MfClassicAuthContext, + backdoor_auth: bool, + early_ret: bool, ) -> MfClassicError; } extern "C" { From 57531a05ff346dcb4f53a2bec706947fabed97e8 Mon Sep 17 00:00:00 2001 From: David Coles Date: Tue, 12 Nov 2024 12:55:40 -0800 Subject: [PATCH 2/2] Fix build broken by API changes `FuriThreadState` now takes a `FuriThread` pointer. --- crates/flipperzero/src/furi/thread.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/flipperzero/src/furi/thread.rs b/crates/flipperzero/src/furi/thread.rs index d4c3494..b143ddb 100644 --- a/crates/flipperzero/src/furi/thread.rs +++ b/crates/flipperzero/src/furi/thread.rs @@ -104,7 +104,11 @@ impl Builder { let callback: sys::FuriThreadCallback = Some(run_thread_body); let context = Box::into_raw(thread_body); - unsafe extern "C" fn run_state_callback(state: sys::FuriThreadState, context: *mut c_void) { + unsafe extern "C" fn run_state_callback( + _thread: *mut sys::FuriThread, + state: sys::FuriThreadState, + context: *mut c_void, + ) { if state == sys::FuriThreadState_FuriThreadStateStopped { // SAFETY: We can drop the `Arc` at the end of this function call, // because: