Skip to content

Commit 41ff43d

Browse files
committed
adding hackrf support
1 parent df7e06c commit 41ff43d

17 files changed

+603
-130
lines changed

CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,21 @@ FIND_PACKAGE( BLAS REQUIRED )
5050
FIND_PACKAGE( LAPACK REQUIRED )
5151
FIND_PACKAGE( FFTW REQUIRED )
5252
INCLUDE_DIRECTORIES("${FFTW_INCLUDE_DIR}")
53+
5354
FIND_PACKAGE( RTLSDR REQUIRED )
5455
INCLUDE_DIRECTORIES("${RTLSDR_INCLUDE_DIR}")
56+
57+
FIND_PACKAGE( HACKRF )
58+
IF ( HACKRF_FOUND )
59+
INCLUDE_DIRECTORIES("${HACKRF_INCLUDE_DIR}")
60+
MESSAGE(STATUS "Found HACKRF: ${HACKRF_LIBRARIES}")
61+
SET( HAVE_HACKRF "HAVE_HACKRF")
62+
ELSE ( HACKRF_FOUND )
63+
MESSAGE(STATUS "HACKRF not found")
64+
SET( HAVE_HACKRF "NO_HACKRF")
65+
ENDIF ( HACKRF_FOUND )
66+
67+
5568
FIND_PACKAGE( Curses REQUIRED )
5669
INCLUDE_DIRECTORIES("${CURSES_INCLUDE_DIR}")
5770

cmake/Modules/FindHACKRF.cmake

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# - Find HACKRF
2+
# Find the native HACKRF includes and library
3+
# This module defines
4+
# HACKRF_INCLUDE_DIR, where to find rtlsdr.h, etc.
5+
# HACKRF_LIBRARIES, the libraries needed to use HACKRF.
6+
# HACKRF_FOUND, If false, do not try to use HACKRF.
7+
# also defined, but not for general use are
8+
# HACKRF_LIBRARY, where to find the HACKRF library.
9+
10+
#MESSAGE("HACKRF_DIR set to ${HACKRF_DIR}" )
11+
12+
FIND_PATH(HACKRF_INCLUDE_DIR hackrf.h
13+
${HACKRF_DIR}/include
14+
/usr/local/include/libhackrf
15+
)
16+
17+
FIND_LIBRARY(HACKRF_LIBRARY
18+
NAMES hackrf
19+
PATHS ${HACKRF_DIR}/libs
20+
"${HACKRF_DIR}\\win32\\lib"
21+
/usr/pkgs64/lib
22+
/usr/lib64
23+
/usr/lib
24+
/usr/local/lib
25+
NO_DEFAULT_PATH
26+
)
27+
28+
IF (HACKRF_LIBRARY AND HACKRF_INCLUDE_DIR)
29+
SET(HACKRF_LIBRARIES ${HACKRF_LIBRARY})
30+
SET(HACKRF_FOUND "YES")
31+
ELSE (HACKRF_LIBRARY AND HACKRF_INCLUDE_DIR)
32+
SET(HACKRF_FOUND "NO")
33+
ENDIF (HACKRF_LIBRARY AND HACKRF_INCLUDE_DIR)
34+
35+
IF (HACKRF_FOUND)
36+
IF (NOT HACKRF_FIND_QUIETLY)
37+
MESSAGE(STATUS "Found HACKRF: ${HACKRF_LIBRARIES}")
38+
ENDIF (NOT HACKRF_FIND_QUIETLY)
39+
ELSE (HACKRF_FOUND)
40+
IF (HACKRF_FIND_REQUIRED)
41+
MESSAGE(FATAL_ERROR "Could not find HACKRF library")
42+
ENDIF (HACKRF_FIND_REQUIRED)
43+
ENDIF (HACKRF_FOUND)
44+
45+
# Deprecated declarations.
46+
GET_FILENAME_COMPONENT (NATIVE_HACKRF_LIB_PATH ${HACKRF_LIBRARY} PATH)
47+
48+
MARK_AS_ADVANCED(
49+
HACKRF_LIBRARY
50+
HACKRF_INCLUDE_DIR
51+
)
52+

