changeset 66:599fac1b882d

pathloss: implement FSL
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 25 Oct 2024 08:12:28 +0000
parents b3f04535eb14
children d8ccdccd8b2b
files pathloss/Makefile pathloss/fsl.c pathloss/main.c pathloss/range_func.h
diffstat 4 files changed, 29 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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}
--- /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 <math.h>
+#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);
+}
--- 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 <stdlib.h>
 #include <string.h>
 #include <strings.h>
+#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);
 }
--- /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);