Skip to content

Conversation

@lukipuki
Copy link
Collaborator

Summary
The available_ble_devices() is requested by many users to detect BLE devices running Meshtastic.

Also refactored BleHandler:

  • added available_peripherals method, factoring out logic out of BleHandler::find_ble_radio.
  • added comments
  • added BleDevice struct with name (optional) and MAC address

Related Issues
#32

Checklist

  • Tests pass locally
  • Documentation updated if needed

Also refactored BleHandler:
* added available_peripherals method, factoring out logic out of
  BleHandler::find_ble_radio.
* added comments
It's better than a tuple
@lukipuki lukipuki changed the title Ble scan Add available_ble_devices() method Oct 29, 2025
@lukipuki lukipuki mentioned this pull request Oct 29, 2025
2 tasks
@andrewdavidmackenzie
Copy link
Contributor

Need to make public the BleDevice struct, in the stream module like BleId?

@lukipuki
Copy link
Collaborator Author

Need to make public the BleDevice struct, in the stream module like BleId?

Made it public, also added Clone and Eq.

Also add a few derives.
@andrewdavidmackenzie
Copy link
Contributor

Could I request Debug too please? 🙏

@lukipuki
Copy link
Collaborator Author

Done

@andrewdavidmackenzie
Copy link
Contributor

BleId implemented from_name(). WOuld be useful here too, I think not available?

@lukipuki
Copy link
Collaborator Author

lukipuki commented Oct 29, 2025

Doesn't this work?

if let Some(name) = ble_device.name {
    let ble_id = BleId::from_name(&name);
}

We can add more convenience functions, but right now I want to focus on core functionality. I can add more in followup PRs.

@lukipuki
Copy link
Collaborator Author

The implemented From<BDaddr> suggests how it's supposed to be used (ble_device.mac_address.into()), using the name is only more fragile than a MAC address which is unique.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants