Skip to content

Commit

Permalink
Merge pull request #698 from zarya/talkeralias
Browse files Browse the repository at this point in the history
Added TA to netmon-4
  • Loading branch information
sijskes committed Feb 17, 2017
2 parents f082d02 + 355b9cd commit 5f65c19
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 25 deletions.
30 changes: 23 additions & 7 deletions applet/src/etsi.c
Expand Up @@ -6,10 +6,11 @@
#define DEBUG

#include "etsi.h"

#include "debug.h"

struct TAContext taContext;
struct TAContext talkerAlias;


inline const char* get_flco_str( lc_t *lc )
{
Expand Down Expand Up @@ -66,25 +67,30 @@ void dump_full_lc( lc_t *lc )

PRINT("flco=%02x %s fid=%d svc=%d src=%d dst=%d\n",flco,get_flco_str(lc), fid,opts,get_adr(lc->src),get_adr(lc->dst));

if (flco == 0 && fid == 0x00 && taContext.src != get_adr(lc->src))
{
memset(&taContext, 0, sizeof(taContext)); //Clear TA context
memset(&talkerAlias, 0, sizeof(talkerAlias)); //Clear TA context
taContext.src = (uint32_t)get_adr(lc->src);
}

//Read TA Header from full LC
if (flco == 4 && fid == 0x00)
{
memset(&taContext, 0, sizeof(taContext)); //Clear TA context
struct TAHeader* header = (struct TAHeader*)lc; //Copy LC over TA struct
taContext.format = (header->options >> 6) & 0x03;
taContext.length = (header->options >> 1) & 0x1f;

//Read first 6 bytes of TA
char* destination = taContext.text;
memcpy(destination, header->text, 6);

//Calculate amount of TA blocks
const uint8_t table[] =
{
7, 15, 23, 32,
7, 15, 23, 31,
6, 13, 20, 27,
6, 13, 20, 27,
3, 7, 11, 15
3, 6, 10, 13
};
uint8_t length = taContext.length;
const uint8_t* row = table + taContext.format * 4;
Expand All @@ -100,11 +106,16 @@ void dump_full_lc( lc_t *lc )
{
if (taContext.format == 1 || taContext.format == 2)
{
PRINT("TA (%d): %s\n", taContext.length, taContext.text);
PRINT("TA %d (%d): %s\n", taContext.src, taContext.length, taContext.text);
if (talkerAlias.src != taContext.src)
{
talkerAlias = taContext;
}
}
else
{
PRINT("TA Unsupported format: %s", get_ta_type_str(taContext.format));
talkerAlias.length = 0;
}
}
}
Expand All @@ -125,11 +136,16 @@ void dump_full_lc( lc_t *lc )
{
if (taContext.format == 1 || taContext.format == 2)
{
PRINT("TA (%d): %s\n", taContext.length, taContext.text);
PRINT("TA %d (%d): %s\n", taContext.src, taContext.length, taContext.text);
if (talkerAlias.src != taContext.src)
{
talkerAlias = taContext;
}
}
else
{
PRINT("TA Unsupported format: %s", get_ta_type_str(taContext.format));
talkerAlias.length = 0;
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions applet/src/etsi.h
Expand Up @@ -150,9 +150,14 @@ struct TAContext
uint8_t length;
uint8_t blocks;
uint8_t marked;
uint8_t displayed;
uint32_t src;
char text[28];
};

struct TAContext taContext;
extern struct TAContext talkerAlias;

#ifdef __cplusplus
}
#endif
Expand Down
46 changes: 30 additions & 16 deletions applet/src/netmon.c
Expand Up @@ -21,10 +21,13 @@
#include "codeplug.h"
#include "unclear.h"
#include "usersdb.h"
#include "etsi.h"

uint8_t nm_screen = 0 ;
uint8_t nm_started = 0 ;
uint8_t rx_voice = 0 ;
uint8_t call_start_state = 0;
uint8_t previous_call_state = 0;

char progress_info[] = { "|/-\\" } ;
int progress = 0 ;
Expand Down Expand Up @@ -256,37 +259,48 @@ void netmon4_update()
{
#if defined(FW_D13_020) || defined(FW_S13_020)
lastheard_draw_poll();

int src;
static int lh_cnt = 0 ; // lastheard line counter

if ( nm_started == 0 ) {
lastheard_printf("Netmon 4 - Lastheard ====\n");
nm_started = 1; // flag for restart of LH list
lh_cnt = 1; // reset lh counter
lastheard_printf("Netmon 4 - Lastheard ====\n");
nm_started = 1; // flag for restart of LH list
lh_cnt = 1; // reset lh counter
}

char mode = ' ' ;
if( rst_voice_active != previous_call_state && rst_voice_active)
{
call_start_state = 1;
talkerAlias.displayed = 0;
}
previous_call_state = rst_voice_active;

if( rst_voice_active ) {
if( rst_mycall ) {
mode = '*' ; // on my tg
} else {
mode = '!' ; // on other tg
}
src = rst_src;
user_t usr;
src = rst_src;
user_t usr;


if( ( src != 0 ) && ( rx_voice == 1 ) ) {
//lastheard_printf("%d",lh_cnt++);
print_time_hook() ;
if( usr_find_by_dmrid(&usr, src) == 0 ) {
lastheard_printf("=%d->%d %c\n", src, rst_dst, mode);
} else {
lastheard_printf("=%s->%d %c\n", usr.callsign, rst_dst, mode);
if( ( src != 0 ) && ( rst_flco < 4 ) && call_start_state == 1 ) {
call_start_state = 0;
//lastheard_printf("%d",lh_cnt++);
print_time_hook() ;
if( usr_find_by_dmrid(&usr, src) == 0 ) {
lastheard_printf("=%d->%d %c\n", src, rst_dst, mode);
} else {
lastheard_printf("=%s->%d %c\n", usr.callsign, rst_dst, mode);
}
}
if ( talkerAlias.displayed != 1 && talkerAlias.length > 0 )
{
talkerAlias.displayed = 1;
lastheard_printf("TA: %s\n",talkerAlias.text);
}
rx_voice = 0 ; // call handled, wait until new voice call status received
}
}
#else
lastheard_printf("No lastheard available\n");
Expand Down
6 changes: 4 additions & 2 deletions applet/src/radiostate.c
Expand Up @@ -20,6 +20,7 @@ int rst_src = 0 ;
int rst_dst = 0 ;
int rst_grp = 0 ;
int rst_mycall = 0 ;
uint8_t rst_flco = 0;

int rst_hdr_sap ;
int rst_hdr_src ;
Expand All @@ -43,6 +44,7 @@ void rst_voice_lc_header(lc_t *lc)
if( !rst_voice_active || rst_src != src || rst_dst != dst) {
rst_src = src ;
rst_dst = dst ;
rst_flco = flco ;

PRINT("\n* Call from %d to %s%d started.\n", src, groupcall ? "group ":"", dst);

Expand All @@ -60,7 +62,7 @@ void rst_voice_lc_header(lc_t *lc)
LOGR("cs %c %d->%d\n", grp_c, src, dst );

rst_voice_active = 1 ;
rx_voice = 1 ; // flag for new voice call received
rx_voice = 1 ; // flag for new voice call received
}
}

Expand Down Expand Up @@ -88,7 +90,7 @@ void rst_term_with_lc(lc_t *lc)
LOGR("ce %c %d->%d\n", grp_c, src, dst );

rst_voice_active = 0 ;
rx_voice = 0 ; // flag for voice call ended
rx_voice = 0 ; // flag for voice call ended
}
}

Expand Down
1 change: 1 addition & 0 deletions applet/src/radiostate.h
Expand Up @@ -17,6 +17,7 @@ extern int rst_src ;
extern int rst_dst ;
extern int rst_grp ;
extern int rst_mycall ;
extern uint8_t rst_flco ;

extern uint8_t rx_voice ;

Expand Down

0 comments on commit 5f65c19

Please sign in to comment.