Skip to content

Commit

Permalink
Updating Logic to add a timer for every second
Browse files Browse the repository at this point in the history
New timer to support new modules
  • Loading branch information
Dloranger committed Feb 2, 2018
1 parent 380e533 commit fdf94a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/svxlink/svxlink/Logic.cpp
Expand Up @@ -645,6 +645,11 @@ bool Logic::initialize(void)
timeoutNextMinute();
every_minute_timer.start();

every_second_timer.setExpireOffset(100);
every_second_timer.expired.connect(mem_fun(*this, &Logic::everySecond));
timeoutNextSecond();
every_second_timer.start();

dtmf_digit_handler = new DtmfDigitHandler;
dtmf_digit_handler->commandComplete.connect(
mem_fun(*this, &Logic::putCmdOnQueue));
Expand Down Expand Up @@ -1484,6 +1489,22 @@ void Logic::everyMinute(AtTimer *t)
timeoutNextMinute();
} /* Logic::everyMinute */

void Logic::timeoutNextSecond(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm *tm = localtime(&tv.tv_sec);
tm->tm_min += 0;
tm->tm_sec += 1;
every_second_timer.setTimeout(*tm);
} /* Logic::timeoutNextSecond */


void Logic::everySecond(AtTimer *t)
{
processEvent("every_second");
timeoutNextSecond();
} /* Logic::everySecond */

void Logic::dtmfDigitDetectedP(char digit, int duration)
{
Expand Down
3 changes: 3 additions & 0 deletions src/svxlink/svxlink/Logic.h
Expand Up @@ -253,6 +253,7 @@ class Logic : public LogicBase
Async::AudioSplitter *logic_con_in;
CmdParser cmd_parser;
Async::AtTimer every_minute_timer;
Async::AtTimer every_second_timer;
Async::AudioRecorder *recorder;
Async::AudioMixer *tx_audio_mixer;
Async::AudioAmp *fx_gain_ctrl;
Expand Down Expand Up @@ -291,7 +292,9 @@ class Logic : public LogicBase
void putCmdOnQueue(void);
void sendRgrSound(void);
void timeoutNextMinute(void);
void timeoutNextSecond(void);
void everyMinute(Async::AtTimer *t);
void everySecond(Async::AtTimer *t);
void checkIfOnlineCmd(void);
void dtmfDigitDetectedP(char digit, int duration);
void cleanup(void);
Expand Down

0 comments on commit fdf94a6

Please sign in to comment.