@@ -86,6 +86,14 @@ impl Display for BleId {
8686 }
8787}
8888
89+ /// A Meshtastic device discovered via Bluetooth LE.
90+ pub struct BleDevice {
91+ /// The broadcast name of the device.
92+ pub name : Option < String > ,
93+ /// The MAC address of the device.
94+ pub mac_address : BDAddr ,
95+ }
96+
8997impl BleHandler {
9098 pub async fn new ( ble_id : & BleId , scan_duration : Duration ) -> Result < Self , Error > {
9199 let ( radio, adapter) = Self :: find_ble_radio ( ble_id, scan_duration) . await ?;
@@ -155,16 +163,17 @@ impl BleHandler {
155163 /// Returns a list of all available Meshtastic BLE devices.
156164 ///
157165 /// This function scans for devices that expose the Meshtastic service UUID
158- /// (`6ba1b218-15a8-461f-9fa8-5dcae273eafd`) and returns a list of (name, MAC address) tuples
166+ /// (`6ba1b218-15a8-461f-9fa8-5dcae273eafd`) and returns a list of [`BleDevice`]s
159167 /// that can be used to connect to them.
160- pub async fn available_ble_devices (
161- scan_duration : Duration ,
162- ) -> Result < Vec < ( Option < String > , BDAddr ) > , Error > {
168+ pub async fn available_ble_devices ( scan_duration : Duration ) -> Result < Vec < BleDevice > , Error > {
163169 let peripherals = Self :: available_peripherals ( scan_duration) . await ?;
164170 let mut devices = Vec :: new ( ) ;
165171 for ( p, _) in & peripherals {
166172 if let Ok ( Some ( properties) ) = p. properties ( ) . await {
167- devices. push ( ( properties. local_name , properties. address ) ) ;
173+ devices. push ( BleDevice {
174+ name : properties. local_name ,
175+ mac_address : properties. address ,
176+ } ) ;
168177 }
169178 }
170179 Ok ( devices)
0 commit comments