bjoernQ / bleps

A toy-level BLE peripheral stack
MIT License
55 stars 18 forks source link

List nearby BLE devices? #34

Closed David-OConnor closed 9 months ago

David-OConnor commented 9 months ago

Hi! I notice examples here and in the esp-wifi crate for advertising device data. Is there a way to view nearby device advertisements? Thank you!

I'm experimenting along these lines:

    let bluetooth = peripherals.BT;

    let connector = BleConnector::new(&init, bluetooth);
    let hci = HciConnector::new(connector, esp_wifi::current_millis);
    let mut ble = Ble::new(&hci);

    ble.cmd_set_le_scan_rsp_data(
        // todo temp
        create_advertising_data(&[
            AdStructure::Flags(LE_GENERAL_DISCOVERABLE | BR_EDR_NOT_SUPPORTED),
            AdStructure::ServiceUuids16(&[Uuid::Uuid16(0x1809)]),
            // AdStructure::CompleteLocalName(examples_util::SOC_NAME),
            AdStructure::CompleteLocalName("TEST"),
        ]).unwrap()
    ).unwrap();

    println!("BLE init: {:?}", ble.init());
bjoernQ commented 9 months ago

Hi! Scanning is not supported by this library and there are no plans to do so

When using esp-wifi you could implement scanning by exchanging HCI packets with the driver directly - there is an example here: https://github.com/alexiionescu/esp-ble-scan

David-OConnor commented 9 months ago

Excellent!