Skip to content

Commit

Permalink
♻️ refactored bluetooth
Browse files Browse the repository at this point in the history
  • Loading branch information
chriamue committed Oct 14, 2023
1 parent 7c1bc0e commit ebd04e7
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 186 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ build = "build.rs"

[features]
default = ["server", "camera", "yolo"]
full = ["bluetooth", "camera", "detect", "hotspot", "server"]
pi = ["bluetooth", "camera", "detect", "server"]
bluetooth = ["base64", "bluer"]
full = ["bt-server", "camera", "detect", "hotspot", "server"]
pi = ["bt-server", "camera", "detect", "server"]
bluetooth = ["base64"]
bt-server = ["bluetooth", "bluer"]
camera = ["nokhwa/input-native"]
hotspot = ["wifi-rs"]
server = ["axum", "base64", "tower", "tower-http"]
Expand Down
5 changes: 1 addition & 4 deletions examples/bt_rfcomm_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use bluer::{
Address,
};

use ornithology_pi::bluetooth::{
rfcomm_srv::{CHANNEL, MTU},
Message,
};
use ornithology_pi::bluetooth::{Message, CHANNEL, MTU};
use std::time::Duration;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::time::sleep;
Expand Down
10 changes: 5 additions & 5 deletions src/bluetooth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ pub mod gatt_srv;
pub mod rfcomm_srv;

pub const MANUFACTURER_ID: u16 = 0xf00d;
pub const SERVICE_UUID: uuid::Uuid = uuid::Uuid::from_u128(0xF00DC0DE00001);
pub const CHARACTERISTIC_UUID: uuid::Uuid = uuid::Uuid::from_u128(0xF00DC0DE00002);
pub const CHANNEL: u8 = 7;
pub const MTU: u16 = 8192;

pub async fn setup_session(session: &bluer::Session) -> bluer::Result<()> {
let adapter_names = session.adapter_names().await?;
Expand All @@ -35,11 +39,7 @@ pub async fn run_bluetooth(sightings: Arc<Mutex<Vec<Sighting>>>) -> bluer::Resul
.unwrap();
*/

rfcomm_srv::run_session(&session, sightings.clone())
.await
.unwrap();

//drop(gatt_handle);
rfcomm_srv::run_session(&session, sightings.clone()).await?;

Ok(())
}
Loading

0 comments on commit ebd04e7

Please sign in to comment.