Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add disc_mode and high_duty_cycle functions. #49

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ pub enum ConnMode {
Und = esp_idf_sys::BLE_GAP_CONN_MODE_UND as _,
}

#[repr(u8)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum DiscMode {
/// non-discoverable; 3.C.9.2.2
Non = BLE_GAP_DISC_MODE_NON as _,
/// limited-discoverable; 3.C.9.2.3
Ltd = BLE_GAP_DISC_MODE_LTD as _,
/// general-discoverable; 3.C.9.2.4
Gen = BLE_GAP_DISC_MODE_GEN as _,
}

bitflags! {
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down
14 changes: 14 additions & 0 deletions src/server/ble_advertising.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,20 @@ impl BLEAdvertising {
self
}

/// Set discoverable mode.
pub fn disc_mode(&mut self, mode: DiscMode) -> &mut Self {
self.adv_params.disc_mode = mode as _;
self
}

/// Set the duty cycle for advertisement_type.
///
/// Valid only if advertisement_type is directed-connectable.
pub fn high_duty_cycle(&mut self, val: bool) -> &mut Self {
self.adv_params.set_high_duty_cycle(val as _);
self
}

/// Set if scan response is available.
pub fn scan_response(&mut self, value: bool) -> &mut Self {
self.scan_response = value;
Expand Down