6#include "AudioTools/Concurrency.h"
9#if defined(RP2040) && !defined(USE_FREERTOS)
10#error "ModemStreamRTOS on RP2040: select Tools > Operating System > FreeRTOS SMP and #include <FreeRTOS.h> before AudioTools.h"
32 using Config =
typename Base::ConfigType;
48 if (!Base::begin(cfg, rx_buffer_size))
return false;
49 if (this->p_audio_in ==
nullptr)
return true;
57 LOGE(
"BasicModemStreamRTOS: could not create the receive task");
64 if (!
task.begin([
this]() { receive(); })) {
65 LOGE(
"BasicModemStreamRTOS: could not start the receive task");
86 audio_tools::LockGuard guard(
mutex);
87 return this->rx_queue.available();
91 audio_tools::LockGuard guard(
mutex);
92 return this->rx_queue.read();
96 audio_tools::LockGuard guard(
mutex);
97 return this->rx_queue.peek();
112 using Queue =
typename Base::ReceiveQueue;
119 audio_tools::LockGuard guard(
p_mutex);
122 size_t write(
const uint8_t* data,
size_t len)
override {
123 audio_tools::LockGuard guard(
p_mutex);
124 for (
size_t j = 0; j < len; j++)
p_queue->write(data[j]);
154 audio_tools::LockGuard guard(
mutex);
155 if (this->rx_queue.available() >= this->rx_limit)
return 0;
157 return this->readInput();
168 using BasicModemStreamRTOS::BasicModemStreamRTOS;
178 using BasicModemStreamRTOS::BasicModemStreamRTOS;
188 using BasicModemStreamRTOS::BasicModemStreamRTOS;
198 using BasicModemStreamRTOS::BasicModemStreamRTOS;
208 using BasicModemStreamRTOS::BasicModemStreamRTOS;
218 using BasicModemStreamRTOS::BasicModemStreamRTOS;
228 using BasicModemStreamRTOS::BasicModemStreamRTOS;
238 using BasicModemStreamRTOS::BasicModemStreamRTOS;
248 using BasicModemStreamRTOS::BasicModemStreamRTOS;
258 using BasicModemStreamRTOS::BasicModemStreamRTOS;
AX25Stream (APRS) which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:186
BasicModemStream which receives in a separate task (FreeRTOS on ESP32 and RP2040, a std::thread on th...
Definition ModemStreamRTOS.h:29
audio_tools::Mutex mutex
Definition ModemStreamRTOS.h:130
LockedQueue locked_queue
Definition ModemStreamRTOS.h:131
bool is_task_active
Definition ModemStreamRTOS.h:136
std::atomic< bool > is_idle
Definition ModemStreamRTOS.h:138
void receive()
One iteration of the receive task.
Definition ModemStreamRTOS.h:141
bool begin(Config cfg, int rx_buffer_size=256)
Definition ModemStreamRTOS.h:46
void setTaskConfig(int stack_size, int priority=1, int core=-1)
Definition ModemStreamRTOS.h:38
std::atomic< bool > is_running
Definition ModemStreamRTOS.h:137
int available() override
Definition ModemStreamRTOS.h:85
size_t readInputLocked()
Reads the available audio input and feeds it to the decoder.
Definition ModemStreamRTOS.h:151
typename Base::ReceiveQueue Queue
Definition ModemStreamRTOS.h:112
size_t update()
Not needed: the receive task processes the input.
Definition ModemStreamRTOS.h:101
int task_stack_size
Definition ModemStreamRTOS.h:132
int read() override
Definition ModemStreamRTOS.h:90
audio_tools::Task task
Definition ModemStreamRTOS.h:129
bool task_created
Definition ModemStreamRTOS.h:135
typename Base::ConfigType Config
Definition ModemStreamRTOS.h:32
~BasicModemStreamRTOS()
Definition ModemStreamRTOS.h:34
bool isRunning()
true while the receive task is running
Definition ModemStreamRTOS.h:104
void end()
Stops the receive task and the modem.
Definition ModemStreamRTOS.h:74
int peek() override
Definition ModemStreamRTOS.h:95
int task_core
Definition ModemStreamRTOS.h:134
static constexpr int DEFAULT_STACK_SIZE
Definition ModemStreamRTOS.h:110
int task_priority
Definition ModemStreamRTOS.h:133
CSSStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:236
DTMFStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:256
GGWaveStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:216
MFSKStream (multi-tone FSK) which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:176
ModemStream (FSK) which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:166
MorseStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:246
OFDMStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:206
OliviaStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:226
PSKStream which receives in a separate task. See BasicModemStreamRTOS.
Definition ModemStreamRTOS.h:196
TinyModem: software audio modems and packets with error correction.
Definition AX25.h:11
Print which writes the decoded data into the queue with a lock.
Definition ModemStreamRTOS.h:115
Queue * p_queue
Definition ModemStreamRTOS.h:116
audio_tools::MutexBase * p_mutex
Definition ModemStreamRTOS.h:117
size_t write(uint8_t ch) override
Definition ModemStreamRTOS.h:118
size_t write(const uint8_t *data, size_t len) override
Definition ModemStreamRTOS.h:122