lora-gateway-hal: Add package lora-gateway

Add a package for the Semtech lora-gateway-hal.
This package includes three sub packages which
are libloragw, lora-gateway-tests and lora-gateway-utils.

Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
This commit is contained in:
Xue Liu 2018-08-19 13:24:30 +02:00
parent 23efd1f3f1
commit e2ce890a31
5 changed files with 684 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# libloragw configuration
if PACKAGE_libloragw
config SX1301_SPI_PATH
string "SPI Dev Path"
default /dev/spidev0.0
config SX1301_SPI_SPEED
string "SPI Speed (Hz)"
default 8000000
endif

View File

@ -0,0 +1,95 @@
#
# Copyright (C) 2019 Xue Liu <liuxuenetmail@gmail>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=lora-gateway-hal
PKG_VERSION:=5.0.1
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://codeload.github.com/Lora-net/lora_gateway/tar.gz/v$(PKG_VERSION)?
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_HASH:=1a0447d5e8183d08e6dce5f739f6872b9c57824b98f4078830d5ee21b15782c1
PKG_MAINTAINER:=Xue Liu <liuxuenetmail@gmail.com>
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DIR:=$(BUILD_DIR)/lora_gateway-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/libloragw
SECTION:=libs
CATEGORY:=Libraries
TITLE:=Driver/HAL library for Semtech SX1301
URL:=https://www.semtech.com/products/wireless-rf/lora-gateways/sx1301
DEPENDS:=+kmod-spi-dev @(!PACKAGE_lora-picogw-hal)
endef
define Package/libloragw/description
Driver/HAL library for Semtech SX1301 multi-channel modem and
SX1257/SX1255 RF transceivers.
endef
define Package/libloragw/config
source "$(SOURCE)/Config.in"
endef
define Package/libloragw-tests
SECTION:=net
CATEGORY:=Network
SUBMENU:=LoRaWAN
TITLE:=Test programs for libloragw to check functionality
DEPENDS:=+libloragw
endef
define Package/libloragw-utils
SECTION:=net
CATEGORY:=Network
SUBMENU:=LoRaWAN
TITLE:=Utility programs for libloragw
DEPENDS:=+libloragw
endef
CMAKE_OPTIONS += \
-DSPI_DEV_PATH:FILEPATH=$(CONFIG_SX1301_SPI_PATH) \
-DSPI_SPEED:STRING=$(CONFIG_SX1301_SPI_SPEED) \
-Dlora_gateway_build_shared_libs=ON
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include/libloragw
$(CP) $(PKG_BUILD_DIR)/libloragw/inc/loragw_* $(1)/usr/include/libloragw
$(CP) $(PKG_BUILD_DIR)/libloragw/config.h $(1)/usr/include/libloragw
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libloragw/libloragw.so* $(1)/usr/lib/
$(LN) libloragw.so.0 $(1)/usr/lib/libloragw.so
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_BUILD_DIR)/loragw.pc $(1)/usr/lib/pkgconfig/
endef
define Package/libloragw/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libloragw/libloragw.so.* $(1)/usr/lib/
endef
define Package/libloragw-tests/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libloragw/test* $(1)/usr/sbin
endef
define Package/libloragw-utils/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_lbt_test $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_pkt_logger $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_spectral_scan $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_tx_continuous $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_spi_stress $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/util_tx_test $(1)/usr/sbin
endef
$(eval $(call BuildPackage,libloragw))
$(eval $(call BuildPackage,libloragw-tests))
$(eval $(call BuildPackage,libloragw-utils))

View File

