diff --git a/devices/CMakeLists.txt b/devices/CMakeLists.txt index 84a66d0aa..8e7cfccd6 100644 --- a/devices/CMakeLists.txt +++ b/devices/CMakeLists.txt @@ -7,7 +7,13 @@ if(LIBUSB_FOUND AND LIBBLADERF_FOUND) add_subdirectory(bladerf) endif(LIBUSB_FOUND AND LIBBLADERF_FOUND) +find_package(LibHACKRF) +if(LIBUSB_FOUND AND LIBHACKRF_FOUND) + add_subdirectory(hackrf) +endif(LIBUSB_FOUND AND LIBHACKRF_FOUND) + if (BUILD_DEBIAN) add_subdirectory(bladerf) + add_subdirectory(hackrf) endif (BUILD_DEBIAN) diff --git a/devices/bladerf/CMakeLists.txt b/devices/bladerf/CMakeLists.txt index e8507ff01..8482f74ac 100644 --- a/devices/bladerf/CMakeLists.txt +++ b/devices/bladerf/CMakeLists.txt @@ -2,10 +2,13 @@ project(bladerfdevice) set(bladerfdevice_SOURCES devicebladerf.cpp + devicebladerfvalues.cpp ) set(bladerfdevice_HEADERS devicebladerf.h + devicebladerfvalues.h + devicebladerfparam.h ) if (BUILD_DEBIAN) diff --git a/devices/hackrf/CMakeLists.txt b/devices/hackrf/CMakeLists.txt new file mode 100644 index 000000000..27cd5ea7f --- /dev/null +++ b/devices/hackrf/CMakeLists.txt @@ -0,0 +1,45 @@ +project(hackrfdevice) + +set(hackrfdevice_SOURCES + devicehackrf.cpp +) + +set(hackrfdevice_HEADERS + devicehackrf.h +) + +if (BUILD_DEBIAN) +include_directories( + . + ${CMAKE_CURRENT_BINARY_DIR} + ${LIBHACKRFLIBSRC}/include + ${LIBHACKRFLIBSRC}/src +) +else (BUILD_DEBIAN) +include_directories( + . + ${CMAKE_CURRENT_BINARY_DIR} + ${LIBHACKRF_INCLUDE_DIR} +) +endif (BUILD_DEBIAN) + +#add_definitions(${QT_DEFINITIONS}) +#add_definitions(-DQT_SHARED) + +add_library(hackrfdevice SHARED + ${hackrfdevice_SOURCES} +) + +if (BUILD_DEBIAN) +target_link_libraries(hackrfdevice + hackrf + sdrbase +) +else (BUILD_DEBIAN) +target_link_libraries(hackrfdevice + ${LIBHACKRF_LIBRARIES} + sdrbase +) +endif (BUILD_DEBIAN) + +install(TARGETS hackrfdevice DESTINATION lib) diff --git a/devices/hackrf/devicehackrf.cpp b/devices/hackrf/devicehackrf.cpp new file mode 100644 index 000000000..972c0d379 --- /dev/null +++ b/devices/hackrf/devicehackrf.cpp @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "devicehackrf.h" + +hackrf_device *DeviceHackRF::open_hackrf_from_sequence(int sequence) +{ + hackrf_device_list_t *hackrf_devices = hackrf_device_list(); + hackrf_device *hackrf_ptr; + hackrf_error rc; + + rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr); + + if (rc == HACKRF_SUCCESS) + { + return hackrf_ptr; + } + else + { + return 0; + } +} + + + diff --git a/devices/hackrf/devicehackrf.h b/devices/hackrf/devicehackrf.h new file mode 100644 index 000000000..d976500d0 --- /dev/null +++ b/devices/hackrf/devicehackrf.h @@ -0,0 +1,30 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 Edouard Griffiths, F4EXB // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef DEVICES_HACKRF_DEVICEHACKRF_H_ +#define DEVICES_HACKRF_DEVICEHACKRF_H_ + +#include "libhackrf/hackrf.h" + +class DeviceHackRF +{ +public: + static hackrf_device *open_hackrf_from_sequence(int sequence); +}; + + + +#endif /* DEVICES_HACKRF_DEVICEHACKRF_H_ */ diff --git a/plugins/samplesource/hackrfinput/CMakeLists.txt b/plugins/samplesource/hackrfinput/CMakeLists.txt index 632095950..270820836 100644 --- a/plugins/samplesource/hackrfinput/CMakeLists.txt +++ b/plugins/samplesource/hackrfinput/CMakeLists.txt @@ -24,6 +24,7 @@ if (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/devices ${LIBHACKRFSRC} ${LIBHACKRFSRC}/libhackrf/src ) @@ -31,6 +32,7 @@ else (BUILD_DEBIAN) include_directories( . ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/devices ${LIBHACKRF_INCLUDE_DIR} ) endif (BUILD_DEBIAN) @@ -55,12 +57,14 @@ target_link_libraries(inputhackrf ${QT_LIBRARIES} hackrf sdrbase + hackrfdevice ) else (BUILD_DEBIAN) target_link_libraries(inputhackrf ${QT_LIBRARIES} ${LIBHACKRF_LIBRARIES} sdrbase + hackrfdevice ) endif (BUILD_DEBIAN) diff --git a/plugins/samplesource/hackrfinput/hackrfinput.cpp b/plugins/samplesource/hackrfinput/hackrfinput.cpp index b97ffc2d1..353c6b332 100644 --- a/plugins/samplesource/hackrfinput/hackrfinput.cpp +++ b/plugins/samplesource/hackrfinput/hackrfinput.cpp @@ -25,8 +25,8 @@ #include "dsp/dspengine.h" #include -#include "../hackrfinput/hackrfinputgui.h" -#include "../hackrfinput/hackrfinputthread.h" +#include "hackrfinputgui.h" +#include "hackrfinputthread.h" MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message) MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message) @@ -73,7 +73,7 @@ bool HackRFInput::start(int device) return false; } - if ((m_dev = open_hackrf_from_sequence(device)) == 0) + if ((m_dev = DeviceHackRF::open_hackrf_from_sequence(device)) == 0) { qCritical("HackRFInput::start: could not open HackRF #%d", device); return false; @@ -405,20 +405,20 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) return true; } -hackrf_device *HackRFInput::open_hackrf_from_sequence(int sequence) -{ - hackrf_device_list_t *hackrf_devices = hackrf_device_list(); - hackrf_device *hackrf_ptr; - hackrf_error rc; - - rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr); - - if (rc == HACKRF_SUCCESS) - { - return hackrf_ptr; - } - else - { - return 0; - } -} +//hackrf_device *HackRFInput::open_hackrf_from_sequence(int sequence) +//{ +// hackrf_device_list_t *hackrf_devices = hackrf_device_list(); +// hackrf_device *hackrf_ptr; +// hackrf_error rc; +// +// rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr); +// +// if (rc == HACKRF_SUCCESS) +// { +// return hackrf_ptr; +// } +// else +// { +// return 0; +// } +//} diff --git a/plugins/samplesource/hackrfinput/hackrfinput.h b/plugins/samplesource/hackrfinput/hackrfinput.h index 1251572f5..9e50eec1f 100644 --- a/plugins/samplesource/hackrfinput/hackrfinput.h +++ b/plugins/samplesource/hackrfinput/hackrfinput.h @@ -21,7 +21,8 @@ #include "libhackrf/hackrf.h" #include -#include "../hackrfinput/hackrfinputsettings.h" +#include "hackrf/devicehackrf.h" +#include "hackrfinputsettings.h" class DeviceSourceAPI; class HackRFInputThread; @@ -81,7 +82,7 @@ public: private: bool applySettings(const HackRFInputSettings& settings, bool force); - hackrf_device *open_hackrf_from_sequence(int sequence); +// hackrf_device *open_hackrf_from_sequence(int sequence); void setCenterFrequency(quint64 freq); DeviceSourceAPI *m_deviceAPI;