shajen / rtl-sdr-scanner-cpp

GNU General Public License v3.0
614 stars 62 forks source link

Sending frequency, time and file name to SQL database #5

Closed GarryCZ closed 2 years ago

GarryCZ commented 2 years ago

Hi, your project is amazing. It works absolutely great. But I would have a query, I would need to write data (frequency, file name and time) to the SQL database (for example via http request) Could you please advise me? Thank you so much

shajen commented 2 years ago

Hi, good place to do this is Recorder::start. You should replace line

m_mp3Writer = std::make_unique<Mp3Writer>(m_config, frequency, mp3SampleRate);

with

if (m_mp3Writer) {
  addToDb(m_mp3Writer->getFrequency(), m_mp3Writer->getFilename(), m_mp3Writer->getTime());
}
m_mp3Writer = std::make_unique<Mp3Writer>(m_config, frequency, mp3SampleRate);

You should implement addToDb method with any db/http library you want and add getFrequency, getFilename, getTime getter to Mp3Writer class.

Another way to do this is add similar code in Mp3Writer::~Mp3Writer().

GarryCZ commented 2 years ago

thank you so much, i will try.

GarryCZ commented 2 years ago

hi, i wrote it in mp3_writer and it already works for me. thank you very much

D0han commented 1 year ago

@GarryCZ will you publish that code? Create PR maybe?