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 support for missing GATT constants and delay trait #5

Merged
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
6 changes: 6 additions & 0 deletions src/command/gatt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,9 @@ bitflags! {
/// [Permissions](AddCharacteristicParameter::security_permissions) available for
/// characteristics.
pub struct CharacteristicPermission: u8 {
/// No security.
const NONE = 0x00;

/// Need authentication to read.
const AUTHENTICATED_READ = 0x01;

Expand All @@ -1572,6 +1575,9 @@ bitflags! {
bitflags! {
/// Which events may be generated when a characteristic is accessed.
pub struct CharacteristicEvent: u8 {
/// No events.
const NONE = 0x00;

/// The application will be notified when a client writes to this attribute.
const ATTRIBUTE_WRITE = 0x01;

Expand Down
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern crate embedded_hal as emhal;
extern crate nb;

use byteorder::{ByteOrder, LittleEndian};
use emhal::blocking;
use core::cmp::min;
use core::convert::TryFrom;
use core::marker::PhantomData;
Expand Down Expand Up @@ -493,6 +494,22 @@ where
Ok(())
}

/// Resets the BlueNRG Controller. Uses the given delay to wait
/// `time` milliseconds after toggling the reset pin.
pub fn reset_with_delay<D, UXX>(&mut self, delay: &mut D, time: UXX) -> nb::Result<(), OutputPin2::Error>
where
D: blocking::delay::DelayMs<UXX>,
UXX: Copy,
{
self.reset.set_low().map_err(nb::Error::Other)?;
delay.delay_ms(time);

self.reset.set_high().map_err(nb::Error::Other)?;
delay.delay_ms(time);

Ok(())
}

/// Returns true if the controller has data ready to transmit to the host.
fn data_ready(&self) -> Result<bool, InputPin::Error> {
self.data_ready.is_high()
Expand Down