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
15 changes: 9 additions & 6 deletions pico/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use alloc::string::ToString;
use atat::asynch::Client;
use atat::heapless::String;
use atat::{AtatIngress, DefaultDigester, Ingress, ResponseSlot, UrcChannel};
use core::ptr::addr_of_mut;
use defmt::*;
Expand All @@ -23,7 +24,7 @@ use {defmt_rtt as _, panic_probe as _};
use pico_lib::at::PicoHW;
use pico_lib::poro;
use pico_lib::urc;
use pico_lib::utils::send_command_logged;
use pico_lib::utils::{astring_to_string, send_command_logged};
use pico_lib::{at, battery, call, gps, gsm, network, sms};

extern crate alloc;
Expand Down Expand Up @@ -131,7 +132,6 @@ async fn main(spawner: Spawner) {
info!("After spawning Urc Task");
Timer::after(Duration::from_secs(2)).await;

pico.restart_module().await;
info!("Network init");
Timer::after(Duration::from_secs(2)).await;

Expand Down Expand Up @@ -167,21 +167,24 @@ async fn main(spawner: Spawner) {
None => (),
}

const PHONE_NUMBER: &'static str = "+36301234567";
let phone_number: String<30> = String::try_from("+36301234567").unwrap();

call::call_number(
&mut client,
&mut pico,
PHONE_NUMBER,
&phone_number,
Duration::from_secs(10).as_millis(),
)
.await;

let mut tata_response: String<160> = String::try_from("$tATA/").unwrap();
let _ = tata_response.push_str(dumped.as_str());

sms::send_sms(
&mut client,
&mut pico,
PHONE_NUMBER,
"this is a text message",
&phone_number,
&astring_to_string(tata_response.as_str()),
)
.await;

Expand Down
17 changes: 13 additions & 4 deletions pico/pico-lib/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum AudioChannels {
// ATD+36301234567,i; <- call this number and i: Deactivates CLIR (Enable presentation of own number to called party)
#[derive(Clone, Debug)]
pub struct AtDialNumber {
pub number: String<16>,
pub number: String<30>,
}

impl<'a> AtatCmd for AtDialNumber {
Expand Down Expand Up @@ -104,6 +104,9 @@ pub async fn init<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
client: &mut T,
_pico: &mut U,
) {
// Note, this is NO_SAVE, and by default is enabled on my device.
// It takes a bit of time, but having an extra Read command messes
// up the URC handling.
send_command_logged(
client,
&AtCallingLineIdentificationPresentationWrite {
Expand All @@ -118,7 +121,7 @@ pub async fn init<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
pub async fn call_number<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
client: &mut T,
pico: &mut U,
number: &'static str,
number: &String<30>,
duration_millis: u64,
) {
send_command_logged(
Expand All @@ -134,7 +137,7 @@ pub async fn call_number<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
send_command_logged(
client,
&AtDialNumber {
number: String::<16>::try_from(number).unwrap(),
number: number.clone(),
},
"AtSwapAudioChannelsAtDialNumberWrite".to_string(),
)
Expand Down Expand Up @@ -224,7 +227,13 @@ mod tests {
client.results.push_back(Ok("".as_bytes()));

let mut pico = crate::at::tests::PicoMock::default();
call_number(&mut client, &mut pico, "+36301234567", 100).await;
call_number(
&mut client,
&mut pico,
&String::try_from("+36301234567").unwrap(),
100,
)
.await;
assert_eq!(3, client.sent_commands.len());
assert_eq!("AT+CHFA=1\r", client.sent_commands.get(0).unwrap());
assert_eq!("ATD+36301234567,i;\r", client.sent_commands.get(1).unwrap());
Expand Down
46 changes: 1 addition & 45 deletions pico/pico-lib/src/gps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ use atat::serde_at;
use defmt::Format;
use defmt::debug;

use core::num::ParseFloatError;
use core::num::ParseIntError;
use core::str::Utf8Error;

use alloc::format;
use alloc::string::ToString;
use atat::atat_derive::AtatCmd;
Expand All @@ -18,6 +14,7 @@ use fasttime::DateTime;
use crate::at::NoResponse;
use crate::location;
use crate::utils;
use crate::utils::AtatError;
use crate::utils::as_tokens;
use crate::utils::bytes_to_string;
use crate::utils::send_command_logged;
Expand Down Expand Up @@ -92,47 +89,6 @@ pub struct GnssNavigationInformationResponse { // Length Format
pub vpa: Option<f64>, // 6 [0,9999.9] meters (Vertical Positional Accuracy) reversed
} // 94

extern crate atat;

#[allow(dead_code)] // field `0` is never read, TODO: research
pub struct AtatError(atat::Error);

impl From<ParseFloatError> for AtatError {
fn from(_: ParseFloatError) -> Self {
AtatError(atat::Error::Parse)
}
}

impl From<ParseIntError> for AtatError {
fn from(_: ParseIntError) -> Self {
AtatError(atat::Error::Parse)
}
}

impl From<()> for AtatError {
fn from(_: ()) -> Self {
AtatError(atat::Error::Parse)
}
}

impl From<Utf8Error> for AtatError {
fn from(_: Utf8Error) -> Self {
AtatError(atat::Error::Parse)
}
}

impl From<atat::Error> for AtatError {
fn from(value: atat::Error) -> Self {
AtatError(value)
}
}

impl From<atat::serde_at::de::Error> for AtatError {
fn from(_: atat::serde_at::de::Error) -> Self {
AtatError(atat::Error::Parse)
}
}

fn parse_gnss_navigation_information(
response: &[u8],
) -> Result<GnssNavigationInformationResponse, AtatError> {
Expand Down
Loading