mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-16 10:47:21 -05:00
Migrate Call Alert Beeper to New Event Function; Ring different tones on voice start, end, and data calls; #287
Fix and Tweak Calloc Size to the size_t of Event_History * 600 total events (little extra overhead) ;
This commit is contained in:
@@ -1336,7 +1336,7 @@ void dmr_cspdu (dsd_opts * opts, dsd_state * state, uint8_t cs_pdu_bits[], uint8
|
|||||||
void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]);
|
void dmr_slco (dsd_opts * opts, dsd_state * state, uint8_t slco_bits[]);
|
||||||
uint8_t dmr_cach (dsd_opts * opts, dsd_state * state, uint8_t cach_bits[25]);
|
uint8_t dmr_cach (dsd_opts * opts, dsd_state * state, uint8_t cach_bits[25]);
|
||||||
uint32_t dmr_34(uint8_t * input, uint8_t treturn[18]); //simplier trellis decoder
|
uint32_t dmr_34(uint8_t * input, uint8_t treturn[18]); //simplier trellis decoder
|
||||||
void beeper (dsd_opts * opts, dsd_state * state, int lr); //the tone beeper function
|
void beeper (dsd_opts * opts, dsd_state * state, int lr, int id, int ad, int len);
|
||||||
void dmr_gateway_identifier (uint32_t source, uint32_t target); //translate special addresses
|
void dmr_gateway_identifier (uint32_t source, uint32_t target); //translate special addresses
|
||||||
|
|
||||||
//Embedded Alias and GPS reports
|
//Embedded Alias and GPS reports
|
||||||
|
|||||||
@@ -1320,7 +1320,16 @@
|
|||||||
state->dmr_color_code = 16;
|
state->dmr_color_code = 16;
|
||||||
state->dmr_t3_syscode = 0;
|
state->dmr_t3_syscode = 0;
|
||||||
|
|
||||||
state->event_history_s = calloc(1, 10000000000); //TODO: tweak this size later on
|
//TODO: Test this in different environments before pushing it out
|
||||||
|
state->event_history_s = calloc(600, sizeof(Event_History)); //600 items at the size of the Event_History struct
|
||||||
|
|
||||||
|
//debug
|
||||||
|
// fprintf (stderr, "allocated size of event history struct: %ld bytes; \n", 600 * sizeof(Event_History));
|
||||||
|
|
||||||
|
if (state->event_history_s == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "memory allocation failure! \n");
|
||||||
|
}
|
||||||
|
|
||||||
//initialize event history items (0 to 255)
|
//initialize event history items (0 to 255)
|
||||||
for (uint8_t i = 0; i < 2; i++)
|
for (uint8_t i = 0; i < 2; i++)
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ char * DMRBusrtTypes[32] = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Sorry Remus :(
|
void beeper (dsd_opts * opts, dsd_state * state, int lr, int id, int ad, int len)
|
||||||
void beeper (dsd_opts * opts, dsd_state * state, int lr)
|
|
||||||
{
|
{
|
||||||
UNUSED(state);
|
UNUSED(state);
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
@@ -156,14 +155,14 @@ void beeper (dsd_opts * opts, dsd_state * state, int lr)
|
|||||||
n = 0; //rolling sine wave 'degree'
|
n = 0; //rolling sine wave 'degree'
|
||||||
|
|
||||||
//each j increment is 20 ms at 160 samples / 8 kHz
|
//each j increment is 20 ms at 160 samples / 8 kHz
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < len; j++)
|
||||||
{
|
{
|
||||||
//'zero' out stereo mix samples
|
//'zero' out stereo mix samples
|
||||||
memset (samp_fs, 0.1f, sizeof(samp_fs));
|
memset (samp_fs, 0.1f, sizeof(samp_fs));
|
||||||
memset (samp_ss, 0, sizeof(samp_ss));
|
memset (samp_ss, 0, sizeof(samp_ss));
|
||||||
|
|
||||||
//generate a tone (ID=45, AD=103, rolling n value)
|
//generate a tone (ID=45, AD=103, rolling n value)
|
||||||
soft_tonef(samp_f, n, 45, 103);
|
soft_tonef(samp_f, n, id, ad);
|
||||||
|
|
||||||
//convert float to short if required
|
//convert float to short if required
|
||||||
if (opts->floating_point == 0)
|
if (opts->floating_point == 0)
|
||||||
@@ -2224,10 +2223,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
sprintf (alias_ch[9], "%s", "");
|
sprintf (alias_ch[9], "%s", "");
|
||||||
sprintf (state->str50a, "%s", "");
|
sprintf (state->str50a, "%s", "");
|
||||||
|
|
||||||
if (opts->call_alert == 1)
|
// if (opts->call_alert == 1)
|
||||||
{
|
// {
|
||||||
beeper (opts, state, 0);
|
// beeper (opts, state, 0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2260,12 +2259,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
call_matrix[9][4] = dcc;
|
call_matrix[9][4] = dcc;
|
||||||
call_matrix[9][5] = time(NULL);
|
call_matrix[9][5] = time(NULL);
|
||||||
|
|
||||||
if (opts->call_alert == 1 && rd != 0 && tg != 0)
|
// if (opts->call_alert == 1 && rd != 0 && tg != 0)
|
||||||
{
|
// {
|
||||||
//fprintf (stderr, "BEEP 0 MS LEFT\n");
|
// //fprintf (stderr, "BEEP 0 MS LEFT\n");
|
||||||
beeper (opts, state, 0);
|
// beeper (opts, state, 0);
|
||||||
state->dmr_end_alert[0] = 0; //new voice frame, okay to beep at the end of it
|
// state->dmr_end_alert[0] = 0; //new voice frame, okay to beep at the end of it
|
||||||
}
|
// }
|
||||||
|
|
||||||
memset(state->dmr_alias_block_segment[0], 0, sizeof(state->dmr_alias_block_segment[0]));
|
memset(state->dmr_alias_block_segment[0], 0, sizeof(state->dmr_alias_block_segment[0]));
|
||||||
sprintf (state->dmr_embedded_gps[0], "%s", "");
|
sprintf (state->dmr_embedded_gps[0], "%s", "");
|
||||||
@@ -2293,12 +2292,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
call_matrix[4][4] = dcc;
|
call_matrix[4][4] = dcc;
|
||||||
call_matrix[4][5] = time(NULL);
|
call_matrix[4][5] = time(NULL);
|
||||||
|
|
||||||
if (opts->call_alert == 1 && rd != 0 && tg != 0)
|
// if (opts->call_alert == 1 && rd != 0 && tg != 0)
|
||||||
{
|
// {
|
||||||
//fprintf (stderr, "BEEP 0 BS LEFT\n");
|
// //fprintf (stderr, "BEEP 0 BS LEFT\n");
|
||||||
beeper (opts, state, 0);
|
// beeper (opts, state, 0);
|
||||||
state->dmr_end_alert[0] = 0; //new voice frame, okay to beep at the end of it
|
// state->dmr_end_alert[0] = 0; //new voice frame, okay to beep at the end of it
|
||||||
}
|
// }
|
||||||
|
|
||||||
memset(state->dmr_alias_block_segment[0], 0, sizeof(state->dmr_alias_block_segment[0]));
|
memset(state->dmr_alias_block_segment[0], 0, sizeof(state->dmr_alias_block_segment[0]));
|
||||||
sprintf (state->dmr_embedded_gps[0], "%s", "");
|
sprintf (state->dmr_embedded_gps[0], "%s", "");
|
||||||
@@ -2326,12 +2325,12 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
call_matrix[9][4] = dcc;
|
call_matrix[9][4] = dcc;
|
||||||
call_matrix[9][5] = time(NULL);
|
call_matrix[9][5] = time(NULL);
|
||||||
|
|
||||||
if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
|
// if (opts->call_alert == 1 && rdR != 0 && tgR != 0)
|
||||||
{
|
// {
|
||||||
//fprintf (stderr, "BEEP 1 BS RIGHT\n");
|
// //fprintf (stderr, "BEEP 1 BS RIGHT\n");
|
||||||
beeper (opts, state, 1);
|
// beeper (opts, state, 1);
|
||||||
state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
|
// state->dmr_end_alert[1] = 0; //new voice frame, okay to beep at the end of it
|
||||||
}
|
// }
|
||||||
|
|
||||||
memset(state->dmr_alias_block_segment[1], 0, sizeof(state->dmr_alias_block_segment[1]));
|
memset(state->dmr_alias_block_segment[1], 0, sizeof(state->dmr_alias_block_segment[1]));
|
||||||
sprintf (state->dmr_embedded_gps[1], "%s", "");
|
sprintf (state->dmr_embedded_gps[1], "%s", "");
|
||||||
@@ -2358,10 +2357,10 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
|||||||
call_matrix[9][4] = nc;
|
call_matrix[9][4] = nc;
|
||||||
call_matrix[9][5] = time(NULL);
|
call_matrix[9][5] = time(NULL);
|
||||||
|
|
||||||
if (opts->call_alert == 1)
|
// if (opts->call_alert == 1)
|
||||||
{
|
// {
|
||||||
beeper (opts, state, 0);
|
// beeper (opts, state, 0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4881,6 +4880,10 @@ void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//call alert beep when new call detected
|
||||||
|
if (last_source_id == 0 && source_id != 0 && opts->call_alert == 1)
|
||||||
|
beeper (opts, state, slot, 45, 103, 3);
|
||||||
|
|
||||||
if (source_id != last_source_id && last_source_id != 0)
|
if (source_id != last_source_id && last_source_id != 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -4907,6 +4910,10 @@ void watchdog_event_history (dsd_opts * opts, dsd_state * state, uint8_t slot)
|
|||||||
memset(state->dstar_gps, 0, sizeof(state->dstar_gps));
|
memset(state->dstar_gps, 0, sizeof(state->dstar_gps));
|
||||||
memset(state->dstar_txt, 0, sizeof(state->dstar_txt));
|
memset(state->dstar_txt, 0, sizeof(state->dstar_txt));
|
||||||
state->gi[slot] = -1; //return to an unset value
|
state->gi[slot] = -1; //return to an unset value
|
||||||
|
|
||||||
|
//end of voice call alert
|
||||||
|
if (opts->call_alert == 1)
|
||||||
|
beeper (opts, state, slot, 35, 103, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5410,4 +5417,8 @@ void watchdog_event_datacall (dsd_opts * opts, dsd_state * state, uint32_t src,
|
|||||||
free (datestr);
|
free (datestr);
|
||||||
datestr = NULL;
|
datestr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//call alert on data calls
|
||||||
|
if (opts->call_alert)
|
||||||
|
beeper (opts, state, slot, 25, 103, 3); //TODO: Find good souding Tone ID and AD values
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user