Compare commits
3 Commits
7ef059fa5b
...
main
Author | SHA1 | Date | |
---|---|---|---|
3c2f3365e8
|
|||
8a6e51c877
|
|||
5a3798732c
|
28
cellular/src/amps.rs
Normal file
28
cellular/src/amps.rs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
enum DSPMode {
|
||||||
|
OFF, // Channel not active
|
||||||
|
AUDIO_RX_AUDIO_TX, // stream audio
|
||||||
|
AUDIO_RX_FRAME_TX, // stream audio and send frames
|
||||||
|
AUDIO_RX_SILENCE_TX, // stream audio and send silence
|
||||||
|
FRAME_RX_FRAME_TX, // send and receive frames
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AMPSChannelType {
|
||||||
|
CC, // control channel
|
||||||
|
PC, // paging channel
|
||||||
|
CC_PC, // combined control+paging
|
||||||
|
VC, // voice channel
|
||||||
|
CC_PC_VC, // combined control+paging+voice
|
||||||
|
}
|
||||||
|
|
||||||
|
enum AMPSState {
|
||||||
|
NULL, // power off
|
||||||
|
IDLE, // channel not in use
|
||||||
|
BUSY, // channel busy (call in progress)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FSK_RX_Sync {
|
||||||
|
NONE, // not in sync, waiting for valid dotting sequence
|
||||||
|
DOTTING, // received a valid dotting sequence, check for sync sequence
|
||||||
|
POSITIVE, // valid sync, read all bits from the frame
|
||||||
|
NEGATIVE, // negative sync (high frequency deviation detected as low signal)
|
||||||
|
}
|
36
cellular/src/iir_filter.rs
Normal file
36
cellular/src/iir_filter.rs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
struct IIRFilter {
|
||||||
|
iter: i32,
|
||||||
|
a0: f64,
|
||||||
|
a1: f64,
|
||||||
|
a2: f64,
|
||||||
|
b1: f64,
|
||||||
|
b2: f64,
|
||||||
|
z1: f64,
|
||||||
|
z2: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IIRFilter {
|
||||||
|
pub fn lowpass_init(&mut self, frequency: f64, samplerate: i32, iterations: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn highpass_init(&mut self, frequency: f64, samplerate: i32, iterations: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bandpass_init(&mut self, frequency: f64, samplerate: i32, iterations: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn notch_init(&mut self, frequency: f64, samplerate: i32, iterations: i32, Q: f64) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn process(&mut self, samples: Sample, length: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn process_baseband(&mut self, filter: IIRFilter, baseband: f64, length: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
45
cellular/src/libmobile_sender.rs
Normal file
45
cellular/src/libmobile_sender.rs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
enum PagingSignal {
|
||||||
|
NONE = 0,
|
||||||
|
TONE,
|
||||||
|
NOTONE,
|
||||||
|
POSITIVE,
|
||||||
|
NEGATIVE,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Sender {
|
||||||
|
// System Info
|
||||||
|
channel: char,
|
||||||
|
send_freq: f64,
|
||||||
|
recv_freq: f64,
|
||||||
|
|
||||||
|
// FM/AM levels
|
||||||
|
am: i32,
|
||||||
|
max_deviation: f64,
|
||||||
|
max_modulation: f64,
|
||||||
|
speech_deviation: f64,
|
||||||
|
modulation_index: f64,
|
||||||
|
max_display: f64,
|
||||||
|
|
||||||
|
// Audio
|
||||||
|
audio: void,
|
||||||
|
device: char,
|
||||||
|
audio_open: void,
|
||||||
|
audio_start: i32,
|
||||||
|
audio_close: void,
|
||||||
|
audio_write: i32,
|
||||||
|
audio_get_tosend: i32,
|
||||||
|
samplerate: i32,
|
||||||
|
samplerate_state: SampleRate,
|
||||||
|
rx_gain: f64,
|
||||||
|
tx_gain: f64,
|
||||||
|
pre_emphasis: i32,
|
||||||
|
de_emphasis: i32,
|
||||||
|
epmphasis_state: EmphasisState,
|
||||||
|
|
||||||
|
// Loopback
|
||||||
|
loopback: i32,
|
||||||
|
|
||||||
|
// Record & Playback
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -2,6 +2,10 @@ use ferris_says::say;
|
|||||||
use std::io::{stdout, BufWriter};
|
use std::io::{stdout, BufWriter};
|
||||||
|
|
||||||
mod sdr;
|
mod sdr;
|
||||||
|
mod amps;
|
||||||
|
mod libmobile_sender;
|
||||||
|
mod iir_filter;
|
||||||
|
mod samplerate;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let stdout = stdout();
|
let stdout = stdout();
|
||||||
|
45
cellular/src/samplerate.rs
Normal file
45
cellular/src/samplerate.rs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
struct SampleRate {
|
||||||
|
factor: f64,
|
||||||
|
filter_cutoff: f64,
|
||||||
|
down: DownSampler,
|
||||||
|
up: UpSampler,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DownSampler {
|
||||||
|
lp: IIRFilter,
|
||||||
|
last_sample: Sample,
|
||||||
|
in_index: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct UpSampler {
|
||||||
|
lp: IIRFilter,
|
||||||
|
current_sample: Sample,
|
||||||
|
last_sample: Sample,
|
||||||
|
in_index: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SampleRate {
|
||||||
|
pub fn init(&mut self, low_samplerate: f64, high_samplerate: f64, filter_cutoff: f64) -> Result<(), i32> {
|
||||||
|
// Implementation goes here
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
// or Err(error_code) if there's an error
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn downsample(&mut self, state: SampleRate, samples: Sample, input_num: i32) -> Result<(), i32> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn upsample_input_num(&mut self, state: SampleRate, output_num: i32) -> Result<(), i32> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn upsample_output_num(&mut self, state: SampleRate, input_num: i32) -> Result<(), i32> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn upsample(&mut self, state: SampleRate, input: Sample, input_num: i32, output: Sample, output_num: i32) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -21,7 +21,8 @@
|
|||||||
with pkgs;
|
with pkgs;
|
||||||
{
|
{
|
||||||
devShells.default = mkShell {
|
devShells.default = mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
pkgs.bashInteractive
|
||||||
rust-bin.stable.latest.default
|
rust-bin.stable.latest.default
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
pkgs.alsa-lib
|
pkgs.alsa-lib
|
||||||
|
Reference in New Issue
Block a user