Skip to content

Commit 00090a0

Browse files
committed
feat: add TxPowerLevel advertisement
1 parent 1979dff commit 00090a0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

host/src/advertise.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ pub enum AdStructure<'a> {
384384
/// The UUID data matches the ble network's endian order (should be little endian).
385385
CompleteServiceUuids128(&'a [[u8; 16]]),
386386

387+
/// Sets the Tx Power Level in dBm.
388+
TxPowerLevel(i8),
389+
387390
/// Service data with 16-bit service UUID.
388391
/// The UUID data matches the ble network's endian order (should be little endian).
389392
ServiceData16 {
@@ -477,6 +480,9 @@ impl AdStructure<'_> {
477480
w.append(&[(name.len() + 1) as u8, 0x09])?;
478481
w.append(name)?;
479482
}
483+
AdStructure::TxPowerLevel(power) => {
484+
w.append(&[0x02, 0x0a, *power as u8])?;
485+
}
480486
AdStructure::ServiceData16 { uuid, data } => {
481487
w.append(&[(data.len() + 3) as u8, 0x16])?;
482488
w.write(Uuid::Uuid16(*uuid))?;
@@ -576,8 +582,9 @@ impl<'d> AdStructureIter<'d> {
576582
0x08 => Ok(AdStructure::ShortenedLocalName(data)),
577583
// Complete Local Name
578584
0x09 => Ok(AdStructure::CompleteLocalName(data)),
585+
// Tx Power Level
586+
0x0a => Ok(AdStructure::TxPowerLevel(data[0] as i8)),
579587
/*
580-
0x0A Tx Power Level
581588
0x0D Class of Device
582589
0x0E Simple Pairing Hash C-192
583590
0x0F Simple Pairing Randomizer R-192

0 commit comments

Comments
 (0)