diff --git a/README.md b/README.md index 32906e93..036aac3b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Rust for Flipper Zero 🐬❤️🦀 [![crates.io](https://img.shields.io/crates/v/flipperzero)](https://crates.io/crates/flipperzero) -[![Flipper Zero API](https://img.shields.io/badge/Flipper%20Zero%20API-14.0-orange)](https://github.com/flipperdevices/flipperzero-firmware/blob/0.77.1/firmware/targets/f7/api_symbols.csv) +[![Flipper Zero API](https://img.shields.io/badge/Flipper%20Zero%20API-20.0-orange)](https://github.com/flipperdevices/flipperzero-firmware/blob/0.80.1/firmware/targets/f7/api_symbols.csv) [![docs.rs](https://img.shields.io/docsrs/flipperzero)](https://docs.rs/flipperzero) [![MIT license](https://img.shields.io/crates/l/flipperzero)](LICENSE) @@ -17,12 +17,13 @@ This means it's not possible to use anything in the [`std`](https://doc.rust-lan ## SDK version -Currently supports SDK 14.0 ([flipperzero-firmware@0.77.1](https://github.com/flipperdevices/flipperzero-firmware/tree/0.77.1)). +Currently supports SDK 20.0 ([flipperzero-firmware@0.80.1](https://github.com/flipperdevices/flipperzero-firmware/tree/0.80.1)). The crate major version number will be updated after a bump in [API version](https://github.com/flipperdevices/flipperzero-firmware/blob/release/firmware/targets/f7/api_symbols.csv) in the Flipper Zero firmware. | Crate version | API version | | ------------- | ----------- | +| 0.8.x | 20.0 | | 0.7.x | 14.0 | | 0.6.x | 11.2 | | 0.5.x | 10.1 | diff --git a/crates/Cargo.toml b/crates/Cargo.toml index a8a4d448..8423c574 100644 --- a/crates/Cargo.toml +++ b/crates/Cargo.toml @@ -8,7 +8,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.7.2" +version = "0.8.0" description = "Rust for Flipper Zero" edition = "2021" rust-version = "1.68.0" @@ -17,9 +17,9 @@ readme = "../README.md" license = "MIT" [workspace.dependencies] -flipperzero-sys = { path = "sys", version = "0.7.0" } -flipperzero-rt = { path = "rt", version = "0.7.0" } -flipperzero-alloc = { path = "alloc", version = "0.7.0" } +flipperzero-sys = { path = "sys", version = "0.8.0" } +flipperzero-rt = { path = "rt", version = "0.8.0" } +flipperzero-alloc = { path = "alloc", version = "0.8.0" } ufmt = "0.2.0" [profile.dev] diff --git a/crates/sys/src/bindings.rs b/crates/sys/src/bindings.rs index 5a4bd8aa..5b3ba41a 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 = 917504; +pub const API_VERSION: u32 = 1310720; pub type wint_t = core::ffi::c_int; pub type _off_t = core::ffi::c_long; pub type _fpos_t = core::ffi::c_long; @@ -2020,6 +2020,10 @@ extern "C" { #[doc = "Set FuriThread name\n\n# Arguments\n\n* `thread` - FuriThread instance\n* `name` - string\n\n"] pub fn furi_thread_set_name(thread: *mut FuriThread, name: *const core::ffi::c_char); } +extern "C" { + #[doc = "Set FuriThread appid Technically, it is like a \"process id\", but it is not a system-wide unique identifier. All threads spawned by the same app will have the same appid.\n\n# Arguments\n\n* `thread` - \n* `appid` - \n\n"] + pub fn furi_thread_set_appid(thread: *mut FuriThread, appid: *const core::ffi::c_char); +} extern "C" { #[doc = "Mark thread as service The service cannot be stopped or removed, and cannot exit from the thread body\n\n# Arguments\n\n* `thread` - \n\n"] pub fn furi_thread_mark_as_service(thread: *mut FuriThread); @@ -2112,12 +2116,19 @@ extern "C" { pub fn furi_thread_flags_wait(flags: u32, options: u32, timeout: u32) -> u32; } extern "C" { + #[doc = "Enumerate threads\n\nReturns:\n\n* uint32_t threads count\n\n# Arguments\n\n* `thread_array` - array of FuriThreadId, where thread ids will be stored\n* `array_items` - array size\n\n"] pub fn furi_thread_enumerate(thread_array: *mut FuriThreadId, array_items: u32) -> u32; } extern "C" { + #[doc = "Get thread name\n\nReturns:\n\n* const char* name or NULL\n\n# Arguments\n\n* `thread_id` - \n\n"] pub fn furi_thread_get_name(thread_id: FuriThreadId) -> *const core::ffi::c_char; } extern "C" { + #[doc = "Get thread appid\n\nReturns:\n\n* const char* appid\n\n# Arguments\n\n* `thread_id` - \n\n"] + pub fn furi_thread_get_appid(thread_id: FuriThreadId) -> *const core::ffi::c_char; +} +extern "C" { + #[doc = "Get thread stack watermark\n\nReturns:\n\n* uint32_t\n\n# Arguments\n\n* `thread_id` - \n\n"] pub fn furi_thread_get_stack_space(thread_id: FuriThreadId) -> u32; } extern "C" { @@ -2343,79 +2354,6 @@ extern "C" { #[doc = "Is timer running\n\nReturns:\n\n* 0: not running, 1: running\n\n# Arguments\n\n* `instance` - The pointer to FuriTimer instance\n\n"] pub fn furi_timer_is_running(instance: *mut FuriTimer) -> u32; } -#[doc = "== ValueMutex ==\nThe most simple concept is ValueMutex. It is wrapper around mutex and value pointer. You can take and give mutex to work with value and read and write value.\n\n"] -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct ValueMutex { - pub value: *mut core::ffi::c_void, - pub size: usize, - pub mutex: *mut FuriMutex, -} -#[test] -fn bindgen_test_layout_ValueMutex() { - 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!(ValueMutex)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(ValueMutex)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).value) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(ValueMutex), - "::", - stringify!(value) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(ValueMutex), - "::", - stringify!(size) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).mutex) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(ValueMutex), - "::", - stringify!(mutex) - ) - ); -} -extern "C" { - #[doc = "Creates ValueMutex.\n\n"] - pub fn init_mutex( - valuemutex: *mut ValueMutex, - value: *mut core::ffi::c_void, - size: usize, - ) -> bool; -} -extern "C" { - #[doc = "Free resources allocated by `init_mutex`. This function doesn't free the memory occupied by `ValueMutex` itself.\n\n"] - pub fn delete_mutex(valuemutex: *mut ValueMutex) -> bool; -} -extern "C" { - #[doc = "Call for work with data stored in mutex.\n\nReturns:\n\n* pointer to data if success, NULL otherwise.\n\n"] - pub fn acquire_mutex(valuemutex: *mut ValueMutex, timeout: u32) -> *mut core::ffi::c_void; -} -extern "C" { - #[doc = "Release mutex after end of work with data. Call `release_mutex` and pass ValueData instance and pointer to data.\n\n"] - pub fn release_mutex(valuemutex: *mut ValueMutex, value: *const core::ffi::c_void) -> bool; -} extern "C" { pub static _ctype_: [core::ffi::c_char; 0usize]; } @@ -4958,6 +4896,12 @@ pub const Align_AlignBottom: Align = 3; pub const Align_AlignCenter: Align = 4; #[doc = "Alignment enumeration\n\n"] pub type Align = core::ffi::c_uchar; +pub const CanvasOrientation_CanvasOrientationHorizontal: CanvasOrientation = 0; +pub const CanvasOrientation_CanvasOrientationHorizontalFlip: CanvasOrientation = 1; +pub const CanvasOrientation_CanvasOrientationVertical: CanvasOrientation = 2; +pub const CanvasOrientation_CanvasOrientationVerticalFlip: CanvasOrientation = 3; +#[doc = "Canvas Orientation\n\n"] +pub type CanvasOrientation = core::ffi::c_uchar; pub const CanvasDirection_CanvasDirectionLeftToRight: CanvasDirection = 0; pub const CanvasDirection_CanvasDirectionTopToBottom: CanvasDirection = 1; pub const CanvasDirection_CanvasDirectionRightToLeft: CanvasDirection = 2; @@ -5481,36 +5425,124 @@ pub const InputType_InputTypeMAX: InputType = 5; pub type InputType = core::ffi::c_uchar; #[doc = "Input Event, dispatches with FuriPubSub\n\n"] #[repr(C)] -#[derive(Debug, Copy, Clone)] +#[derive(Copy, Clone)] pub struct InputEvent { - pub sequence: u32, + pub __bindgen_anon_1: InputEvent__bindgen_ty_1, pub key: InputKey, pub type_: InputType, } +#[repr(C)] +#[derive(Copy, Clone)] +pub union InputEvent__bindgen_ty_1 { + pub sequence: u32, + pub __bindgen_anon_1: InputEvent__bindgen_ty_1__bindgen_ty_1, +} +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct InputEvent__bindgen_ty_1__bindgen_ty_1 { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, +} #[test] -fn bindgen_test_layout_InputEvent() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_InputEvent__bindgen_ty_1__bindgen_ty_1() { + assert_eq!( + ::core::mem::size_of::(), + 4usize, + concat!( + "Size of: ", + stringify!(InputEvent__bindgen_ty_1__bindgen_ty_1) + ) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!( + "Alignment of ", + stringify!(InputEvent__bindgen_ty_1__bindgen_ty_1) + ) + ); +} +impl InputEvent__bindgen_ty_1__bindgen_ty_1 { + #[inline] + pub fn sequence_source(&self) -> u8 { + unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u8) } + } + #[inline] + pub fn set_sequence_source(&mut self, val: u8) { + unsafe { + let val: u8 = ::core::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn sequence_counter(&self) -> u32 { + unsafe { ::core::mem::transmute(self._bitfield_1.get(2usize, 30u8) as u32) } + } + #[inline] + pub fn set_sequence_counter(&mut self, val: u32) { + unsafe { + let val: u32 = ::core::mem::transmute(val); + self._bitfield_1.set(2usize, 30u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + sequence_source: u8, + sequence_counter: u32, + ) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let sequence_source: u8 = unsafe { ::core::mem::transmute(sequence_source) }; + sequence_source as u64 + }); + __bindgen_bitfield_unit.set(2usize, 30u8, { + let sequence_counter: u32 = unsafe { ::core::mem::transmute(sequence_counter) }; + sequence_counter as u64 + }); + __bindgen_bitfield_unit + } +} +#[test] +fn bindgen_test_layout_InputEvent__bindgen_ty_1() { + 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!(InputEvent)) + ::core::mem::size_of::(), + 4usize, + concat!("Size of: ", stringify!(InputEvent__bindgen_ty_1)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(InputEvent)) + concat!("Alignment of ", stringify!(InputEvent__bindgen_ty_1)) ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).sequence) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(InputEvent), + stringify!(InputEvent__bindgen_ty_1), "::", stringify!(sequence) ) ); +} +#[test] +fn bindgen_test_layout_InputEvent() { + 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!(InputEvent)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(InputEvent)) + ); assert_eq!( unsafe { ::core::ptr::addr_of!((*ptr).key) as usize - ptr as usize }, 4usize, @@ -6282,7 +6314,12 @@ pub const GuiLayer_GuiLayerMAX: GuiLayer = 5; pub type GuiLayer = core::ffi::c_uchar; #[doc = "Gui Canvas Commit Callback\n\n"] pub type GuiCanvasCommitCallback = ::core::option::Option< - unsafe extern "C" fn(data: *mut u8, size: usize, context: *mut core::ffi::c_void), + unsafe extern "C" fn( + data: *mut u8, + size: usize, + orientation: CanvasOrientation, + context: *mut core::ffi::c_void, + ), >; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -7202,7 +7239,7 @@ extern "C" { ); } extern "C" { - #[doc = "Add Text Scroll Element\n\n# Arguments\n\n* `widget` - Widget instance\n* `x` - x coordinate\n* `y` - y coordinate\n* `width` - width to fit text\n* `height` - height to fit text\n* `text` - [Direction: In] Formatted text. Default format: align left, Secondary font. The following formats are available:\n * \n * text\"* - sets bold font before until next '\\n' symbol\n * text\"* - sets center horizontal align until the next '\\n' symbol\n * text\"* - sets right horizontal align until the next '\\n' symbol\n\n"] + #[doc = "Add Text Scroll Element\n\n# Arguments\n\n* `widget` - Widget instance\n* `x` - x coordinate\n* `y` - y coordinate\n* `width` - width to fit text\n* `height` - height to fit text\n* `text` - [Direction: In] Formatted text. Default format: align left, Secondary font. The following formats are available:\n * \n * text\"* - sets bold font before until next '\\n' symbol\n * text\\e*\"* - sets monospaced font before until next '\\n' symbol\n * text\"* - sets center horizontal align until the next '\\n' symbol\n * text\"* - sets right horizontal align until the next '\\n' symbol\n\n"] pub fn widget_add_text_scroll_element( widget: *mut Widget, x: u8, @@ -7576,6 +7613,69 @@ extern "C" { #[doc = "Remove any View in ViewStack. If no View to remove found - ignore.\n\n# Arguments\n\n* `view_stack` - instance\n\n"] pub fn view_stack_remove_view(view_stack: *mut ViewStack, view: *mut View); } +pub type Elf32_Addr = u32; +#[doc = "Interface for ELF loader to resolve symbols\n\n"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct ElfApiInterface { + pub api_version_major: u16, + pub api_version_minor: u16, + pub resolver_callback: ::core::option::Option< + unsafe extern "C" fn( + interface: *const ElfApiInterface, + name: *const core::ffi::c_char, + address: *mut Elf32_Addr, + ) -> bool, + >, +} +#[test] +fn bindgen_test_layout_ElfApiInterface() { + 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!(ElfApiInterface)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(ElfApiInterface)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).api_version_major) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(ElfApiInterface), + "::", + stringify!(api_version_major) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).api_version_minor) as usize - ptr as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(ElfApiInterface), + "::", + stringify!(api_version_minor) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).resolver_callback) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(ElfApiInterface), + "::", + stringify!(resolver_callback) + ) + ); +} +extern "C" { + pub static firmware_api_interface: *const ElfApiInterface; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct Loader { @@ -8790,6 +8890,7 @@ pub const FuriHalRtcFlag_FuriHalRtcFlagDebug: FuriHalRtcFlag = 1; pub const FuriHalRtcFlag_FuriHalRtcFlagFactoryReset: FuriHalRtcFlag = 2; pub const FuriHalRtcFlag_FuriHalRtcFlagLock: FuriHalRtcFlag = 4; pub const FuriHalRtcFlag_FuriHalRtcFlagC2Update: FuriHalRtcFlag = 8; +pub const FuriHalRtcFlag_FuriHalRtcFlagHandOrient: FuriHalRtcFlag = 16; pub type FuriHalRtcFlag = core::ffi::c_uchar; #[doc = "Normal boot mode, default value\n\n"] pub const FuriHalRtcBootMode_FuriHalRtcBootModeNormal: FuriHalRtcBootMode = 0; @@ -9175,12 +9276,12 @@ extern "C" { pub fn furi_hal_power_is_otg_enabled() -> bool; } extern "C" { - #[doc = "Get battery charging voltage in V\n\nReturns:\n\n* voltage in V\n\n"] - pub fn furi_hal_power_get_battery_charging_voltage() -> f32; + #[doc = "Get battery charge voltage limit in V\n\nReturns:\n\n* voltage in V\n\n"] + pub fn furi_hal_power_get_battery_charge_voltage_limit() -> f32; } extern "C" { - #[doc = "Set battery charging voltage in V\nInvalid values will be clamped to the nearest valid value.\n\nReturns:\n\n* voltage in V\n\n# Arguments\n\n* `voltage[in]` - voltage in V\n\n"] - pub fn furi_hal_power_set_battery_charging_voltage(voltage: f32); + #[doc = "Set battery charge voltage limit in V\nInvalid values will be clamped downward to the nearest valid value.\n\nReturns:\n\n* voltage in V\n\n# Arguments\n\n* `voltage[in]` - voltage in V\n\n"] + pub fn furi_hal_power_set_battery_charge_voltage_limit(voltage: f32); } extern "C" { #[doc = "Get remaining battery battery capacity in mAh\n\nReturns:\n\n* capacity in mAh\n\n"] @@ -13619,7 +13720,7 @@ pub struct PowerInfo { pub is_charging: bool, pub current_charger: f32, pub current_gauge: f32, - pub voltage_battery_charging: f32, + pub voltage_battery_charge_limit: f32, pub voltage_charger: f32, pub voltage_gauge: f32, pub voltage_vbus: f32, @@ -13685,13 +13786,15 @@ fn bindgen_test_layout_PowerInfo() { ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).voltage_battery_charging) as usize - ptr as usize }, + unsafe { + ::core::ptr::addr_of!((*ptr).voltage_battery_charge_limit) as usize - ptr as usize + }, 12usize, concat!( "Offset of field: ", stringify!(PowerInfo), "::", - stringify!(voltage_battery_charging) + stringify!(voltage_battery_charge_limit) ) ); assert_eq!( @@ -14046,6 +14149,10 @@ extern "C" { #[doc = "Gets the error text from FS_Error\n\nReturns:\n\n* const char* error text\n\n# Arguments\n\n* `error_id` - error id\n\n"] pub fn filesystem_api_error_get_desc(error_id: FS_Error) -> *const core::ffi::c_char; } +extern "C" { + #[doc = "Checks if file info is directory\n\nReturns:\n\n* bool is directory\n\n# Arguments\n\n* `file_info` - file info pointer\n\n"] + pub fn file_info_is_dir(file_info: *const FileInfo) -> bool; +} pub const SDFsType_FST_UNKNOWN: SDFsType = 0; pub const SDFsType_FST_FAT12: SDFsType = 1; pub const SDFsType_FST_FAT16: SDFsType = 2; @@ -14317,6 +14424,10 @@ extern "C" { #[doc = "Check that file exists\n\nReturns:\n\n* true if file exists\n\n# Arguments\n\n* `storage` - \n* `path` - \n\n"] pub fn storage_file_exists(storage: *mut Storage, path: *const core::ffi::c_char) -> bool; } +extern "C" { + #[doc = "Copy data from one opened file to another opened file Size bytes will be copied from current position of source file to current position of destination file\n\nReturns:\n\n* bool success flag\n\n# Arguments\n\n* `source` - source file\n* `destination` - destination file\n* `size` - size of data to copy\n\n"] + pub fn storage_file_copy_to_file(source: *mut File, destination: *mut File, size: u32) -> bool; +} extern "C" { #[doc = "Opens a directory to get objects from it\n\nReturns:\n\n* bool success flag. You need to close the directory even if the open operation failed.\n\n# Arguments\n\n* `app` - pointer to the api\n* `file` - pointer to file object.\n* `path` - path to directory\n\n"] pub fn storage_dir_open(file: *mut File, path: *const core::ffi::c_char) -> bool; @@ -14334,6 +14445,10 @@ extern "C" { name_length: u16, ) -> bool; } +extern "C" { + #[doc = "Check that dir exists\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `storage` - \n* `path` - \n\n"] + pub fn storage_dir_exists(storage: *mut Storage, path: *const core::ffi::c_char) -> bool; +} extern "C" { #[doc = "Retrieves unix timestamp of last access\n\nReturns:\n\n* FS_Error operation result\n\n# Arguments\n\n* `storage` - The storage instance\n* `path` - path to file/directory\n* `timestamp` - the timestamp pointer\n\n"] pub fn storage_common_timestamp( @@ -14392,6 +14507,25 @@ extern "C" { free_space: *mut u64, ) -> FS_Error; } +extern "C" { + #[doc = "Parse aliases in path and replace them with real path Also will create special folders if they are not exist\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `storage` - \n* `path` - \n\n"] + pub fn storage_common_resolve_path_and_ensure_app_directory( + storage: *mut Storage, + path: *mut FuriString, + ); +} +extern "C" { + #[doc = "Move content of one folder to another, with rename of all conflicting files. Source folder will be deleted if the migration is successful.\n\nReturns:\n\n* FS_Error\n\n# Arguments\n\n* `storage` - \n* `source` - \n* `dest` - \n\n"] + pub fn storage_common_migrate( + storage: *mut Storage, + source: *const core::ffi::c_char, + dest: *const core::ffi::c_char, + ) -> FS_Error; +} +extern "C" { + #[doc = "Check that file or dir exists\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `storage` - \n* `path` - \n\n"] + pub fn storage_common_exists(storage: *mut Storage, path: *const core::ffi::c_char) -> bool; +} extern "C" { #[doc = "Retrieves the error text from the error id\n\nReturns:\n\n* const char* error text\n\n# Arguments\n\n* `error_id` - error id\n\n"] pub fn storage_error_get_desc(error_id: FS_Error) -> *const core::ffi::c_char; @@ -15690,94 +15824,47 @@ extern "C" { extern "C" { pub fn LL_SetSystemCoreClock(HCLKFrequency: u32); } -pub type Elf32_Addr = u32; -#[repr(C)] +extern "C" { + #[doc = "Resolver for API entries using a pre-sorted table with hashes\n\nReturns:\n\n* true if the table contains a function\n\n# Arguments\n\n* `interface` - pointer to HashtableApiInterface\n* `name` - function name\n* `address` - output for function address\n\n"] + pub fn elf_resolve_from_hashtable( + interface: *const ElfApiInterface, + name: *const core::ffi::c_char, + address: *mut Elf32_Addr, + ) -> bool; +} +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub struct FlipperApplicationManifestBase { + pub manifest_magic: u32, + pub manifest_version: u32, + pub api_version: FlipperApplicationManifestBase__bindgen_ty_1, + pub hardware_target_id: u16, +} +#[repr(C, packed)] +#[derive(Copy, Clone)] +pub union FlipperApplicationManifestBase__bindgen_ty_1 { + pub __bindgen_anon_1: FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1, + pub version: u32, +} +#[repr(C, packed)] #[derive(Debug, Copy, Clone)] -pub struct ElfApiInterface { - pub api_version_major: u16, - pub api_version_minor: u16, - pub resolver_callback: ::core::option::Option< - unsafe extern "C" fn(name: *const core::ffi::c_char, address: *mut Elf32_Addr) -> bool, - >, +pub struct FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1 { + pub minor: u16, + pub major: u16, } #[test] -fn bindgen_test_layout_ElfApiInterface() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1() { + const UNINIT: ::core::mem::MaybeUninit< + FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1, + > = ::core::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::core::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(ElfApiInterface)) - ); - assert_eq!( - ::core::mem::align_of::(), + ::core::mem::size_of::(), 4usize, - concat!("Alignment of ", stringify!(ElfApiInterface)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).api_version_major) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(ElfApiInterface), - "::", - stringify!(api_version_major) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).api_version_minor) as usize - ptr as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(ElfApiInterface), - "::", - stringify!(api_version_minor) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).resolver_callback) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(ElfApiInterface), - "::", - stringify!(resolver_callback) - ) - ); -} -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub struct FlipperApplicationManifestBase { - pub manifest_magic: u32, - pub manifest_version: u32, - pub api_version: FlipperApplicationManifestBase__bindgen_ty_1, - pub hardware_target_id: u16, -} -#[repr(C, packed)] -#[derive(Copy, Clone)] -pub union FlipperApplicationManifestBase__bindgen_ty_1 { - pub __bindgen_anon_1: FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1, - pub version: u32, -} -#[repr(C, packed)] -#[derive(Debug, Copy, Clone)] -pub struct FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1 { - pub minor: u16, - pub major: u16, -} -#[test] -fn bindgen_test_layout_FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1() { - const UNINIT: ::core::mem::MaybeUninit< - FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1, - > = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 4usize, - concat!( - "Size of: ", - stringify!(FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1) - ) + concat!( + "Size of: ", + stringify!(FlipperApplicationManifestBase__bindgen_ty_1__bindgen_ty_1) + ) ); assert_eq!( ::core::mem::align_of::(), @@ -16024,6 +16111,12 @@ pub const FlipperApplicationLoadStatus_FlipperApplicationLoadStatusNoFreeMemory: pub const FlipperApplicationLoadStatus_FlipperApplicationLoadStatusMissingImports: FlipperApplicationLoadStatus = 3; pub type FlipperApplicationLoadStatus = core::ffi::c_uchar; +extern "C" { + #[doc = "Get text description of preload status\n\nReturns:\n\n* String pointer to description\n\n# Arguments\n\n* `status` - Status code\n\n"] + pub fn flipper_application_preload_status_to_string( + status: FlipperApplicationPreloadStatus, + ) -> *const core::ffi::c_char; +} extern "C" { #[doc = "Get text description of load status\n\nReturns:\n\n* String pointer to description\n\n# Arguments\n\n* `status` - Status code\n\n"] pub fn flipper_application_load_status_to_string( @@ -16079,6 +16172,150 @@ extern "C" { args: *mut core::ffi::c_void, ) -> *mut FuriThread; } +extern "C" { + #[doc = "Check if application is a plugin (not a runnable standalone app)\n\nReturns:\n\n* true if application is a plugin, false otherwise\n\n# Arguments\n\n* `app` - Application pointer\n\n"] + pub fn flipper_application_is_plugin(app: *mut FlipperApplication) -> bool; +} +#[doc = "An object that describes a plugin - must be returned by plugin's entry point\n\n"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct FlipperAppPluginDescriptor { + pub appid: *const core::ffi::c_char, + pub ep_api_version: u32, + pub entry_point: *const core::ffi::c_void, +} +#[test] +fn bindgen_test_layout_FlipperAppPluginDescriptor() { + 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!(FlipperAppPluginDescriptor)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(FlipperAppPluginDescriptor)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).appid) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(FlipperAppPluginDescriptor), + "::", + stringify!(appid) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).ep_api_version) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(FlipperAppPluginDescriptor), + "::", + stringify!(ep_api_version) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).entry_point) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(FlipperAppPluginDescriptor), + "::", + stringify!(entry_point) + ) + ); +} +extern "C" { + #[doc = "Get plugin descriptor for preloaded plugin\n\nReturns:\n\n* Pointer to plugin descriptor\n\n# Arguments\n\n* `app` - Application pointer\n\n"] + pub fn flipper_application_plugin_get_descriptor( + app: *mut FlipperApplication, + ) -> *const FlipperAppPluginDescriptor; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct CompositeApiResolver { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Allocate composite API resolver\n\nReturns:\n\n* CompositeApiResolver* instance\n\n"] + pub fn composite_api_resolver_alloc() -> *mut CompositeApiResolver; +} +extern "C" { + #[doc = "Free composite API resolver\n\n# Arguments\n\n* `resolver` - Instance\n\n"] + pub fn composite_api_resolver_free(resolver: *mut CompositeApiResolver); +} +extern "C" { + #[doc = "Add API resolver to composite resolver\n\n# Arguments\n\n* `resolver` - Instance\n* `interface` - API resolver\n\n"] + pub fn composite_api_resolver_add( + resolver: *mut CompositeApiResolver, + interface: *const ElfApiInterface, + ); +} +extern "C" { + #[doc = "Get API interface from composite resolver\n\nReturns:\n\n* API interface\n\n# Arguments\n\n* `resolver` - Instance\n\n"] + pub fn composite_api_resolver_get( + resolver: *mut CompositeApiResolver, + ) -> *const ElfApiInterface; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct PluginManager { + _unused: [u8; 0], +} +pub const PluginManagerError_PluginManagerErrorNone: PluginManagerError = 0; +pub const PluginManagerError_PluginManagerErrorLoaderError: PluginManagerError = 1; +pub const PluginManagerError_PluginManagerErrorApplicationIdMismatch: PluginManagerError = 2; +pub const PluginManagerError_PluginManagerErrorAPIVersionMismatch: PluginManagerError = 3; +pub type PluginManagerError = core::ffi::c_uchar; +extern "C" { + #[doc = "Allocates new PluginManager\n\nReturns:\n\n* new PluginManager instance\n\n# Arguments\n\n* `application_id` - Application ID filter - only plugins with matching ID will be loaded\n* `api_version` - Application API version filter - only plugins with matching API version\n* `api_interface` - Application API interface - used to resolve plugins' API imports If plugin uses private application's API, use CompoundApiInterface\n\n"] + pub fn plugin_manager_alloc( + application_id: *const core::ffi::c_char, + api_version: u32, + api_interface: *const ElfApiInterface, + ) -> *mut PluginManager; +} +extern "C" { + #[doc = "Frees PluginManager\n\n# Arguments\n\n* `manager` - PluginManager instance\n\n"] + pub fn plugin_manager_free(manager: *mut PluginManager); +} +extern "C" { + #[doc = "Loads single plugin by full path\n\nReturns:\n\n* Error code\n\n# Arguments\n\n* `manager` - PluginManager instance\n* `path` - Path to plugin\n\n"] + pub fn plugin_manager_load_single( + manager: *mut PluginManager, + path: *const core::ffi::c_char, + ) -> PluginManagerError; +} +extern "C" { + #[doc = "Loads all plugins from specified directory\n\nReturns:\n\n* Error code\n\n# Arguments\n\n* `manager` - PluginManager instance\n* `path` - Path to directory\n\n"] + pub fn plugin_manager_load_all( + manager: *mut PluginManager, + path: *const core::ffi::c_char, + ) -> PluginManagerError; +} +extern "C" { + #[doc = "Returns number of loaded plugins\n\nReturns:\n\n* Number of loaded plugins\n\n# Arguments\n\n* `manager` - PluginManager instance\n\n"] + pub fn plugin_manager_get_count(manager: *mut PluginManager) -> u32; +} +extern "C" { + #[doc = "Returns plugin descriptor by index\n\nReturns:\n\n* Plugin descriptor\n\n# Arguments\n\n* `manager` - PluginManager instance\n* `index` - Plugin index\n\n"] + pub fn plugin_manager_get( + manager: *mut PluginManager, + index: u32, + ) -> *const FlipperAppPluginDescriptor; +} +extern "C" { + #[doc = "Returns plugin entry point by index\n\nReturns:\n\n* Plugin entry point\n\n# Arguments\n\n* `manager` - PluginManager instance\n* `index` - Plugin index\n\n"] + pub fn plugin_manager_get_ep( + manager: *mut PluginManager, + index: u32, + ) -> *const core::ffi::c_void; +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct FlipperFormat { @@ -16104,7 +16341,7 @@ extern "C" { ) -> bool; } extern "C" { - #[doc = "Open existing file, buffered mode. Use only if FlipperFormat allocated as a file.\n\nReturns:\n\n* True on success\n\n# Arguments\n\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `path` - File path\n\n"] + #[doc = "Open existing file, buffered mode. Use only if FlipperFormat allocated as a buffered file.\n\nReturns:\n\n* True on success\n\n# Arguments\n\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `path` - File path\n\n"] pub fn flipper_format_buffered_file_open_existing( flipper_format: *mut FlipperFormat, path: *const core::ffi::c_char, @@ -16124,6 +16361,13 @@ extern "C" { path: *const core::ffi::c_char, ) -> bool; } +extern "C" { + #[doc = "Open file. Creates a new file, or deletes the contents of the file if it already exists, buffered mode. Use only if FlipperFormat allocated as a buffered file.\n\nReturns:\n\n* True on success\n\n# Arguments\n\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `path` - File path\n\n"] + pub fn flipper_format_buffered_file_open_always( + flipper_format: *mut FlipperFormat, + path: *const core::ffi::c_char, + ) -> bool; +} extern "C" { #[doc = "Open file. Creates a new file, fails if file already exists. Use only if FlipperFormat allocated as a file.\n\nReturns:\n\n* True on success\n\n# Arguments\n\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `path` - File path\n\n"] pub fn flipper_format_file_open_new( @@ -16682,142 +16926,421 @@ extern "C" { #[doc = "Returns the underlying stream instance. Use only if you know what you are doing.\n\nReturns:\n\n* Stream*\n\n# Arguments\n\n* `flipper_format` - \n\n"] pub fn flipper_format_get_raw_stream(flipper_format: *mut FlipperFormat) -> *mut Stream; } +pub type iButtonProtocolId = i32; #[repr(C)] #[derive(Debug, Copy, Clone)] -pub struct InfraredDecoderHandler { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct InfraredEncoderHandler { - _unused: [u8; 0], -} -pub const InfraredProtocol_InfraredProtocolUnknown: InfraredProtocol = -1; -pub const InfraredProtocol_InfraredProtocolNEC: InfraredProtocol = 0; -pub const InfraredProtocol_InfraredProtocolNECext: InfraredProtocol = 1; -pub const InfraredProtocol_InfraredProtocolNEC42: InfraredProtocol = 2; -pub const InfraredProtocol_InfraredProtocolNEC42ext: InfraredProtocol = 3; -pub const InfraredProtocol_InfraredProtocolSamsung32: InfraredProtocol = 4; -pub const InfraredProtocol_InfraredProtocolRC6: InfraredProtocol = 5; -pub const InfraredProtocol_InfraredProtocolRC5: InfraredProtocol = 6; -pub const InfraredProtocol_InfraredProtocolRC5X: InfraredProtocol = 7; -pub const InfraredProtocol_InfraredProtocolSIRC: InfraredProtocol = 8; -pub const InfraredProtocol_InfraredProtocolSIRC15: InfraredProtocol = 9; -pub const InfraredProtocol_InfraredProtocolSIRC20: InfraredProtocol = 10; -pub const InfraredProtocol_InfraredProtocolKaseikyo: InfraredProtocol = 11; -pub const InfraredProtocol_InfraredProtocolMAX: InfraredProtocol = 12; -pub type InfraredProtocol = core::ffi::c_schar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct InfraredMessage { - pub protocol: InfraredProtocol, - pub address: u32, - pub command: u32, - pub repeat: bool, +pub struct iButtonEditableData { + pub ptr: *mut u8, + pub size: usize, } #[test] -fn bindgen_test_layout_InfraredMessage() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_iButtonEditableData() { + 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!(InfraredMessage)) + ::core::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(iButtonEditableData)) ); assert_eq!( - ::core::mem::align_of::(), + ::core::mem::align_of::(), 4usize, - concat!("Alignment of ", stringify!(InfraredMessage)) + concat!("Alignment of ", stringify!(iButtonEditableData)) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).ptr) as usize - ptr as usize }, 0usize, concat!( "Offset of field: ", - stringify!(InfraredMessage), + stringify!(iButtonEditableData), "::", - stringify!(protocol) + stringify!(ptr) ) ); assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, + unsafe { ::core::ptr::addr_of!((*ptr).size) as usize - ptr as usize }, 4usize, concat!( "Offset of field: ", - stringify!(InfraredMessage), - "::", - stringify!(address) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).command) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(InfraredMessage), - "::", - stringify!(command) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).repeat) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(InfraredMessage), + stringify!(iButtonEditableData), "::", - stringify!(repeat) + stringify!(size) ) ); } -pub const InfraredStatus_InfraredStatusError: InfraredStatus = 0; -pub const InfraredStatus_InfraredStatusOk: InfraredStatus = 1; -pub const InfraredStatus_InfraredStatusDone: InfraredStatus = 2; -pub const InfraredStatus_InfraredStatusReady: InfraredStatus = 3; -pub type InfraredStatus = core::ffi::c_uchar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct iButtonKey { + _unused: [u8; 0], +} extern "C" { - #[doc = "Initialize decoder.\n\nReturns:\n\n* returns pointer to INFRARED decoder handler if success, otherwise - error.\n\n"] - pub fn infrared_alloc_decoder() -> *mut InfraredDecoderHandler; + #[doc = "Allocate a key object\n\nReturns:\n\n* pointer to the key object\n\n# Arguments\n\n* `[in]` - data_size maximum data size held by the key\n\n"] + pub fn ibutton_key_alloc(data_size: usize) -> *mut iButtonKey; } extern "C" { - #[doc = "Provide to decoder next timing.\n\nReturns:\n\n* if message is ready, returns pointer to decoded message, returns NULL. Note: ownership of returned ptr belongs to handler. So pointer is valid up to next infrared_free_decoder(), infrared_reset_decoder(), infrared_decode(), infrared_check_decoder_ready() calls.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n* `level` - [Direction: In] - high(true) or low(false) level of input signal to analyze. it should alternate every call, otherwise it is an error case, and decoder resets its state and start decoding from the start.\n* `duration` - [Direction: In] - duration of steady high/low input signal.\n\n"] - pub fn infrared_decode( - handler: *mut InfraredDecoderHandler, - level: bool, - duration: u32, - ) -> *const InfraredMessage; + #[doc = "Destroy the key object, free resources\n\n# Arguments\n\n* `[in]` - key pointer to the key object\n\n"] + pub fn ibutton_key_free(key: *mut iButtonKey); } extern "C" { - #[doc = "Check whether decoder is ready. Functionality is quite similar to infrared_decode(), but with no timing providing. Some protocols (e.g. Sony SIRC) has variable payload length, which means we can't recognize end of message right after receiving last bit. That's why application should call to infrared_check_decoder_ready() after some timeout to retrieve decoded message, if so.\n\nReturns:\n\n* if message is ready, returns pointer to decoded message, returns NULL. Note: ownership of returned ptr belongs to handler. So pointer is valid up to next infrared_free_decoder(), infrared_reset_decoder(), infrared_decode(), infrared_check_decoder_ready() calls.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] - pub fn infrared_check_decoder_ready( - handler: *mut InfraredDecoderHandler, - ) -> *const InfraredMessage; + #[doc = "Get the protocol id held by the key\n\nReturns:\n\n* protocol id held by the key\n\n# Arguments\n\n* `[in]` - key pointer to the key object\n\n"] + pub fn ibutton_key_get_protocol_id(key: *const iButtonKey) -> iButtonProtocolId; } extern "C" { - #[doc = "Deinitialize decoder and free allocated memory.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] - pub fn infrared_free_decoder(handler: *mut InfraredDecoderHandler); + #[doc = "Set the protocol id held by the key\n\n# Arguments\n\n* `[in]` - key pointer to the key object\n* `[in]` - protocol_id new protocol id\n\n"] + pub fn ibutton_key_set_protocol_id(key: *mut iButtonKey, protocol_id: iButtonProtocolId); } extern "C" { - #[doc = "Reset INFRARED decoder.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] - pub fn infrared_reset_decoder(handler: *mut InfraredDecoderHandler); + #[doc = "Reset the protocol id and data held by the key\n\n# Arguments\n\n* `[in]` - key pointer to the key object\n\n"] + pub fn ibutton_key_reset(key: *mut iButtonKey); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct iButtonProtocols { + _unused: [u8; 0], } extern "C" { - #[doc = "Get protocol name by protocol enum.\n\nReturns:\n\n* string to protocol name.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] - pub fn infrared_get_protocol_name(protocol: InfraredProtocol) -> *const core::ffi::c_char; + #[doc = "Allocate an iButtonProtocols object\n\nReturns:\n\n* pointer to an iButtonProtocols object\n\n"] + pub fn ibutton_protocols_alloc() -> *mut iButtonProtocols; } extern "C" { - #[doc = "Get protocol enum by protocol name.\n\nReturns:\n\n* protocol identifier.\n\n# Arguments\n\n* `protocol_name` - [Direction: In] - string to protocol name.\n\n"] - pub fn infrared_get_protocol_by_name( - protocol_name: *const core::ffi::c_char, - ) -> InfraredProtocol; + #[doc = "Destroy an iButtonProtocols object, free resources\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n\n"] + pub fn ibutton_protocols_free(protocols: *mut iButtonProtocols); } extern "C" { - #[doc = "Get address length by protocol enum.\n\nReturns:\n\n* length of address in bits.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] - pub fn infrared_get_protocol_address_length(protocol: InfraredProtocol) -> u8; + #[doc = "Get the total number of available protocols\n\n"] + pub fn ibutton_protocols_get_protocol_count() -> u32; } extern "C" { - #[doc = "Get command length by protocol enum.\n\nReturns:\n\n* length of command in bits.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] - pub fn infrared_get_protocol_command_length(protocol: InfraredProtocol) -> u8; + #[doc = "Get maximum data size out of all protocols available\n\nReturns:\n\n* maximum data size in bytes\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n\n"] + pub fn ibutton_protocols_get_max_data_size(protocols: *mut iButtonProtocols) -> usize; +} +extern "C" { + #[doc = "Get the protocol id based on its name\n\nReturns:\n\n* protocol id on success on iButtonProtocolIdInvalid on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - name pointer to a string containing the name\n\n"] + pub fn ibutton_protocols_get_id_by_name( + protocols: *mut iButtonProtocols, + name: *const core::ffi::c_char, + ) -> iButtonProtocolId; +} +extern "C" { + #[doc = "Get the manufacturer name based on the protocol id\n\nReturns:\n\n* pointer to a statically allocated string with manufacturer name\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - id id of the protocol in question\n\n"] + pub fn ibutton_protocols_get_manufacturer( + protocols: *mut iButtonProtocols, + id: iButtonProtocolId, + ) -> *const core::ffi::c_char; +} +extern "C" { + #[doc = "Get the protocol name based on the protocol id\n\nReturns:\n\n* pointer to a statically allocated string with protocol name\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - id id of the protocol in question\n\n"] + pub fn ibutton_protocols_get_name( + protocols: *mut iButtonProtocols, + id: iButtonProtocolId, + ) -> *const core::ffi::c_char; +} +extern "C" { + #[doc = "Get protocol features bitmask by protocol id\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - id id of the protocol in question\n\n"] + pub fn ibutton_protocols_get_features( + protocols: *mut iButtonProtocols, + id: iButtonProtocolId, + ) -> u32; +} +extern "C" { + #[doc = "Read a physical device (a key or an emulator)\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[out]` - key pointer to the key to read into (must be allocated before)\n\n"] + pub fn ibutton_protocols_read(protocols: *mut iButtonProtocols, key: *mut iButtonKey) -> bool; +} +extern "C" { + #[doc = "Write the key to a blank\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be written\n\n"] + pub fn ibutton_protocols_write_blank( + protocols: *mut iButtonProtocols, + key: *mut iButtonKey, + ) -> bool; +} +extern "C" { + #[doc = "Write the key to another one of the same type\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be written\n\n"] + pub fn ibutton_protocols_write_copy( + protocols: *mut iButtonProtocols, + key: *mut iButtonKey, + ) -> bool; +} +extern "C" { + #[doc = "Start emulating the key\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be emulated\n\n"] + pub fn ibutton_protocols_emulate_start(protocols: *mut iButtonProtocols, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Stop emulating the key\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be emulated\n\n"] + pub fn ibutton_protocols_emulate_stop(protocols: *mut iButtonProtocols, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Save the key data to a file.\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be saved\n* `[in]` - file_name full absolute path to the file name\n\n"] + pub fn ibutton_protocols_save( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + file_name: *const core::ffi::c_char, + ) -> bool; +} +extern "C" { + #[doc = "Load the key from a file.\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[out]` - key pointer to the key to load into (must be allocated before)\n* `[in]` - file_name full absolute path to the file name\n\n"] + pub fn ibutton_protocols_load( + protocols: *mut iButtonProtocols, + key: *mut iButtonKey, + file_name: *const core::ffi::c_char, + ) -> bool; +} +extern "C" { + #[doc = "Format a string containing device full data\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be rendered\n* `[out]` - result pointer to the FuriString instance (must be initialized)\n\n"] + pub fn ibutton_protocols_render_data( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + result: *mut FuriString, + ); +} +extern "C" { + #[doc = "Format a string containing device brief data\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be rendered\n* `[out]` - result pointer to the FuriString instance (must be initialized)\n\n"] + pub fn ibutton_protocols_render_brief_data( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + result: *mut FuriString, + ); +} +extern "C" { + #[doc = "Format a string containing error message (for invalid keys)\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be rendered\n* `[out]` - result pointer to the FuriString instance (must be initialized)\n\n"] + pub fn ibutton_protocols_render_error( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + result: *mut FuriString, + ); +} +extern "C" { + #[doc = "Check whether the key data is valid\n\nReturns:\n\n* true if data is valid, false otherwise\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be checked\n\n"] + pub fn ibutton_protocols_is_valid( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + ) -> bool; +} +extern "C" { + #[doc = "Get a pointer to the key's editable data (for in-place editing)\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in]` - key pointer to the key to be checked\n* `[out]` - editable pointer to a structure to contain the editable data\n\n"] + pub fn ibutton_protocols_get_editable_data( + protocols: *mut iButtonProtocols, + key: *const iButtonKey, + editable: *mut iButtonEditableData, + ); +} +extern "C" { + #[doc = "Make all necessary internal adjustments after editing the key\n\n# Arguments\n\n* `[in]` - protocols pointer to an iButtonProtocols object\n* `[in,out]` - key pointer to the key to be adjusted\n\n"] + pub fn ibutton_protocols_apply_edits(protocols: *mut iButtonProtocols, key: *const iButtonKey); +} +pub const iButtonWorkerWriteResult_iButtonWorkerWriteOK: iButtonWorkerWriteResult = 0; +pub const iButtonWorkerWriteResult_iButtonWorkerWriteSameKey: iButtonWorkerWriteResult = 1; +pub const iButtonWorkerWriteResult_iButtonWorkerWriteNoDetect: iButtonWorkerWriteResult = 2; +pub const iButtonWorkerWriteResult_iButtonWorkerWriteCannotWrite: iButtonWorkerWriteResult = 3; +pub type iButtonWorkerWriteResult = core::ffi::c_uchar; +pub type iButtonWorkerReadCallback = + ::core::option::Option; +pub type iButtonWorkerWriteCallback = ::core::option::Option< + unsafe extern "C" fn(context: *mut core::ffi::c_void, result: iButtonWorkerWriteResult), +>; +pub type iButtonWorkerEmulateCallback = + ::core::option::Option; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct iButtonWorker { + _unused: [u8; 0], +} +extern "C" { + #[doc = "Allocate ibutton worker\n\nReturns:\n\n* iButtonWorker*\n\n"] + pub fn ibutton_worker_alloc(protocols: *mut iButtonProtocols) -> *mut iButtonWorker; +} +extern "C" { + #[doc = "Free ibutton worker\n\n# Arguments\n\n* `worker` - \n\n"] + pub fn ibutton_worker_free(worker: *mut iButtonWorker); +} +extern "C" { + #[doc = "Start ibutton worker thread\n\n# Arguments\n\n* `worker` - \n\n"] + pub fn ibutton_worker_start_thread(worker: *mut iButtonWorker); +} +extern "C" { + #[doc = "Stop ibutton worker thread\n\n# Arguments\n\n* `worker` - \n\n"] + pub fn ibutton_worker_stop_thread(worker: *mut iButtonWorker); +} +extern "C" { + #[doc = "Set \"read success\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] + pub fn ibutton_worker_read_set_callback( + worker: *mut iButtonWorker, + callback: iButtonWorkerReadCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Start read mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] + pub fn ibutton_worker_read_start(worker: *mut iButtonWorker, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Set \"write event\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] + pub fn ibutton_worker_write_set_callback( + worker: *mut iButtonWorker, + callback: iButtonWorkerWriteCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Start write blank mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] + pub fn ibutton_worker_write_blank_start(worker: *mut iButtonWorker, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Start write copy mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] + pub fn ibutton_worker_write_copy_start(worker: *mut iButtonWorker, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Set \"emulate success\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] + pub fn ibutton_worker_emulate_set_callback( + worker: *mut iButtonWorker, + callback: iButtonWorkerEmulateCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Start emulate mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] + pub fn ibutton_worker_emulate_start(worker: *mut iButtonWorker, key: *mut iButtonKey); +} +extern "C" { + #[doc = "Stop all modes\n\n# Arguments\n\n* `worker` - \n\n"] + pub fn ibutton_worker_stop(worker: *mut iButtonWorker); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct InfraredDecoderHandler { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct InfraredEncoderHandler { + _unused: [u8; 0], +} +pub const InfraredProtocol_InfraredProtocolUnknown: InfraredProtocol = -1; +pub const InfraredProtocol_InfraredProtocolNEC: InfraredProtocol = 0; +pub const InfraredProtocol_InfraredProtocolNECext: InfraredProtocol = 1; +pub const InfraredProtocol_InfraredProtocolNEC42: InfraredProtocol = 2; +pub const InfraredProtocol_InfraredProtocolNEC42ext: InfraredProtocol = 3; +pub const InfraredProtocol_InfraredProtocolSamsung32: InfraredProtocol = 4; +pub const InfraredProtocol_InfraredProtocolRC6: InfraredProtocol = 5; +pub const InfraredProtocol_InfraredProtocolRC5: InfraredProtocol = 6; +pub const InfraredProtocol_InfraredProtocolRC5X: InfraredProtocol = 7; +pub const InfraredProtocol_InfraredProtocolSIRC: InfraredProtocol = 8; +pub const InfraredProtocol_InfraredProtocolSIRC15: InfraredProtocol = 9; +pub const InfraredProtocol_InfraredProtocolSIRC20: InfraredProtocol = 10; +pub const InfraredProtocol_InfraredProtocolKaseikyo: InfraredProtocol = 11; +pub const InfraredProtocol_InfraredProtocolMAX: InfraredProtocol = 12; +pub type InfraredProtocol = core::ffi::c_schar; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct InfraredMessage { + pub protocol: InfraredProtocol, + pub address: u32, + pub command: u32, + pub repeat: bool, +} +#[test] +fn bindgen_test_layout_InfraredMessage() { + 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!(InfraredMessage)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(InfraredMessage)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).protocol) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(InfraredMessage), + "::", + stringify!(protocol) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).address) as usize - ptr as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(InfraredMessage), + "::", + stringify!(address) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).command) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(InfraredMessage), + "::", + stringify!(command) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).repeat) as usize - ptr as usize }, + 12usize, + concat!( + "Offset of field: ", + stringify!(InfraredMessage), + "::", + stringify!(repeat) + ) + ); +} +pub const InfraredStatus_InfraredStatusError: InfraredStatus = 0; +pub const InfraredStatus_InfraredStatusOk: InfraredStatus = 1; +pub const InfraredStatus_InfraredStatusDone: InfraredStatus = 2; +pub const InfraredStatus_InfraredStatusReady: InfraredStatus = 3; +pub type InfraredStatus = core::ffi::c_uchar; +extern "C" { + #[doc = "Initialize decoder.\n\nReturns:\n\n* returns pointer to INFRARED decoder handler if success, otherwise - error.\n\n"] + pub fn infrared_alloc_decoder() -> *mut InfraredDecoderHandler; +} +extern "C" { + #[doc = "Provide to decoder next timing.\n\nReturns:\n\n* if message is ready, returns pointer to decoded message, returns NULL. Note: ownership of returned ptr belongs to handler. So pointer is valid up to next infrared_free_decoder(), infrared_reset_decoder(), infrared_decode(), infrared_check_decoder_ready() calls.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n* `level` - [Direction: In] - high(true) or low(false) level of input signal to analyze. it should alternate every call, otherwise it is an error case, and decoder resets its state and start decoding from the start.\n* `duration` - [Direction: In] - duration of steady high/low input signal.\n\n"] + pub fn infrared_decode( + handler: *mut InfraredDecoderHandler, + level: bool, + duration: u32, + ) -> *const InfraredMessage; +} +extern "C" { + #[doc = "Check whether decoder is ready. Functionality is quite similar to infrared_decode(), but with no timing providing. Some protocols (e.g. Sony SIRC) has variable payload length, which means we can't recognize end of message right after receiving last bit. That's why application should call to infrared_check_decoder_ready() after some timeout to retrieve decoded message, if so.\n\nReturns:\n\n* if message is ready, returns pointer to decoded message, returns NULL. Note: ownership of returned ptr belongs to handler. So pointer is valid up to next infrared_free_decoder(), infrared_reset_decoder(), infrared_decode(), infrared_check_decoder_ready() calls.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] + pub fn infrared_check_decoder_ready( + handler: *mut InfraredDecoderHandler, + ) -> *const InfraredMessage; +} +extern "C" { + #[doc = "Deinitialize decoder and free allocated memory.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] + pub fn infrared_free_decoder(handler: *mut InfraredDecoderHandler); +} +extern "C" { + #[doc = "Reset INFRARED decoder.\n\n# Arguments\n\n* `handler` - [Direction: In] - handler to INFRARED decoders. Should be acquired with \\c infrared_alloc_decoder().\n\n"] + pub fn infrared_reset_decoder(handler: *mut InfraredDecoderHandler); +} +extern "C" { + #[doc = "Get protocol name by protocol enum.\n\nReturns:\n\n* string to protocol name.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] + pub fn infrared_get_protocol_name(protocol: InfraredProtocol) -> *const core::ffi::c_char; +} +extern "C" { + #[doc = "Get protocol enum by protocol name.\n\nReturns:\n\n* protocol identifier.\n\n# Arguments\n\n* `protocol_name` - [Direction: In] - string to protocol name.\n\n"] + pub fn infrared_get_protocol_by_name( + protocol_name: *const core::ffi::c_char, + ) -> InfraredProtocol; +} +extern "C" { + #[doc = "Get address length by protocol enum.\n\nReturns:\n\n* length of address in bits.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] + pub fn infrared_get_protocol_address_length(protocol: InfraredProtocol) -> u8; +} +extern "C" { + #[doc = "Get command length by protocol enum.\n\nReturns:\n\n* length of command in bits.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] + pub fn infrared_get_protocol_command_length(protocol: InfraredProtocol) -> u8; } extern "C" { #[doc = "Checks whether protocol valid.\n\nReturns:\n\n* true if protocol is valid, false otherwise.\n\n# Arguments\n\n* `protocol` - [Direction: In] - protocol identifier.\n\n"] @@ -19897,201 +20420,13 @@ extern "C" { context: *mut core::ffi::c_void, ); } -pub const iButtonKeyType_iButtonKeyDS1990: iButtonKeyType = 0; -pub const iButtonKeyType_iButtonKeyCyfral: iButtonKeyType = 1; -pub const iButtonKeyType_iButtonKeyMetakom: iButtonKeyType = 2; -pub type iButtonKeyType = core::ffi::c_uchar; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct iButtonKey { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Allocate key\n\nReturns:\n\n* iButtonKey*\n\n"] - pub fn ibutton_key_alloc() -> *mut iButtonKey; -} -extern "C" { - #[doc = "Free key\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_free(key: *mut iButtonKey); -} -extern "C" { - #[doc = "Copy key\n\n# Arguments\n\n* `to` - \n* `from` - \n\n"] - pub fn ibutton_key_set(to: *mut iButtonKey, from: *const iButtonKey); -} -extern "C" { - #[doc = "Set key data\n\n# Arguments\n\n* `key` - \n* `data` - \n* `data_count` - \n\n"] - pub fn ibutton_key_set_data(key: *mut iButtonKey, data: *mut u8, data_count: u8); -} -extern "C" { - #[doc = "Clear key data\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_clear_data(key: *mut iButtonKey); -} -extern "C" { - #[doc = "Get pointer to key data\n\nReturns:\n\n* const uint8_t*\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_get_data_p(key: *mut iButtonKey) -> *const u8; -} -extern "C" { - #[doc = "Get key data size\n\nReturns:\n\n* uint8_t\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_get_data_size(key: *mut iButtonKey) -> u8; -} -extern "C" { - #[doc = "Set key type\n\n# Arguments\n\n* `key` - \n* `key_type` - \n\n"] - pub fn ibutton_key_set_type(key: *mut iButtonKey, key_type: iButtonKeyType); -} -extern "C" { - #[doc = "Get key type\n\nReturns:\n\n* iButtonKeyType\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_get_type(key: *mut iButtonKey) -> iButtonKeyType; -} -extern "C" { - #[doc = "Get type string from key type\n\nReturns:\n\n* const char*\n\n# Arguments\n\n* `key_type` - \n\n"] - pub fn ibutton_key_get_string_by_type(key_type: iButtonKeyType) -> *const core::ffi::c_char; -} -extern "C" { - #[doc = "Get key type from string\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `type_string` - \n* `key_type` - \n\n"] - pub fn ibutton_key_get_type_by_string( - type_string: *const core::ffi::c_char, - key_type: *mut iButtonKeyType, - ) -> bool; -} -extern "C" { - #[doc = "Get key data size from type\n\nReturns:\n\n* uint8_t\n\n# Arguments\n\n* `key_type` - \n\n"] - pub fn ibutton_key_get_size_by_type(key_type: iButtonKeyType) -> u8; -} -extern "C" { - #[doc = "Get max key size\n\nReturns:\n\n* uint8_t\n\n"] - pub fn ibutton_key_get_max_size() -> u8; -} -extern "C" { - #[doc = "Check if CRC for onewire key is valid\n\nReturns:\n\n* true\n* false\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_dallas_crc_is_valid(key: *mut iButtonKey) -> bool; -} -extern "C" { - #[doc = "Check if onewire key is a DS1990 key\n\nReturns:\n\n* true\n* false\n\n# Arguments\n\n* `key` - \n\n"] - pub fn ibutton_key_dallas_is_1990_key(key: *mut iButtonKey) -> bool; -} -pub const iButtonWorkerWriteResult_iButtonWorkerWriteOK: iButtonWorkerWriteResult = 0; -pub const iButtonWorkerWriteResult_iButtonWorkerWriteSameKey: iButtonWorkerWriteResult = 1; -pub const iButtonWorkerWriteResult_iButtonWorkerWriteNoDetect: iButtonWorkerWriteResult = 2; -pub const iButtonWorkerWriteResult_iButtonWorkerWriteCannotWrite: iButtonWorkerWriteResult = 3; -pub type iButtonWorkerWriteResult = core::ffi::c_uchar; -pub type iButtonWorkerReadCallback = - ::core::option::Option; -pub type iButtonWorkerWriteCallback = ::core::option::Option< - unsafe extern "C" fn(context: *mut core::ffi::c_void, result: iButtonWorkerWriteResult), ->; -pub type iButtonWorkerEmulateCallback = - ::core::option::Option; -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct iButtonWorker { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Allocate ibutton worker\n\nReturns:\n\n* iButtonWorker*\n\n"] - pub fn ibutton_worker_alloc() -> *mut iButtonWorker; -} -extern "C" { - #[doc = "Free ibutton worker\n\n# Arguments\n\n* `worker` - \n\n"] - pub fn ibutton_worker_free(worker: *mut iButtonWorker); -} -extern "C" { - #[doc = "Start ibutton worker thread\n\n# Arguments\n\n* `worker` - \n\n"] - pub fn ibutton_worker_start_thread(worker: *mut iButtonWorker); -} -extern "C" { - #[doc = "Stop ibutton worker thread\n\n# Arguments\n\n* `worker` - \n\n"] - pub fn ibutton_worker_stop_thread(worker: *mut iButtonWorker); -} -extern "C" { - #[doc = "Set \"read success\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] - pub fn ibutton_worker_read_set_callback( - worker: *mut iButtonWorker, - callback: iButtonWorkerReadCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Start read mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] - pub fn ibutton_worker_read_start(worker: *mut iButtonWorker, key: *mut iButtonKey); -} -extern "C" { - #[doc = "Set \"write event\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] - pub fn ibutton_worker_write_set_callback( - worker: *mut iButtonWorker, - callback: iButtonWorkerWriteCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Start write mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] - pub fn ibutton_worker_write_start(worker: *mut iButtonWorker, key: *mut iButtonKey); -} -extern "C" { - #[doc = "Set \"emulate success\" callback\n\n# Arguments\n\n* `worker` - \n* `callback` - \n* `context` - \n\n"] - pub fn ibutton_worker_emulate_set_callback( - worker: *mut iButtonWorker, - callback: iButtonWorkerEmulateCallback, - context: *mut core::ffi::c_void, - ); -} -extern "C" { - #[doc = "Start emulate mode\n\n# Arguments\n\n* `worker` - \n* `key` - \n\n"] - pub fn ibutton_worker_emulate_start(worker: *mut iButtonWorker, key: *mut iButtonKey); -} -extern "C" { - #[doc = "Stop all modes\n\n# Arguments\n\n* `worker` - \n\n"] - pub fn ibutton_worker_stop(worker: *mut iButtonWorker); -} extern "C" { pub fn maxim_crc8(data: *const u8, data_size: u8, crc_init: u8) -> u8; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct OneWireSlave { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct OneWireDevice { - _unused: [u8; 0], -} -extern "C" { - #[doc = "Allocate onewire device with ID\n\nReturns:\n\n* OneWireDevice*\n\n# Arguments\n\n* `id_1` - \n* `id_2` - \n* `id_3` - \n* `id_4` - \n* `id_5` - \n* `id_6` - \n* `id_7` - \n* `id_8` - \n\n"] - pub fn onewire_device_alloc( - id_1: u8, - id_2: u8, - id_3: u8, - id_4: u8, - id_5: u8, - id_6: u8, - id_7: u8, - id_8: u8, - ) -> *mut OneWireDevice; -} -extern "C" { - #[doc = "Deallocate onewire device\n\n# Arguments\n\n* `device` - \n\n"] - pub fn onewire_device_free(device: *mut OneWireDevice); -} -extern "C" { - #[doc = "Send ID report, called from onewire slave\n\n# Arguments\n\n* `device` - \n\n"] - pub fn onewire_device_send_id(device: *mut OneWireDevice); -} -extern "C" { - #[doc = "Attach device to onewire slave bus\n\n# Arguments\n\n* `device` - \n* `bus` - \n\n"] - pub fn onewire_device_attach(device: *mut OneWireDevice, bus: *mut OneWireSlave); -} -extern "C" { - #[doc = "Attach device from onewire slave bus\n\n# Arguments\n\n* `device` - \n\n"] - pub fn onewire_device_detach(device: *mut OneWireDevice); -} -extern "C" { - #[doc = "Get pointer to device id array\n\nReturns:\n\n* uint8_t*\n\n# Arguments\n\n* `device` - \n\n"] - pub fn onewire_device_get_id_p(device: *mut OneWireDevice) -> *mut u8; -} #[doc = "Search for alarmed device\n\n"] -pub const OneWireHostSearchMode_CONDITIONAL_SEARCH: OneWireHostSearchMode = 0; -#[doc = "Search all devices\n\n"] -pub const OneWireHostSearchMode_NORMAL_SEARCH: OneWireHostSearchMode = 1; +pub const OneWireHostSearchMode_OneWireHostSearchModeConditional: OneWireHostSearchMode = 0; +#[doc = "Search for all devices\n\n"] +pub const OneWireHostSearchMode_OneWireHostSearchModeNormal: OneWireHostSearchMode = 1; pub type OneWireHostSearchMode = core::ffi::c_uchar; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -20099,93 +20434,136 @@ pub struct OneWireHost { _unused: [u8; 0], } extern "C" { - #[doc = "Allocate onewire host bus\n\nReturns:\n\n* OneWireHost*\n\n# Arguments\n\n* `pin` - \n\n"] + #[doc = "Allocate OneWireHost instance\n\nReturns:\n\n* pointer to OneWireHost instance\n\n# Arguments\n\n* `[in]` - gpio_pin connection pin\n\n"] pub fn onewire_host_alloc(gpio_pin: *const GpioPin) -> *mut OneWireHost; } extern "C" { - #[doc = "Deallocate onewire host bus\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Destroy OneWireHost instance, free resources\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_free(host: *mut OneWireHost); } extern "C" { - #[doc = "Reset bus\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Reset the 1-Wire bus\n\nReturns:\n\n* true if presence was detected, false otherwise\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_reset(host: *mut OneWireHost) -> bool; } extern "C" { - #[doc = "Read one bit\n\nReturns:\n\n* bool\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Read one bit\n\nReturns:\n\n* received bit value\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_read_bit(host: *mut OneWireHost) -> bool; } extern "C" { - #[doc = "Read one byte\n\nReturns:\n\n* uint8_t\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Read one byte\n\nReturns:\n\n* received byte value\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_read(host: *mut OneWireHost) -> u8; } extern "C" { - #[doc = "Read many bytes\n\n# Arguments\n\n* `host` - \n* `buffer` - \n* `count` - \n\n"] + #[doc = "Read one or more bytes\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `[out]` - buffer received data buffer\n* `[in]` - count number of bytes to read\n\n"] pub fn onewire_host_read_bytes(host: *mut OneWireHost, buffer: *mut u8, count: u16); } extern "C" { - #[doc = "Write one bit\n\n# Arguments\n\n* `host` - \n* `value` - \n\n"] + #[doc = "Write one bit\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `value` - bit value to write\n\n"] pub fn onewire_host_write_bit(host: *mut OneWireHost, value: bool); } extern "C" { - #[doc = "Write one byte\n\n# Arguments\n\n* `host` - \n* `value` - \n\n"] + #[doc = "Write one byte\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `value` - byte value to write\n\n"] pub fn onewire_host_write(host: *mut OneWireHost, value: u8); } extern "C" { - #[doc = "Skip ROM command\n\n# Arguments\n\n* `host` - \n\n"] - pub fn onewire_host_skip(host: *mut OneWireHost); + #[doc = "Write one or more bytes\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `[in]` - buffer pointer to the data to write\n* `[in]` - count size of the data to write\n\n"] + pub fn onewire_host_write_bytes(host: *mut OneWireHost, buffer: *const u8, count: u16); } extern "C" { - #[doc = "Start working with the bus\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Start working with the bus\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_start(host: *mut OneWireHost); } extern "C" { - #[doc = "Stop working with the bus\n\n# Arguments\n\n* `host` - \n\n"] + #[doc = "Stop working with the bus\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_stop(host: *mut OneWireHost); } extern "C" { - #[doc = "# Arguments\n\n* `host` - \n\n"] + #[doc = "Reset previous search results\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n\n"] pub fn onewire_host_reset_search(host: *mut OneWireHost); } extern "C" { - #[doc = "# Arguments\n\n* `host` - \n* `family_code` - \n\n"] + #[doc = "Set the family code to search for\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `[in]` - family_code device family code\n\n"] pub fn onewire_host_target_search(host: *mut OneWireHost, family_code: u8); } extern "C" { - #[doc = "Returns:\n\n* uint8_t\n\n# Arguments\n\n* `host` - \n* `newAddr` - \n* `mode` - \n\n"] + #[doc = "Search for devices on the 1-Wire bus\n\nReturns:\n\n* true on success, false otherwise\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `[out]` - new_addr pointer to the buffer to contain the unique ROM of the found device\n* `[in]` - mode search mode\n\n"] pub fn onewire_host_search( host: *mut OneWireHost, new_addr: *mut u8, mode: OneWireHostSearchMode, - ) -> u8; + ) -> bool; } +extern "C" { + #[doc = "Enable overdrive mode\n\n# Arguments\n\n* `[in]` - host pointer to OneWireHost instance\n* `[in]` - set true to turn overdrive on, false to turn it off\n\n"] + pub fn onewire_host_set_overdrive(host: *mut OneWireHost, set: bool); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct OneWireSlave { + _unused: [u8; 0], +} +pub type OneWireSlaveResetCallback = ::core::option::Option< + unsafe extern "C" fn(is_short: bool, context: *mut core::ffi::c_void) -> bool, +>; +pub type OneWireSlaveCommandCallback = ::core::option::Option< + unsafe extern "C" fn(command: u8, context: *mut core::ffi::c_void) -> bool, +>; pub type OneWireSlaveResultCallback = ::core::option::Option; extern "C" { - #[doc = "Allocate onewire slave\n\nReturns:\n\n* OneWireSlave*\n\n# Arguments\n\n* `gpio_pin` - \n\n"] + #[doc = "Allocate OneWireSlave instance\n\nReturns:\n\n* pointer to OneWireSlave instance\n\n# Arguments\n\n* `[in]` - gpio_pin connection pin\n\n"] pub fn onewire_slave_alloc(gpio_pin: *const GpioPin) -> *mut OneWireSlave; } extern "C" { - #[doc = "Free onewire slave\n\n# Arguments\n\n* `bus` - \n\n"] + #[doc = "Destroy OneWireSlave instance, free resources\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n\n"] pub fn onewire_slave_free(bus: *mut OneWireSlave); } extern "C" { - #[doc = "Start working with the bus\n\n# Arguments\n\n* `bus` - \n\n"] + #[doc = "Start working with the bus\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n\n"] pub fn onewire_slave_start(bus: *mut OneWireSlave); } extern "C" { - #[doc = "Stop working with the bus\n\n# Arguments\n\n* `bus` - \n\n"] + #[doc = "Stop working with the bus\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n\n"] pub fn onewire_slave_stop(bus: *mut OneWireSlave); } extern "C" { - #[doc = "Attach device for emulation\n\n# Arguments\n\n* `bus` - \n* `device` - \n\n"] - pub fn onewire_slave_attach(bus: *mut OneWireSlave, device: *mut OneWireDevice); + #[doc = "Receive one bit\n\nReturns:\n\n* received bit value\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n\n"] + pub fn onewire_slave_receive_bit(bus: *mut OneWireSlave) -> bool; } extern "C" { - #[doc = "Detach device from bus\n\n# Arguments\n\n* `bus` - \n\n"] - pub fn onewire_slave_detach(bus: *mut OneWireSlave); + #[doc = "Send one bit\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - value bit value to send\n\n"] + pub fn onewire_slave_send_bit(bus: *mut OneWireSlave, value: bool) -> bool; } extern "C" { - #[doc = "Set a callback to report emulation success\n\n# Arguments\n\n* `bus` - \n* `result_cb` - \n* `context` - \n\n"] + #[doc = "Send one or more bytes of data\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - data pointer to the data to send\n* `[in]` - data_size size of the data to send\n\n"] + pub fn onewire_slave_send(bus: *mut OneWireSlave, data: *const u8, data_size: usize) -> bool; +} +extern "C" { + #[doc = "Receive one or more bytes of data\n\nReturns:\n\n* true on success, false on failure\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[out]` - data pointer to the receive buffer\n* `[in]` - data_size number of bytes to receive\n\n"] + pub fn onewire_slave_receive(bus: *mut OneWireSlave, data: *mut u8, data_size: usize) -> bool; +} +extern "C" { + #[doc = "Enable overdrive mode\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - set true to turn overdrive on, false to turn it off\n\n"] + pub fn onewire_slave_set_overdrive(bus: *mut OneWireSlave, set: bool); +} +extern "C" { + #[doc = "Set a callback function to be called on each reset. The return value of the callback determines whether the emulated device supports the short reset (passed as the is_short parameter). In most applications, it should also call onewire_slave_set_overdrive() to set the appropriate speed mode.\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - callback pointer to a callback function\n* `[in]` - context additional parameter to be passed to the callback\n\n"] + pub fn onewire_slave_set_reset_callback( + bus: *mut OneWireSlave, + callback: OneWireSlaveResetCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Set a callback function to be called on each command. The return value of the callback determines whether further operation is possible. As a rule of thumb, return true unless a critical error happened.\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - callback pointer to a callback function\n* `[in]` - context additional parameter to be passed to the callback\n\n"] + pub fn onewire_slave_set_command_callback( + bus: *mut OneWireSlave, + callback: OneWireSlaveCommandCallback, + context: *mut core::ffi::c_void, + ); +} +extern "C" { + #[doc = "Set a callback to report emulation success\n\n# Arguments\n\n* `[in]` - bus pointer to OneWireSlave instance\n* `[in]` - result_cb pointer to a callback function\n* `[in]` - context additional parameter to be passed to the callback\n\n"] pub fn onewire_slave_set_result_callback( bus: *mut OneWireSlave, result_cb: OneWireSlaveResultCallback, @@ -20500,6 +20878,37 @@ fn bindgen_test_layout_SubGhzRadioPreset() { ) ); } +pub const SubGhzProtocolStatus_SubGhzProtocolStatusOk: SubGhzProtocolStatus = 0; +#[doc = "General unclassified error\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusError: SubGhzProtocolStatus = -1; +#[doc = "Missing or invalid file header\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserHeader: SubGhzProtocolStatus = -2; +#[doc = "Missing `Frequency`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserFrequency: SubGhzProtocolStatus = -3; +#[doc = "Missing `Preset`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserPreset: SubGhzProtocolStatus = -4; +#[doc = "Missing `Custom_preset_module`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserCustomPreset: SubGhzProtocolStatus = + -5; +#[doc = "Missing `Protocol` name\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserProtocolName: SubGhzProtocolStatus = + -6; +#[doc = "Missing `Bit`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserBitCount: SubGhzProtocolStatus = -7; +#[doc = "Missing `Key`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserKey: SubGhzProtocolStatus = -8; +#[doc = "Missing `Te`\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserTe: SubGhzProtocolStatus = -9; +#[doc = "Missing some other mandatory keys\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorParserOthers: SubGhzProtocolStatus = -10; +#[doc = "Invalid bit count value\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorValueBitCount: SubGhzProtocolStatus = -11; +#[doc = "Payload encoder failure\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusErrorEncoderGetUpload: SubGhzProtocolStatus = + -12; +#[doc = "Prevents enum down-size compiler optimization.\n\n"] +pub const SubGhzProtocolStatus_SubGhzProtocolStatusReserved: SubGhzProtocolStatus = 2147483647; +pub type SubGhzProtocolStatus = core::ffi::c_int; pub type SubGhzAlloc = ::core::option::Option< unsafe extern "C" fn(environment: *mut SubGhzEnvironment) -> *mut core::ffi::c_void, >; @@ -20509,13 +20918,13 @@ pub type SubGhzSerialize = ::core::option::Option< context: *mut core::ffi::c_void, flipper_format: *mut FlipperFormat, preset: *mut SubGhzRadioPreset, - ) -> bool, + ) -> SubGhzProtocolStatus, >; pub type SubGhzDeserialize = ::core::option::Option< unsafe extern "C" fn( context: *mut core::ffi::c_void, flipper_format: *mut FlipperFormat, - ) -> bool, + ) -> SubGhzProtocolStatus, >; pub type SubGhzDecoderFeed = ::core::option::Option< unsafe extern "C" fn(decoder: *mut core::ffi::c_void, level: bool, duration: u32), @@ -20900,19 +21309,27 @@ extern "C" { ); } extern "C" { - #[doc = "Serialize data SubGhzBlockGeneric.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzBlockGeneric instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `preset` - The modulation on which the signal was received, SubGhzRadioPreset\n\n"] + #[doc = "Serialize data SubGhzBlockGeneric.\n\nReturns:\n\n* Status Error\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzBlockGeneric instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `preset` - The modulation on which the signal was received, SubGhzRadioPreset\n\n"] pub fn subghz_block_generic_serialize( instance: *mut SubGhzBlockGeneric, flipper_format: *mut FlipperFormat, preset: *mut SubGhzRadioPreset, - ) -> bool; + ) -> SubGhzProtocolStatus; } extern "C" { - #[doc = "Deserialize data SubGhzBlockGeneric.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzBlockGeneric instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] + #[doc = "Deserialize data SubGhzBlockGeneric.\n\nReturns:\n\n* Status Error\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzBlockGeneric instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] pub fn subghz_block_generic_deserialize( instance: *mut SubGhzBlockGeneric, flipper_format: *mut FlipperFormat, - ) -> bool; + ) -> SubGhzProtocolStatus; +} +extern "C" { + #[doc = "Deserialize data SubGhzBlockGeneric.\n\nReturns:\n\n* Status Error\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzBlockGeneric instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `count_bit` - Count bit protocol\n\n"] + pub fn subghz_block_generic_deserialize_check_count_bit( + instance: *mut SubGhzBlockGeneric, + flipper_format: *mut FlipperFormat, + count_bit: u16, + ) -> SubGhzProtocolStatus; } extern "C" { #[doc = "Flip the data bitwise\n\nReturns:\n\n* Reverse data\n\n# Arguments\n\n* `key` - In data\n* `bit_count` - number of data bits\n\n"] @@ -21083,12 +21500,19 @@ extern "C" { ) -> bool; } extern "C" { - #[doc = "Serialize data SubGhzProtocolDecoderBase.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `decoder_base` - Pointer to a SubGhzProtocolDecoderBase instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `preset` - The modulation on which the signal was received, SubGhzRadioPreset\n\n"] + #[doc = "Serialize data SubGhzProtocolDecoderBase.\n\nReturns:\n\n* Status Error\n\n# Arguments\n\n* `decoder_base` - Pointer to a SubGhzProtocolDecoderBase instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n* `preset` - The modulation on which the signal was received, SubGhzRadioPreset\n\n"] pub fn subghz_protocol_decoder_base_serialize( decoder_base: *mut SubGhzProtocolDecoderBase, flipper_format: *mut FlipperFormat, preset: *mut SubGhzRadioPreset, - ) -> bool; + ) -> SubGhzProtocolStatus; +} +extern "C" { + #[doc = "Deserialize data SubGhzProtocolDecoderBase.\n\nReturns:\n\n* Status Error\n\n# Arguments\n\n* `decoder_base` - Pointer to a SubGhzProtocolDecoderBase instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] + pub fn subghz_protocol_decoder_base_deserialize( + decoder_base: *mut SubGhzProtocolDecoderBase, + flipper_format: *mut FlipperFormat, + ) -> SubGhzProtocolStatus; } extern "C" { #[doc = "Getting the hash sum of the last randomly received parcel.\n\nReturns:\n\n* hash Hash sum\n\n# Arguments\n\n* `decoder_base` - Pointer to a SubGhzProtocolDecoderBase instance\n\n"] @@ -21187,11 +21611,11 @@ extern "C" { ); } extern "C" { - #[doc = "Deserialize data SubGhzProtocolDecoderRAW.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolDecoderRAW instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] + #[doc = "Deserialize data SubGhzProtocolDecoderRAW.\n\nReturns:\n\n* status\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolDecoderRAW instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] pub fn subghz_protocol_decoder_raw_deserialize( context: *mut core::ffi::c_void, flipper_format: *mut FlipperFormat, - ) -> bool; + ) -> SubGhzProtocolStatus; } extern "C" { #[doc = "Getting a textual representation of the received data.\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolDecoderRAW instance\n* `output` - Resulting text\n\n"] @@ -21237,11 +21661,11 @@ extern "C" { ); } extern "C" { - #[doc = "Deserialize and generating an upload to send.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolEncoderRAW instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] + #[doc = "Deserialize and generating an upload to send.\n\nReturns:\n\n* status\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolEncoderRAW instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] pub fn subghz_protocol_encoder_raw_deserialize( context: *mut core::ffi::c_void, flipper_format: *mut FlipperFormat, - ) -> bool; + ) -> SubGhzProtocolStatus; } extern "C" { #[doc = "Getting the level and duration of the upload to be loaded into DMA.\n\nReturns:\n\n* LevelDuration\n\n# Arguments\n\n* `context` - Pointer to a SubGhzProtocolEncoderRAW instance\n\n"] @@ -21565,11 +21989,11 @@ extern "C" { pub fn subghz_transmitter_stop(instance: *mut SubGhzTransmitter) -> bool; } extern "C" { - #[doc = "Deserialize and generating an upload to send.\n\nReturns:\n\n* true On success\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzTransmitter instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] + #[doc = "Deserialize and generating an upload to send.\n\nReturns:\n\n* status\n\n# Arguments\n\n* `instance` - Pointer to a SubGhzTransmitter instance\n* `flipper_format` - Pointer to a FlipperFormat instance\n\n"] pub fn subghz_transmitter_deserialize( instance: *mut SubGhzTransmitter, flipper_format: *mut FlipperFormat, - ) -> bool; + ) -> SubGhzProtocolStatus; } extern "C" { #[doc = "Getting the level and duration of the upload to be loaded into DMA.\n\nReturns:\n\n* LevelDuration\n\n# Arguments\n\n* `context` - Pointer to a SubGhzTransmitter instance\n\n"] @@ -21685,240 +22109,6 @@ extern "C" { #[doc = "Compare two floating point numbers\n\nReturns:\n\n* bool true if a equals b, false otherwise\n\n# Arguments\n\n* `a` - First number to compare\n* `b` - Second number to compare\n\n"] pub fn float_is_equal(a: f32, b: f32) -> bool; } -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct sha256_context { - pub total: [u32; 2usize], - pub state: [u32; 8usize], - pub wbuf: [u32; 16usize], -} -#[test] -fn bindgen_test_layout_sha256_context() { - const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 104usize, - concat!("Size of: ", stringify!(sha256_context)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(sha256_context)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).total) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(sha256_context), - "::", - stringify!(total) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(sha256_context), - "::", - stringify!(state) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).wbuf) as usize - ptr as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(sha256_context), - "::", - stringify!(wbuf) - ) - ); -} -extern "C" { - pub fn sha256( - input: *const core::ffi::c_uchar, - ilen: core::ffi::c_uint, - output: *mut core::ffi::c_uchar, - ); -} -extern "C" { - pub fn sha256_start(ctx: *mut sha256_context); -} -extern "C" { - pub fn sha256_finish(ctx: *mut sha256_context, output: *mut core::ffi::c_uchar); -} -extern "C" { - pub fn sha256_update( - ctx: *mut sha256_context, - input: *const core::ffi::c_uchar, - ilen: core::ffi::c_uint, - ); -} -extern "C" { - pub fn sha256_process(ctx: *mut sha256_context); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct hmac_context { - pub init_hash: ::core::option::Option, - pub update_hash: ::core::option::Option< - unsafe extern "C" fn( - context: *const hmac_context, - message: *const u8, - message_size: core::ffi::c_uint, - ), - >, - pub finish_hash: ::core::option::Option< - unsafe extern "C" fn(context: *const hmac_context, hash_result: *mut u8), - >, - pub block_size: core::ffi::c_uint, - pub result_size: core::ffi::c_uint, - pub tmp: *mut u8, -} -#[test] -fn bindgen_test_layout_hmac_context() { - 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!(hmac_context)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(hmac_context)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).init_hash) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(init_hash) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).update_hash) as usize - ptr as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(update_hash) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).finish_hash) as usize - ptr as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(finish_hash) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).block_size) as usize - ptr as usize }, - 12usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(block_size) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).result_size) as usize - ptr as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(result_size) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tmp) as usize - ptr as usize }, - 20usize, - concat!( - "Offset of field: ", - stringify!(hmac_context), - "::", - stringify!(tmp) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct hmac_sha256_context { - pub hmac_ctx: hmac_context, - pub sha_ctx: sha256_context, - pub tmp: [u8; 128usize], -} -#[test] -fn bindgen_test_layout_hmac_sha256_context() { - const UNINIT: ::core::mem::MaybeUninit = - ::core::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::core::mem::size_of::(), - 256usize, - concat!("Size of: ", stringify!(hmac_sha256_context)) - ); - assert_eq!( - ::core::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(hmac_sha256_context)) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).hmac_ctx) as usize - ptr as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(hmac_sha256_context), - "::", - stringify!(hmac_ctx) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).sha_ctx) as usize - ptr as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(hmac_sha256_context), - "::", - stringify!(sha_ctx) - ) - ); - assert_eq!( - unsafe { ::core::ptr::addr_of!((*ptr).tmp) as usize - ptr as usize }, - 128usize, - concat!( - "Offset of field: ", - stringify!(hmac_sha256_context), - "::", - stringify!(tmp) - ) - ); -} -extern "C" { - pub fn hmac_sha256_init(ctx: *mut hmac_sha256_context, K: *const u8); -} -extern "C" { - pub fn hmac_sha256_update( - ctx: *const hmac_sha256_context, - message: *const u8, - message_size: core::ffi::c_uint, - ); -} -extern "C" { - pub fn hmac_sha256_finish(ctx: *const hmac_sha256_context, K: *const u8, hash_result: *mut u8); -} pub const ManchesterEvent_ManchesterEventShortLow: ManchesterEvent = 0; pub const ManchesterEvent_ManchesterEventShortHigh: ManchesterEvent = 2; pub const ManchesterEvent_ManchesterEventLongLow: ManchesterEvent = 4; @@ -22114,6 +22304,16 @@ extern "C" { #[doc = "Check that path contains only ascii characters\n\nReturns:\n\n* true\n* false\n\n# Arguments\n\n* `path` - \n\n"] pub fn path_contains_only_ascii(path: *const core::ffi::c_char) -> bool; } +extern "C" { + #[doc = "Format a data buffer as a canonical HEX dump\n\n# Arguments\n\n* `[out]` - result pointer to the output string (must be initialised)\n* `[in]` - num_places the number of bytes on one line (both as HEX and ASCII)\n* `[in]` - line_prefix if not NULL, prepend this string to each line\n* `[in]` - data pointer to the input data buffer\n* `[in]` - data_size input data size\n\n"] + pub fn pretty_format_bytes_hex_canonical( + result: *mut FuriString, + num_places: usize, + line_prefix: *const core::ffi::c_char, + data: *const u8, + data_size: usize, + ); +} extern "C" { #[doc = "Generates random name\n\n# Arguments\n\n* `name` - buffer to write random name\n* `max_name_size` - length of given buffer\n\n"] pub fn set_random_name(name: *mut core::ffi::c_char, max_name_size: u8); @@ -22144,6 +22344,81 @@ extern "C" { payload_size: *mut usize, ) -> bool; } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct sha256_context { + pub total: [u32; 2usize], + pub state: [u32; 8usize], + pub wbuf: [u32; 16usize], +} +#[test] +fn bindgen_test_layout_sha256_context() { + const UNINIT: ::core::mem::MaybeUninit = ::core::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::core::mem::size_of::(), + 104usize, + concat!("Size of: ", stringify!(sha256_context)) + ); + assert_eq!( + ::core::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(sha256_context)) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).total) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(sha256_context), + "::", + stringify!(total) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).state) as usize - ptr as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(sha256_context), + "::", + stringify!(state) + ) + ); + assert_eq!( + unsafe { ::core::ptr::addr_of!((*ptr).wbuf) as usize - ptr as usize }, + 40usize, + concat!( + "Offset of field: ", + stringify!(sha256_context), + "::", + stringify!(wbuf) + ) + ); +} +extern "C" { + pub fn sha256( + input: *const core::ffi::c_uchar, + ilen: core::ffi::c_uint, + output: *mut core::ffi::c_uchar, + ); +} +extern "C" { + pub fn sha256_start(ctx: *mut sha256_context); +} +extern "C" { + pub fn sha256_finish(ctx: *mut sha256_context, output: *mut core::ffi::c_uchar); +} +extern "C" { + pub fn sha256_update( + ctx: *mut sha256_context, + input: *const core::ffi::c_uchar, + ilen: core::ffi::c_uint, + ); +} +extern "C" { + pub fn sha256_process(ctx: *mut sha256_context); +} extern "C" { #[doc = "Allocate string stream\n\nReturns:\n\n* Stream*\n\n"] pub fn string_stream_alloc() -> *mut Stream; diff --git a/tools/src/bin/generate-bindings.rs b/tools/src/bin/generate-bindings.rs index 41ad1228..3f97419a 100644 --- a/tools/src/bin/generate-bindings.rs +++ b/tools/src/bin/generate-bindings.rs @@ -20,6 +20,8 @@ const TOOLCHAIN: &str = "../../../toolchain/x86_64-windows/arm-none-eabi/include const TOOLCHAIN: &str = "../../../toolchain/i686-linux/arm-none-eabi/include"; #[cfg(all(unix, target_arch = "x86_64"))] const TOOLCHAIN: &str = "../../../toolchain/x86_64-linux/arm-none-eabi/include"; +#[cfg(all(target_os="macos", target_arch = "aarch64"))] +const TOOLCHAIN: &str = "../../../toolchain/x86_64-darwin/arm-none-eabi/include"; const VISIBILITY_PUBLIC: &str = "+"; #[derive(Debug)]