Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.3.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
persello committed Nov 13, 2022
2 parents ef06d66 + b3683a3 commit ce1b16f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bluedroid"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
license = "MIT"
description = "A wrapper for the ESP32 Bluedroid Bluetooth stack."
Expand Down
29 changes: 8 additions & 21 deletions src/gatt_server/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Service {
esp_nofail!(esp_ble_gatts_create_service(
interface,
leaky_box_raw!(id),
64, // TODO: count the number of characteristics and descriptors.
128, // TODO: count the number of characteristics and descriptors.
));
}
}
Expand All @@ -128,28 +128,15 @@ impl Service {
// Loghi docet.

let service_handle = self.handle.unwrap();
let characteristics = self.characteristics.iter().cloned().zip(0..);
let current_index = Arc::new(RwLock::new(0));

for (characteristic, index) in characteristics {
let i = current_index.clone();
std::thread::spawn(move || {
while *i.read().unwrap() != index {
let characteristics = self.characteristics.clone();
std::thread::spawn(move || {
for c in characteristics {
c.write().unwrap().register_self(service_handle);
while c.read().unwrap().attribute_handle.is_none() {
std::thread::yield_now();
}

characteristic
.write()
.unwrap()
.register_self(service_handle);

while characteristic.read().unwrap().attribute_handle.is_none() {
std::thread::yield_now();
}

*i.write().unwrap() += 1;
});
}
}
});
}
}

Expand Down

0 comments on commit ce1b16f

Please sign in to comment.