@ -0,0 +1,496 @@
From d49e5ea2988b2086c7deaa40d3e077531e449844 Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxuenetmail@gmail.com>
Date: Thu, 21 Feb 2019 00:27:42 +0100
Subject: [PATCH 1/3] - add cmake support
Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
---
CMakeLists.txt | 77 +++++++++++++++
cmake/loragw-config.cmake | 1 +
libloragw/CMakeLists.txt | 150 ++++++++++++++++++++++++++++++
libloragw/loragw.pc.in | 10 ++
libloragw/loragw_config.h.in | 14 +++
util_lbt_test/CMakeLists.txt | 23 +++++
util_pkt_logger/CMakeLists.txt | 29 ++++++
util_spectral_scan/CMakeLists.txt | 23 +++++
util_spi_stress/CMakeLists.txt | 23 +++++
util_tx_continuous/CMakeLists.txt | 23 +++++
util_tx_test/CMakeLists.txt | 23 +++++
11 files changed, 396 insertions(+)
create mode 100644 CMakeLists.txt
create mode 100644 cmake/loragw-config.cmake
create mode 100644 libloragw/CMakeLists.txt
create mode 100644 libloragw/loragw.pc.in
create mode 100644 libloragw/loragw_config.h.in
create mode 100644 util_lbt_test/CMakeLists.txt
create mode 100644 util_pkt_logger/CMakeLists.txt
create mode 100644 util_spectral_scan/CMakeLists.txt
create mode 100644 util_spi_stress/CMakeLists.txt
create mode 100644 util_tx_continuous/CMakeLists.txt
create mode 100644 util_tx_test/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..b112150
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,77 @@
+# -- Minimum required version
+cmake_minimum_required (VERSION 3.2)
+
+# -- Project name
+project (lora_gateway)
+
+# -- Various includes
+include (CMakePackageConfigHelpers)
+include (GNUInstallDirs)
+include (CheckFunctionExists)
+
+# -- set c99 standard default
+set(CMAKE_C_STANDARD 99)
+
+# -- options for shared lib (defaults off)
+option(lora_gateway_build_shared_libs "build as a shared library" OFF)
+set(BUILD_SHARED_LIBS ${lora_gateway_build_shared_libs})
+
+# -- Required to build
+set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+find_package(Threads REQUIRED)
+
+# -- Versioning with git tag
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+ execute_process(
+ COMMAND git describe --tags --always
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ OUTPUT_VARIABLE "lora_gateway_VERSION"
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(lora_gateway_VERSION STREQUAL "")
+ set(lora_gateway_VERSION 0)
+ endif(lora_gateway_VERSION STREQUAL "")
+ message( STATUS "Git full version: ${lora_gateway_VERSION}" )
+ execute_process(
+ COMMAND /bin/bash -c "git describe --tags --abbrev=0 | cut --delimiter='v' --fields=2"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ OUTPUT_VARIABLE "lora_gateway_VERSION_SHORT"
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(lora_gateway_VERSION_SHORT STREQUAL "")
+ set(lora_gateway_VERSION_SHORT 0)
+ endif(lora_gateway_VERSION_SHORT STREQUAL "")
+ message( STATUS "Git version: ${lora_gateway_VERSION_SHORT}" )
+else(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+ set(lora_gateway_VERSION_SHORT 0)
+ set(lora_gateway_VERSION 0)
+endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+if (NOT (${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" ) )
+ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+endif()
+
+# -- add the core library
+add_subdirectory(libloragw)
+
+# -- add util_lbt_test
+add_subdirectory(util_lbt_test)
+
+# -- add util_pkt_logger
+add_subdirectory(util_pkt_logger)
+
+# -- add util_pkt_logger
+add_subdirectory(util_spectral_scan)
+
+# -- add util_spi_stress
+add_subdirectory(util_spi_stress)
+
+# -- add util_tx_continuous
+add_subdirectory(util_tx_continuous)
+
+# -- add util_tx_test
+add_subdirectory(util_tx_test)
diff --git a/cmake/loragw-config.cmake b/cmake/loragw-config.cmake
new file mode 100644
index 0000000..ee8687b
--- /dev/null
+++ b/cmake/loragw-config.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/loragw-targets.cmake")
diff --git a/libloragw/CMakeLists.txt b/libloragw/CMakeLists.txt
new file mode 100644
index 0000000..b2102ae
--- /dev/null
+++ b/libloragw/CMakeLists.txt
@@ -0,0 +1,150 @@
+set(TARGET loragw)
+
+add_library(${TARGET} "")
+
+# -- add additional debug options
+# Set the DEBUG_* to 1 to activate debug mode in individual modules.
+# Warning: that makes the module *very verbose*, do not use for production
+option(DEBUG_AUX "Active debug mode in AUX module" OFF)
+option(DEBUG_SPI "Active debug mode in SPI module" OFF)
+option(DEBUG_REG "Active debug mode in REG module" OFF)
+option(DEBUG_HAL "Active debug mode in HAL module" OFF)
+option(DEBUG_GPIO "Active debug mode in GPIO module" OFF)
+option(DEBUG_LBT "Active debug mode in LBT module" OFF)
+option(DEBUG_GPS "Active debug mode in GPS module" OFF)
+
+message("-- Build with debug AUX: ${DEBUG_AUX}")
+message("-- Build with debug SPI: ${DEBUG_SPI}")
+message("-- Build with debug REG: ${DEBUG_REG}")
+message("-- Build with debug HAL: ${DEBUG_HAL}")
+message("-- Build with debug GPIO: ${DEBUG_GPIO}")
+message("-- Build with debug LBT: ${DEBUG_LBT}")
+message("-- Build with debug GPS: ${DEBUG_GPS}")
+
+# -- add the compile options
+target_compile_options(
+ ${TARGET}
+ PRIVATE
+ -Werror
+ -Wall
+ -Wextra
+)
+
+target_sources(${TARGET}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_aux.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_fpga.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_gps.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_hal.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_lbt.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_radio.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_reg.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_spi.native.c
+)
+
+# -- add the public headers
+set (${TARGET}_PUBLIC_HEADERS
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_aux.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_fpga.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_gps.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_hal.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_lbt.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_radio.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_reg.h
+)
+
+target_include_directories(${TARGET}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+ PUBLIC
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
+)
+
+configure_file(${CMAKE_CURRENT_LIST_DIR}/${TARGET}_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
+
+target_link_libraries(${TARGET}
+ PUBLIC
+ Threads::Threads
+ m
+)
+
+set_target_properties(${TARGET} PROPERTIES VERSION ${lora_gateway_VERSION_SHORT})
+set_target_properties(${TARGET} PROPERTIES SOVERSION ${lora_gateway_VERSION_SHORT})
+set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/config.h;${${TARGET}_PUBLIC_HEADERS}")
+
+# -- add the install targets
+install (TARGETS ${TARGET}
+ EXPORT ${TARGET}_targets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET}
+)
+
+# -- add pkg config file
+configure_file ("${CMAKE_CURRENT_LIST_DIR}/${TARGET}.pc.in" "${PROJECT_BINARY_DIR}/${TARGET}.pc" @ONLY)
+install (FILES ${PROJECT_BINARY_DIR}/${TARGET}.pc DESTINATION lib/pkgconfig)
+
+# -- write cmake package config file
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake"
+ VERSION ${lora_gateway_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+export(EXPORT ${TARGET}_targets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-targets.cmake"
+ NAMESPACE Semtech::
+)
+
+configure_file(${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config.cmake"
+ COPYONLY
+)
+
+set(ConfigPackageLocation lib/cmake/${TARGET})
+
+install(EXPORT ${TARGET}_targets
+ FILE ${TARGET}-targets.cmake
+ NAMESPACE Semtech::
+ DESTINATION ${ConfigPackageLocation}
+)
+
+install(
+ FILES ${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake"
+ DESTINATION ${ConfigPackageLocation}
+ COMPONENT Devel
+)
+
+# -- add test programs
+foreach(TEST test_loragw_spi test_loragw_gps test_loragw_reg test_loragw_hal test_loragw_cal)
+ add_executable(${TEST} "")
+
+ target_sources(${TEST}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/tst/${TEST}.c
+ )
+
+ target_include_directories(${TEST}
+ PRIVATE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ target_link_libraries(${TEST}
+ PRIVATE
+ loragw
+ )
+
+ install (
+ TARGETS ${TEST}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+
+endforeach()
+
diff --git a/libloragw/loragw.pc.in b/libloragw/loragw.pc.in
new file mode 100644
index 0000000..01bb3cf
--- /dev/null
+++ b/libloragw/loragw.pc.in
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include/libloragw
+libdir=${prefix}/lib
+
+Name: LIBLORAGW
+Description: BLANK_TEXT
+Version: @lora_gateway_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lloragw
diff --git a/libloragw/loragw_config.h.in b/libloragw/loragw_config.h.in
new file mode 100644
index 0000000..76ad35a
--- /dev/null
+++ b/libloragw/loragw_config.h.in
@@ -0,0 +1,14 @@
+#ifndef _LORAGW_CONFIGURATION_H
+#define _LORAGW_CONFIGURATION_H
+
+#define LIBLORAGW_VERSION "@lora_gateway_VERSION_SHORT@"
+
+#cmakedefine01 DEBUG_AUX
+#cmakedefine01 DEBUG_SPI
+#cmakedefine01 DEBUG_REG
+#cmakedefine01 DEBUG_HAL
+#cmakedefine01 DEBUG_GPS
+#cmakedefine01 DEBUG_GPIO
+#cmakedefine01 DEBUG_LBT
+
+#endif
diff --git a/util_lbt_test/CMakeLists.txt b/util_lbt_test/CMakeLists.txt
new file mode 100644
index 0000000..f184b82
--- /dev/null
+++ b/util_lbt_test/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_lbt_test "")
+target_sources(util_lbt_test
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_lbt_test.c
+)
+
+target_link_libraries(util_lbt_test
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_lbt_test PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_lbt_test
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/util_pkt_logger/CMakeLists.txt b/util_pkt_logger/CMakeLists.txt
new file mode 100644
index 0000000..82cfc86
--- /dev/null
+++ b/util_pkt_logger/CMakeLists.txt
@@ -0,0 +1,29 @@
+
+add_executable(util_pkt_logger "")
+target_sources(util_pkt_logger
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_pkt_logger.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/parson.c
+)
+
+target_include_directories(util_pkt_logger
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+)
+
+target_link_libraries(util_pkt_logger
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_pkt_logger PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_pkt_logger
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/util_spectral_scan/CMakeLists.txt b/util_spectral_scan/CMakeLists.txt
new file mode 100644
index 0000000..3cec2a9
--- /dev/null
+++ b/util_spectral_scan/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_spectral_scan "")
+target_sources(util_spectral_scan
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_spectral_scan.c
+)
+
+target_link_libraries(util_spectral_scan
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_spectral_scan PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_spectral_scan
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/util_spi_stress/CMakeLists.txt b/util_spi_stress/CMakeLists.txt
new file mode 100644
index 0000000..d5f0eea
--- /dev/null
+++ b/util_spi_stress/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_spi_stress "")
+target_sources(util_spi_stress
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_spi_stress.c
+)
+
+target_link_libraries(util_spi_stress
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_spi_stress PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_spi_stress
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/util_tx_continuous/CMakeLists.txt b/util_tx_continuous/CMakeLists.txt
new file mode 100644
index 0000000..97c70e5
--- /dev/null
+++ b/util_tx_continuous/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_tx_continuous "")
+target_sources(util_tx_continuous
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_continuous.c
+)
+
+target_link_libraries(util_tx_continuous
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_tx_continuous PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_tx_continuous
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
diff --git a/util_tx_test/CMakeLists.txt b/util_tx_test/CMakeLists.txt
new file mode 100644
index 0000000..6cc0e04
--- /dev/null
+++ b/util_tx_test/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_tx_test "")
+target_sources(util_tx_test
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_test.c
+)
+
+target_link_libraries(util_tx_test
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_tx_test PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_tx_test
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--
2.20.1

View File

@ -0,0 +1,35 @@
From ea2a7752295ab734464c2877e1f484a9bf08d58d Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxuenetmail@gmail.com>
Date: Sun, 24 Feb 2019 01:03:48 +0100
Subject: [PATCH 2/3] - add preprocessing for SPI_DEV_PATH and SPI_SPEED
Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
---
libloragw/src/loragw_spi.native.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libloragw/src/loragw_spi.native.c b/libloragw/src/loragw_spi.native.c
index c01ed1c..fe251e3 100644
--- a/libloragw/src/loragw_spi.native.c
+++ b/libloragw/src/loragw_spi.native.c
@@ -53,8 +53,15 @@ Maintainer: Sylvain Miermont
#define READ_ACCESS 0x00
#define WRITE_ACCESS 0x80
-#define SPI_SPEED 8000000
-#define SPI_DEV_PATH "/dev/spidev0.0"
+
+#ifndef SPI_SPEED
+#error SPI_SPEED is not defined
+#endif
+
+#ifndef SPI_DEV_PATH
+#error SPI_DEV_PATH is not defined
+#endif
+
//#define SPI_DEV_PATH "/dev/spidev32766.0"
/* -------------------------------------------------------------------------- */
--
2.20.1

View File

@ -0,0 +1,45 @@
From 81cd227c04ccb615cffaaa7b6372affb7964df2e Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxuenetmail@gmail.com>
Date: Sun, 24 Feb 2019 01:04:29 +0100
Subject: [PATCH 3/3] - add SPI_DEV_PATH and SPI_SPEED to cmake
Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
---
libloragw/CMakeLists.txt | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libloragw/CMakeLists.txt b/libloragw/CMakeLists.txt
index b2102ae..32abf51 100644
--- a/libloragw/CMakeLists.txt
+++ b/libloragw/CMakeLists.txt
@@ -13,6 +13,9 @@ option(DEBUG_GPIO "Active debug mode in GPIO module" OFF)
option(DEBUG_LBT "Active debug mode in LBT module" OFF)
option(DEBUG_GPS "Active debug mode in GPS module" OFF)
+set(SPI_DEV_PATH "/dev/spidev0.0" CACHE FILEPATH "Path of spi-dev")
+set(SPI_SPEED 8000000 CACHE STRING "SPI clock frequency")
+
message("-- Build with debug AUX: ${DEBUG_AUX}")
message("-- Build with debug SPI: ${DEBUG_SPI}")
message("-- Build with debug REG: ${DEBUG_REG}")
@@ -20,6 +23,8 @@ message("-- Build with debug HAL: ${DEBUG_HAL}")
message("-- Build with debug GPIO: ${DEBUG_GPIO}")
message("-- Build with debug LBT: ${DEBUG_LBT}")
message("-- Build with debug GPS: ${DEBUG_GPS}")
+message("-- Build with SPI_DEV_PATH: ${SPI_DEV_PATH}")
+message("-- Build with SPI_SPEED: ${SPI_SPEED}")
# -- add the compile options
target_compile_options(
@@ -28,6 +33,8 @@ target_compile_options(
-Werror
-Wall
-Wextra
+ -DSPI_DEV_PATH="${SPI_DEV_PATH}"
+ -DSPI_SPEED=${SPI_SPEED}
)
target_sources(${TARGET}
--
2.20.1