Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pico/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use pico_lib::at::PicoHW;
use pico_lib::poro;
use pico_lib::urc;
use pico_lib::utils::send_command_logged;
use pico_lib::{at, battery, call, network, sms};
use pico_lib::{at, battery, call, gps, gsm, network, sms};

extern crate alloc;

Expand Down Expand Up @@ -154,6 +154,16 @@ async fn main(spawner: Spawner) {
Err(_) => (),
}

match gps::get_gps_location(&mut client, &mut pico, 30).await {
Some(v) => log::info!("GPS location: {:?}", v),
None => (),
}

match gsm::get_gsm_location(&mut client, &mut pico, 30, "online").await {
Some(v) => log::info!("GSM location: {:?}", v),
None => (),
}

call::call_number(
&mut client,
&mut pico,
Expand Down
14 changes: 14 additions & 0 deletions pico/pico-lib/src/location.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
use crate::{gps::get_gps_location, gsm::get_gsm_location};

#[derive(Clone, Debug, PartialEq)]
pub struct Location {
pub latitude: f64,
pub longitude: f64,
pub accuracy: f64,
pub timestamp: i64,
}

// TODO how to abstract this in rust, a Locator trait Vec<dyn Locator>
pub async fn get_location<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
client: &mut T,
pico: &mut U,
max_retries: u8,
apn: &str,
) -> Option<Location> {
return get_gps_location(client, pico, max_retries)
.await
.or(get_gsm_location(client, pico, max_retries, apn).await);
}