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
3 changes: 3 additions & 0 deletions pico/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ This project uses [atat](https://github.com/FactbirdHQ/atat/) a no_std crate for
## Sim868 documentation

- [SIM800 Series AT Command Manual V1.11.pdf](https://www.waveshare.com/wiki/File:SIM800_Series_AT_Command_Manual_V1.11.pdf)
- [SIM868_Series_GNSS_Application_Note_V1.02.pdf](https://www.waveshare.com/wiki/File:SIM868_Series_GNSS_Application_Note_V1.02.pdf)
- [SIM800_Series_GSM_Location_Application_Note_V1.03.pdf](https://www.waveshare.com/wiki/File:SIM800_Series_GSM_Location_Application_Note_V1.03.pdf)
- [SIM868_Series_Hardware_Design_V1.07.pdf](https://www.waveshare.com/wiki/File:SIM868_Series_Hardware_Design_V1.07.pdf)
- [Sim868](https://www.simcom.com/product/SIM868.html)
21 changes: 13 additions & 8 deletions pico/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![no_main]

use alloc::string::ToString;
use atat::asynch::{AtatClient, Client};
use atat::asynch::Client;
use atat::{AtatIngress, DefaultDigester, Ingress, ResponseSlot, UrcChannel};
use core::ptr::addr_of_mut;
use embassy_executor::Spawner;
Expand All @@ -23,7 +23,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::LogBE;
use pico_lib::utils::send_command_logged;
use pico_lib::{at, battery, call, network, sms};

extern crate alloc;
Expand Down Expand Up @@ -143,13 +143,15 @@ async fn main(spawner: Spawner) {
Timer::after(Duration::from_millis(100)).await;
}

match send_command_logged(
&mut client,
&battery::AtBatteryChargeExecute,
"AtBatteryChargeExecute".to_string(),
)
.await
{
let _l = LogBE::new("AtBatteryChargeExecute".to_string());
let r = client.send(&battery::AtBatteryChargeExecute).await;
match r {
Ok(b) => log::info!(" OK {:?}", b),
Err(e) => log::info!(" ERROR: {:?}", e),
}
Ok(v) => log::info!(" {:?}", v),
Err(_) => (),
}

call::call_number(
Expand Down Expand Up @@ -227,6 +229,9 @@ async fn urc_handler_task(
urc::Urc::SMSReady => {
log::info!("URC SMSReady");
}
urc::Urc::SetBearer(v) => {
log::info!("SetBearer {:?}", v);
}
},
pubsub::WaitResult::Lagged(b) => {
log::info!("Urc Lagged messages: {}", b);
Expand Down
4 changes: 2 additions & 2 deletions pico/pico-lib/src/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ pub mod tests {
$(
#[test]
fn $name() {
let (cmd, len, text) = $value;
let (cmd, text) = $value;
let mut buffer = crate::at::tests::zeros();
assert_eq!(len, cmd.write(&mut buffer));
assert_eq!(text.len(), cmd.write(&mut buffer));
assert_eq!(
String::from_utf8(buffer)
.unwrap()
Expand Down
1 change: 0 additions & 1 deletion pico/pico-lib/src/battery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ mod tests {
cmd_serialization_tests! {
test_at_battery_charge_execute: (
AtBatteryChargeExecute,
7,
"AT+CBC\r",
),
}
Expand Down
59 changes: 23 additions & 36 deletions pico/pico-lib/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use atat::heapless::String;

use crate::at::NoResponse;
use crate::utils::LogBE;
use crate::utils::send_command_logged;

// 6.2.19 AT+CHFA Swap the Audio Channels
#[derive(Clone, Debug, AtatCmd)]
Expand Down Expand Up @@ -61,45 +62,34 @@ pub async fn call_number<T: atat::asynch::AtatClient, U: crate::at::PicoHW>(
number: &'static str,
duration_millis: u64,
) {
{
let _l = LogBE::new("AtSwapAudioChannelsWrite".to_string());
let r = client
.send(&AtSwapAudioChannelsWrite {
n: AudioChannels::Main,
})
.await;
match r {
Ok(_) => log::info!(" OK"),
Err(e) => log::info!(" ERROR: {:?}", e),
}
}

{
let _l = LogBE::new("AtDialNumber".to_string());
let r = client
.send(&AtDialNumber {
number: String::<16>::try_from(number).unwrap(),
})
.await;
match r {
Ok(_) => log::info!(" OK"),
Err(e) => log::info!(" ERROR: {:?}", e),
}
}
send_command_logged(
client,
&AtSwapAudioChannelsWrite {
n: AudioChannels::Main,
},
"AtSwapAudioChannelsWrite".to_string(),
)
.await
.ok();

send_command_logged(
client,
&AtDialNumber {
number: String::<16>::try_from(number).unwrap(),
},
"AtSwapAudioChannelsAtDialNumberWrite".to_string(),
)
.await
.ok();

{
let _l = LogBE::new("Sleeping".to_string());
pico.sleep(duration_millis).await;
}

{
let _l = LogBE::new("AtHangup".to_string());
let r = client.send(&AtHangup).await;
match r {
Ok(_) => log::info!(" OK"),
Err(e) => log::info!(" ERROR: {:?}", e),
}
}
send_command_logged(client, &AtHangup, "AtHangup".to_string())
.await
.ok();
}

#[cfg(test)]
Expand All @@ -114,19 +104,16 @@ mod tests {
AtSwapAudioChannelsWrite {
n: AudioChannels::Main,
},
10,
"AT+CHFA=1\r",
),
test_at_dial_number: (
AtDialNumber {
number: String::try_from("+361234567").unwrap(),
},
17,
"ATD+361234567,i;\r",
),
test_at_hangup: (
AtHangup,
9,
"AT+CHUP;\r",
),
}
Expand Down
Loading