DEFINITION MODULE sondeaprs; (* encode demodulated sonde to aprs axudp by OE5DXL *)

FROM aprsstr IMPORT IPNUM, UDPPORT, POSITION;

TYPE TIME=CARDINAL;
     SDRBLOCK=RECORD
                freq,
                maxafc,
                db           : CARDINAL;
                afc          : INTEGER;
                name         : ARRAY[0..3] OF CHAR; 
                valid        : BOOLEAN;
     END;


CONST
  <* IF __GEN_C__ THEN *>
      VERSION="sondemod 1.37c";
  <* ELSE *>
      VERSION="sondemod(m) 1.37c";
  <* END *>

  minusG="G";
  minusE="E";
  minusP="P";
  minusa="a";
  LASTSECONDS=3600;            (* last seconds force sending count down tx on time *)
  BEFOREBURST=100000;

TYPE SATSIG=ARRAY[0..11] OF RECORD num, level:CARDINAL END;
     pSATSIG=POINTER TO SATSIG;
     pUDPDESTS=POINTER TO UDPDESTS;
     UDPDESTS=RECORD
       next:pUDPDESTS;
       ipnum:IPNUM;
       port:UDPPORT;
     END; 
     XDATA=RECORD
       cnt:CARDINAL;
       xdata:ARRAY[0..9] OF RECORD
         len:CARDINAL;
         frame:ARRAY[0..255] OF CHAR;
       END;
     END;
 
PROCEDURE senddata(lat, long, alt, speed, dir, clb, fakehp, hyg, temp,
                   ozon, otemp, pumpmA, pumpv, mhz, hrms, vrms:LONGREAL;
                   sattime, uptime:TIME;
                   objname:ARRAY OF CHAR;
                   almanachage, goodsats, txpower:CARDINAL;
                   vBatt:LONGREAL;
                   usercall:ARRAY OF CHAR;
                   calperc:CARDINAL;
                   hp:LONGREAL;
                   force, altnoegm:BOOLEAN;
                   txtime:INTEGER;
                   typstr, fullid:ARRAY OF CHAR;
                   satsigs:pSATSIG;
                   sdr:SDRBLOCK;
                   leapsecs:INTEGER;
                   xdata:XDATA);

PROCEDURE GetIp(h:ARRAY OF CHAR; VAR p:CARDINAL; VAR ip:CARDINAL; VAR port:CARDINAL):INTEGER;

VAR 
    via, destcall, objname:ARRAY[0..99] OF CHAR;
    commentfn, csvfilename:ARRAY[0..1024] OF CHAR;
    sym:ARRAY[0..1] OF CHAR;
    toport, maxsenddistance:CARDINAL;
    expire:TIME;
    ipnum:IPNUM; 
    verb, verb2, nofilter, json: BOOLEAN;
    comptyp,
    udpsock:INTEGER;
    anyip, sendmon, dao   : BOOLEAN;
    mypos                 : POSITION;
    myalt                 : REAL;
    beacontimes:ARRAY[0..19] OF RECORD
      beacontime,
      below:CARDINAL;
    END;
    rectfence:RECORD
                leftdown,
                rightup:POSITION;
             END;
    axudpdests,
    jsondests   :pUDPDESTS;


END sondeaprs.

