--- /dev/null
+#
+# Copyright (C) 2022 TDT AG <development@tdt.de>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+#
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=sx1302_hal
+PKG_VERSION:=2.1.0
+PKG_RELEASE:=$(AUTORELEASE)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/Lora-net/sx1302_hal/tar.gz/V$(PKG_VERSION)?
+PKG_HASH:=4b62aa6a83ad449c68fdd844fc35024586c9faabca3c5a90a2544735b380de5b
+
+PKG_MAINTAINER:=Marcus Schref <mschref@tdt.de>
+PKG_LICENSE:=MIT BSD-3-Clause
+PKG_LICENSE_FILES:=LICENSE.TXT
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/sx1302_hal/Default
+ SECTION:=libs
+ CATEGORY:=Libraries
+ SUBMENU:=IoT
+ TITLE:=SX1302/SX1303 HAL
+endef
+
+define Package/sx1302_hal-tests
+ $(call Package/sx1302_hal/Default)
+ TITLE+=(Tests)
+ DEPENDS:=+kmod-usb-acm
+endef
+
+define Package/sx1302_hal-tests/description
+ Tests for SX1302/SX1303 Hardware Abstraction Layer
+endef
+
+define Package/sx1302_hal-utils
+ $(call Package/sx1302_hal/Default)
+ TITLE+=(Utilities)
+ DEPENDS:=+kmod-usb-acm
+endef
+
+define Package/sx1302_hal-utils/description
+ Utilities for SX1302/SX1303 Hardware Abstraction Layer
+endef
+
+CFLAGS = $(TARGET_CFLAGS)
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR)/libtools \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+
+ $(MAKE) -C $(PKG_BUILD_DIR)/libloragw \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+
+ $(MAKE) -C $(PKG_BUILD_DIR)/util_boot \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+
+ $(MAKE) -C $(PKG_BUILD_DIR)/util_chip_id \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+
+ $(MAKE) -C $(PKG_BUILD_DIR)/util_net_downlink \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+
+ $(MAKE) -C $(PKG_BUILD_DIR)/util_spectral_scan \
+ CROSS_COMPILE="$(TARGET_CROSS)" \
+ ARCH="$(ARCH)"
+endef
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include
+ $(CP) $(PKG_BUILD_DIR)/libtools/inc/tinymt32.h $(1)/usr/include
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libtools/libtinymt32.a $(1)/usr/lib
+
+ $(INSTALL_DIR) $(1)/usr/include/lgw
+ $(CP) $(PKG_BUILD_DIR)/libloragw/inc/*.h $(1)/usr/include/lgw
+
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) $(PKG_BUILD_DIR)/libloragw/*.a $(1)/usr/lib
+endef
+
+define Package/sx1302_hal-tests/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/libloragw/test* $(1)/usr/bin
+endef
+
+define Package/sx1302_hal-utils/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/util_boot/boot $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/util_chip_id/chip_id $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/util_net_downlink/net_downlink \
+ $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/util_spectral_scan/spectral_scan \
+ $(1)/usr/bin
+endef
+
+$(eval $(call BuildPackage,sx1302_hal-tests))
+$(eval $(call BuildPackage,sx1302_hal-utils))
--- /dev/null
+From 389e8138f543baf334442ca52edf5f7b4cfe13dc Mon Sep 17 00:00:00 2001
+From: Marcus Schref <mschref@web.de>
+Date: Mon, 22 Aug 2022 10:02:13 +0200
+Subject: [PATCH] sx1302_hal: edit cflags
+
+Enable use of TARGET_CFLAGS in addition to specified CFLAGS
+
+Signed-off-by: Marcus Schref <mschref@web.de>
+---
+ libloragw/Makefile | 2 +-
+ libtools/Makefile | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/libloragw/Makefile
++++ b/libloragw/Makefile
+@@ -11,7 +11,7 @@ CROSS_COMPILE ?=
+ CC := $(CROSS_COMPILE)gcc
+ AR := $(CROSS_COMPILE)ar
+
+-CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. -I../libtools/inc
++CFLAGS += -O2 -Wall -Wextra -std=c99 -Iinc -I. -I../libtools/inc
+
+ OBJDIR = obj
+ INCLUDES = $(wildcard inc/*.h) $(wildcard ../libtools/inc/*.h)
+--- a/libtools/Makefile
++++ b/libtools/Makefile
+@@ -7,7 +7,7 @@ CROSS_COMPILE ?=
+ CC := $(CROSS_COMPILE)gcc
+ AR := $(CROSS_COMPILE)ar
+
+-CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
++CFLAGS += -O2 -Wall -Wextra -std=c99 -Iinc -I.
+
+ OBJDIR = obj
+ INCLUDES = $(wildcard inc/*.h)
--- /dev/null
+From a6ae15dc6709e32f0604b6eeb0f07cc50bde18b1 Mon Sep 17 00:00:00 2001
+From: Marcus Schref <mschref@web.de>
+Date: Mon, 22 Aug 2022 10:06:03 +0200
+Subject: [PATCH] sx1302_hal: add compatibility with basicstation
+
+Add LGW_LBT_ISSUE define used by Basicstation
+
+Signed-off-by: Marcus Schref <mschref@web.de>
+---
+ libloragw/inc/loragw_hal.h | 1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/libloragw/inc/loragw_hal.h
++++ b/libloragw/inc/loragw_hal.h
+@@ -45,6 +45,7 @@ License: Revised BSD License, see LICENS
+ #define LGW_HAL_SUCCESS 0
+ #define LGW_HAL_ERROR -1
+ #define LGW_LBT_NOT_ALLOWED 1
++#define LGW_LBT_ISSUE 1
+
+ /* radio-specific parameters */
+ #define LGW_XTAL_FREQU 32000000 /* frequency of the RF reference oscillator */