xref: /aosp_15_r20/external/pigweed/pw_bluetooth_sapphire/host/README.md (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# bt-host
2*61c4878aSAndroid Build Coastguard Worker
3*61c4878aSAndroid Build Coastguard Worker## Test
4*61c4878aSAndroid Build Coastguard Worker
5*61c4878aSAndroid Build Coastguard Worker`$ fx test $dir_pw_bluetooth_sapphire/host`
6*61c4878aSAndroid Build Coastguard Worker
7*61c4878aSAndroid Build Coastguard Worker### Fuzz Testing
8*61c4878aSAndroid Build Coastguard Worker
9*61c4878aSAndroid Build Coastguard Workerbt-host contains fuzz tests for several libraries. Make sure to include the desired fuzzing target
10*61c4878aSAndroid Build Coastguard Workerin your `fx set`. For example, to include all bt-host fuzzing targets, use:
11*61c4878aSAndroid Build Coastguard Worker
12*61c4878aSAndroid Build Coastguard Worker```
13*61c4878aSAndroid Build Coastguard Workerfx set core.x64 --fuzz-with asan --with $dir_pw_bluetooth_sapphire/host:fuzzers
14*61c4878aSAndroid Build Coastguard Worker```
15*61c4878aSAndroid Build Coastguard Worker
16*61c4878aSAndroid Build Coastguard WorkerBefore running the test, ensure QEMU is running.
17*61c4878aSAndroid Build Coastguard Worker
18*61c4878aSAndroid Build Coastguard WorkerRun `fx fuzz list` to see the full list of available fuzzing targets. To run a specific fuzz test,
19*61c4878aSAndroid Build Coastguard Workerdo `fx fuzz $package/$fuzzer` where `$package` and `$fuzzer` match those reported by `fx fuzz list`.
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Worker
22*61c4878aSAndroid Build Coastguard Worker
23*61c4878aSAndroid Build Coastguard WorkerSee the [fuzzing documentation](https://fuchsia.dev/fuchsia-src/development/testing/fuzzing/overview?hl=en)
24*61c4878aSAndroid Build Coastguard Workerfor a more in depth guide.
25*61c4878aSAndroid Build Coastguard Worker
26*61c4878aSAndroid Build Coastguard Worker## Inspect
27*61c4878aSAndroid Build Coastguard Worker
28*61c4878aSAndroid Build Coastguard Worker`bt-host` uses the [standard driver processes](https://fuchsia.googlesource.com/fuchsia/+/57edce1df72b148c33e8f219bddbd038cdbb861b/zircon/system/ulib/inspect/) to expose its inspect hierarchy
29*61c4878aSAndroid Build Coastguard Workerto the Fuchsia system.
30*61c4878aSAndroid Build Coastguard Worker
31*61c4878aSAndroid Build Coastguard Worker### Usage
32*61c4878aSAndroid Build Coastguard Worker
33*61c4878aSAndroid Build Coastguard WorkerTo query the current state of the `bt-host` Inspect hierarchy through `ffx` tooling, run
34*61c4878aSAndroid Build Coastguard Worker
35*61c4878aSAndroid Build Coastguard Worker`ffx inspect show bootstrap/driver_manager --file class/bt-host/000.inspect`
36*61c4878aSAndroid Build Coastguard Worker
37*61c4878aSAndroid Build Coastguard Worker### Hierarchy
38*61c4878aSAndroid Build Coastguard Worker```
39*61c4878aSAndroid Build Coastguard Workeradapter:
40*61c4878aSAndroid Build Coastguard Worker    adapter_id
41*61c4878aSAndroid Build Coastguard Worker    hci_version
42*61c4878aSAndroid Build Coastguard Worker    bredr_max_num_packets
43*61c4878aSAndroid Build Coastguard Worker    bredr_max_data_length
44*61c4878aSAndroid Build Coastguard Worker    le_max_num_packets
45*61c4878aSAndroid Build Coastguard Worker    le_max_data_length
46*61c4878aSAndroid Build Coastguard Worker    sco_max_num_packets
47*61c4878aSAndroid Build Coastguard Worker    sco_max_data_length
48*61c4878aSAndroid Build Coastguard Worker    lmp_features
49*61c4878aSAndroid Build Coastguard Worker    le_features
50*61c4878aSAndroid Build Coastguard Worker    hci:
51*61c4878aSAndroid Build Coastguard Worker        command_channel:
52*61c4878aSAndroid Build Coastguard Worker            allowed_command_packets
53*61c4878aSAndroid Build Coastguard Worker            next_event_handler_id
54*61c4878aSAndroid Build Coastguard Worker            next_transaction_id
55*61c4878aSAndroid Build Coastguard Worker        acl_data_channel:
56*61c4878aSAndroid Build Coastguard Worker            num_queue_packets
57*61c4878aSAndroid Build Coastguard Worker            num_overflow_packets
58*61c4878aSAndroid Build Coastguard Worker            num_recent_overflow_packets
59*61c4878aSAndroid Build Coastguard Worker            bredr:
60*61c4878aSAndroid Build Coastguard Worker                num_sent_packets
61*61c4878aSAndroid Build Coastguard Worker            le:
62*61c4878aSAndroid Build Coastguard Worker                num_sent_packets
63*61c4878aSAndroid Build Coastguard Worker                independent_from_bredr
64*61c4878aSAndroid Build Coastguard Worker            metrics:
65*61c4878aSAndroid Build Coastguard Worker                send_latency:
66*61c4878aSAndroid Build Coastguard Worker                    50th_percentile_us
67*61c4878aSAndroid Build Coastguard Worker                    95th_percentile_us
68*61c4878aSAndroid Build Coastguard Worker                    99th_percentile_us
69*61c4878aSAndroid Build Coastguard Worker                send_size:
70*61c4878aSAndroid Build Coastguard Worker                    10th_percentile_bytes
71*61c4878aSAndroid Build Coastguard Worker                    50th_percentile_bytes
72*61c4878aSAndroid Build Coastguard Worker                    90th_percentile_bytes
73*61c4878aSAndroid Build Coastguard Worker    low_energy_discovery_manager:
74*61c4878aSAndroid Build Coastguard Worker        state
75*61c4878aSAndroid Build Coastguard Worker        paused
76*61c4878aSAndroid Build Coastguard Worker        failed_count
77*61c4878aSAndroid Build Coastguard Worker        scan_interval_ms
78*61c4878aSAndroid Build Coastguard Worker        scan_window_ms
79*61c4878aSAndroid Build Coastguard Worker    bredr_discovery_manager:
80*61c4878aSAndroid Build Coastguard Worker        discoverable_sessions
81*61c4878aSAndroid Build Coastguard Worker        pending_discoverable
82*61c4878aSAndroid Build Coastguard Worker        discoverable_sessions_count
83*61c4878aSAndroid Build Coastguard Worker        last_discoverable_length_sec
84*61c4878aSAndroid Build Coastguard Worker        discovery_sessions
85*61c4878aSAndroid Build Coastguard Worker        inquiry_sessions_count
86*61c4878aSAndroid Build Coastguard Worker        last_inquiry_length_sec
87*61c4878aSAndroid Build Coastguard Worker    metrics:
88*61c4878aSAndroid Build Coastguard Worker        bredr:
89*61c4878aSAndroid Build Coastguard Worker            open_l2cap_channel_requests
90*61c4878aSAndroid Build Coastguard Worker            outgoing_connection_requests
91*61c4878aSAndroid Build Coastguard Worker            pair_requests
92*61c4878aSAndroid Build Coastguard Worker            request_discoverable_events
93*61c4878aSAndroid Build Coastguard Worker            request_discovery_events
94*61c4878aSAndroid Build Coastguard Worker            set_connectable_false_events
95*61c4878aSAndroid Build Coastguard Worker            set_connectable_true_events
96*61c4878aSAndroid Build Coastguard Worker        le:
97*61c4878aSAndroid Build Coastguard Worker            outgoing_connection_requests
98*61c4878aSAndroid Build Coastguard Worker            pair_requests
99*61c4878aSAndroid Build Coastguard Worker            start_advertising_events
100*61c4878aSAndroid Build Coastguard Worker            start_discovery_events
101*61c4878aSAndroid Build Coastguard Worker            stop_advertising_events
102*61c4878aSAndroid Build Coastguard Worker    l2cap:
103*61c4878aSAndroid Build Coastguard Worker        logical_links:
104*61c4878aSAndroid Build Coastguard Worker          logical_link_0x0:
105*61c4878aSAndroid Build Coastguard Worker            handle
106*61c4878aSAndroid Build Coastguard Worker            link_type
107*61c4878aSAndroid Build Coastguard Worker            flush_timeout_ms
108*61c4878aSAndroid Build Coastguard Worker            channels:
109*61c4878aSAndroid Build Coastguard Worker              channel_0x0:
110*61c4878aSAndroid Build Coastguard Worker                local_id
111*61c4878aSAndroid Build Coastguard Worker                remote_id
112*61c4878aSAndroid Build Coastguard Worker                psm
113*61c4878aSAndroid Build Coastguard Worker        services:
114*61c4878aSAndroid Build Coastguard Worker          service_0x0:
115*61c4878aSAndroid Build Coastguard Worker            psm
116*61c4878aSAndroid Build Coastguard Worker    peer_cache:
117*61c4878aSAndroid Build Coastguard Worker        metrics:
118*61c4878aSAndroid Build Coastguard Worker            bredr:
119*61c4878aSAndroid Build Coastguard Worker                bond_failure_events
120*61c4878aSAndroid Build Coastguard Worker                bond_success_events
121*61c4878aSAndroid Build Coastguard Worker                connection_events
122*61c4878aSAndroid Build Coastguard Worker                disconnection_events
123*61c4878aSAndroid Build Coastguard Worker            le:
124*61c4878aSAndroid Build Coastguard Worker                bond_failure_events
125*61c4878aSAndroid Build Coastguard Worker                bond_success_events
126*61c4878aSAndroid Build Coastguard Worker                connection_events
127*61c4878aSAndroid Build Coastguard Worker                disconnection_events
128*61c4878aSAndroid Build Coastguard Worker        peer_0x0:
129*61c4878aSAndroid Build Coastguard Worker            peer_id
130*61c4878aSAndroid Build Coastguard Worker            technology
131*61c4878aSAndroid Build Coastguard Worker            address
132*61c4878aSAndroid Build Coastguard Worker            connectable
133*61c4878aSAndroid Build Coastguard Worker            temporary
134*61c4878aSAndroid Build Coastguard Worker            features
135*61c4878aSAndroid Build Coastguard Worker            hci_version
136*61c4878aSAndroid Build Coastguard Worker            manufacturer
137*61c4878aSAndroid Build Coastguard Worker            bredr_data:
138*61c4878aSAndroid Build Coastguard Worker                connection_state
139*61c4878aSAndroid Build Coastguard Worker                services
140*61c4878aSAndroid Build Coastguard Worker                link_key:
141*61c4878aSAndroid Build Coastguard Worker                    security_properties:
142*61c4878aSAndroid Build Coastguard Worker                        encrypted
143*61c4878aSAndroid Build Coastguard Worker                        secure_connections
144*61c4878aSAndroid Build Coastguard Worker                        authenticated
145*61c4878aSAndroid Build Coastguard Worker                        level
146*61c4878aSAndroid Build Coastguard Worker                        key_type
147*61c4878aSAndroid Build Coastguard Worker            le_data:
148*61c4878aSAndroid Build Coastguard Worker                connection_state
149*61c4878aSAndroid Build Coastguard Worker                bonded
150*61c4878aSAndroid Build Coastguard Worker                features
151*61c4878aSAndroid Build Coastguard Worker    sdp_server:
152*61c4878aSAndroid Build Coastguard Worker        record_0x2:
153*61c4878aSAndroid Build Coastguard Worker            record
154*61c4878aSAndroid Build Coastguard Worker            // TODO(fxbug.dev/42129247): Migrate this to UIntArray when support is better.
155*61c4878aSAndroid Build Coastguard Worker            registered_psms:
156*61c4878aSAndroid Build Coastguard Worker                psm_0x0:
157*61c4878aSAndroid Build Coastguard Worker                    psm
158*61c4878aSAndroid Build Coastguard Worker                psm_0x1:
159*61c4878aSAndroid Build Coastguard Worker                    psm
160*61c4878aSAndroid Build Coastguard Worker        record_0x3:
161*61c4878aSAndroid Build Coastguard Worker            record
162*61c4878aSAndroid Build Coastguard Worker            registered_psms:
163*61c4878aSAndroid Build Coastguard Worker                (none)
164*61c4878aSAndroid Build Coastguard Worker    low_energy_connection_manager:
165*61c4878aSAndroid Build Coastguard Worker        disconnect_explicit_disconnect_count
166*61c4878aSAndroid Build Coastguard Worker        disconnect_link_error_count
167*61c4878aSAndroid Build Coastguard Worker        disconnect_remote_disconnection_count
168*61c4878aSAndroid Build Coastguard Worker        disconnect_zero_ref_count
169*61c4878aSAndroid Build Coastguard Worker        incoming_connection_failure_count
170*61c4878aSAndroid Build Coastguard Worker        incoming_connection_success_count
171*61c4878aSAndroid Build Coastguard Worker        outgoing_connection_failure_count
172*61c4878aSAndroid Build Coastguard Worker        outgoing_connection_success_count
173*61c4878aSAndroid Build Coastguard Worker        recent_connection_failures
174*61c4878aSAndroid Build Coastguard Worker        pending_requests:
175*61c4878aSAndroid Build Coastguard Worker            pending_request_0x0:
176*61c4878aSAndroid Build Coastguard Worker                peer_id
177*61c4878aSAndroid Build Coastguard Worker                callbacks
178*61c4878aSAndroid Build Coastguard Worker        outbound_connector:
179*61c4878aSAndroid Build Coastguard Worker            peer_id
180*61c4878aSAndroid Build Coastguard Worker            is_outbound
181*61c4878aSAndroid Build Coastguard Worker            connection_attempt
182*61c4878aSAndroid Build Coastguard Worker            state
183*61c4878aSAndroid Build Coastguard Worker        connections:
184*61c4878aSAndroid Build Coastguard Worker            connection_0x0:
185*61c4878aSAndroid Build Coastguard Worker                peer_id
186*61c4878aSAndroid Build Coastguard Worker                peer_address
187*61c4878aSAndroid Build Coastguard Worker                ref_count
188*61c4878aSAndroid Build Coastguard Worker    bredr_connection_manager:
189*61c4878aSAndroid Build Coastguard Worker        security_mode
190*61c4878aSAndroid Build Coastguard Worker        disconnect_acl_link_error_count
191*61c4878aSAndroid Build Coastguard Worker        disconnect_interrogation_failed_count
192*61c4878aSAndroid Build Coastguard Worker        disconnect_local_api_request_count
193*61c4878aSAndroid Build Coastguard Worker        disconnect_pairing_failed_count
194*61c4878aSAndroid Build Coastguard Worker        disconnect_peer_disconnection_count
195*61c4878aSAndroid Build Coastguard Worker        interrogation_complete_count
196*61c4878aSAndroid Build Coastguard Worker        incoming:
197*61c4878aSAndroid Build Coastguard Worker            connection_attempts
198*61c4878aSAndroid Build Coastguard Worker            failed_connections
199*61c4878aSAndroid Build Coastguard Worker            successful_connections
200*61c4878aSAndroid Build Coastguard Worker        outgoing:
201*61c4878aSAndroid Build Coastguard Worker            connection_attempts
202*61c4878aSAndroid Build Coastguard Worker            failed_connections
203*61c4878aSAndroid Build Coastguard Worker            successful_connections
204*61c4878aSAndroid Build Coastguard Worker        connection_requests:
205*61c4878aSAndroid Build Coastguard Worker            request_0x0:
206*61c4878aSAndroid Build Coastguard Worker                peer_id
207*61c4878aSAndroid Build Coastguard Worker                has_incoming
208*61c4878aSAndroid Build Coastguard Worker                callbacks
209*61c4878aSAndroid Build Coastguard Worker        connections:
210*61c4878aSAndroid Build Coastguard Worker            connection_0x0:
211*61c4878aSAndroid Build Coastguard Worker                peer_id
212*61c4878aSAndroid Build Coastguard Worker                pairing_state:
213*61c4878aSAndroid Build Coastguard Worker                    encryption_status
214*61c4878aSAndroid Build Coastguard Worker                    security_properties:
215*61c4878aSAndroid Build Coastguard Worker                        encrypted
216*61c4878aSAndroid Build Coastguard Worker                        secure_connections
217*61c4878aSAndroid Build Coastguard Worker                        authenticated
218*61c4878aSAndroid Build Coastguard Worker                        level
219*61c4878aSAndroid Build Coastguard Worker                        key_type
220*61c4878aSAndroid Build Coastguard Worker        last_disconnected:
221*61c4878aSAndroid Build Coastguard Worker            0:
222*61c4878aSAndroid Build Coastguard Worker                peer_id
223*61c4878aSAndroid Build Coastguard Worker                duration_s
224*61c4878aSAndroid Build Coastguard Worker                @time
225*61c4878aSAndroid Build Coastguard Worker```
226