kopia lustrzana https://github.com/sp9skp/spdxl
ATMS,IMS
rodzic
0844a52796
commit
a63804f069
335
src/sondemod.c
335
src/sondemod.c
|
@ -58,6 +58,10 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
/* decode RS92, RS41, SRS-C34 and DFM06 Radiosonde by OE5DXL */
|
||||
/*FROM rsc IMPORT initrsc, decodersc; */
|
||||
#define sondemod_CONTEXTLIFE 3600
|
||||
|
@ -317,9 +321,7 @@ struct CONTEXTMP3 {
|
|||
char posok;
|
||||
char framesent;
|
||||
float freq;
|
||||
//uint32_t gpssecond;
|
||||
uint32_t prevgpstime;
|
||||
//uint32_t tused;
|
||||
uint32_t prevfrno;
|
||||
double prevalt,prevlon,prevlat;
|
||||
double vbat;
|
||||
|
@ -327,6 +329,46 @@ struct CONTEXTMP3 {
|
|||
};
|
||||
|
||||
|
||||
struct CONTEXTIMS;
|
||||
|
||||
typedef struct CONTEXTIMS * pCONTEXTIMS;
|
||||
|
||||
struct CONTEXTIMS {
|
||||
pCONTEXTIMS next;
|
||||
OBJNAME name;
|
||||
char posok;
|
||||
char framesent;
|
||||
float freq;
|
||||
uint16_t framenum;
|
||||
uint32_t prevgpstime;
|
||||
uint32_t prevfrno;
|
||||
double prevalt,prevlon,prevlat;
|
||||
double vbat;
|
||||
float snd;
|
||||
uint32_t tused;
|
||||
};
|
||||
|
||||
struct CONTEXTATMS;
|
||||
|
||||
typedef struct CONTEXTATMS * pCONTEXTATMS;
|
||||
|
||||
struct CONTEXTATMS {
|
||||
pCONTEXTATMS next;
|
||||
OBJNAME name;
|
||||
char posok;
|
||||
char framesent;
|
||||
float freq;
|
||||
uint16_t framenum;
|
||||
uint32_t prevgpstime;
|
||||
uint32_t prevfrno;
|
||||
double prevalt,prevlon,prevlat;
|
||||
double vbat;
|
||||
float snd;
|
||||
uint32_t tused;
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct CONTEXTPS;
|
||||
|
||||
typedef struct CONTEXTPS * pCONTEXTPS;
|
||||
|
@ -419,6 +461,8 @@ static pCONTEXTPS pcontextps;
|
|||
static pCONTEXTM10 pcontextm10;
|
||||
static pCONTEXTM20 pcontextm20;
|
||||
static pCONTEXTMP3 pcontextmp3;
|
||||
static pCONTEXTIMS pcontextims;
|
||||
static pCONTEXTATMS pcontextatms;
|
||||
|
||||
// SKP
|
||||
|
||||
|
@ -649,7 +693,7 @@ void saveMysql( char *name,uint32_t frameno, double lat, double lon, double alt
|
|||
strcpy(Pass,dbPass);
|
||||
str[0]=0;
|
||||
|
||||
sprintf( UDPbuf, "S0;1;5;0;%s;%lf;%lf;%5.1lf;%lu;%3.1f;%3.0f;%3.1f;%4.1f;%4.1f;%u;%i;%i;%i;%7.3f;%3.2f;%3.1f;%3.1f;%3.0f;%s",
|
||||
sprintf( UDPbuf, "S0;1;6;0;%s;%lf;%lf;%5.1lf;%lu;%3.1f;%3.0f;%3.1f;%4.1f;%4.1f;%u;%i;%i;%i;%7.3f;%3.2f;%3.1f;%3.1f;%3.0f;%s",
|
||||
name,lat,lon,alt,frameno,speed,dir,climb,press,ozon,swv,bk,typ,aux,frq,vbat,t1,t2,hum,mycall);
|
||||
|
||||
//wylicznie hasha
|
||||
|
@ -4167,6 +4211,289 @@ static void decodemp3(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t
|
|||
} /* end decodemp3() */
|
||||
|
||||
|
||||
static void decodeims(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t fromport)
|
||||
{
|
||||
CALLSSID usercall;
|
||||
double frq;
|
||||
OBJNAME nam;
|
||||
char tmps[20];
|
||||
uint8_t tmpD[155];
|
||||
uint32_t gpstime,frno;
|
||||
pCONTEXTIMS pc;
|
||||
pCONTEXTIMS pc0;
|
||||
pCONTEXTIMS pc1;
|
||||
int k;
|
||||
double dir;
|
||||
double v;
|
||||
double vv;
|
||||
double vn;
|
||||
double ve;
|
||||
double alt;
|
||||
double lon;
|
||||
double lat;
|
||||
uint32_t tmpf;
|
||||
char sntxt[12]={0,0};
|
||||
char frs[10];
|
||||
int calok=0;
|
||||
float *fcfg = (float *)&tmpf;
|
||||
double vH,freq;
|
||||
char nsend=0;
|
||||
|
||||
if(rxb[0]!='i' && rxb[0]!='I') return;
|
||||
if(rxb[0]=='i') { nsend=1;}
|
||||
|
||||
getcall(rxb+62, rxb_len-62, usercall, 11ul);
|
||||
|
||||
tmps[0]=rxb[68];
|
||||
tmps[1]=rxb[69];
|
||||
tmps[2]=rxb[70];
|
||||
tmps[3]='.';
|
||||
tmps[4]=rxb[71];
|
||||
tmps[5]=rxb[72];
|
||||
tmps[6]=rxb[73];
|
||||
tmps[7]=0;
|
||||
frq=atof(tmps);
|
||||
uint16_t ms,hm,dt;
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *gmtime(&t);
|
||||
struct tm tmfn = *gmtime(&t);
|
||||
int czas=tm.tm_mon + 1 + tm.tm_mday;
|
||||
|
||||
strncpy(nam,rxb,9);
|
||||
nam[9]=0;
|
||||
nam[0]='I';
|
||||
|
||||
strncpy(tmps,rxb+9,5);
|
||||
tmps[5]=0;
|
||||
frno=atol(tmps);
|
||||
|
||||
strncpy(tmps,rxb+14,7);
|
||||
tmps[7]=0;
|
||||
lat=atof(tmps)/100000;
|
||||
|
||||
strncpy(tmps,rxb+21,8);
|
||||
tmps[8]=0;
|
||||
lon=atof(tmps)/100000;
|
||||
|
||||
strncpy(tmps,rxb+29,5);
|
||||
tmps[5]=0;
|
||||
alt=atof(tmps);
|
||||
|
||||
strncpy(tmps,rxb+34,3);
|
||||
tmps[3]=0;
|
||||
dir=atoi(tmps);
|
||||
|
||||
strncpy(tmps,rxb+37,4);
|
||||
tmps[4]=0;
|
||||
vv=(atof(tmps)/10)-200.0;
|
||||
|
||||
strncpy(tmps,rxb+41,6);
|
||||
tmps[6]=0;
|
||||
freq=atof(tmps)/1000.0;
|
||||
|
||||
|
||||
pc = 0;
|
||||
|
||||
pc = pcontextims;
|
||||
pc0 = 0;
|
||||
for (;;) {
|
||||
if (pc==0) break;
|
||||
pc1 = pc->next;
|
||||
if (pc->tused+3600UL<systime) {
|
||||
|
||||
if (pc0==0) pcontextims = pc1;
|
||||
else pc0->next = pc1;
|
||||
osic_free((char * *) &pc, sizeof(struct CONTEXTIMS));
|
||||
}
|
||||
else {
|
||||
if (aprsstr_StrCmp(nam, 10ul, pc->name, 10ul)) break;
|
||||
pc0 = pc;
|
||||
}
|
||||
pc = pc1;
|
||||
}
|
||||
if (pc==0) {
|
||||
osic_alloc((char * *) &pc, sizeof(struct CONTEXTIMS));
|
||||
if (pc==0) Error("allocate context out im memory", 31ul);
|
||||
memset((char *)pc,(char)0,sizeof(struct CONTEXTIMS));
|
||||
pc->next = pcontextims;
|
||||
pcontextims = pc;
|
||||
aprsstr_Assign(pc->name, 10ul, nam, 10ul);
|
||||
if (sondeaprs_verb) osi_WrStrLn("is new ", 8ul);
|
||||
}
|
||||
|
||||
if (frno > pc->framenum) {
|
||||
pc->framesent = 0;
|
||||
calok = 1;
|
||||
pc->framenum = frno;
|
||||
pc->tused = systime;
|
||||
}
|
||||
else if (pc->framenum==frno) {
|
||||
if (!pc->framesent) calok = 1;
|
||||
}
|
||||
else if (sondeaprs_verb) {
|
||||
osi_WrStr(" got old frame ", 16ul);
|
||||
osic_WrINT32(frno, 1UL);
|
||||
osi_WrStr(" expected> ", 12ul);
|
||||
osic_WrINT32(pc->framenum, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
}
|
||||
|
||||
if(freq>=400.0) frq=freq;
|
||||
|
||||
if (pc && lat>0 && lat<90 && lon<90 && lon>0 && alt<45000 ) {
|
||||
|
||||
if (sondeaprs_verb)
|
||||
printf("IMS: (%s) %s,%08lu,%09.5f,%010.5f,%05.0f,%03.0f,%05.1f,%05.1f, %3.3f\n",usercall,pc->name,pc->framenum,lat,lon,alt,dir,v,vv,frq);
|
||||
if(saveLog) save_Slog( pc->name,pc->framenum,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,v,dir,vv,ST_IMS,0,0,0,0,0.0,frq,0,0,0,0);
|
||||
|
||||
if(pc->name[0]=='I'){
|
||||
if(nsend==0) store_sonde_db( pc->name,pc->framenum,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,v,dir,vv,ST_IMS,0,0,0,0,0.0,frq,0,0,0,0);
|
||||
store_sonde_rs( pc->name,pc->framenum,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,v,dir,vv,ST_IMS,0,0,0,0,0.0,frq,0,0,0,0,usercall);
|
||||
pc->framesent = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void decodeatms(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t fromport)
|
||||
{
|
||||
CALLSSID usercall;
|
||||
double frq;
|
||||
OBJNAME nam;
|
||||
char tmps[10];
|
||||
uint8_t tmpD[155];
|
||||
uint32_t gpstime,frno;
|
||||
pCONTEXTIMS pc;
|
||||
pCONTEXTIMS pc0;
|
||||
pCONTEXTIMS pc1;
|
||||
int k;
|
||||
double alt;
|
||||
double lon;
|
||||
double lat;
|
||||
uint32_t tmpf;
|
||||
char sntxt[12]={0,0};
|
||||
char frs[10];
|
||||
int calok=0;
|
||||
float *fcfg = (float *)&tmpf;
|
||||
double freq;
|
||||
int d,m,y,hr,mn,sec;
|
||||
uint16_t tmp,sn;
|
||||
uint64_t tmpl;
|
||||
|
||||
|
||||
getcall(rxb+62, rxb_len-62, usercall, 11ul); //decode callsign from table
|
||||
|
||||
tmps[0]=rxb[68];
|
||||
tmps[1]=rxb[69];
|
||||
tmps[2]=rxb[70];
|
||||
tmps[3]='.';
|
||||
tmps[4]=rxb[71];
|
||||
tmps[5]=rxb[72];
|
||||
tmps[6]=rxb[73];
|
||||
tmps[7]=0;
|
||||
frq=atof(tmps);
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *gmtime(&t);
|
||||
struct tm tmfn = *gmtime(&t);
|
||||
int czas=tm.tm_mon + 1 + tm.tm_mday;
|
||||
|
||||
strncpy(nam,rxb,9);
|
||||
nam[9]=0;
|
||||
|
||||
strncpy(tmps,rxb+ 9,2); tmps[2]=0; y=atoi(tmps);
|
||||
strncpy(tmps,rxb+11,2); tmps[2]=0; m=atoi(tmps);
|
||||
strncpy(tmps,rxb+13,2); tmps[2]=0; d=atoi(tmps);
|
||||
strncpy(tmps,rxb+15,2); tmps[2]=0; hr=atoi(tmps);
|
||||
strncpy(tmps,rxb+17,2); tmps[2]=0; mn=atoi(tmps);
|
||||
strncpy(tmps,rxb+19,2); tmps[2]=0; sec=atoi(tmps);
|
||||
|
||||
strncpy(tmps,rxb+21,5);
|
||||
tmps[5]=0;
|
||||
alt=atof(tmps);
|
||||
|
||||
strncpy(tmps,rxb+26,7);
|
||||
tmps[7]=0;
|
||||
lat=atof(tmps)/100000;
|
||||
|
||||
strncpy(tmps,rxb+33,8);
|
||||
tmps[8]=0;
|
||||
lon=atof(tmps)/100000;
|
||||
|
||||
frno=sec+60*mn+3600*hr+86400*m;
|
||||
|
||||
|
||||
pc = 0;
|
||||
|
||||
pc = pcontextatms;
|
||||
pc0 = 0;
|
||||
for (;;) {
|
||||
if (pc==0) break;
|
||||
pc1 = pc->next;
|
||||
if (pc->tused+3600UL<systime) {
|
||||
|
||||
if (pc0==0) pcontextatms = pc1;
|
||||
else pc0->next = pc1;
|
||||
osic_free((char * *) &pc, sizeof(struct CONTEXTATMS));
|
||||
}
|
||||
else {
|
||||
if (aprsstr_StrCmp(nam, 9ul, pc->name, 9ul)) break;
|
||||
pc0 = pc;
|
||||
}
|
||||
pc = pc1;
|
||||
}
|
||||
if (pc==0) {
|
||||
osic_alloc((char * *) &pc, sizeof(struct CONTEXTATMS));
|
||||
if (pc==0) Error("allocate context out im memory", 31ul);
|
||||
memset((char *)pc,(char)0,sizeof(struct CONTEXTATMS));
|
||||
pc->next = pcontextatms;
|
||||
pcontextatms = pc;
|
||||
aprsstr_Assign(pc->name, 9ul, nam, 9ul);
|
||||
if (sondeaprs_verb) osi_WrStrLn("is new ", 8ul);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (frno > pc->framenum) {
|
||||
pc->framesent = 0;
|
||||
calok = 1;
|
||||
pc->framenum = frno;
|
||||
pc->tused = systime;
|
||||
}
|
||||
else if (pc->framenum==frno) {
|
||||
if (!pc->framesent) calok = 1;
|
||||
}
|
||||
else if (sondeaprs_verb) {
|
||||
osi_WrStr(" got old frame ", 16ul);
|
||||
osic_WrINT32(frno, 1UL);
|
||||
osi_WrStr(" expected> ", 12ul);
|
||||
osic_WrINT32(pc->framenum, 1UL);
|
||||
osi_WrStr(" ", 2ul);
|
||||
}
|
||||
|
||||
|
||||
if (pc && lat>0 && lat<90 && lon>0 && alt<45000 ) {
|
||||
|
||||
if (sondeaprs_verb)
|
||||
printf("ATMS: (%s) %s,%08lu,%09.5f,%010.5f alt:%05.0f f:%06.3f\n",usercall,pc->name,frno,lat,lon,alt,frq);
|
||||
store_sonde_db( pc->name,frno,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,0,0,0,ST_ATMS,0,0,0,0,0.0,frq,0,0,0,0);
|
||||
store_sonde_rs( pc->name,frno,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,0,0,0,ST_ATMS,0,0,0,0,0.0,frq,0,0,0,0,usercall);
|
||||
if(saveLog) save_Slog( pc->name,frno,lat* 1.7453292519943E-2,lon* 1.7453292519943E-2,alt,0,0,0,ST_ATMS,0,0,0,0,0.0,frq,0,0,0,0);
|
||||
pc->framesent = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void decodeskpp(const char rxb[], uint32_t rxb_len, uint32_t ip, uint32_t fromport){
|
||||
|
||||
char ToHash[300];
|
||||
|
@ -4224,6 +4551,8 @@ static void udprx(void)
|
|||
case 100: decodem20(chan[sondemod_LEFT].rxbuf, 520ul, ip, fromport); break;
|
||||
case 61: decodepils(chan[sondemod_LEFT].rxbuf, 520ul, ip, fromport); break;
|
||||
case 115: decodemp3(chan[sondemod_LEFT].rxbuf, 115ul, ip, fromport); break;
|
||||
case 74: decodeims(chan[sondemod_LEFT].rxbuf, 66ul, ip, fromport); break;
|
||||
case 73: decodeatms(chan[sondemod_LEFT].rxbuf, 65ul, ip, fromport); break;
|
||||
case SKPFRL: decodeskpp(chan[sondemod_LEFT].rxbuf, 115ul, ip, fromport); break;
|
||||
|
||||
default: fprintf(stderr,"unsupported frame len %d\n", len);
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#define ST_DFM15 15
|
||||
#define ST_DFM17 17
|
||||
#define ST_IMS 18
|
||||
#define ST_ATMS 19
|
||||
|
||||
#define ST_MP3 20
|
||||
#define ST_SKP 40
|
||||
|
|
1173
src/sondeudp.c
1173
src/sondeudp.c
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue