1 #include "AudioTools/CoreAudio/Buffers.h"
29 int32_t spi_speed = 8E6;
31 int frequency = 868E6;
34 int spreading_factor = 12;
35 int signal_bandwidth =
41 bool process_audio_info =
true;
71 buffer.resize(cfg.max_size);
72 LoRa.setSignalBandwidth(cfg.signal_bandwidth);
73 LoRa.setSpreadingFactor(cfg.spreading_factor);
74 LoRa.setTxPower(cfg.tx_power);
75 LoRa.setSPIFrequency(cfg.spi_speed);
76 LoRa.setPins(cfg.pin_ss, cfg.pin_rst, cfg.pin_dio0);
77 LoRa.setSyncWord(cfg.sync_word);
78 bool rc = LoRa.begin(cfg.frequency);
79 if (cfg.process_audio_info) {
85 void end() { LoRa.end(); }
87 size_t readBytes(uint8_t* data,
size_t len) {
89 size_t packetSize = LoRa.parsePacket();
90 if (cfg.process_audio_info && packetSize ==
sizeof(AudioInfo)) {
92 packetSize = LoRa.parsePacket();
94 int toRead = min(len, packetSize);
95 int read = LoRa.readBytes(data, toRead);
99 int available() {
return cfg.max_size; }
101 int availableForWrite() {
return cfg.max_size; }
103 size_t write(
const uint8_t* data,
size_t len) {
105 for (
int j = 0; j < len; j++) {
106 buffer.
write(data[j]);
119 SingleBuffer<uint8_t> buffer;
121 void readAudioInfo() {
123 int read = LoRa.readBytes((uint8_t*)&tmp,
sizeof(AudioInfo));
127 void writeAudioInfo() {
130 LoRa.write((uint8_t*)&ai,
sizeof(ai));