-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
176 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use env_logger::{Builder, Target}; | ||
use log::LevelFilter; | ||
|
||
use soundcore_lib::ble::{BLEConnectionFactory, BLEConnectionManager}; | ||
use soundcore_lib::device_manager::create_device_manager; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
Builder::new() | ||
.target(Target::Stdout) | ||
.filter_level(LevelFilter::Trace) | ||
.init(); | ||
let manager = create_device_manager().await; | ||
let scan_res = manager.ble_scan(None).await?; | ||
println!("{:?}", scan_res); | ||
let device = scan_res | ||
.iter() | ||
.find(|d| d.descriptor.name.contains("Q45")) | ||
.unwrap(); | ||
let connection = manager.connect(device.clone()).await?; | ||
|
||
let mut state_channel = connection.state_channel().await; | ||
|
||
while let Ok(()) = state_channel.changed().await { | ||
println!("{:?}", state_channel.borrow_and_update()); | ||
} | ||
// let registry = BtlePlugDeviceRegistry::new().await?; | ||
// let scan_res = registry.scan(None).await?; | ||
// println!("{:?}", scan_res); | ||
// let q45 = scan_res.iter().find(|d| d.name.contains("Q45")).unwrap(); | ||
// let _connection = registry.connect(q45.clone(), None).await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use soundcore_lib::{packets::ResponsePacket, types::SupportedModels}; | ||
|
||
#[test] | ||
fn should_parse_state_update() { | ||
let packet = ResponsePacket::from_bytes(&test_data::a3040::UNKN); | ||
match packet { | ||
Ok(ResponsePacket::DeviceState(state)) => { | ||
// TODO: Assert state | ||
assert_eq!(state.tag, SupportedModels::A3040); | ||
println!("{:?}", state.data); | ||
} | ||
Err(err) => panic!("Failed to parse state update packet, error: {:X?}", err), | ||
_ => panic!("Parsed as wrong packet type"), | ||
} | ||
} | ||
|
||
#[test] | ||
fn should_parse_sound_mode_update_packet() { | ||
// Normal | ||
// { | ||
// let packet = ResponsePacket::from_bytes(&test_data::a3040::SOUND_MODE_UPDATE_NORMAL); | ||
// match packet { | ||
// Ok(ResponsePacket::SoundModeUpdate(state)) => { | ||
// assert_eq!(state.0.current, CurrentSoundMode::Normal); | ||
// } | ||
// Err(_err) => panic!("Failed to parse state update packet"), | ||
// _ => panic!("Parsed as wrong packet type"), | ||
// } | ||
// } | ||
// // Noise Cancelling | ||
// { | ||
// let packet = ResponsePacket::from_bytes(&test_data::a3040::SOUND_MODE_UPDATE_NOISE_CANCELLING); | ||
// match packet { | ||
// Ok(ResponsePacket::SoundModeUpdate(state)) => { | ||
// todo!() | ||
// } | ||
// Err(_err) => panic!("Failed to parse state update packet"), | ||
// _ => panic!("Parsed as wrong packet type"), | ||
// } | ||
// } | ||
// // Transparency | ||
// { | ||
// let packet = ResponsePacket::from_bytes(&test_data::a3040::SOUND_MODE_UPDATE_TRANSPARENCY); | ||
// match packet { | ||
// Ok(ResponsePacket::SoundModeUpdate(state)) => { | ||
// todo!() | ||
// } | ||
// Err(_err) => panic!("Failed to parse state update packet"), | ||
// _ => panic!("Parsed as wrong packet type"), | ||
// } | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
pub mod a3040; | ||
pub mod a3951; | ||
pub mod a3040; |