Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pybombs support. Add SoapySDR support #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
cmake_minimum_required(VERSION 3.9)
project(ice9-bluetooth)
INCLUDE(FindPkgConfig)

# Install to PyBOMBS target prefix if defined
if(DEFINED ENV{PYBOMBS_PREFIX})
set(CMAKE_INSTALL_PREFIX $ENV{PYBOMBS_PREFIX})
set(PYBOMBS_PREFIX $ENV{PYBOMBS_PREFIX})
message(STATUS "PyBOMBS installed GNU Radio. Setting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}")
endif()

set (CMAKE_CXX_STANDARD 17)

Expand Down Expand Up @@ -34,6 +42,7 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

# Add required dependencies
find_package(SoapySDR REQUIRED)
find_package(HackRF REQUIRED)
find_package(BladeRF REQUIRED)
find_package(UHD REQUIRED)
Expand Down Expand Up @@ -70,6 +79,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE)

include_directories(${PROJECT_SOURCE_DIR})
include_directories(${SOAPYSDR_INCLUDE_DIR})
include_directories(${LIBHACKRF_INCLUDE_DIR})
include_directories(${LIBBLADERF_INCLUDE_DIR})
include_directories(${UHD_INCLUDE_DIR})
Expand All @@ -81,6 +91,7 @@ set(SOURCES
${PROJECT_SOURCE_DIR}/btbb/btbb.c
${PROJECT_SOURCE_DIR}/burst_catcher.c
${PROJECT_SOURCE_DIR}/fsk.c
${PROJECT_SOURCE_DIR}/soapysdr.c
${PROJECT_SOURCE_DIR}/hackrf.c
${PROJECT_SOURCE_DIR}/hash.c
${PROJECT_SOURCE_DIR}/help.c
Expand All @@ -91,6 +102,8 @@ set(SOURCES
${PROJECT_SOURCE_DIR}/window.c

${PROJECT_SOURCE_DIR}/main.c
soapysdr.c
soapysdr.h
)

if(USE_VKFFT)
Expand Down Expand Up @@ -130,6 +143,7 @@ target_link_libraries(ice9-bluetooth
PRIVATE Threads::Threads
m
${LIBHACKRF_LIBRARIES}
${SOAPYSDR_LIBRARIES}
${LIBBLADERF_LIBRARIES}
${UHD_LIBRARIES}
${LIQUID_LIBRARIES}
Expand Down
4 changes: 3 additions & 1 deletion cmake/Modules/FindBladeRF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ find_path(LIBBLADERF_INCLUDE_DIR
NAMES libbladeRF.h
HINTS
${LIBBLADERF_DIR}/include
${PYBOMBS_PREFIX}/include
${PC_LIBBLADERF_INCLUDEDIR}
${PC_LIBBLADERF_INCLUDE_DIRS}
/opt/homebrew/include
Expand All @@ -27,6 +28,7 @@ find_library(LIBBLADERF_LIBRARY
HINTS
$ENV{LIBBLADERF_DIR}/lib
${PC_LIBBLADERF_LIBDIR}
${PYBOMBS_PREFIX}/lib
${PC_LIBBLADERF_LIBRARY_DIRS}
/opt/homebrew/lib
/opt/local/lib
Expand Down Expand Up @@ -63,4 +65,4 @@ mark_as_advanced(
)

set(LIBBLADERF_INCLUDE_DIRS ${LIBBLADERF_INCLUDE_DIR})
set(LIBBLADERF_LIBRARIES ${LIBBLADERF_LIBRARY})
set(LIBBLADERF_LIBRARIES ${LIBBLADERF_LIBRARY})
2 changes: 1 addition & 1 deletion cmake/Modules/FindFFTW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if( FFTW_ROOT )
find_library(
FFTW_DOUBLE_LIB
NAMES "fftw3" libfftw3-3
PATHS ${FFTW_ROOT}
PATHS ${FFTW_ROOT} ${PYBOMBS_PREFIX}
PATH_SUFFIXES "lib" "lib64"
NO_DEFAULT_PATH
)
Expand Down
4 changes: 3 additions & 1 deletion cmake/Modules/FindHackRF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ find_path(LIBHACKRF_INCLUDE_DIR
$ENV{LIBHACKRF_DIR}/include
${PC_LIBHACKRF_INCLUDEDIR}
${PC_LIBHACKRF_INCLUDE_DIRS}
${PYBOMBS_PREFIX}/include/libhackrf
/opt/homebrew/include
/opt/local/include
/home/linuxbrew/.linuxbrew/include
Expand All @@ -28,6 +29,7 @@ find_library(LIBHACKRF_LIBRARY
NAMES hackrf
HINTS
$ENV{LIBHACKRF_DIR}/lib
${PYBOMBS_PREFIX}/lib
${PC_LIBHACKRF_LIBDIR}
${PC_LIBHACKRF_LIBRARY_DIRS}
/opt/homebrew/lib
Expand Down Expand Up @@ -65,4 +67,4 @@ mark_as_advanced(
)

set(LIBHACKRF_INCLUDE_DIRS ${LIBHACKRF_INCLUDE_DIR})
set(LIBHACKRF_LIBRARIES ${LIBHACKRF_LIBRARY})
set(LIBHACKRF_LIBRARIES ${LIBHACKRF_LIBRARY})
4 changes: 3 additions & 1 deletion cmake/Modules/FindLiquid.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ find_path(LIQUID_INCLUDE_DIR
${LIQUID_DIR}/include
${PC_LIQUID_INCLUDEDIR}
${PC_LIQUID_INCLUDE_DIRS}
${PYBOMBS_PREFIX}/include/liquid
/opt/homebrew/include
/home/linuxbrew/.linuxbrew/include
/opt/local/include
Expand All @@ -28,6 +29,7 @@ find_library(LIQUID_LIBRARY
NAMES liquid
HINTS
$ENV{LIQUID_DIR}/lib
${PYBOMBS_PREFIX}/lib
${PC_LIQUID_LIBDIR}
${PC_LIQUID_LIBRARY_DIRS}
/opt/homebrew/lib
Expand Down Expand Up @@ -65,4 +67,4 @@ mark_as_advanced(
)

set(LIQUID_INCLUDE_DIRS ${LIQUID_INCLUDE_DIR})
set(LIQUID_LIBRARIES ${LIQUID_LIBRARY})
set(LIQUID_LIBRARIES ${LIQUID_LIBRARY})
33 changes: 33 additions & 0 deletions cmake/Modules/FindSoapySDR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
message(STATUS "FINDING SOAPY.")
if(NOT SOAPYSDR_FOUND)
pkg_check_modules (SOAPYSDR_PKG SoapySDR)

find_path(SOAPYSDR_INCLUDE_DIRS
NAMES SoapySDR/Device.h
HINTS $ENV{SOAPY_DIR}/include ${PYBOMBS_PREFIX}/include/SoapySDR
PATHS ${SOAPYSDR_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)

find_library(SOAPYSDR_LIBRARIES
NAMES SoapySDR
HINTS $ENV{SOAPY_DIR}/lib ${PYBOMBS_PREFIX}/lib
PATHS ${SOAPYSDR_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
/usr/lib/arm-linux-gnueabihf
)


if(SOAPYSDR_INCLUDE_DIRS AND SOAPYSDR_LIBRARIES)
set(SOAPYSDR_FOUND TRUE CACHE INTERNAL "libSOAPYSDR found")
message(STATUS "Found libSOAPYSDR: ${SOAPYSDR_INCLUDE_DIRS}, ${SOAPYSDR_LIBRARIES}")
else(SOAPYSDR_INCLUDE_DIRS AND SOAPYSDR_LIBRARIES)
set(SOAPYSDR_FOUND FALSE CACHE INTERNAL "libSOAPYSDR found")
message(STATUS "libSOAPYSDR not found.")
endif(SOAPYSDR_INCLUDE_DIRS AND SOAPYSDR_LIBRARIES)

mark_as_advanced(SOAPYSDR_LIBRARIES SOAPYSDR_INCLUDE_DIRS)

endif(NOT SOAPYSDR_FOUND)
4 changes: 3 additions & 1 deletion cmake/Modules/FindUHD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ find_path(UHD_INCLUDE_DIR
NAMES uhd/config.hpp
HINTS
${UHD_DIR}/include
${PYBOMBS_PREFIX}/include
${PC_UHD_INCLUDEDIR}
${PC_UHD_INCLUDE_DIRS}
/opt/homebrew/include
Expand All @@ -26,6 +27,7 @@ find_library(UHD_LIBRARY
NAMES uhd
HINTS
${UHD_DIR}/lib
${PYBOMBS_PREFIX}/lib
${PC_UHD_LIBDIR}
${PC_UHD_LIBRARY_DIRS}
/opt/homebrew/lib
Expand Down Expand Up @@ -63,4 +65,4 @@ mark_as_advanced(
)

set(UHD_INCLUDE_DIRS ${UHD_INCLUDE_DIR})
set(UHD_LIBRARIES ${UHD_LIBRARY})
set(UHD_LIBRARIES ${UHD_LIBRARY})
2 changes: 1 addition & 1 deletion fsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int cfo_median(fsk_demod_t *fsk, float *demod, unsigned burst_len, float

// find the median of the positive and negative points
for (i = 8; i < 8 + median_size(); ++i) {
if (fabsf(demod[i]) > max_freq_offset)
if (fabsf((float)demod[i]) > max_freq_offset)
return 0;
if (demod[i] > 0)
fsk->pos_points[pos_count++] = demod[i];
Expand Down
13 changes: 12 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <liquid/liquid.h>

#include "bladerf.h"
#include "soapysdr.h"
#include "bluetooth.h"
#include "btbb/btbb.h"
#include "burst_catcher.h"
Expand Down Expand Up @@ -57,6 +58,7 @@ FILE *in = NULL;
char *serial = NULL;
char *usrp_serial = NULL;
int bladerf_num = -1;
int soapysdr_num = -1;
int verbose = 0;
int stats = 0;

Expand Down Expand Up @@ -523,8 +525,9 @@ int main(int argc, char **argv) {
// char *out_filename = NULL;
hackrf_device *hackrf = NULL;
struct bladerf *bladerf = NULL;
struct SoapySDRDevice *soapysdr = NULL;
uhd_usrp_handle usrp = NULL;
pthread_t bladerf_thread, usrp_thread;
pthread_t bladerf_thread, usrp_thread, soapysdr_thread;

signal(SIGINT, sig);
signal(SIGTERM, sig);
Expand All @@ -542,6 +545,8 @@ int main(int argc, char **argv) {
bladerf = bladerf_setup(bladerf_num);
else if (usrp_serial != NULL)
usrp = usrp_setup(usrp_serial);
else if (soapysdr_num >= 0)
soapysdr = soapysdr_setup(soapysdr_num);
else
hackrf = hackrf_setup();
}
Expand Down Expand Up @@ -577,6 +582,8 @@ int main(int argc, char **argv) {
hackrf_start_rx(hackrf, hackrf_rx_cb, NULL);
else if (usrp != NULL)
pthread_create(&usrp_thread, NULL, usrp_stream_thread, (void *)usrp);
else if (soapysdr != NULL)
pthread_create(&soapysdr_thread, NULL, soapysdr_stream_thread, (void *)soapysdr);
else
pthread_create(&bladerf_thread, NULL, bladerf_stream_thread, (void *)bladerf);
}
Expand All @@ -593,6 +600,8 @@ int main(int argc, char **argv) {
hackrf_stop_rx(hackrf);
else if (usrp != NULL)
; // do nothing (stream is stopped in thread)
else if (soapysdr != NULL)
; // do nothing (stream is stopped in thread)
else
bladerf_enable_module(bladerf, BLADERF_MODULE_RX, false);
}
Expand All @@ -606,6 +615,8 @@ int main(int argc, char **argv) {
} else if (usrp != NULL) {
pthread_join(usrp_thread, NULL);
usrp_close(usrp);
} else if (soapysdr != NULL) {
pthread_join(soapysdr_thread, NULL);
} else {
pthread_join(bladerf_thread, NULL);
bladerf_close(bladerf);
Expand Down
7 changes: 6 additions & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

#include "hackrf.h"
#include "bladerf.h"
#include "soapysdr.h"
#include "pcap.h"
#include "usrp.h"

extern FILE *in;
extern char *serial;
extern char *usrp_serial;
extern int bladerf_num;
extern int soapysdr_num;

extern float samp_rate;
extern unsigned channels;
Expand Down Expand Up @@ -86,6 +88,7 @@ static void _print_interfaces(void) {
hackrf_list();
bladerf_list();
usrp_list();
soapysdr_list();
exit(0);
}

Expand Down Expand Up @@ -148,8 +151,10 @@ void parse_options(int argc, char **argv) {
bladerf_num = atoi(optarg + strlen("bladerf"));
else if (strstr(optarg, "usrp-") == optarg)
usrp_serial = strdup(usrp_get_serial(optarg));
else if (strstr(optarg, "soapy-") == optarg)
soapysdr_num = atoi(optarg + strlen("soapy-"));
else
errx(1, "invalid interface, must start with \"hackrf-\" or \"bladerf\"");
errx(1, "invalid interface, must start with \"hackrf-\" or \"bladerf\" or \"soapy-\"");
break;

case 'w':
Expand Down
Loading
Loading