# HG changeset patch # User Mychaela Falconia # Date 1729843948 0 # Node ID 599fac1b882df24c475785a4f7f38a282596fb8a # Parent b3f04535eb146850ca3b5c4ebe2d83ff7d65c6cd pathloss: implement FSL diff -r b3f04535eb14 -r 599fac1b882d pathloss/Makefile --- a/pathloss/Makefile Fri Oct 25 07:42:53 2024 +0000 +++ b/pathloss/Makefile Fri Oct 25 08:12:28 2024 +0000 @@ -1,12 +1,12 @@ CC= gcc CFLAGS= -O2 PROG= pathloss -OBJS= main.o +OBJS= fsl.o main.o all: ${PROG} ${PROG}: ${OBJS} - ${CC} -o $@ ${OBJS} + ${CC} -o $@ ${OBJS} -lm clean: rm -f *.o ${PROG} diff -r b3f04535eb14 -r 599fac1b882d pathloss/fsl.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pathloss/fsl.c Fri Oct 25 08:12:28 2024 +0000 @@ -0,0 +1,16 @@ +/* + * Free Space Loss calculation + */ + +#define _GNU_SOURCE +#include +#include "range_func.h" + +#define PI_f ((float) M_PI) + +float rf_range_freespace(float freq_mhz, float path_loss) +{ + float wavelen = 300.0f / freq_mhz; + + return (wavelen / pow10f(path_loss / -20.0f)) / (PI_f * 4.0f); +} diff -r b3f04535eb14 -r 599fac1b882d pathloss/main.c --- a/pathloss/main.c Fri Oct 25 07:42:53 2024 +0000 +++ b/pathloss/main.c Fri Oct 25 08:12:28 2024 +0000 @@ -8,6 +8,7 @@ #include #include #include +#include "range_func.h" #define MAX_FIELDS 5 static char linebuf[256], *fields[MAX_FIELDS]; @@ -269,6 +270,10 @@ path_loss_ul = ms_power + bts_ant_gain - bts_rxs - misc_loss; printf("Path loss budget: %.2f dB DL, %.2f dB UL\n", path_loss_dl, path_loss_ul); - /* distance calculations will go here */ + /* distance per various models */ + printf("FSL: %.2f m DL, %.2f m UL\n", + rf_range_freespace(freq_dl, path_loss_dl), + rf_range_freespace(freq_ul, path_loss_ul)); + /* Egli and Hata coming next */ exit(0); } diff -r b3f04535eb14 -r 599fac1b882d pathloss/range_func.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pathloss/range_func.h Fri Oct 25 08:12:28 2024 +0000 @@ -0,0 +1,5 @@ +/* + * Declarations for RF range functions + */ + +float rf_range_freespace(float freq_mhz, float path_loss);