58 lines
1.9 KiB
Rust
58 lines
1.9 KiB
Rust
// Copyright (C) 2022 Maxime “pep” Buquet <pep@bouah.net>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU Affero General Public License as published by the
|
|
// Free Software Foundation, either version 3 of the License, or (at your
|
|
// option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
|
|
// for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
mod error;
|
|
mod modem;
|
|
|
|
use crate::error::Error;
|
|
use crate::modem::ModemManager;
|
|
|
|
use futures::{StreamExt, future::join_all};
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Error> {
|
|
pretty_env_logger::init();
|
|
|
|
let mut join_handlers = vec![];
|
|
let manager = ModemManager::connect().await?;
|
|
for modem in manager {
|
|
println!("FOO0: {:?}", modem);
|
|
println!("FOO0: {:?}", modem.foo().manufacturer().await?);
|
|
println!("FOO0: {:?}", modem.foo().model().await?);
|
|
|
|
println!("FOO1: {:?}", modem.messaging().list().await?);
|
|
|
|
let mut sms_added_stream = modem.messaging().receive_added().await?;
|
|
let mut call_added_stream = modem.voice().receive_call_added().await?;
|
|
|
|
let handle_sms = tokio::spawn(async move {
|
|
while let Some(sms) = sms_added_stream.next().await {
|
|
println!("BAR0: {:?}", sms);
|
|
}
|
|
});
|
|
let handle_call = tokio::spawn(async move {
|
|
while let Some(call) = call_added_stream.next().await {
|
|
println!("MEH0: {:?}", call);
|
|
}
|
|
});
|
|
join_handlers.push(handle_sms);
|
|
join_handlers.push(handle_call);
|
|
}
|
|
|
|
let _ = join_all(join_handlers).await;
|
|
|
|
Ok(())
|
|
}
|