include/capbuf.h

+24
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,34 @@
1515
// You should have received a copy of the GNU Affero General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
19+
#ifdef HAVE_HACKRF
20+
#include "hackrf.h"
21+
#else
22+
typedef struct hackrf_device hackrf_device;
23+
#endif
24+
1825
#ifndef HAVE_CAPBUF_H
1926
#define HAVE_CAPBUF_H
2027

2128
// Number of complex samples to capture.
2229
#define CAPLENGTH 153600
2330

31+
32+
typedef struct {
33+
std::vector <unsigned char> * buf;
34+
rtlsdr_dev_t * dev;
35+
} callback_package_t;
36+
37+
#ifdef HAVE_HACKRF
38+
39+
typedef struct {
40+
std::vector <unsigned char> * buf;
41+
hackrf_device * dev;
42+
} callback_hackrf_package_t;
43+
44+
#endif
45+
2446
double calculate_fc_programmed_in_context(
2547
// Inputs
2648
const double & fc_requested,
@@ -51,6 +73,8 @@ int capture_data(
5173
const char * load_bin_filename,
5274
const std::string & str,
5375
rtlsdr_dev_t * & dev,
76+
hackrf_device * & hackrf_dev,
77+
const dev_type_t::dev_type_t & dev_use,
5478
// Output
5579
itpp::cvec & capbuf,
5680
double & fc_programmed,

include/common.h.in

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#define @USE_OPENCL@
55

6+
#define @HAVE_HACKRF@
7+
68
// This is filled in by cmake
79
#define MAJOR_VERSION @CellSearch_MAJOR_VERSION@
810
#define MINOR_VERSION @CellSearch_MINOR_VERSION@
@@ -47,6 +49,11 @@ typedef std::vector < std::vector < float > > vf2d;
4749

4850
// Some enums must be enclosed in their own namespace because their
4951
// names conflict with each other and also with ITPP declared enums.
52+
53+
namespace dev_type_t {
54+
enum dev_type_t { UNKNOWN = -4321, RTLSDR=9832, HACKRF=432134 };
55+
}
56+
5057
namespace cp_type_t {
5158
enum cp_type_t { UNKNOWN = 0, NORMAL, EXTENDED };
5259
}

src/CMakeLists.txt

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# Create a library of all the shared functions.
22
add_library(LTE_MISC capbuf.cpp constants.cpp itpp_ext.cpp macros.cpp searcher.cpp common.cpp dsp.cpp lte_lib.cpp from_osmocom.cpp)
33

4-
IF ( OPENCL_FOUND )
5-
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${CURSES_LIBRARIES} ${OPENCL_LIBRARIES})
6-
ELSE ( OPENCL_FOUND )
7-
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${CURSES_LIBRARIES})
8-
ENDIF ( OPENCL_FOUND )
4+
IF ( HACKRF_FOUND )
5+
IF ( OPENCL_FOUND )
6+
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${HACKRF_LIBRARIES} ${CURSES_LIBRARIES} ${OPENCL_LIBRARIES})
7+
ELSE ( OPENCL_FOUND )
8+
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${HACKRF_LIBRARIES} ${CURSES_LIBRARIES})
9+
ENDIF ( OPENCL_FOUND )
10+
ELSE ( HACKRF_FOUND )
11+
IF ( OPENCL_FOUND )
12+
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${CURSES_LIBRARIES} ${OPENCL_LIBRARIES})
13+
ELSE ( OPENCL_FOUND )
14+
SET (common_link_libs ${Boost_LIBRARIES} ${Boost_THREAD_LIBRARY} ${LAPACK_LIBRARIES} ${FFTW_LIBRARIES} ${RTLSDR_LIBRARIES} ${CURSES_LIBRARIES})
15+
ENDIF ( OPENCL_FOUND )
16+
ENDIF ( HACKRF_FOUND )
917

1018
# Create the cell search executable
1119
ADD_EXECUTABLE (CellSearch CellSearch.cpp)

0 commit comments

Comments
 (0)