• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Merged bridge
2 
3 pub use crate::controller::*;
4 pub use crate::hci::*;
5 pub use crate::stack::*;
6 
7 #[cxx::bridge(namespace = bluetooth::shim::rust)]
8 pub mod ffi {
9     extern "Rust" {
10         type Stack;
11         type Hci;
12         type Controller;
13 
14         // Stack
stack_create() -> Box<Stack>15         fn stack_create() -> Box<Stack>;
stack_start(stack: &mut Stack)16         fn stack_start(stack: &mut Stack);
stack_stop(stack: &mut Stack)17         fn stack_stop(stack: &mut Stack);
18 
get_hci(stack: &mut Stack) -> Box<Hci>19         fn get_hci(stack: &mut Stack) -> Box<Hci>;
get_controller(stack: &mut Stack) -> Box<Controller>20         fn get_controller(stack: &mut Stack) -> Box<Controller>;
21 
22         // HCI
hci_set_acl_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>)23         fn hci_set_acl_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>);
hci_set_evt_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>)24         fn hci_set_evt_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>);
hci_set_le_evt_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>)25         fn hci_set_le_evt_callback(hci: &mut Hci, callback: UniquePtr<u8SliceCallback>);
26 
hci_send_command(hci: &mut Hci, data: &[u8], callback: UniquePtr<u8SliceOnceCallback>)27         fn hci_send_command(hci: &mut Hci, data: &[u8], callback: UniquePtr<u8SliceOnceCallback>);
hci_send_acl(hci: &mut Hci, data: &[u8])28         fn hci_send_acl(hci: &mut Hci, data: &[u8]);
hci_register_event(hci: &mut Hci, event: u8)29         fn hci_register_event(hci: &mut Hci, event: u8);
hci_register_le_event(hci: &mut Hci, subevent: u8)30         fn hci_register_le_event(hci: &mut Hci, subevent: u8);
31 
32         // Controller
controller_supports_simple_pairing(c: &Controller) -> bool33         fn controller_supports_simple_pairing(c: &Controller) -> bool;
controller_supports_secure_connections(c: &Controller) -> bool34         fn controller_supports_secure_connections(c: &Controller) -> bool;
controller_supports_simultaneous_le_bredr(c: &Controller) -> bool35         fn controller_supports_simultaneous_le_bredr(c: &Controller) -> bool;
controller_supports_interlaced_inquiry_scan(c: &Controller) -> bool36         fn controller_supports_interlaced_inquiry_scan(c: &Controller) -> bool;
controller_supports_rssi_with_inquiry_results(c: &Controller) -> bool37         fn controller_supports_rssi_with_inquiry_results(c: &Controller) -> bool;
controller_supports_extended_inquiry_response(c: &Controller) -> bool38         fn controller_supports_extended_inquiry_response(c: &Controller) -> bool;
controller_supports_role_switch(c: &Controller) -> bool39         fn controller_supports_role_switch(c: &Controller) -> bool;
controller_supports_three_slot_packets(c: &Controller) -> bool40         fn controller_supports_three_slot_packets(c: &Controller) -> bool;
controller_supports_five_slot_packets(c: &Controller) -> bool41         fn controller_supports_five_slot_packets(c: &Controller) -> bool;
controller_supports_classic_2m_phy(c: &Controller) -> bool42         fn controller_supports_classic_2m_phy(c: &Controller) -> bool;
controller_supports_classic_3m_phy(c: &Controller) -> bool43         fn controller_supports_classic_3m_phy(c: &Controller) -> bool;
controller_supports_three_slot_edr_packets(c: &Controller) -> bool44         fn controller_supports_three_slot_edr_packets(c: &Controller) -> bool;
controller_supports_five_slot_edr_packets(c: &Controller) -> bool45         fn controller_supports_five_slot_edr_packets(c: &Controller) -> bool;
controller_supports_sco(c: &Controller) -> bool46         fn controller_supports_sco(c: &Controller) -> bool;
controller_supports_hv2_packets(c: &Controller) -> bool47         fn controller_supports_hv2_packets(c: &Controller) -> bool;
controller_supports_hv3_packets(c: &Controller) -> bool48         fn controller_supports_hv3_packets(c: &Controller) -> bool;
controller_supports_ev3_packets(c: &Controller) -> bool49         fn controller_supports_ev3_packets(c: &Controller) -> bool;
controller_supports_ev4_packets(c: &Controller) -> bool50         fn controller_supports_ev4_packets(c: &Controller) -> bool;
controller_supports_ev5_packets(c: &Controller) -> bool51         fn controller_supports_ev5_packets(c: &Controller) -> bool;
controller_supports_esco_2m_phy(c: &Controller) -> bool52         fn controller_supports_esco_2m_phy(c: &Controller) -> bool;
controller_supports_esco_3m_phy(c: &Controller) -> bool53         fn controller_supports_esco_3m_phy(c: &Controller) -> bool;
controller_supports_three_slot_esco_edr_packets(c: &Controller) -> bool54         fn controller_supports_three_slot_esco_edr_packets(c: &Controller) -> bool;
controller_supports_hold_mode(c: &Controller) -> bool55         fn controller_supports_hold_mode(c: &Controller) -> bool;
controller_supports_sniff_mode(c: &Controller) -> bool56         fn controller_supports_sniff_mode(c: &Controller) -> bool;
controller_supports_park_mode(c: &Controller) -> bool57         fn controller_supports_park_mode(c: &Controller) -> bool;
controller_supports_non_flushable_pb(c: &Controller) -> bool58         fn controller_supports_non_flushable_pb(c: &Controller) -> bool;
controller_supports_sniff_subrating(c: &Controller) -> bool59         fn controller_supports_sniff_subrating(c: &Controller) -> bool;
controller_supports_encryption_pause(c: &Controller) -> bool60         fn controller_supports_encryption_pause(c: &Controller) -> bool;
controller_supports_ble(c: &Controller) -> bool61         fn controller_supports_ble(c: &Controller) -> bool;
62 
controller_supports_privacy(c: &Controller) -> bool63         fn controller_supports_privacy(c: &Controller) -> bool;
controller_supports_packet_extension(c: &Controller) -> bool64         fn controller_supports_packet_extension(c: &Controller) -> bool;
controller_supports_connection_parameters_request(c: &Controller) -> bool65         fn controller_supports_connection_parameters_request(c: &Controller) -> bool;
controller_supports_ble_2m_phy(c: &Controller) -> bool66         fn controller_supports_ble_2m_phy(c: &Controller) -> bool;
controller_supports_ble_coded_phy(c: &Controller) -> bool67         fn controller_supports_ble_coded_phy(c: &Controller) -> bool;
controller_supports_extended_advertising(c: &Controller) -> bool68         fn controller_supports_extended_advertising(c: &Controller) -> bool;
controller_supports_periodic_advertising(c: &Controller) -> bool69         fn controller_supports_periodic_advertising(c: &Controller) -> bool;
controller_supports_peripheral_initiated_feature_exchange(c: &Controller) -> bool70         fn controller_supports_peripheral_initiated_feature_exchange(c: &Controller) -> bool;
controller_supports_connection_parameter_request(c: &Controller) -> bool71         fn controller_supports_connection_parameter_request(c: &Controller) -> bool;
controller_supports_periodic_advertising_sync_transfer_sender(c: &Controller) -> bool72         fn controller_supports_periodic_advertising_sync_transfer_sender(c: &Controller) -> bool;
controller_supports_periodic_advertising_sync_transfer_recipient(c: &Controller) -> bool73         fn controller_supports_periodic_advertising_sync_transfer_recipient(c: &Controller)
74             -> bool;
controller_supports_connected_iso_stream_central(c: &Controller) -> bool75         fn controller_supports_connected_iso_stream_central(c: &Controller) -> bool;
controller_supports_connected_iso_stream_peripheral(c: &Controller) -> bool76         fn controller_supports_connected_iso_stream_peripheral(c: &Controller) -> bool;
controller_supports_iso_broadcaster(c: &Controller) -> bool77         fn controller_supports_iso_broadcaster(c: &Controller) -> bool;
controller_supports_synchronized_receiver(c: &Controller) -> bool78         fn controller_supports_synchronized_receiver(c: &Controller) -> bool;
79 
controller_supports_reading_remote_extended_features(c: &Controller) -> bool80         fn controller_supports_reading_remote_extended_features(c: &Controller) -> bool;
controller_supports_enhanced_setup_synchronous_connection(c: &Controller) -> bool81         fn controller_supports_enhanced_setup_synchronous_connection(c: &Controller) -> bool;
controller_supports_enhanced_accept_synchronous_connection(c: &Controller) -> bool82         fn controller_supports_enhanced_accept_synchronous_connection(c: &Controller) -> bool;
controller_supports_ble_set_privacy_mode(c: &Controller) -> bool83         fn controller_supports_ble_set_privacy_mode(c: &Controller) -> bool;
84 
controller_get_acl_buffer_length(c: &Controller) -> u1685         fn controller_get_acl_buffer_length(c: &Controller) -> u16;
controller_get_le_buffer_length(c: &Controller) -> u1686         fn controller_get_le_buffer_length(c: &Controller) -> u16;
controller_get_iso_buffer_length(c: &Controller) -> u1687         fn controller_get_iso_buffer_length(c: &Controller) -> u16;
controller_get_le_suggested_default_data_length(c: &Controller) -> u1688         fn controller_get_le_suggested_default_data_length(c: &Controller) -> u16;
controller_get_le_maximum_tx_data_length(c: &Controller) -> u1689         fn controller_get_le_maximum_tx_data_length(c: &Controller) -> u16;
controller_get_le_maximum_tx_time(c: &Controller) -> u1690         fn controller_get_le_maximum_tx_time(c: &Controller) -> u16;
controller_get_le_max_advertising_data_length(c: &Controller) -> u1691         fn controller_get_le_max_advertising_data_length(c: &Controller) -> u16;
controller_get_le_supported_advertising_sets(c: &Controller) -> u892         fn controller_get_le_supported_advertising_sets(c: &Controller) -> u8;
controller_get_le_periodic_advertiser_list_size(c: &Controller) -> u893         fn controller_get_le_periodic_advertiser_list_size(c: &Controller) -> u8;
controller_get_acl_buffers(c: &Controller) -> u1694         fn controller_get_acl_buffers(c: &Controller) -> u16;
controller_get_le_buffers(c: &Controller) -> u895         fn controller_get_le_buffers(c: &Controller) -> u8;
controller_get_iso_buffers(c: &Controller) -> u896         fn controller_get_iso_buffers(c: &Controller) -> u8;
controller_get_le_connect_list_size(c: &Controller) -> u897         fn controller_get_le_connect_list_size(c: &Controller) -> u8;
controller_get_le_resolving_list_size(c: &Controller) -> u898         fn controller_get_le_resolving_list_size(c: &Controller) -> u8;
controller_get_le_supported_states(c: &Controller) -> u6499         fn controller_get_le_supported_states(c: &Controller) -> u64;
100 
controller_get_address(c: &Controller) -> String101         fn controller_get_address(c: &Controller) -> String;
102     }
103 
104     unsafe extern "C++" {
105         include!("callbacks/callbacks.h");
106 
107         type u8SliceCallback;
Run(self: &u8SliceCallback, data: &[u8])108         fn Run(self: &u8SliceCallback, data: &[u8]);
109 
110         type u8SliceOnceCallback;
Run(self: &u8SliceOnceCallback, data: &[u8])111         fn Run(self: &u8SliceOnceCallback, data: &[u8]);
112     }
113 }
114