├── .gitignore ├── .idea ├── .name ├── caches │ ├── build_file_checksums.ser │ └── gradle_models.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── copyright │ └── GNU_Signalware.xml ├── deploymentTargetSelector.xml ├── encodings.xml ├── gradle.xml ├── migrations.xml ├── misc.xml ├── modules.xml ├── other.xml └── vcs.xml ├── COPYING ├── COPYING.hackrf_android ├── COPYING.rtlsdr ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── release │ └── output-metadata.json ├── sdrdrivertools │ ├── .gitignore │ ├── build.gradle │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── info │ │ │ └── martinmarinov │ │ │ └── sdrdrivertools │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ └── AndroidManifest.xml │ │ └── test │ │ └── java │ │ └── info │ │ └── martinmarinov │ │ └── sdrdrivertools │ │ └── ExampleUnitTest.java └── src │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ │ └── com │ │ │ └── sdrtouch │ │ │ ├── rtlsdr │ │ │ ├── BinaryRunnerService.java │ │ │ ├── DeviceOpenActivity.java │ │ │ ├── RtlSdrApplication.java │ │ │ ├── SdrDeviceProviderRegistry.java │ │ │ ├── SdrServiceConnection.java │ │ │ ├── StreamActivity.java │ │ │ └── UsbDelegate.java │ │ │ └── tools │ │ │ ├── DeviceDialog.java │ │ │ ├── DialogManager.java │ │ │ └── ExceptionTools.java │ └── res │ │ ├── layout │ │ ├── activity_stream.xml │ │ └── progress.xml │ │ ├── menu │ │ └── menu_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── raw │ │ └── license.txt │ │ ├── values-nb │ │ └── strings.xml │ │ ├── values │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── autostart_device_filter.xml │ └── test │ └── java │ └── com │ └── sdrtouch │ └── tools │ └── ArgumentParserTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── hackrf ├── .gitignore ├── COPYING ├── Readme.md ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ ├── mantz_it │ │ └── hackrf_android │ │ │ ├── Hackrf.java │ │ │ ├── HackrfCallbackInterface.java │ │ │ └── HackrfUsbException.java │ │ └── sdrtouch │ │ └── rtlsdr │ │ └── hackrf │ │ ├── HackRfDeviceProvider.java │ │ ├── HackRfSdrDevice.java │ │ ├── HackRfTcp.java │ │ └── TcpCommand.java │ └── res │ └── xml │ └── hackrf_device_filter.xml ├── rtl_tcp_andro_keystore.jks ├── rtlsdr ├── .gitignore ├── COPYING ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── cpp │ ├── CMakeLists.txt │ ├── librtlsdr │ │ ├── AUTHORS │ │ ├── CMakeLists.txt │ │ ├── COPYING │ │ ├── README │ │ ├── include │ │ │ ├── reg_field.h │ │ │ ├── rtl-sdr-android.h │ │ │ ├── rtl-sdr.h │ │ │ ├── rtl-sdr_export.h │ │ │ ├── rtlsdr_i2c.h │ │ │ ├── tuner_e4k.h │ │ │ ├── tuner_fc0012.h │ │ │ ├── tuner_fc0013.h │ │ │ ├── tuner_fc2580.h │ │ │ └── tuner_r82xx.h │ │ ├── libusb │ │ │ ├── AUTHORS │ │ │ ├── CMakeLists.txt │ │ │ ├── COPYING │ │ │ ├── ChangeLog │ │ │ ├── NEWS │ │ │ ├── README │ │ │ ├── README.git │ │ │ ├── TODO │ │ │ ├── android │ │ │ │ └── config.h │ │ │ └── libusb │ │ │ │ ├── core.c │ │ │ │ ├── descriptor.c │ │ │ │ ├── hotplug.c │ │ │ │ ├── hotplug.h │ │ │ │ ├── io.c │ │ │ │ ├── libusb.h │ │ │ │ ├── libusbi.h │ │ │ │ ├── os │ │ │ │ ├── linux_netlink.c │ │ │ │ ├── linux_usbfs.c │ │ │ │ ├── linux_usbfs.h │ │ │ │ ├── poll_posix.c │ │ │ │ ├── poll_posix.h │ │ │ │ ├── threads_posix.c │ │ │ │ └── threads_posix.h │ │ │ │ ├── strerror.c │ │ │ │ ├── sync.c │ │ │ │ ├── version.h │ │ │ │ └── version_nano.h │ │ └── src │ │ │ ├── convenience │ │ │ ├── convenience.c │ │ │ └── convenience.h │ │ │ ├── getopt │ │ │ ├── getopt.c │ │ │ └── getopt.h │ │ │ ├── librtlsdr.c │ │ │ ├── rtl_sdr.c │ │ │ ├── tuner_e4k.c │ │ │ ├── tuner_fc0012.c │ │ │ ├── tuner_fc0013.c │ │ │ ├── tuner_fc2580.c │ │ │ └── tuner_r82xx.c │ └── src │ │ ├── SdrException.h │ │ ├── common.c │ │ ├── common.h │ │ ├── extbuffer.c │ │ ├── extbuffer.h │ │ ├── queue.c │ │ ├── queue.h │ │ ├── rtlsdrdevice.c │ │ ├── sdrtcp.c │ │ ├── sdrtcp.h │ │ ├── tcp_commands.h │ │ ├── threading.c │ │ ├── threading.h │ │ ├── workpool.c │ │ └── workpool.h │ ├── java │ └── com │ │ └── sdrtouch │ │ └── rtlsdr │ │ └── driver │ │ ├── RtlSdrDevice.java │ │ ├── RtlSdrDeviceProvider.java │ │ ├── RtlSdrException.java │ │ └── enums │ │ └── RtlSdrExceptionCode.java │ └── res │ └── xml │ └── rtl_sdr_device_filter.xml ├── sdrdrivertools ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── sdrtouch │ │ ├── core │ │ ├── SdrTcpArguments.java │ │ ├── UsedByJni.java │ │ ├── devices │ │ │ ├── SdrDevice.java │ │ │ └── SdrDeviceProvider.java │ │ └── exceptions │ │ │ └── SdrException.java │ │ └── tools │ │ ├── ArgumentParser.java │ │ ├── AsyncFuture.java │ │ ├── Check.java │ │ ├── CompletedFuture.java │ │ ├── Log.java │ │ ├── StrRes.java │ │ ├── UsbPermissionHelper.java │ │ └── UsbPermissionObtainer.java │ └── res │ ├── values-nb │ └── strings.xml │ └── values │ └── strings.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | */.cxx/ 10 | *.aab 11 | /.idea/markdown-navigator.xml 12 | /.idea/markdown-navigator/profiles_settings.xml -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | rtl_tcp_andro -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/caches/gradle_models.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/.idea/caches/gradle_models.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | xmlns:android 11 | 12 | ^$ 13 | 14 | 15 | 16 |
17 |
18 | 19 | 20 | 21 | xmlns:.* 22 | 23 | ^$ 24 | 25 | 26 | BY_NAME 27 | 28 |
29 |
30 | 31 | 32 | 33 | .*:id 34 | 35 | http://schemas.android.com/apk/res/android 36 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | 44 | .*:name 45 | 46 | http://schemas.android.com/apk/res/android 47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | name 56 | 57 | ^$ 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 66 | style 67 | 68 | ^$ 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | .* 78 | 79 | ^$ 80 | 81 | 82 | BY_NAME 83 | 84 |
85 |
86 | 87 | 88 | 89 | .* 90 | 91 | http://schemas.android.com/apk/res/android 92 | 93 | 94 | ANDROID_ATTRIBUTE_ORDER 95 | 96 |
97 |
98 | 99 | 100 | 101 | .* 102 | 103 | .* 104 | 105 | 106 | BY_NAME 107 | 108 |
109 |
110 |
111 |
112 |
113 |
-------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/copyright/GNU_Signalware.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetSelector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 22 | 23 | -------------------------------------------------------------------------------- /.idea/migrations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 26 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | namespace 'marto.rtl_tcp_andro' 7 | compileSdk 34 8 | 9 | defaultConfig { 10 | applicationId "marto.rtl_tcp_andro" 11 | minSdk 21 12 | targetSdk 34 13 | versionCode 31 14 | versionName "3.151" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | compileOptions { 26 | sourceCompatibility JavaVersion.VERSION_1_8 27 | targetCompatibility JavaVersion.VERSION_1_8 28 | } 29 | } 30 | 31 | dependencies { 32 | 33 | implementation 'androidx.appcompat:appcompat:1.5.1' 34 | implementation 'com.google.android.material:material:1.6.1' 35 | testImplementation 'junit:junit:4.13.2' 36 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 38 | 39 | implementation project(path: ':sdrdrivertools') 40 | implementation project(path: ':hackrf') 41 | implementation project(path: ':rtlsdr') 42 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/martinmarinov/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | -dontwarn java.lang.invoke.* 20 | -------------------------------------------------------------------------------- /app/release/output-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "artifactType": { 4 | "type": "APK", 5 | "kind": "Directory" 6 | }, 7 | "applicationId": "marto.rtl_tcp_andro", 8 | "variantName": "release", 9 | "elements": [ 10 | { 11 | "type": "SINGLE", 12 | "filters": [], 13 | "attributes": [], 14 | "versionCode": 30, 15 | "versionName": "3.15", 16 | "outputFile": "app-release.apk" 17 | } 18 | ], 19 | "elementType": "File" 20 | } -------------------------------------------------------------------------------- /app/sdrdrivertools/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/sdrdrivertools/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'info.martinmarinov.sdrdrivertools' 7 | compileSdk 32 8 | 9 | defaultConfig { 10 | minSdk 16 11 | targetSdk 33 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | } 28 | 29 | dependencies { 30 | 31 | implementation 'androidx.appcompat:appcompat:1.5.1' 32 | implementation 'com.google.android.material:material:1.6.1' 33 | testImplementation 'junit:junit:4.13.2' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 36 | } -------------------------------------------------------------------------------- /app/sdrdrivertools/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/sdrdrivertools/consumer-rules.pro -------------------------------------------------------------------------------- /app/sdrdrivertools/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/sdrdrivertools/src/androidTest/java/info/martinmarinov/sdrdrivertools/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package info.martinmarinov.sdrdrivertools; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("info.martinmarinov.sdrdrivertools.test", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/sdrdrivertools/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/sdrdrivertools/src/test/java/info/martinmarinov/sdrdrivertools/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package info.martinmarinov.sdrdrivertools; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 54 | 55 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 72 | 73 | 74 | 75 | 76 | 79 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 95 | 96 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/rtlsdr/RtlSdrApplication.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr; 22 | 23 | import static com.sdrtouch.rtlsdr.SdrDeviceProviderRegistry.SDR_DEVICE_PROVIDERS; 24 | 25 | import android.app.Application; 26 | 27 | import com.sdrtouch.core.devices.SdrDeviceProvider; 28 | import com.sdrtouch.tools.StrRes; 29 | 30 | public class RtlSdrApplication extends Application { 31 | public final static boolean IS_PLATFORM_SUPPORTED; 32 | 33 | static { 34 | boolean isPlatformSupported = false; 35 | try { 36 | isPlatformSupported = loadNativeLibraries(); 37 | } catch (Throwable t) { 38 | t.printStackTrace(); 39 | } 40 | IS_PLATFORM_SUPPORTED = isPlatformSupported; 41 | } 42 | 43 | private static boolean loadNativeLibraries() { 44 | for (SdrDeviceProvider sdrDeviceProvider : SDR_DEVICE_PROVIDERS) { 45 | if (!sdrDeviceProvider.loadNativeLibraries()) { 46 | return false; 47 | } 48 | } 49 | return true; 50 | } 51 | 52 | public void onCreate() { 53 | super.onCreate(); 54 | 55 | StrRes.res = getResources(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/rtlsdr/SdrDeviceProviderRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sdrtouch.rtlsdr; 2 | 3 | import com.sdrtouch.core.devices.SdrDeviceProvider; 4 | import com.sdrtouch.rtlsdr.driver.RtlSdrDeviceProvider; 5 | import com.sdrtouch.rtlsdr.hackrf.HackRfDeviceProvider; 6 | 7 | public class SdrDeviceProviderRegistry { 8 | final static SdrDeviceProvider[] SDR_DEVICE_PROVIDERS = new SdrDeviceProvider[] { 9 | new RtlSdrDeviceProvider(), 10 | new HackRfDeviceProvider(), 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/rtlsdr/SdrServiceConnection.java: -------------------------------------------------------------------------------- 1 | package com.sdrtouch.rtlsdr; 2 | 3 | import android.content.ComponentName; 4 | import android.content.ServiceConnection; 5 | import android.os.IBinder; 6 | 7 | import com.sdrtouch.core.SdrTcpArguments; 8 | import com.sdrtouch.core.devices.SdrDevice; 9 | 10 | public class SdrServiceConnection implements ServiceConnection { 11 | private final SdrDevice sdrDevice; 12 | private final SdrTcpArguments sdrTcpArguments; 13 | private final Runnable onDisconnected; 14 | private volatile boolean isBound; 15 | 16 | SdrServiceConnection(SdrDevice sdrDevice, SdrTcpArguments sdrTcpArguments, Runnable onDisconnected) { 17 | this.sdrDevice = sdrDevice; 18 | this.sdrTcpArguments = sdrTcpArguments; 19 | this.onDisconnected = onDisconnected; 20 | this.isBound = false; 21 | } 22 | 23 | @Override 24 | public void onServiceConnected(ComponentName name, IBinder ibinder) { 25 | isBound = true; 26 | BinaryRunnerService.LocalBinder binder = (BinaryRunnerService.LocalBinder) ibinder; 27 | binder.startWithDevice(sdrDevice, sdrTcpArguments); 28 | } 29 | 30 | @Override 31 | public void onServiceDisconnected(ComponentName name) { 32 | isBound = false; 33 | onDisconnected.run(); 34 | } 35 | 36 | boolean isBound() { 37 | return isBound; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/rtlsdr/UsbDelegate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr; 22 | 23 | import android.app.Activity; 24 | import android.content.ActivityNotFoundException; 25 | import android.content.Intent; 26 | import android.hardware.usb.UsbDevice; 27 | import android.hardware.usb.UsbManager; 28 | import android.os.Bundle; 29 | import com.sdrtouch.tools.Log; 30 | 31 | public class UsbDelegate extends Activity { 32 | 33 | private static final String TAG = UsbDelegate.class.getSimpleName(); 34 | 35 | @Override 36 | public void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | 39 | Intent intent = getIntent(); 40 | 41 | if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(intent.getAction())) { 42 | UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); 43 | if (usbDevice != null) { 44 | Log.appendLine(TAG + " USB attached: " + usbDevice.getDeviceName()); 45 | Intent newIntent = new Intent(BinaryRunnerService.ACTION_SDR_DEVICE_ATTACHED); 46 | newIntent.putExtra(UsbManager.EXTRA_DEVICE, usbDevice); 47 | try { 48 | startActivity(newIntent); 49 | } catch (ActivityNotFoundException e) { 50 | Log.appendLine(TAG + " no activity found for SDR handling"); 51 | } 52 | } 53 | } 54 | 55 | finish(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/tools/DeviceDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import android.app.AlertDialog; 24 | import android.app.Dialog; 25 | import android.content.DialogInterface; 26 | import android.os.Bundle; 27 | 28 | import androidx.annotation.NonNull; 29 | import androidx.fragment.app.DialogFragment; 30 | 31 | import com.sdrtouch.core.devices.SdrDevice; 32 | 33 | import java.util.List; 34 | 35 | import marto.rtl_tcp_andro.R; 36 | 37 | public class DeviceDialog extends DialogFragment { 38 | private final static String SDR_DEVICE = "sdrDevice_%d"; 39 | private final static String SDR_DEVICES_COUNT = "sdrDevices_count"; 40 | 41 | public static DialogFragment invokeDialog(List devices) { 42 | final Bundle b = new Bundle(); 43 | 44 | synchronized (devices) { 45 | b.putInt(SDR_DEVICES_COUNT, devices.size()); 46 | for (int id = 0; id < devices.size(); id++) { 47 | b.putSerializable(String.format(SDR_DEVICE, id), Check.isNotNull(devices.get(id))); 48 | } 49 | } 50 | 51 | final DeviceDialog dmg = new DeviceDialog(); 52 | dmg.setArguments(b); 53 | 54 | return dmg; 55 | } 56 | 57 | @Override @NonNull 58 | public Dialog onCreateDialog(Bundle savedInstanceState) { 59 | final OnDeviceDialog callback = (OnDeviceDialog) getActivity(); 60 | final Bundle b = getArguments(); 61 | final int devicesCount = b.getInt(SDR_DEVICES_COUNT); 62 | final SdrDevice[] devices = new SdrDevice[devicesCount]; 63 | final String[] options = new String[devicesCount]; 64 | for (int id = 0; id < devicesCount; id++) { 65 | SdrDevice sdrDevice = (SdrDevice) Check.isNotNull(b.getSerializable(String.format(SDR_DEVICE, id))); 66 | devices[id] = sdrDevice; 67 | options[id] = sdrDevice.getName(); 68 | } 69 | 70 | return new AlertDialog.Builder(getActivity()) 71 | .setItems(options, new DialogInterface.OnClickListener() { 72 | @Override 73 | public void onClick(DialogInterface dialog, int which) { 74 | final SdrDevice selected = devices[which]; 75 | callback.onDeviceDialogDeviceChosen(selected); 76 | } 77 | }) 78 | .setTitle(R.string.choose_device) 79 | .create(); 80 | } 81 | 82 | @Override 83 | public void onCancel(DialogInterface dialog) { 84 | super.onCancel(dialog); 85 | final OnDeviceDialog callback = (OnDeviceDialog) getActivity(); 86 | callback.onDeviceDialogCanceled(); 87 | } 88 | 89 | public interface OnDeviceDialog { 90 | void onDeviceDialogDeviceChosen(SdrDevice selected); 91 | void onDeviceDialogCanceled(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/tools/DialogManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import android.app.AlertDialog; 24 | import android.app.Dialog; 25 | import android.os.Bundle; 26 | import android.text.Html; 27 | import android.text.method.LinkMovementMethod; 28 | import android.widget.TextView; 29 | 30 | import androidx.annotation.NonNull; 31 | import androidx.fragment.app.DialogFragment; 32 | 33 | import java.io.BufferedReader; 34 | import java.io.IOException; 35 | import java.io.InputStream; 36 | import java.io.InputStreamReader; 37 | 38 | import marto.rtl_tcp_andro.R; 39 | 40 | /** 41 | * Creates various dialogs 42 | * 43 | * @author martinmarinov 44 | * 45 | */ 46 | public class DialogManager extends DialogFragment { 47 | 48 | /** List of possible dialogs to create */ 49 | public enum dialogs { 50 | DIAG_ABOUT, 51 | DIAG_LICENSE 52 | } 53 | 54 | public static DialogFragment invokeDialog(final dialogs id, final String ... args) { 55 | final Bundle b = new Bundle(); 56 | 57 | b.putInt("elements", args.length); 58 | for (int i = 0; i < args.length; i++) b.putString("e"+i, args[i]); 59 | 60 | b.putInt("id", id.ordinal()); 61 | 62 | final DialogManager dmg = new DialogManager(); 63 | dmg.setArguments(b); 64 | 65 | return dmg; 66 | } 67 | 68 | @Override @NonNull 69 | public Dialog onCreateDialog( Bundle savedInstanceState) { 70 | final Bundle b = getArguments(); 71 | final dialogs id = dialogs.values()[b.getInt("id")]; 72 | 73 | Dialog dialog = createDialog(id); 74 | 75 | if (dialog != null) 76 | return dialog; 77 | else 78 | return new AlertDialog.Builder(getActivity()) 79 | .setTitle(R.string.error) 80 | .setPositiveButton(R.string.btn_ok, (dialog1, which) -> dialog1.dismiss()) 81 | .setMessage(R.string.notsupported).create(); 82 | } 83 | 84 | private Dialog createDialog(final dialogs id) { 85 | switch (id) { 86 | case DIAG_ABOUT: 87 | final AlertDialog addd = new AlertDialog.Builder(getActivity()) 88 | .setTitle(R.string.help) 89 | .setPositiveButton(R.string.btn_ok, (dialog, which) -> dialog.dismiss()) 90 | .setMessage(Html.fromHtml(getString(R.string.help_info))).create(); 91 | try { 92 | addd.setOnShowListener(paramDialogInterface -> { 93 | try { 94 | final TextView tv = addd.getWindow().findViewById(android.R.id.message); 95 | if (tv != null) tv.setMovementMethod(LinkMovementMethod.getInstance()); 96 | 97 | } catch (Exception ignored) { 98 | } 99 | }); 100 | } catch (Exception ignored) {} 101 | 102 | return addd; 103 | case DIAG_LICENSE: 104 | return new AlertDialog.Builder(getActivity()) 105 | .setTitle("License") 106 | .setPositiveButton(R.string.btn_ok, (dialog, which) -> dialog.dismiss()) 107 | .setMessage(readWholeStream(R.raw.license)) 108 | .create(); 109 | } 110 | return null; 111 | } 112 | 113 | private String readWholeStream(final int resoureId) { 114 | 115 | final StringBuilder total = new StringBuilder(); 116 | 117 | try { 118 | final InputStream in = getActivity().getResources().openRawResource(resoureId); 119 | final BufferedReader r = new BufferedReader(new InputStreamReader(in)); 120 | 121 | String line; 122 | while ((line = r.readLine()) != null) { 123 | total.append(line); 124 | total.append("\n"); 125 | } 126 | in.close(); 127 | } catch (IOException e) { 128 | e.printStackTrace(); 129 | } 130 | 131 | return total.toString(); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /app/src/main/java/com/sdrtouch/tools/ExceptionTools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import java.io.PrintWriter; 24 | import java.io.StringWriter; 25 | 26 | public class ExceptionTools { 27 | 28 | public static String getFullStackTrace(Throwable t) { 29 | StringWriter sw = new StringWriter(); 30 | PrintWriter pw = new PrintWriter(sw); 31 | t.printStackTrace(pw); 32 | return sw.toString(); 33 | } 34 | 35 | public static String getNicelyFormattedTrace(Throwable t) { 36 | StackTraceElement[] elements = t.getStackTrace(); 37 | StringBuilder sb = new StringBuilder(); 38 | sb.append(t.getClass().getSimpleName()).append(": ").append(t.getMessage()).append("\n"); 39 | 40 | String lastForeign = null; 41 | for (StackTraceElement stackTraceElement : elements) { 42 | if (stackTraceElement.getClassName().startsWith("marto.")) { 43 | sb.append(String.format(" -> %s(%s:%d)\n", getSimpleClassName(stackTraceElement.getClassName()), stackTraceElement.getMethodName(), stackTraceElement.getLineNumber())); 44 | } else { 45 | String line = String.format(" -> %s ", getSimpleClassName(stackTraceElement.getClassName())); 46 | if (!line.equals(lastForeign)) sb.append(line); 47 | lastForeign = line; 48 | } 49 | } 50 | if (t.getCause() != null) sb.append("\nCaused by ").append(getNicelyFormattedTrace(t.getCause())); 51 | return sb.toString(); 52 | } 53 | 54 | private static String getSimpleClassName(String fullName) { 55 | if (fullName.indexOf('.') < 0) return fullName; 56 | String[] path = fullName.split("\\."); 57 | return path[path.length-1]; 58 | } 59 | 60 | private ExceptionTools() {} 61 | } 62 | -------------------------------------------------------------------------------- /app/src/main/res/layout/progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rtl-sdr driver 5 | sdr_tcp 6 | Hjelp 7 | Begynn strømmen 8 | Full stopp 9 | sdr_tcp-ledetekstargumenter 10 | -a 0.0.0.0 -p 14423 -f 91800000 -s 1024000 11 | Kopier 12 | Utdataen ble kopiert til utklippstavlen 13 | Tøm 14 | 15 | Feil 16 | Den påkrevde handlingen ble ikke iverksatt, fordi den ikke var tilgjengelig. 17 | 18 | Enhetsvelger 19 | 20 | OK 21 | 22 | Lisens 23 | Om denne appen 26 |

Denne appen er en port av rtl_tcp til Android-plattformen. Den gjør det mulig for andre apper å starte opp rtl_tcp og å bruke de uendrede I/Q-prøvene som den leser inn fra 27 | USB DVB-T-pinner basert på RTL2832U-chippen.

28 |

Den gjør det også mulig for Android å strømme over nettverket direkte ifra driverens grensesnitt. Dette er en avansert egenskap og det kan være bugs i den.

29 |

Bemerkninger og lisens

30 |

Appen er for øyeblikket eksperimentell og kan være ustabil. Del gjerne dine opplevelser ved å sende meg en E-post.

31 |

Denne appen er åpen-kildet og er lisensiert som GPL2+. Kildekoden kan bli sett hos github.com/martinmarinov/rtl_tcp_andro-

32 |

For detaljert informasjon om lisensen, bruk Lisens-knappen.

33 |

Inkludert åpen-kildet programvare

34 |

En modifisert versjon av librtlsdr sdr.osmocom.org/trac/wiki/rtl-sdr

35 |

En modifisert versjon av libusb libusb.info

36 |

En modifisert versjon av hackrf_android github.com/demantz/hackrf_android

37 |

En modifisert versjon av libhackrf github.com/mossmann/libhackrf

38 | ]]>
39 | 40 | Driveren har blitt vellykket installert! Vennligst start opp din vertsapp og den vil sette i gang driveren automatisk. 41 | Din Android-plattform er ikke støttet. Vennligst ta kontakt med oss for å fortelle oss mer om enheten din, sånn at vi kan støtte den i fremtiden. 42 | Aktiver avansert modus (for avlusing og for strømming til PC) 43 | 44 | Innstillinger 45 | 46 |
47 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Rtl-sdr driver 4 | sdr_tcp 5 | Help 6 | Start stream 7 | Kill 8 | sdr_tcp command line arguments 9 | -a 0.0.0.0 -p 14423 -f 91800000 -s 1024000 -T 0 10 | Copy 11 | Output was copied to clipboard 12 | Clear 13 | 14 | Error 15 | The required action was not executed due to being not available. 16 | 17 | Device Chooser 18 | 19 | OK 20 | 21 | License 22 | About this app 25 |

This application is a port of rtl_tcp to the android platform. It allows other applications to start rtl_tcp and use the raw I/Q samples that it reads from 26 | USB DVB-T dongles based on the RTL2832U chip and Hack RF

27 |

It also allows Android to stream over the network directly from the UI of the driver. This is an advanced feature and there could be bugs.

28 |

Notes and license

29 |

The app currently is experimental and could be unstable. Please, share your experience by sending me an email.

30 |

This app is open source and is licensed under GPL2+. The source code could be found on github.com/signalwareltd/rtl_tcp_andro-

31 |

For detailed information about the license, use the License button.

32 |

Included open source software

33 |

Modified version of librtlsdr sdr.osmocom.org/trac/wiki/rtl-sdr

34 |

Modified version of libusb libusb.info

35 |

Modified version of hackrf_android github.com/demantz/hackrf_android

36 |

Modified version of libhackrf github.com/mossmann/libhackrf

37 | ]]>
38 | 39 | The driver has been installed successfully! Please, launch your host application and it will trigger the driver automatically. 40 | Your Android platform is not supported. Please get in touch with us to provide us more information about your device so we can support it in future. 41 | Enable advanced mode (for debug & stream to PC) 42 | 43 | Settings 44 | 45 |
-------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/xml/autostart_device_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /app/src/test/java/com/sdrtouch/tools/ArgumentParserTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import org.junit.Test; 24 | 25 | import static org.hamcrest.CoreMatchers.equalTo; 26 | import static org.junit.Assert.assertThat; 27 | 28 | public class ArgumentParserTest { 29 | 30 | @Test 31 | public void testBasicParsing() { 32 | ArgumentParser argumentParser = new ArgumentParser("-a 123 -bc hello"); 33 | assertThat(argumentParser.getIntArgumentOrDefault("a", -1), equalTo(123)); 34 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello")); 35 | } 36 | 37 | @Test 38 | public void testBasicParsingExtraSpace() { 39 | ArgumentParser argumentParser = new ArgumentParser("-a 123 -bc hello"); 40 | assertThat(argumentParser.getStringArgument("a"), equalTo("123")); 41 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello")); 42 | } 43 | 44 | @Test 45 | public void testDoubleQuote() { 46 | ArgumentParser argumentParser = new ArgumentParser("-bc \"hello\""); 47 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello")); 48 | } 49 | 50 | @Test 51 | public void testDoubleQuoteSpace() { 52 | ArgumentParser argumentParser = new ArgumentParser("-bc \"hello world\""); 53 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello world")); 54 | } 55 | 56 | @Test 57 | public void testSingleQuoteSpace() { 58 | ArgumentParser argumentParser = new ArgumentParser("-bc 'hello world'"); 59 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello world")); 60 | } 61 | 62 | @Test 63 | public void testMixedQuoteSpace() { 64 | ArgumentParser argumentParser = new ArgumentParser("-bc 'hello \"world\"'"); 65 | assertThat(argumentParser.getStringArgument("bc"), equalTo("hello \"world\"")); 66 | } 67 | 68 | @Test 69 | public void setDefaultIntegerIfArgMissing() { 70 | ArgumentParser argumentParser = new ArgumentParser("-bc 'hello \"world\"'"); 71 | assertThat(argumentParser.getIntArgumentOrDefault("a", -1), equalTo(-1)); 72 | } 73 | 74 | @Test 75 | public void testNoArgs() { 76 | new ArgumentParser(""); 77 | } 78 | 79 | @Test 80 | public void testSpace() { 81 | new ArgumentParser(" "); 82 | } 83 | 84 | @Test(expected = IllegalArgumentException.class) 85 | public void testBrokenArgs1() { 86 | new ArgumentParser("-bc Hello World"); 87 | } 88 | 89 | @Test(expected = IllegalArgumentException.class) 90 | public void testBrokenArgs2() { 91 | new ArgumentParser("-bc Hello -dc "); 92 | } 93 | 94 | @Test(expected = IllegalArgumentException.class) 95 | public void testBrokenArgs3() { 96 | new ArgumentParser("-bc Hello - world"); 97 | } 98 | 99 | @Test(expected = IllegalArgumentException.class) 100 | public void testReadEmptyArg() { 101 | ArgumentParser argumentParser = new ArgumentParser("-a 123 -bc hello"); 102 | argumentParser.getStringArgument(""); 103 | } 104 | 105 | @Test(expected = NumberFormatException.class) 106 | public void testNumericExceptionWhenNumberIsWrong() { 107 | ArgumentParser argumentParser = new ArgumentParser("-a 123abc"); 108 | argumentParser.getIntArgumentOrDefault("a", -1); 109 | } 110 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 22 | plugins { 23 | id 'com.android.application' version '8.5.2' apply false 24 | id 'com.android.library' version '8.5.2' apply false 25 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true 22 | android.defaults.buildfeatures.buildconfig=true 23 | android.nonFinalResIds=false -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 04 18:55:38 BST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /hackrf/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /hackrf/Readme.md: -------------------------------------------------------------------------------- 1 | HackRF Library for Android 2 | ========================== 3 | 4 | This is a slightly modified version of Dennis Mantz's HackRF library for Android. You can find the original sources: 5 | 6 | https://github.com/demantz/hackrf_android 7 | 8 | Dennis Mantz's HackRF library for Android is a ported version of Michael Ossmann's libhackrf 9 | ([https://github.com/mossmann/hackrf/tree/master/host/libhackrf] 10 | (https://github.com/mossmann/hackrf/tree/master/host/libhackrf)) 11 | library to work with Android 3.1+. 12 | 13 | 14 | License 15 | ------- 16 | This library is free software; you can redistribute it and/or 17 | modify it under the terms of the GNU General Public 18 | License as published by the Free Software Foundation; either 19 | version 2 of the License, or (at your option) any later version. 20 | [http://www.gnu.org/licenses/gpl.html](http://www.gnu.org/licenses/gpl.html) GPL version 2 or higher 21 | 22 | principal author: Dennis Mantz 23 | 24 | principal author of libhackrf: Michael Ossmann 25 | -------------------------------------------------------------------------------- /hackrf/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'info.martinmarinov.hackrf' 7 | compileSdk 34 8 | 9 | defaultConfig { 10 | minSdk 21 11 | targetSdk 34 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | } 28 | 29 | dependencies { 30 | 31 | implementation 'androidx.appcompat:appcompat:1.5.1' 32 | implementation 'com.google.android.material:material:1.6.1' 33 | testImplementation 'junit:junit:4.13.2' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 36 | 37 | implementation project(path: ':sdrdrivertools') 38 | } -------------------------------------------------------------------------------- /hackrf/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /hackrf/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /hackrf/src/main/java/com/mantz_it/hackrf_android/HackrfCallbackInterface.java: -------------------------------------------------------------------------------- 1 | package com.mantz_it.hackrf_android; 2 | 3 | /** 4 | *

HackRF USB Library for Android

5 | * 6 | * Module: HackrfCallbackInterface.java 7 | * Description: This Interface declares a callback method to return a 8 | * HackRF instance to the application after it was opened 9 | * by the initialization routine (asynchronous process 10 | * because it includes requesting the USB permissions) 11 | * 12 | * @author Dennis Mantz 13 | * 14 | * Copyright (C) 2014 Dennis Mantz 15 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher 16 | * 17 | * This library is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU General Public 19 | * License as published by the Free Software Foundation; either 20 | * version 2 of the License, or (at your option) any later version. 21 | * 22 | * This library is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | * General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU General Public 28 | * License along with this library; if not, write to the Free Software 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 30 | */ 31 | public interface HackrfCallbackInterface { 32 | 33 | /** 34 | * Called by initHackrf() after the device is ready to be used. 35 | * 36 | * @param hackrf Instance of the HackRF that provides access to the device 37 | */ 38 | public void onHackrfReady(Hackrf hackrf); 39 | 40 | 41 | /** 42 | * Called if there was an error when accessing the device. 43 | * 44 | * @param message Reason for the Error 45 | */ 46 | public void onHackrfError(String message); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /hackrf/src/main/java/com/mantz_it/hackrf_android/HackrfUsbException.java: -------------------------------------------------------------------------------- 1 | package com.mantz_it.hackrf_android; 2 | 3 | /** 4 | *

HackRF USB Library for Android

5 | * 6 | * Module: HackrfUsbException.java 7 | * Description: This Exception will be thrown if an Error with the USB 8 | * communication occurs. 9 | * 10 | * @author Dennis Mantz 11 | * 12 | * Copyright (C) 2014 Dennis Mantz 13 | * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher 14 | * 15 | * This library is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public 17 | * License as published by the Free Software Foundation; either 18 | * version 2 of the License, or (at your option) any later version. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 28 | */ 29 | public class HackrfUsbException extends Exception { 30 | 31 | private static final long serialVersionUID = 1L; 32 | 33 | public HackrfUsbException(String message) { 34 | super(message); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /hackrf/src/main/java/com/sdrtouch/rtlsdr/hackrf/HackRfDeviceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.hackrf; 22 | 23 | import android.content.Context; 24 | import android.hardware.usb.UsbDevice; 25 | 26 | import com.sdrtouch.core.devices.SdrDevice; 27 | import com.sdrtouch.core.devices.SdrDeviceProvider; 28 | import com.sdrtouch.tools.UsbPermissionHelper; 29 | 30 | import java.util.Collections; 31 | import java.util.List; 32 | import java.util.Set; 33 | 34 | import info.martinmarinov.hackrf.R; 35 | 36 | 37 | public class HackRfDeviceProvider implements SdrDeviceProvider { 38 | @Override 39 | public List listDevices(Context ctx, boolean forceRoot) { 40 | Set availableUsbDevices = UsbPermissionHelper.getAvailableUsbDevices(ctx, R.xml.hackrf_device_filter); 41 | if (!availableUsbDevices.isEmpty()) { 42 | // Hack RF library can't choose between multiple HackRFs plugged in at the same time 43 | // so it's essentially a singleton 44 | UsbDevice device = availableUsbDevices.iterator().next(); 45 | return Collections.singletonList(new HackRfSdrDevice(ctx, device)); 46 | } 47 | return Collections.emptyList(); 48 | } 49 | 50 | @Override 51 | public String getName() { 52 | return "HackRF"; 53 | } 54 | 55 | @Override 56 | public boolean loadNativeLibraries() { 57 | // No native libraries to load 58 | return true; 59 | } 60 | } -------------------------------------------------------------------------------- /hackrf/src/main/java/com/sdrtouch/rtlsdr/hackrf/HackRfSdrDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.hackrf; 22 | 23 | import android.content.Context; 24 | import android.hardware.usb.UsbDevice; 25 | 26 | import com.mantz_it.hackrf_android.Hackrf; 27 | import com.mantz_it.hackrf_android.HackrfCallbackInterface; 28 | import com.mantz_it.hackrf_android.HackrfUsbException; 29 | import com.sdrtouch.core.SdrTcpArguments; 30 | import com.sdrtouch.core.devices.SdrDevice; 31 | import com.sdrtouch.tools.Log; 32 | 33 | import java.io.IOException; 34 | import java.util.List; 35 | 36 | public class HackRfSdrDevice extends SdrDevice { 37 | private final static double BUFF_TIME = 0.1; 38 | private final UsbDevice device; 39 | 40 | private Thread processingThread; 41 | private volatile HackRfTcp tcp; 42 | 43 | public HackRfSdrDevice(Context context, UsbDevice device) { 44 | super(context); 45 | this.device = device; 46 | } 47 | 48 | @Override 49 | public int[] getSupportedCommands() { 50 | List commands = HackRfTcp.SUPPORTED_COMMANDS; 51 | int[] supported_commands = new int[commands.size()]; 52 | for (int i = 0; i < commands.size(); i++) { 53 | supported_commands[i] = commands.get(i).getCode(); 54 | } 55 | return supported_commands; 56 | } 57 | 58 | @Override 59 | public void openAsync(final SdrTcpArguments sdrTcpArguments) { 60 | processingThread = new Thread() { 61 | @Override 62 | public void run() { 63 | int queue_size = (int) (2 * BUFF_TIME * sdrTcpArguments.getSamplerateHz()); 64 | try { 65 | Log.appendLine("Opening HackRF"); 66 | Hackrf.initHackrf(context, device, new HackrfCallbackInterface() { 67 | @Override 68 | public void onHackrfReady(Hackrf hackrf) { 69 | try { 70 | Log.appendLine("HackRF ready"); 71 | tcp = new HackRfTcp(hackrf, sdrTcpArguments); 72 | 73 | Log.appendLine("Initialising TCP"); 74 | tcp.initDevice(); 75 | tcp.prepareToAcceptConnections(); 76 | 77 | // ready to accept connections 78 | announceOnOpen(); 79 | tcp.serveAndBlock(); 80 | 81 | // close device 82 | Log.appendLine("Closing HackRF"); 83 | hackrf.stop(); 84 | announceOnClosed(null); 85 | } catch (Exception e) { 86 | announceOnClosed(e); 87 | if (hackrf != null) { 88 | try { 89 | Log.appendLine("Closing HackRF due to "+e.getMessage()); 90 | hackrf.stop(); 91 | } catch (HackrfUsbException ee) { 92 | Log.appendLine("Failed to close HackRF due to "+ee.getMessage()); 93 | } 94 | } 95 | } 96 | } 97 | 98 | @Override 99 | public void onHackrfError(String message) { 100 | announceOnClosed(new IOException(message)); 101 | } 102 | }, queue_size); 103 | } catch (Exception e) { 104 | announceOnClosed(e); 105 | } finally { 106 | processingThread = null; 107 | } 108 | Log.appendLine("HackRF device thread finished."); 109 | } 110 | }; 111 | processingThread.start(); 112 | } 113 | 114 | @Override 115 | public void close() { 116 | if (tcp != null) { 117 | tcp.close(); 118 | } 119 | if (processingThread != null && processingThread.isAlive()) { 120 | processingThread.interrupt(); 121 | try { 122 | Log.appendLine("Attempting to join HackRF thread"); 123 | processingThread.join(); 124 | Log.appendLine("HackRF thread is dead"); 125 | } catch (InterruptedException e) { 126 | e.printStackTrace(); 127 | } 128 | } 129 | } 130 | 131 | @Override 132 | public String getName() { 133 | return "HackRF"; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /hackrf/src/main/java/com/sdrtouch/rtlsdr/hackrf/TcpCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.hackrf; 22 | 23 | import android.util.SparseArray; 24 | 25 | public enum TcpCommand { 26 | TCP_SET_FREQ(0x01), 27 | TCP_SET_SAMPLE_RATE(0x02), 28 | TCP_SET_GAIN_MODE(0x03), 29 | TCP_SET_GAIN(0x04), 30 | TCP_SET_FREQ_CORRECTION(0x05), 31 | TCP_SET_IF_TUNER_GAIN(0x06), 32 | TCP_SET_TEST_MODE(0x07), 33 | TCP_SET_AGC_MODE(0x08), 34 | TCP_SET_DIRECT_SAMPLING(0x09), 35 | TCP_SET_OFFSET_TUNING(0x0a), 36 | TCP_SET_RTL_XTAL(0x0b), 37 | TCP_SET_TUNER_XTAL(0x0c), 38 | TCP_SET_TUNER_GAIN_BY_ID(0x0d), 39 | TCP_ANDROID_EXIT(0x7e), 40 | TCP_ANDROID_GAIN_BY_PERCENTAGE(0x7f), 41 | TCP_ANDROID_ENABLE_16_BIT_SIGNED(0x80), 42 | 43 | // SDR Play commands 44 | RSP_TCP_COMMAND_SET_ANTENNA(0x1f), 45 | RSP_TCP_COMMAND_SET_LNASTATE(0x20), 46 | RSP_TCP_COMMAND_SET_IF_GAIN_R(0x21), 47 | RSP_TCP_COMMAND_SET_AGC(0x22), 48 | RSP_TCP_COMMAND_SET_AGC_SETPOINT(0x23), 49 | RSP_TCP_COMMAND_SET_NOTCH(0x24), 50 | RSP_TCP_COMMAND_SET_BIAST(0x25); 51 | 52 | private final static SparseArray COMMAND_MAP = new SparseArray<>(TcpCommand.values().length); 53 | 54 | static { 55 | for (TcpCommand c : TcpCommand.values()) { 56 | if (COMMAND_MAP.indexOfKey(c.code) >= 0) { 57 | throw new RuntimeException("Duplicate code for "+c); 58 | } 59 | COMMAND_MAP.put(c.code, c); 60 | } 61 | } 62 | 63 | private final int code; 64 | 65 | TcpCommand(int code) { 66 | this.code = code; 67 | } 68 | 69 | public static TcpCommand fromCode(int code) { 70 | return COMMAND_MAP.get(code); 71 | } 72 | 73 | public int getCode() { 74 | return code; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /hackrf/src/main/res/xml/hackrf_device_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /rtl_tcp_andro_keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/rtl_tcp_andro_keystore.jks -------------------------------------------------------------------------------- /rtlsdr/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /rtlsdr/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'info.martinmarinov.rtlsdr' 7 | compileSdk 34 8 | 9 | defaultConfig { 10 | minSdk 21 11 | targetSdk 34 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | externalNativeBuild { 28 | cmake { 29 | path file('src/main/cpp/CMakeLists.txt') 30 | } 31 | } 32 | } 33 | 34 | dependencies { 35 | 36 | implementation 'androidx.appcompat:appcompat:1.5.1' 37 | implementation 'com.google.android.material:material:1.6.1' 38 | testImplementation 'junit:junit:4.13.2' 39 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 41 | 42 | implementation project(path: ':sdrdrivertools') 43 | } -------------------------------------------------------------------------------- /rtlsdr/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/martinmarinov/Android/Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3.1) 2 | 3 | PROJECT( "rtlSdrAndroid" C ) 4 | 5 | ADD_SUBDIRECTORY(librtlsdr) 6 | 7 | FILE ( GLOB_RECURSE SOURCES_LIB "src/*.c" ) 8 | 9 | SET ( CMAKE_C_FLAGS "-Wall" ) 10 | SET ( CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") 11 | SET ( CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG" ) # Keep optimization low to reduce random libusb crashes 12 | 13 | FIND_LIBRARY( LOG_LIB log ) 14 | 15 | ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SOURCES_LIB} ) 16 | TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME} PRIVATE include ) 17 | TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LOG_LIB} librtlsdr ) -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/AUTHORS: -------------------------------------------------------------------------------- 1 | Steve Markgraf 2 | Dimitri Stolnikov 3 | Hoernchen 4 | Kyle Keen 5 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3.1) 2 | 3 | PROJECT( "librtlsdr" C ) 4 | 5 | ADD_SUBDIRECTORY(libusb) 6 | 7 | FILE ( GLOB_RECURSE SOURCES_LIB "src/*.c" ) 8 | 9 | SET ( CMAKE_C_FLAGS "-Wall" ) 10 | SET ( CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") 11 | SET ( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" ) 12 | 13 | FIND_LIBRARY( LOG_LIB log ) 14 | 15 | ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SOURCES_LIB} ) 16 | TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) 17 | TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LOG_LIB} libusb ) -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/README: -------------------------------------------------------------------------------- 1 | rtl-sdr 2 | turns your Realtek RTL2832 based DVB dongle into a SDR receiver 3 | ====================================================================== 4 | 5 | For more information see: 6 | http://sdr.osmocom.org/trac/wiki/rtl-sdr 7 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/reg_field.h: -------------------------------------------------------------------------------- 1 | #ifndef _REG_FIELD_H 2 | #define _REG_FIELD_H 3 | 4 | #include 5 | #include 6 | 7 | enum cmd_op { 8 | CMD_OP_GET = (1 << 0), 9 | CMD_OP_SET = (1 << 1), 10 | CMD_OP_EXEC = (1 << 2), 11 | }; 12 | 13 | enum pstate { 14 | ST_IN_CMD, 15 | ST_IN_ARG, 16 | }; 17 | 18 | struct strbuf { 19 | uint8_t idx; 20 | char buf[32]; 21 | }; 22 | 23 | struct cmd_state { 24 | struct strbuf cmd; 25 | struct strbuf arg; 26 | enum pstate state; 27 | void (*out)(const char *format, va_list ap); 28 | }; 29 | 30 | struct cmd { 31 | const char *cmd; 32 | uint32_t ops; 33 | int (*cb)(struct cmd_state *cs, enum cmd_op op, const char *cmd, 34 | int argc, char **argv); 35 | const char *help; 36 | }; 37 | 38 | /* structure describing a field in a register */ 39 | struct reg_field { 40 | uint8_t reg; 41 | uint8_t shift; 42 | uint8_t width; 43 | }; 44 | 45 | struct reg_field_ops { 46 | const struct reg_field *fields; 47 | const char **field_names; 48 | uint32_t num_fields; 49 | void *data; 50 | int (*write_cb)(void *data, uint32_t reg, uint32_t val); 51 | uint32_t (*read_cb)(void *data, uint32_t reg); 52 | }; 53 | 54 | uint32_t reg_field_read(struct reg_field_ops *ops, struct reg_field *field); 55 | int reg_field_write(struct reg_field_ops *ops, struct reg_field *field, uint32_t val); 56 | int reg_field_cmd(struct cmd_state *cs, enum cmd_op op, 57 | const char *cmd, int argc, char **argv, 58 | struct reg_field_ops *ops); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/rtl-sdr-android.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver 3 | * Copyright (C) 2012 by Steve Markgraf 4 | * Copyright (C) 2012 by Dimitri Stolnikov 5 | * 6 | * Modification 2022 by Signalware Ltd 7 | * Modifications: opening a device via file descriptor 8 | * 9 | * This program is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program. If not, see . 21 | */ 22 | 23 | #include "rtl-sdr.h" 24 | 25 | #ifndef __RTL_ANDRO_SDR_H 26 | #define __RTL_ANDRO_SDR_H 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | RTLSDR_API int rtlsdr_open2(rtlsdr_dev_t **out_dev, int fd, const char * devicePath); 33 | 34 | #endif /* __RTL_ANDRO_SDR_H */ 35 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/rtl-sdr_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver 3 | * Copyright (C) 2012 by Hoernchen 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #ifndef RTLSDR_EXPORT_H 20 | #define RTLSDR_EXPORT_H 21 | 22 | #if defined __GNUC__ 23 | # if __GNUC__ >= 4 24 | # define __SDR_EXPORT __attribute__((visibility("default"))) 25 | # define __SDR_IMPORT __attribute__((visibility("default"))) 26 | # else 27 | # define __SDR_EXPORT 28 | # define __SDR_IMPORT 29 | # endif 30 | #elif _MSC_VER 31 | # define __SDR_EXPORT __declspec(dllexport) 32 | # define __SDR_IMPORT __declspec(dllimport) 33 | #else 34 | # define __SDR_EXPORT 35 | # define __SDR_IMPORT 36 | #endif 37 | 38 | #ifndef rtlsdr_STATIC 39 | # ifdef rtlsdr_EXPORTS 40 | # define RTLSDR_API __SDR_EXPORT 41 | # else 42 | # define RTLSDR_API __SDR_IMPORT 43 | # endif 44 | #else 45 | #define RTLSDR_API 46 | #endif 47 | #endif /* RTLSDR_EXPORT_H */ 48 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/rtlsdr_i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __I2C_H 2 | #define __I2C_H 3 | 4 | int rtlsdr_check_dongle_model(void *dev, char *manufact_check, char *product_check); 5 | uint32_t rtlsdr_get_tuner_clock(void *dev); 6 | int rtlsdr_i2c_write_fn(void *dev, uint8_t addr, uint8_t *buf, int len); 7 | int rtlsdr_i2c_read_fn(void *dev, uint8_t addr, uint8_t *buf, int len); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/tuner_fc0012.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Fitipower FC0012 tuner driver 3 | * 4 | * Copyright (C) 2012 Hans-Frieder Vogt 5 | * 6 | * modified for use in librtlsdr 7 | * Copyright (C) 2012 Steve Markgraf 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * 23 | */ 24 | 25 | #ifndef _FC0012_H_ 26 | #define _FC0012_H_ 27 | 28 | #define FC0012_I2C_ADDR 0xc6 29 | #define FC0012_CHECK_ADDR 0x00 30 | #define FC0012_CHECK_VAL 0xa1 31 | 32 | int fc0012_init(void *dev); 33 | int fc0012_set_params(void *dev, uint32_t freq, uint32_t bandwidth); 34 | int fc0012_set_gain(void *dev, int gain); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/tuner_fc0013.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Fitipower FC0013 tuner driver 3 | * 4 | * Copyright (C) 2012 Hans-Frieder Vogt 5 | * 6 | * modified for use in librtlsdr 7 | * Copyright (C) 2012 Steve Markgraf 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | * 23 | */ 24 | 25 | #ifndef _FC0013_H_ 26 | #define _FC0013_H_ 27 | 28 | #define FC0013_I2C_ADDR 0xc6 29 | #define FC0013_CHECK_ADDR 0x00 30 | #define FC0013_CHECK_VAL 0xa3 31 | 32 | int fc0013_init(void *dev); 33 | int fc0013_set_params(void *dev, uint32_t freq, uint32_t bandwidth); 34 | int fc0013_set_gain_mode(void *dev, int manual); 35 | int fc0013_set_lna_gain(void *dev, int gain); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/tuner_fc2580.h: -------------------------------------------------------------------------------- 1 | #ifndef __TUNER_FC2580_H 2 | #define __TUNER_FC2580_H 3 | 4 | #define BORDER_FREQ 2600000 //2.6GHz : The border frequency which determines whether Low VCO or High VCO is used 5 | #define USE_EXT_CLK 0 //0 : Use internal XTAL Oscillator / 1 : Use External Clock input 6 | #define OFS_RSSI 57 7 | 8 | #define FC2580_I2C_ADDR 0xac 9 | #define FC2580_CHECK_ADDR 0x01 10 | #define FC2580_CHECK_VAL 0x56 11 | 12 | typedef enum { 13 | FC2580_UHF_BAND, 14 | FC2580_L_BAND, 15 | FC2580_VHF_BAND, 16 | FC2580_NO_BAND 17 | } fc2580_band_type; 18 | 19 | typedef enum { 20 | FC2580_FCI_FAIL, 21 | FC2580_FCI_SUCCESS 22 | } fc2580_fci_result_type; 23 | 24 | enum FUNCTION_STATUS 25 | { 26 | FUNCTION_SUCCESS, 27 | FUNCTION_ERROR, 28 | }; 29 | 30 | extern void fc2580_wait_msec(void *pTuner, int a); 31 | 32 | fc2580_fci_result_type fc2580_i2c_write(void *pTuner, unsigned char reg, unsigned char val); 33 | fc2580_fci_result_type fc2580_i2c_read(void *pTuner, unsigned char reg, unsigned char *read_data); 34 | 35 | /*============================================================================== 36 | fc2580 initial setting 37 | 38 | This function is a generic function which gets called to initialize 39 | 40 | fc2580 in DVB-H mode or L-Band TDMB mode 41 | 42 | 43 | 44 | ifagc_mode 45 | type : integer 46 | 1 : Internal AGC 47 | 2 : Voltage Control Mode 48 | 49 | ==============================================================================*/ 50 | fc2580_fci_result_type fc2580_set_init(void *pTuner, int ifagc_mode, unsigned int freq_xtal ); 51 | 52 | /*============================================================================== 53 | fc2580 frequency setting 54 | 55 | This function is a generic function which gets called to change LO Frequency 56 | 57 | of fc2580 in DVB-H mode or L-Band TDMB mode 58 | 59 | 60 | 61 | f_lo 62 | Value of target LO Frequency in 'kHz' unit 63 | ex) 2.6GHz = 2600000 64 | 65 | ==============================================================================*/ 66 | fc2580_fci_result_type fc2580_set_freq(void *pTuner, unsigned int f_lo, unsigned int freq_xtal ); 67 | 68 | 69 | /*============================================================================== 70 | fc2580 filter BW setting 71 | 72 | This function is a generic function which gets called to change Bandwidth 73 | 74 | frequency of fc2580's channel selection filter 75 | 76 | 77 | 78 | filter_bw 79 | 1 : 1.53MHz(TDMB) 80 | 6 : 6MHz 81 | 7 : 7MHz 82 | 8 : 7.8MHz 83 | 84 | 85 | ==============================================================================*/ 86 | fc2580_fci_result_type fc2580_set_filter( void *pTuner, unsigned char filter_bw, unsigned int freq_xtal ); 87 | 88 | // The following context is FC2580 tuner API source code 89 | // Definitions 90 | 91 | // AGC mode 92 | enum FC2580_AGC_MODE 93 | { 94 | FC2580_AGC_INTERNAL = 1, 95 | FC2580_AGC_EXTERNAL = 2, 96 | }; 97 | 98 | 99 | // Bandwidth mode 100 | enum FC2580_BANDWIDTH_MODE 101 | { 102 | FC2580_BANDWIDTH_1530000HZ = 1, 103 | FC2580_BANDWIDTH_6000000HZ = 6, 104 | FC2580_BANDWIDTH_7000000HZ = 7, 105 | FC2580_BANDWIDTH_8000000HZ = 8, 106 | }; 107 | 108 | // Manipulaing functions 109 | int 110 | fc2580_Initialize( 111 | void *pTuner 112 | ); 113 | 114 | int 115 | fc2580_SetRfFreqHz( 116 | void *pTuner, 117 | unsigned long RfFreqHz 118 | ); 119 | 120 | // Extra manipulaing functions 121 | int 122 | fc2580_SetBandwidthMode( 123 | void *pTuner, 124 | int BandwidthMode 125 | ); 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/include/tuner_r82xx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Rafael Micro R820T/R828D driver 3 | * 4 | * Copyright (C) 2013 Mauro Carvalho Chehab 5 | * Copyright (C) 2013 Steve Markgraf 6 | * 7 | * This driver is a heavily modified version of the driver found in the 8 | * Linux kernel: 9 | * http://git.linuxtv.org/linux-2.6.git/history/HEAD:/drivers/media/tuners/r820t.c 10 | * 11 | * This program is free software: you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation, either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program. If not, see . 23 | */ 24 | 25 | #ifndef R82XX_H 26 | #define R82XX_H 27 | 28 | #define R820T_I2C_ADDR 0x34 29 | #define R828D_I2C_ADDR 0x74 30 | #define R828D_XTAL_FREQ 16000000 31 | 32 | #define R82XX_CHECK_ADDR 0x00 33 | #define R82XX_CHECK_VAL 0x69 34 | 35 | #define R82XX_IF_FREQ 3570000 36 | 37 | #define REG_SHADOW_START 5 38 | #define NUM_REGS 30 39 | #define NUM_IMR 5 40 | #define IMR_TRIAL 9 41 | 42 | #define VER_NUM 49 43 | 44 | enum r82xx_chip { 45 | CHIP_R820T, 46 | CHIP_R620D, 47 | CHIP_R828D, 48 | CHIP_R828, 49 | CHIP_R828S, 50 | CHIP_R820C, 51 | }; 52 | 53 | enum r82xx_tuner_type { 54 | TUNER_RADIO = 1, 55 | TUNER_ANALOG_TV, 56 | TUNER_DIGITAL_TV 57 | }; 58 | 59 | enum r82xx_xtal_cap_value { 60 | XTAL_LOW_CAP_30P = 0, 61 | XTAL_LOW_CAP_20P, 62 | XTAL_LOW_CAP_10P, 63 | XTAL_LOW_CAP_0P, 64 | XTAL_HIGH_CAP_0P 65 | }; 66 | 67 | struct r82xx_config { 68 | uint8_t i2c_addr; 69 | uint32_t xtal; 70 | enum r82xx_chip rafael_chip; 71 | unsigned int max_i2c_msg_len; 72 | int use_predetect; 73 | }; 74 | 75 | struct r82xx_priv { 76 | struct r82xx_config *cfg; 77 | 78 | uint8_t regs[NUM_REGS]; 79 | uint8_t buf[NUM_REGS + 1]; 80 | enum r82xx_xtal_cap_value xtal_cap_sel; 81 | uint16_t pll; /* kHz */ 82 | uint32_t int_freq; 83 | uint8_t fil_cal_code; 84 | uint8_t input; 85 | int has_lock; 86 | int init_done; 87 | 88 | /* Store current mode */ 89 | uint32_t delsys; 90 | enum r82xx_tuner_type type; 91 | 92 | uint32_t bw; /* in MHz */ 93 | 94 | void *rtl_dev; 95 | }; 96 | 97 | struct r82xx_freq_range { 98 | uint32_t freq; 99 | uint8_t open_d; 100 | uint8_t rf_mux_ploy; 101 | uint8_t tf_c; 102 | uint8_t xtal_cap20p; 103 | uint8_t xtal_cap10p; 104 | uint8_t xtal_cap0p; 105 | }; 106 | 107 | enum r82xx_delivery_system { 108 | SYS_UNDEFINED, 109 | SYS_DVBT, 110 | SYS_DVBT2, 111 | SYS_ISDBT, 112 | }; 113 | 114 | int r82xx_standby(struct r82xx_priv *priv); 115 | int r82xx_init(struct r82xx_priv *priv); 116 | int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq); 117 | int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain); 118 | int r82xx_set_bandwidth(struct r82xx_priv *priv, int bandwidth, uint32_t rate); 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright © 2001 Johannes Erdfelt 2 | Copyright © 2007-2009 Daniel Drake 3 | Copyright © 2010-2012 Peter Stuge 4 | Copyright © 2008-2013 Nathan Hjelm 5 | Copyright © 2009-2013 Pete Batard 6 | Copyright © 2009-2013 Ludovic Rousseau 7 | Copyright © 2010-2012 Michael Plante 8 | Copyright © 2011-2013 Hans de Goede 9 | Copyright © 2012-2013 Martin Pieuchot 10 | Copyright © 2012-2013 Toby Gray 11 | Copyright © 2013-2015 Chris Dickens 12 | 13 | Other contributors: 14 | Akshay Jaggi 15 | Alan Ott 16 | Alan Stern 17 | Alex Vatchenko 18 | Andrew Fernandes 19 | Anthony Clay 20 | Antonio Ospite 21 | Artem Egorkine 22 | Aurelien Jarno 23 | Bastien Nocera 24 | Bei Zhang 25 | Benjamin Dobell 26 | Carl Karsten 27 | Colin Walters 28 | Dave Camarillo 29 | David Engraf 30 | David Moore 31 | Davidlohr Bueso 32 | Federico Manzan 33 | Felipe Balbi 34 | Florian Albrechtskirchinger 35 | Francesco Montorsi 36 | Francisco Facioni 37 | Gaurav Gupta 38 | Graeme Gill 39 | Gustavo Zacarias 40 | Hans Ulrich Niedermann 41 | Hector Martin 42 | Hoi-Ho Chan 43 | Ilya Konstantinov 44 | James Hanko 45 | John Sheu 46 | Joshua Blake 47 | Justin Bischoff 48 | Karsten Koenig 49 | Konrad Rzepecki 50 | Kuangye Guo 51 | Lars Kanis 52 | Lars Wirzenius 53 | Luca Longinotti 54 | Marcus Meissner 55 | Markus Heidelberg 56 | Martin Ettl 57 | Martin Koegler 58 | Matthias Bolte 59 | Mike Frysinger 60 | Mikhail Gusarov 61 | Moritz Fischer 62 | Ларионов Даниил 63 | Nicholas Corgan 64 | Omri Iluz 65 | Orin Eman 66 | Paul Fertser 67 | Pekka Nikander 68 | Rob Walker 69 | Sean McBride 70 | Sebastian Pipping 71 | Simon Haggett 72 | Simon Newton 73 | Thomas Röfer 74 | Tim Hutt 75 | Tim Roberts 76 | Tobias Klauser 77 | Toby Peterson 78 | Tormod Volden 79 | Trygve Laugstøl 80 | Uri Lublin 81 | Vasily Khoruzhick 82 | Vegard Storheil Eriksen 83 | Venkatesh Shukla 84 | Vitali Lovich 85 | Xiaofan Chen 86 | Zoltán Kovács 87 | Роман Донченко 88 | parafin 89 | xantares 90 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3.1) 2 | 3 | PROJECT( "libusb" C ) 4 | 5 | FILE ( GLOB_RECURSE SOURCES_LIB "libusb/*.c" ) 6 | 7 | SET ( CMAKE_C_FLAGS "-Wall" ) 8 | SET ( CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") 9 | SET ( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" ) 10 | 11 | FIND_LIBRARY( LOG_LIB log ) 12 | 13 | ADD_LIBRARY( ${PROJECT_NAME} SHARED ${SOURCES_LIB} ) 14 | TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/android" ) 15 | TARGET_INCLUDE_DIRECTORIES( ${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libusb" ) 16 | 17 | TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${LOG_LIB} ) -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/NEWS: -------------------------------------------------------------------------------- 1 | For the latest libusb news, please refer to the ChangeLog file, or visit: 2 | http://libusb.info 3 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/README: -------------------------------------------------------------------------------- 1 | libusb 2 | ====== 3 | 4 | libusb is a library for USB device access from Linux, Mac OS X, 5 | Windows, OpenBSD/NetBSD and Haiku userspace. 6 | It is written in C (Haiku backend in C++) and licensed under the GNU 7 | Lesser General Public License version 2.1 or, at your option, any later 8 | version (see COPYING). 9 | 10 | libusb is abstracted internally in such a way that it can hopefully 11 | be ported to other operating systems. Please see the PORTING file 12 | for more information. 13 | 14 | libusb homepage: 15 | http://libusb.info/ 16 | 17 | Developers will wish to consult the API documentation: 18 | http://api.libusb.info 19 | 20 | Use the mailing list for questions, comments, etc: 21 | http://mailing-list.libusb.info 22 | 23 | - Pete Batard 24 | - Hans de Goede 25 | - Xiaofan Chen 26 | - Ludovic Rousseau 27 | - Nathan Hjelm 28 | - Chris Dickens 29 | (Please use the mailing list rather than mailing developers directly) 30 | 31 | How To for Android 32 | ================== 33 | 34 | 1. Search for the UsbDevice [1] you are interested in. 35 | 2. Extract the usbfs path [2] from the UsbDevice. 36 | 3. Build a libbox0_device from the path 37 | using libusb_get_device2(context, path) [3] 38 | 4. open the UsbDevice [4], you will get UsbDeviceConnection [5]. 39 | 5. from the UsbDeviceConnection, extract the fd[6] 40 | 6. now, from the fd and the previously 41 | created libusb_device, build a libusb_device_handle 42 | by calling libusb_get_device2(dev, handle, fd)[7]. 43 | 7. and that all you need. 44 | 45 | [1] http://developer.android.com/reference/android/hardware/usb/UsbDevice.html 46 | [2] http://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getDeviceName%28%29 47 | [3] https://github.com/kuldeepdhaka/libusb/blob/android-open2/libusb/core.c#L1492 48 | [4] http://developer.android.com/reference/android/hardware/usb/UsbManager.html#openDevice%28android.hardware.usb.UsbDevice%29 49 | [5] http://developer.android.com/reference/android/hardware/usb/UsbDeviceConnection.html 50 | [6] http://developer.android.com/reference/android/hardware/usb/UsbDeviceConnection.html#getFileDescriptor%28%29 51 | [7] https://github.com/kuldeepdhaka/libusb/blob/android-open2/libusb/core.c#L1267 52 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/README.git: -------------------------------------------------------------------------------- 1 | Notes related to git compilation: 2 | -------------------------------- 3 | 4 | If you retrieved the libusb repository from git and are using a gcc based 5 | toolchain, be mindful that you should have the autotools installed (autoconf, 6 | automake) and will need to run either ./autogen.sh or ./bootstrap.sh to produce 7 | the configure file. 8 | 9 | The difference between autogen.sh and bootstrap.sh is that the former invokes 10 | configure with a default set of options, and will therefore generate a Makefile, 11 | whereas the latter does not invoke configure at all. If using autogen.sh, note 12 | that you can also append options, that will be passed as is to configure. 13 | 14 | OS X-specific notes: 15 | ------------------- 16 | 17 | Starting with Xcode 4.3, neither Xcode.app nor the Xcode 'command line tools' 18 | includes autotools and so running either autogen.sh or bootstrap.sh will result 19 | in the message: 20 | 21 | libtoolize or glibtoolize was not found! Please install libtool. 22 | 23 | To proceed, you must find and install it from somewhere. 24 | 25 | Alternatively, you can use the Xcode project at Xcode/libusb.xcodeproj. 26 | 27 | Notes related to submitting new developments: 28 | -------------------------------------------- 29 | 30 | If you submit a new development to libusb (eg: new backend), that is unlikely 31 | to fit in a couple of small patches, we would kindly suggest that you create a 32 | public account on github, if you don't have one already, and then fork a new 33 | libusb repository under this account from https://github.com/libusb/libusb. 34 | 35 | Then you can create a git branch for your work, that we will be able to better 36 | reference and test. 37 | 38 | We also suggest that, if you are planning to bring in a large development, you 39 | try to involve the libusb community early by letting the mailing list know, as 40 | you may find that other people might be eager to help you out. 41 | See http://mailing-list.libusb.info for details on how to join the mailing list. -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/TODO: -------------------------------------------------------------------------------- 1 | Please see the libusb roadmap by visiting: 2 | https://github.com/libusb/libusb/issues/milestones?direction=asc&sort=due_date 3 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/android/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Android build config for libusb 3 | * Copyright © 2012-2013 RealVNC Ltd. 4 | * Copyright © 2013-2022 by Signalware Ltd 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | /* Start with debug message logging enabled */ 22 | #undef ENABLE_DEBUG_LOGGING 23 | 24 | /* Message logging */ 25 | #define ENABLE_LOGGING 26 | //#define ENABLE_DEBUG_LOGGING 27 | 28 | /* Define to 1 if you have the header file. */ 29 | #define HAVE_DLFCN_H 1 30 | 31 | /* Define to 1 if you have the `gettimeofday' function. */ 32 | #define HAVE_GETTIMEOFDAY 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_INTTYPES_H 1 36 | 37 | /* Linux backend */ 38 | #define OS_LINUX 1 39 | 40 | /* Enable output to system log */ 41 | #define USE_SYSTEM_LOGGING_FACILITY 1 42 | 43 | /* type of second poll() argument */ 44 | #define POLL_NFDS_TYPE nfds_t 45 | 46 | /* Use POSIX Threads */ 47 | #define THREADS_POSIX 1 48 | 49 | /* Default visibility */ 50 | #define DEFAULT_VISIBILITY __attribute__((visibility("default"))) 51 | 52 | /* Define to 1 if you have the header file. */ 53 | #define HAVE_MEMORY_H 1 54 | 55 | /* Define to 1 if you have the header file. */ 56 | #define HAVE_POLL_H 1 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #define HAVE_SIGNAL_H 1 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #define HAVE_SYS_STAT_H 1 63 | 64 | /* Define to 1 if you have the header file. */ 65 | #define HAVE_SYS_TIME_H 1 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #define HAVE_SYS_TYPES_H 1 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #define HAVE_UNISTD_H 1 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #define HAVE_LINUX_FILTER_H 1 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #define HAVE_LINUX_NETLINK_H 1 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #define HAVE_ASM_TYPES_H 1 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #define HAVE_SYS_SOCKET_H 1 84 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/hotplug.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C; indent-tabs-mode:t ; c-basic-offset:8 -*- */ 2 | /* 3 | * Hotplug support for libusb 4 | * Copyright © 2012-2013 Nathan Hjelm 5 | * Copyright © 2012-2013 Peter Stuge 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #if !defined(USBI_HOTPLUG_H) 23 | #define USBI_HOTPLUG_H 24 | 25 | #ifndef LIBUSBI_H 26 | #include "libusbi.h" 27 | #endif 28 | 29 | /** \ingroup hotplug 30 | * The hotplug callback structure. The user populates this structure with 31 | * libusb_hotplug_prepare_callback() and then calls libusb_hotplug_register_callback() 32 | * to receive notification of hotplug events. 33 | */ 34 | struct libusb_hotplug_callback { 35 | /** Context this callback is associated with */ 36 | struct libusb_context *ctx; 37 | 38 | /** Vendor ID to match or LIBUSB_HOTPLUG_MATCH_ANY */ 39 | int vendor_id; 40 | 41 | /** Product ID to match or LIBUSB_HOTPLUG_MATCH_ANY */ 42 | int product_id; 43 | 44 | /** Device class to match or LIBUSB_HOTPLUG_MATCH_ANY */ 45 | int dev_class; 46 | 47 | /** Hotplug callback flags */ 48 | libusb_hotplug_flag flags; 49 | 50 | /** Event(s) that will trigger this callback */ 51 | libusb_hotplug_event events; 52 | 53 | /** Callback function to invoke for matching event/device */ 54 | libusb_hotplug_callback_fn cb; 55 | 56 | /** Handle for this callback (used to match on deregister) */ 57 | libusb_hotplug_callback_handle handle; 58 | 59 | /** User data that will be passed to the callback function */ 60 | void *user_data; 61 | 62 | /** Callback is marked for deletion */ 63 | int needs_free; 64 | 65 | /** List this callback is registered in (ctx->hotplug_cbs) */ 66 | struct list_head list; 67 | }; 68 | 69 | typedef struct libusb_hotplug_callback libusb_hotplug_callback; 70 | 71 | struct libusb_hotplug_message { 72 | /** The hotplug event that occurred */ 73 | libusb_hotplug_event event; 74 | 75 | /** The device for which this hotplug event occurred */ 76 | struct libusb_device *device; 77 | 78 | /** List this message is contained in (ctx->hotplug_msgs) */ 79 | struct list_head list; 80 | }; 81 | 82 | typedef struct libusb_hotplug_message libusb_hotplug_message; 83 | 84 | void usbi_hotplug_deregister_all(struct libusb_context *ctx); 85 | void usbi_hotplug_match(struct libusb_context *ctx, struct libusb_device *dev, 86 | libusb_hotplug_event event); 87 | void usbi_hotplug_notification(struct libusb_context *ctx, struct libusb_device *dev, 88 | libusb_hotplug_event event); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/os/poll_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * poll_posix: poll compatibility wrapper for POSIX systems 3 | * Copyright © 2013 RealVNC Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | * 19 | */ 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "libusbi.h" 29 | 30 | int usbi_pipe(int pipefd[2]) 31 | { 32 | int ret = pipe(pipefd); 33 | if (ret != 0) { 34 | return ret; 35 | } 36 | ret = fcntl(pipefd[1], F_GETFL); 37 | if (ret == -1) { 38 | usbi_dbg("Failed to get pipe fd flags: %d", errno); 39 | goto err_close_pipe; 40 | } 41 | ret = fcntl(pipefd[1], F_SETFL, ret | O_NONBLOCK); 42 | if (ret != 0) { 43 | usbi_dbg("Failed to set non-blocking on new pipe: %d", errno); 44 | goto err_close_pipe; 45 | } 46 | 47 | return 0; 48 | 49 | err_close_pipe: 50 | usbi_close(pipefd[0]); 51 | usbi_close(pipefd[1]); 52 | return ret; 53 | } 54 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/os/poll_posix.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBUSB_POLL_POSIX_H 2 | #define LIBUSB_POLL_POSIX_H 3 | 4 | #define usbi_write write 5 | #define usbi_read read 6 | #define usbi_close close 7 | #define usbi_poll poll 8 | 9 | int usbi_pipe(int pipefd[2]); 10 | 11 | #endif /* LIBUSB_POLL_POSIX_H */ 12 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/os/threads_posix.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libusb synchronization using POSIX Threads 3 | * 4 | * Copyright © 2011 Vitali Lovich 5 | * Copyright © 2011 Peter Stuge 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | 24 | #if defined(__linux__) || defined(__OpenBSD__) 25 | # if defined(__OpenBSD__) 26 | # define _BSD_SOURCE 27 | # endif 28 | # include 29 | # include 30 | #elif defined(__APPLE__) 31 | # include 32 | #elif defined(__CYGWIN__) 33 | # include 34 | #endif 35 | 36 | #include "threads_posix.h" 37 | 38 | int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) 39 | { 40 | int err; 41 | pthread_mutexattr_t stack_attr; 42 | if (!attr) { 43 | attr = &stack_attr; 44 | err = pthread_mutexattr_init(&stack_attr); 45 | if (err != 0) 46 | return err; 47 | } 48 | 49 | /* mutexattr_settype requires _GNU_SOURCE or _XOPEN_SOURCE >= 500 on Linux */ 50 | err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE); 51 | if (err != 0) 52 | goto finish; 53 | 54 | err = pthread_mutex_init(mutex, attr); 55 | 56 | finish: 57 | if (attr == &stack_attr) 58 | pthread_mutexattr_destroy(&stack_attr); 59 | 60 | return err; 61 | } 62 | 63 | int usbi_get_tid(void) 64 | { 65 | int ret = -1; 66 | #if defined(__ANDROID__) 67 | ret = gettid(); 68 | #elif defined(__linux__) 69 | ret = syscall(SYS_gettid); 70 | #elif defined(__OpenBSD__) 71 | /* The following only works with OpenBSD > 5.1 as it requires 72 | real thread support. For 5.1 and earlier, -1 is returned. */ 73 | ret = syscall(SYS_getthrid); 74 | #elif defined(__APPLE__) 75 | ret = mach_thread_self(); 76 | mach_port_deallocate(mach_task_self(), ret); 77 | #elif defined(__CYGWIN__) 78 | ret = GetCurrentThreadId(); 79 | #endif 80 | /* TODO: NetBSD thread ID support */ 81 | return ret; 82 | } 83 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/os/threads_posix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libusb synchronization using POSIX Threads 3 | * 4 | * Copyright © 2010 Peter Stuge 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #ifndef LIBUSB_THREADS_POSIX_H 22 | #define LIBUSB_THREADS_POSIX_H 23 | 24 | #include 25 | 26 | #define usbi_mutex_static_t pthread_mutex_t 27 | #define USBI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER 28 | #define usbi_mutex_static_lock pthread_mutex_lock 29 | #define usbi_mutex_static_unlock pthread_mutex_unlock 30 | 31 | #define usbi_mutex_t pthread_mutex_t 32 | #define usbi_mutex_init pthread_mutex_init 33 | #define usbi_mutex_lock pthread_mutex_lock 34 | #define usbi_mutex_unlock pthread_mutex_unlock 35 | #define usbi_mutex_trylock pthread_mutex_trylock 36 | #define usbi_mutex_destroy pthread_mutex_destroy 37 | 38 | #define usbi_cond_t pthread_cond_t 39 | #define usbi_cond_init pthread_cond_init 40 | #define usbi_cond_wait pthread_cond_wait 41 | #define usbi_cond_timedwait pthread_cond_timedwait 42 | #define usbi_cond_broadcast pthread_cond_broadcast 43 | #define usbi_cond_destroy pthread_cond_destroy 44 | #define usbi_cond_signal pthread_cond_signal 45 | 46 | #define usbi_tls_key_t pthread_key_t 47 | #define usbi_tls_key_create pthread_key_create 48 | #define usbi_tls_key_get pthread_getspecific 49 | #define usbi_tls_key_set pthread_setspecific 50 | #define usbi_tls_key_delete pthread_key_delete 51 | 52 | extern int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr); 53 | 54 | int usbi_get_tid(void); 55 | 56 | #endif /* LIBUSB_THREADS_POSIX_H */ 57 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/version.h: -------------------------------------------------------------------------------- 1 | /* This file is parsed by m4 and windres and RC.EXE so please keep it simple. */ 2 | #include "version_nano.h" 3 | #ifndef LIBUSB_MAJOR 4 | #define LIBUSB_MAJOR 1 5 | #endif 6 | #ifndef LIBUSB_MINOR 7 | #define LIBUSB_MINOR 0 8 | #endif 9 | #ifndef LIBUSB_MICRO 10 | #define LIBUSB_MICRO 20 11 | #endif 12 | #ifndef LIBUSB_NANO 13 | #define LIBUSB_NANO 0 14 | #endif 15 | /* LIBUSB_RC is the release candidate suffix. Should normally be empty. */ 16 | #ifndef LIBUSB_RC 17 | #define LIBUSB_RC "" 18 | #endif 19 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/libusb/libusb/version_nano.h: -------------------------------------------------------------------------------- 1 | #define LIBUSB_NANO 11014 2 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/librtlsdr/src/convenience/convenience.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 by Kyle Keen 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* a collection of user friendly tools */ 19 | 20 | /*! 21 | * Convert standard suffixes (k, M, G) to double 22 | * 23 | * \param s a string to be parsed 24 | * \return double 25 | */ 26 | 27 | double atofs(char *s); 28 | 29 | /*! 30 | * Convert time suffixes (s, m, h) to double 31 | * 32 | * \param s a string to be parsed 33 | * \return seconds as double 34 | */ 35 | 36 | double atoft(char *s); 37 | 38 | /*! 39 | * Convert percent suffixe (%) to double 40 | * 41 | * \param s a string to be parsed 42 | * \return double 43 | */ 44 | 45 | double atofp(char *s); 46 | 47 | /*! 48 | * Find nearest supported gain 49 | * 50 | * \param dev the device handle given by rtlsdr_open() 51 | * \param target_gain in tenths of a dB 52 | * \return 0 on success 53 | */ 54 | 55 | int nearest_gain(rtlsdr_dev_t *dev, int target_gain); 56 | 57 | /*! 58 | * Set device frequency and report status on stderr 59 | * 60 | * \param dev the device handle given by rtlsdr_open() 61 | * \param frequency in Hz 62 | * \return 0 on success 63 | */ 64 | 65 | int verbose_set_frequency(rtlsdr_dev_t *dev, uint32_t frequency); 66 | 67 | /*! 68 | * Set device sample rate and report status on stderr 69 | * 70 | * \param dev the device handle given by rtlsdr_open() 71 | * \param samp_rate in samples/second 72 | * \return 0 on success 73 | */ 74 | 75 | int verbose_set_sample_rate(rtlsdr_dev_t *dev, uint32_t samp_rate); 76 | 77 | /*! 78 | * Enable or disable the direct sampling mode and report status on stderr 79 | * 80 | * \param dev the device handle given by rtlsdr_open() 81 | * \param on 0 means disabled, 1 I-ADC input enabled, 2 Q-ADC input enabled 82 | * \return 0 on success 83 | */ 84 | 85 | int verbose_direct_sampling(rtlsdr_dev_t *dev, int on); 86 | 87 | /*! 88 | * Enable offset tuning and report status on stderr 89 | * 90 | * \param dev the device handle given by rtlsdr_open() 91 | * \return 0 on success 92 | */ 93 | 94 | int verbose_offset_tuning(rtlsdr_dev_t *dev); 95 | 96 | /*! 97 | * Enable auto gain and report status on stderr 98 | * 99 | * \param dev the device handle given by rtlsdr_open() 100 | * \return 0 on success 101 | */ 102 | 103 | int verbose_auto_gain(rtlsdr_dev_t *dev); 104 | 105 | /*! 106 | * Set tuner gain and report status on stderr 107 | * 108 | * \param dev the device handle given by rtlsdr_open() 109 | * \param gain in tenths of a dB 110 | * \return 0 on success 111 | */ 112 | 113 | int verbose_gain_set(rtlsdr_dev_t *dev, int gain); 114 | 115 | /*! 116 | * Set the frequency correction value for the device and report status on stderr. 117 | * 118 | * \param dev the device handle given by rtlsdr_open() 119 | * \param ppm_error correction value in parts per million (ppm) 120 | * \return 0 on success 121 | */ 122 | 123 | int verbose_ppm_set(rtlsdr_dev_t *dev, int ppm_error); 124 | 125 | /*! 126 | * Reset buffer 127 | * 128 | * \param dev the device handle given by rtlsdr_open() 129 | * \return 0 on success 130 | */ 131 | 132 | int verbose_reset_buffer(rtlsdr_dev_t *dev); 133 | 134 | /*! 135 | * Find the closest matching device. 136 | * 137 | * \param s a string to be parsed 138 | * \return dev_index int, -1 on error 139 | */ 140 | 141 | int verbose_device_search(char *s); 142 | 143 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/SdrException.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef RTLSDR_SDREXCEPTION_H 22 | #define RTLSDR_SDREXCEPTION_H 23 | 24 | enum sdr_exception { 25 | EXIT_OK = 0, 26 | EXIT_WRONG_ARGS = 1, 27 | EXIT_INVALID_FD = 2, 28 | EXIT_NO_DEVICES = 3, 29 | EXIT_FAILED_TO_OPEN_DEVICE = 4, 30 | EXIT_CANNOT_RESTART = 5, 31 | EXIT_CANNOT_CLOSE = 6, 32 | EXIT_UNKNOWN = 7, 33 | EXIT_SIGNAL_CAUGHT = 8, 34 | EXIT_NOT_ENOUGH_POWER = 9, 35 | }; 36 | 37 | #endif //RTLSDR_SDREXCEPTION_H 38 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include 22 | #include 23 | #include "common.h" 24 | 25 | void throwExceptionWithInt(JNIEnv *env, const char * className, const int code) { 26 | jclass exClass = (*env)->FindClass(env, className); 27 | if (exClass == NULL) goto err; 28 | jmethodID method = (*env)->GetMethodID(env, exClass, "", "(I)V"); 29 | if (method == NULL) goto err; 30 | jthrowable exception = (jthrowable) (*env)->NewObject(env, exClass, method, (jint) code); 31 | if (exception == NULL) goto err; 32 | (*env)->Throw(env, exception); 33 | return; 34 | err: 35 | LOGI("Cannot throw an exception %s with code %d!", className, code); 36 | } 37 | 38 | extern void initialize(JNIEnv *env); 39 | static JavaVM *mVM = NULL; 40 | static jclass logClass; 41 | static jmethodID logMethod; 42 | jint JNI_OnLoad(JavaVM *vm, void *reserved) { 43 | JNIEnv *env = NULL; 44 | jint result = -1; 45 | if ((*vm)->GetEnv(vm, (void **) &env, JNI_VERSION_1_6) != JNI_OK) { 46 | return result; 47 | } 48 | mVM = vm; 49 | 50 | initialize(env); 51 | logClass = (jclass) (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/sdrtouch/tools/Log")); 52 | logMethod = (*env)->GetStaticMethodID(env, logClass, "appendLine", "(Ljava/lang/String;)V"); 53 | return JNI_VERSION_1_6; 54 | } 55 | 56 | int attachThread(JNIEnv **tEnv) { 57 | if ((*mVM)->GetEnv(mVM, (void **)tEnv, JNI_VERSION_1_6) == JNI_EDETACHED) { 58 | if ((*mVM)->AttachCurrentThread(mVM, tEnv, NULL) != JNI_OK) { 59 | return 0; 60 | } 61 | return 1; 62 | } 63 | // already attached, no need to attach or detatch 64 | return 2; 65 | } 66 | 67 | void detatchThread(int resultFromAttachThread) { 68 | if (resultFromAttachThread == 1) (*mVM)->DetachCurrentThread(mVM); 69 | } 70 | 71 | static void log(char * text) { 72 | JNIEnv * env; 73 | int res = attachThread(&env); 74 | 75 | __android_log_write(ANDROID_LOG_INFO, "SDR", text); 76 | 77 | if (env != NULL) { 78 | jthrowable pendingException = (*env)->ExceptionOccurred(env); 79 | if (pendingException != NULL) { 80 | (*env)->ExceptionClear(env); 81 | } 82 | 83 | jstring textJava = (*env)->NewStringUTF(env, text); 84 | (*env)->CallStaticVoidMethod(env, logClass, logMethod, textJava); 85 | (*env)->DeleteLocalRef(env, textJava); 86 | 87 | if (pendingException != NULL) { 88 | (*env)->Throw(env, pendingException); 89 | } 90 | } 91 | 92 | detatchThread(res); 93 | } 94 | 95 | void common_logf(const char *format, ...) 96 | { 97 | va_list arg; 98 | 99 | va_start (arg, format); 100 | char * output; 101 | 102 | int allocatedBytes = vasprintf(&output, format, arg); 103 | if (output != NULL && allocatedBytes >= 0) { 104 | log(output); 105 | free(output); 106 | } 107 | 108 | va_end (arg); 109 | } -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef COMMON_C_ 22 | #define COMMON_C_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #define LOGI(...) ((void)common_logf(__VA_ARGS__)) 29 | #define LOGI_NATIVE(...) ((void)__android_log_print(ANDROID_LOG_INFO, "SDR", __VA_ARGS__)) 30 | 31 | #define EXCEPT_SAFE_NUM(expression) expression; if ((*env)->ExceptionCheck(env)) return 0; 32 | #define EXCEPT_SAFE_VOID(expression) expression; if ((*env)->ExceptionCheck(env)) return; 33 | #define EXCEPT_SAFE_GOTO(expression, label) expression; if ((*env)->ExceptionCheck(env)) goto label; 34 | #define EXCEPT_DO(expression, action) expression; if ((*env)->ExceptionCheck(env)) action; 35 | 36 | void throwExceptionWithInt(JNIEnv *env, const char * className, const int code); 37 | 38 | int attachThread(JNIEnv **tEnv); 39 | void detatchThread(int resultFromAttachThread); 40 | void common_logf(const char *format, ...); 41 | 42 | #endif -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/extbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef EXTBUFFER_H_ 22 | #define EXTBUFFER_H_ 23 | 24 | #define EXTBUFF_TYPE_INT (0) 25 | #define EXTBUFF_TYPE_FLOAT (1) 26 | #define EXTBUFF_TYPE_CHAR (2) 27 | #define EXTBUFF_TYPE_SHORT (3) 28 | #define EXTBUFF_TYPE_USHORT (4) 29 | 30 | #include "stdint.h" 31 | #include 32 | 33 | // enable for debugging purposes 34 | #define SHOW_EXTBUFF_USAGE (0) 35 | 36 | typedef struct extbuffer { 37 | 38 | jint * intbuffer; 39 | jfloat * floatbuffer; 40 | char * charbuffer; 41 | int16_t * shortbuffer; 42 | uint16_t * ushortbuffer; 43 | 44 | int buffer_max_size; 45 | int type; 46 | 47 | int size_valid_elements; 48 | 49 | volatile int valid; 50 | volatile int cleartozero; 51 | 52 | } extbuffer_t; 53 | 54 | void extbuffer_init(extbuffer_t * container, int type); 55 | void extbuffer_preparetohandle(extbuffer_t * container, int size); 56 | void extbuffer_cleartozero(extbuffer_t * container); 57 | void extbuffer_free(extbuffer_t * container); 58 | 59 | 60 | #endif /* EXTBUFFER_H_ */ 61 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/queue.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include "queue.h" 22 | #include 23 | #include 24 | #include 25 | 26 | typedef struct queue_element queue_element_t; 27 | 28 | struct queue_element { 29 | queue_element_t * next; 30 | queue_element_t * prev; 31 | queue_element_t * last; 32 | void * payload; 33 | }; 34 | 35 | void queue_add(queue_t * queue, void * ptr) { 36 | if (*queue == NULL) { 37 | queue_element_t * new_el = (queue_element_t *) malloc(sizeof(queue_element_t)); 38 | new_el->last = new_el; 39 | new_el->next = NULL; 40 | new_el->prev = NULL; 41 | new_el->payload = ptr; 42 | *queue = (void *) new_el; 43 | } else { 44 | queue_element_t * qe = (queue_element_t *) *queue; 45 | queue_element_t * new_el = (queue_element_t *) malloc(sizeof(queue_element_t)); 46 | new_el->last = NULL; 47 | new_el->next = NULL; 48 | new_el->prev = qe->last; 49 | new_el->payload = ptr; 50 | qe->last->next = new_el; 51 | qe->last = new_el; 52 | } 53 | } 54 | 55 | void * queue_pop(queue_t * queue) { 56 | if (*queue == NULL) return NULL; 57 | 58 | queue_element_t * qe = (queue_element_t *) *queue; 59 | 60 | if (qe->next != NULL) { 61 | qe->next->prev = NULL; 62 | qe->next->last = qe->last; 63 | } 64 | 65 | void * result = qe->payload; 66 | *queue = (void *) qe->next; 67 | 68 | free(qe); 69 | 70 | return result; 71 | } 72 | 73 | /* Usage: 74 | void queue_unit_test(void) { 75 | queue_t queue = NULL; 76 | 77 | int a = 1; int b = 3; int c = 5; int d = 18; 78 | 79 | queue_add(&queue, (void *) &a); 80 | queue_add(&queue, (void *) &b); 81 | queue_add(&queue, (void *) &c); 82 | queue_add(&queue, (void *) &d); 83 | 84 | c = 12; 85 | 86 | int * ans; 87 | while ((ans = (int *) queue_pop(&queue))) 88 | printf("%d ", *ans); 89 | // prints out 1 3 12 18 90 | } 91 | */ 92 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef QUEUE_H 22 | #define QUEUE_H 23 | 24 | typedef void * queue_t; 25 | 26 | void queue_add(queue_t * queue, void * ptr); 27 | void * queue_pop(queue_t * queue); 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/sdrtcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef TCP_SDR_C_ 22 | #define TCP_SDR_C_ 23 | 24 | #include 25 | #include "workpool.h" 26 | #include "threading.h" 27 | 28 | #define DESIRED_MAX_NUMBER_OF_SAMPLES (32767) 29 | 30 | typedef struct sdr_tcp_command{ 31 | uint8_t command; 32 | uint32_t parameter; 33 | }__attribute__((packed)) sdr_tcp_command_t; 34 | 35 | typedef struct sdrtcp sdrtcp_t; 36 | 37 | typedef void (*sdrtcp_command_callback)(sdrtcp_t *, void * ctx, sdr_tcp_command_t *); 38 | typedef void (*sdrtcp_closed_callback)(sdrtcp_t *, void * ctx); 39 | 40 | struct sdrtcp { 41 | volatile int state; 42 | pthread_mutex_t state_locker; 43 | workpool_t workpool; 44 | 45 | sdrtcp_closed_callback closedcb; 46 | sdrtcp_command_callback commandcb; 47 | void * ctx; 48 | 49 | volatile int client_socket; 50 | volatile int listen_socket; 51 | }; 52 | 53 | void sdrtcp_init(sdrtcp_t * obj); 54 | void sdrtcp_free(sdrtcp_t * obj); 55 | 56 | // Opens socket. If this returns true then we are ready to wait for client 57 | // dongleMagic must be exactly 4 characters long! 58 | int sdrtcp_open_socket(sdrtcp_t * obj, const char * address, int port, const char * dongleMagic, uint32_t dongleType, uint32_t gainsCount); 59 | 60 | 61 | // Starts waiting for and feeding a client asynchroneously 62 | // if a command is received command cb will be called (guaranteed in a separate thread). This callback can be called after sdrtcp_stop_serving_client!!! 63 | // if for any reason the server stops, closedcb will be called (in a separate thread unless a config error) 64 | void sdrtcp_serve_client_async(sdrtcp_t * obj, void * ctx, sdrtcp_command_callback commandcb, sdrtcp_closed_callback closedcb); 65 | 66 | // doesn't block 67 | void sdrtcp_stop_serving_client(sdrtcp_t * obj); 68 | 69 | // queue up data to send over the connection 70 | // return 0 if there was an error and this function should not be called anymore until another sdrtcp_open_socket 71 | int sdrtcp_feed(sdrtcp_t * obj, unsigned char * buf, uint32_t len); 72 | 73 | #endif -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/tcp_commands.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef RTLSDR_TCP_COMMANDS_H 22 | #define RTLSDR_TCP_COMMANDS_H 23 | 24 | // These are the commands that clients can send to the driver 25 | // they are send by the client via the TCP connection 26 | // each command consists of a uint8_t code and a uint32_t parameter 27 | // parameter descriptions are on the left 28 | 29 | typedef enum 30 | { 31 | // Standard rtl-tcp API 32 | TCP_SET_FREQ = 0x01, // rtlsdr_set_center_freq 33 | TCP_SET_SAMPLE_RATE = 0x02, // rtlsdr_set_sample_rate 34 | TCP_SET_GAIN_MODE = 0x03, // rtlsdr_set_tuner_gain_mode 35 | TCP_SET_GAIN = 0x04, // rtlsdr_set_tuner_gain 36 | TCP_SET_FREQ_CORRECTION = 0x05, // rtlsdr_set_freq_correction 37 | TCP_SET_IF_TUNER_GAIN = 0x06, // rtlsdr_set_tuner_if_gain 38 | TCP_SET_TEST_MODE = 0x07, // rtlsdr_set_testmode 39 | TCP_SET_AGC_MODE = 0x08, // rtlsdr_set_agc_mode 40 | TCP_SET_DIRECT_SAMPLING = 0x09, // rtlsdr_set_direct_sampling 41 | TCP_SET_OFFSET_TUNING = 0x0a, // rtlsdr_set_offset_tuning 42 | TCP_SET_RTL_XTAL = 0x0b, // rtlsdr_set_xtal_freq with rtl_freq set as the parameter 43 | TCP_SET_TUNER_XTAL = 0x0c, // rtlsdr_set_xtal_freq with tuner_freq set as the parameter 44 | TCP_SET_TUNER_GAIN_BY_ID = 0x0d, // set_gain_by_index 45 | 46 | // Android only rtl-tcp API 47 | TCP_ANDROID_EXIT = 0x7e, // send any value to cause the driver to turn off itself 48 | TCP_ANDROID_GAIN_BY_PERCENTAGE = 0x7f, // set device gain by percentage. send values 0 to 100, where 0 means no gain and 100 means maximum gain 49 | TCP_ANDROID_ENABLE_16_BIT_SIGNED = 0x80, // [NOT SUPPORTED IN RTL-SDR] set to 1 to enable 16 bit unsigned sample size (only supported devices such as SDRplay) 50 | } tcp_commands_t; 51 | 52 | #endif //RTLSDR_TCP_COMMANDS_H 53 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/threading.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include "threading.h" 22 | 23 | void atomic_int_init(atomic_int_t * var, const int value) { 24 | pthread_mutex_init(&var->locker, NULL); 25 | atomic_int_setval(var, value); 26 | } 27 | 28 | int atomic_int_getval(atomic_int_t * var) { 29 | int val; 30 | pthread_mutex_lock(&var->locker); 31 | val = var->value; 32 | pthread_mutex_unlock(&var->locker); 33 | return val; 34 | } 35 | 36 | int atomic_int_getval_and_set(atomic_int_t * var, const int value) { 37 | int val; 38 | pthread_mutex_lock(&var->locker); 39 | val = var->value; 40 | var->value = value; 41 | pthread_mutex_unlock(&var->locker); 42 | return val; 43 | } 44 | 45 | void atomic_int_free(atomic_int_t * var) { 46 | pthread_mutex_destroy(&var->locker); 47 | } 48 | 49 | void atomic_int_setval(atomic_int_t * var, const int value) { 50 | pthread_mutex_lock(&var->locker); 51 | var->value = value; 52 | pthread_mutex_unlock(&var->locker); 53 | } 54 | 55 | 56 | void signaller_wait(thread_signaller_t * var) { 57 | pthread_mutex_lock(&var->locker); 58 | if (!var->already_called) pthread_cond_wait(&var->condition, &var->locker); 59 | pthread_mutex_unlock(&var->locker); 60 | } 61 | 62 | void signaller_signal(thread_signaller_t * var) { 63 | pthread_mutex_lock(&var->locker); 64 | var->already_called = 1; 65 | pthread_cond_broadcast(&var->condition); 66 | pthread_mutex_unlock(&var->locker); 67 | } 68 | 69 | void signaller_reset(thread_signaller_t * var) { 70 | pthread_mutex_lock(&var->locker); 71 | var->already_called = 0; 72 | pthread_mutex_unlock(&var->locker); 73 | } -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/threading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef THREADING_MARTIN_H_ 22 | #define THREADING_MARTIN_H_ 23 | 24 | #include 25 | 26 | struct atomic_int { 27 | volatile int value; 28 | pthread_mutex_t locker; 29 | } typedef atomic_int_t; 30 | 31 | #define ATOMIC_INT_INIT(val) {(val), PTHREAD_MUTEX_INITIALIZER} 32 | 33 | void atomic_int_init(atomic_int_t * var, const int value); 34 | int atomic_int_getval(atomic_int_t * var); 35 | int atomic_int_getval_and_set(atomic_int_t * var, const int value); 36 | void atomic_int_free(atomic_int_t * var); 37 | void atomic_int_setval(atomic_int_t * var, const int value); 38 | 39 | struct thread_signaller { 40 | pthread_mutex_t locker; 41 | pthread_cond_t condition; 42 | volatile int already_called; 43 | } typedef thread_signaller_t; 44 | 45 | #define SIGNALLER_INIT {PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0} 46 | 47 | void signaller_wait(thread_signaller_t * var); 48 | void signaller_signal(thread_signaller_t * var); 49 | void signaller_reset(thread_signaller_t * var); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/workpool.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #include "workpool.h" 22 | #include 23 | 24 | #define WORKPOOL_WARNINGS (DEBUG_MODE) 25 | 26 | #define TIMEOUT_MS (1000) 27 | 28 | static extbuffer_t * pop(workpool_t * pool, int id, int block) { 29 | extbuffer_t * result = NULL; 30 | if (!pool->valid) return result; 31 | #if WORKPOOL_WARNINGS 32 | if (id < 0 || id >= pool->max_ids) LOGI("WORKPOOL EXCEPTION: Tried popping impossible id %d out of %d!\n", id, pool->max_ids); 33 | #endif 34 | 35 | pthread_mutex_lock(&pool->mutexes[id]); 36 | result = queue_pop(&pool->queues[id]); 37 | if (result == NULL && block) { 38 | struct timeval tp; 39 | struct timespec ts; 40 | gettimeofday(&tp, NULL); 41 | 42 | ts.tv_sec = tp.tv_sec; 43 | ts.tv_nsec = tp.tv_usec * 1000; 44 | ts.tv_nsec += TIMEOUT_MS * 1000000; 45 | ts.tv_sec += ts.tv_nsec / 1000000000L; 46 | ts.tv_nsec = ts.tv_nsec % 1000000000L; 47 | 48 | pthread_cond_timedwait(&pool->conditions[id], &pool->mutexes[id], &ts); 49 | 50 | result = queue_pop(&pool->queues[id]); 51 | } 52 | pthread_mutex_unlock(&pool->mutexes[id]); 53 | 54 | return result; 55 | } 56 | 57 | static void add(workpool_t * pool, int id, extbuffer_t * buffer) { 58 | if (!pool->valid) return; 59 | #if WORKPOOL_WARNINGS 60 | if (buffer == NULL) { 61 | LOGI("WORKPOOL EXCEPTION: NULL buffer!"); 62 | return; 63 | } 64 | 65 | if (id < 0 || id >= pool->max_ids) LOGI("WORKPOOL EXCEPTION: Tried adding impossible id %d out of %d!\n", id, pool->max_ids); 66 | #endif 67 | 68 | pthread_mutex_lock(&pool->mutexes[id]); 69 | queue_add(&pool->queues[id], buffer); 70 | pthread_cond_broadcast(&pool->conditions[id]); 71 | pthread_mutex_unlock(&pool->mutexes[id]); 72 | } 73 | 74 | extbuffer_t * pool_get_wait_lock(workpool_t * pool, int id, int block) { 75 | if (!pool->valid) return NULL; 76 | extbuffer_t * result = pop(pool, id, 0); 77 | 78 | if (result == NULL) { 79 | if (id == 0 && pool->elements < pool->max_elements) { 80 | result = (extbuffer_t *) malloc(sizeof(extbuffer_t)); 81 | extbuffer_init(result, pool->extbuffer_type); 82 | pool->elements++; 83 | } else if (block) { 84 | result = pop(pool, id, 1); 85 | } 86 | } 87 | 88 | return result; 89 | } 90 | 91 | void pool_get_unlock(workpool_t * pool, int id, extbuffer_t * buffer) { 92 | if (!pool->valid) return; 93 | #if WORKPOOL_WARNINGS 94 | if (buffer == NULL) LOGI("WORKPOOL EXCEPTION: Was supplied a NULL buffer!\n"); 95 | #endif 96 | if (id == pool->max_ids-1) { 97 | extbuffer_preparetohandle(buffer, 0); 98 | add(pool, 0, buffer); 99 | } else { 100 | add(pool, id+1, buffer); 101 | } 102 | } 103 | 104 | void pool_init(workpool_t * pool, int max_elements, int extbuffer_type) { 105 | pool->queues = NULL; 106 | pool->mutexes = NULL; 107 | pool->conditions = NULL; 108 | pool->max_elements = max_elements; 109 | pool->max_ids = 0; 110 | pool->elements = 0; 111 | pool->extbuffer_type = extbuffer_type; 112 | pool->valid = 0; 113 | } 114 | 115 | void pool_free(workpool_t * pool) { 116 | if (pool->max_ids > 0) { 117 | int i; 118 | for (i = 0; i < pool->max_ids; i++) { 119 | extbuffer_t * buff; 120 | while ((buff = queue_pop(&pool->queues[i]))) { 121 | extbuffer_free(buff); 122 | free (buff); 123 | pool->elements--; 124 | } 125 | pthread_mutex_destroy(&pool->mutexes[i]); 126 | pthread_cond_destroy(&pool->conditions[i]); 127 | } 128 | 129 | free(pool->queues); 130 | free(pool->mutexes); 131 | free(pool->conditions); 132 | 133 | pool->max_ids = 0; 134 | #if WORKPOOL_WARNINGS 135 | if (pool->elements != 0) LOGI("WORKPOOL EXCEPTION: Workpool free has a memory leak! %d elements were not freed!\n", pool->elements); 136 | #endif 137 | pool->elements = 0; 138 | } 139 | pool->valid = 0; 140 | } 141 | 142 | void pool_set_threads(workpool_t * pool, int number_of_ids) { 143 | if (number_of_ids <= 0) return; 144 | pool_free(pool); 145 | pool->max_ids = number_of_ids; 146 | 147 | pool->queues = (queue_t *) malloc(sizeof(queue_t) * pool->max_ids); 148 | pool->mutexes = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t) * pool->max_ids); 149 | pool->conditions = (pthread_cond_t *) malloc(sizeof(pthread_cond_t) * pool->max_ids); 150 | 151 | int i; 152 | for (i = 0; i < pool->max_ids; i++) { 153 | pool->queues[i] = NULL; 154 | pthread_mutex_init(&pool->mutexes[i], NULL); 155 | pthread_cond_init(&pool->conditions[i], NULL); 156 | 157 | } 158 | 159 | pool->valid = 1; 160 | } 161 | -------------------------------------------------------------------------------- /rtlsdr/src/main/cpp/src/workpool.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | #ifndef WORKPOOL_H_ 22 | #define WORKPOOL_H_ 23 | 24 | #include "extbuffer.h" 25 | #include "queue.h" 26 | #include 27 | #include 28 | 29 | typedef struct workpool { 30 | queue_t * queues; 31 | pthread_mutex_t * mutexes; 32 | pthread_cond_t * conditions; 33 | int max_elements; 34 | int max_ids; 35 | int elements; 36 | int extbuffer_type; 37 | volatile int valid; 38 | } workpool_t; 39 | 40 | // thread safe methods 41 | extbuffer_t * pool_get_wait_lock(workpool_t * pool, int id, int block); 42 | void pool_get_unlock(workpool_t * pool, int id, extbuffer_t * buffer); 43 | 44 | 45 | // non thread safe methods 46 | void pool_init(workpool_t * pool, int max_elements, int extbuffer_type); 47 | void pool_free(workpool_t * pool); 48 | void pool_set_threads(workpool_t * pool, int number_of_ids); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /rtlsdr/src/main/java/com/sdrtouch/rtlsdr/driver/RtlSdrDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.driver; 22 | 23 | import android.content.Context; 24 | import android.hardware.usb.UsbDevice; 25 | import android.hardware.usb.UsbDeviceConnection; 26 | 27 | import com.sdrtouch.core.SdrTcpArguments; 28 | import com.sdrtouch.core.devices.SdrDevice; 29 | import com.sdrtouch.core.exceptions.SdrException; 30 | import com.sdrtouch.tools.Log; 31 | import com.sdrtouch.tools.UsbPermissionObtainer; 32 | 33 | import java.util.concurrent.ExecutionException; 34 | 35 | public class RtlSdrDevice extends SdrDevice { 36 | private final UsbDevice usbDevice; 37 | private final long nativeHandler; 38 | 39 | 40 | public RtlSdrDevice(Context context, UsbDevice usbDevice) { 41 | super(context); 42 | this.usbDevice = usbDevice; 43 | this.nativeHandler = initialize(); 44 | } 45 | 46 | @Override 47 | public void openAsync(final SdrTcpArguments sdrTcpArguments) { 48 | new Thread() { 49 | @Override 50 | public void run() { 51 | try { 52 | int fd = openSessionAndGetFd(); 53 | String path = usbDevice.getDeviceName(); 54 | if (!openAsync(nativeHandler, fd, sdrTcpArguments.getGain(), sdrTcpArguments.getSamplerateHz(), sdrTcpArguments.getFrequencyHz(), sdrTcpArguments.getPort(), sdrTcpArguments.getPpm(), sdrTcpArguments.getBiasT(),sdrTcpArguments.getAddress(), path)) { 55 | announceOnClosed(new SdrException(SdrException.EXIT_UNKNOWN)); 56 | } else { 57 | announceOnClosed(null); 58 | } 59 | } catch (Throwable e) { 60 | announceOnClosed(e); 61 | } 62 | } 63 | }.start(); 64 | } 65 | 66 | @Override 67 | public void close() { 68 | close(nativeHandler); 69 | } 70 | 71 | @Override 72 | public String getName() { 73 | return "rtl-sdr "+usbDevice.getDeviceName(); 74 | } 75 | 76 | private int openSessionAndGetFd() throws ExecutionException, InterruptedException { 77 | UsbDeviceConnection deviceConnection = UsbPermissionObtainer.obtainFdFor(context, usbDevice).get(); 78 | if (deviceConnection == null) throw new RuntimeException("Could not get a connection"); 79 | int fd = deviceConnection.getFileDescriptor(); 80 | Log.appendLine("Opening fd "+fd); 81 | return fd; 82 | } 83 | 84 | @Override 85 | protected void finalize() throws Throwable { 86 | super.finalize(); 87 | deInit(nativeHandler); 88 | } 89 | 90 | @Override 91 | public native int[] getSupportedCommands(); 92 | 93 | private native long initialize(); 94 | private native void close(long pointer); 95 | private native void deInit(long pointer); 96 | private native boolean openAsync(long pointer, int fd, int gain, long samplingrate, long frequency, int port, int ppm, int biast, String address, String devicePath) throws Exception; 97 | } 98 | -------------------------------------------------------------------------------- /rtlsdr/src/main/java/com/sdrtouch/rtlsdr/driver/RtlSdrDeviceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.driver; 22 | 23 | import android.content.Context; 24 | import android.hardware.usb.UsbDevice; 25 | 26 | import com.sdrtouch.core.devices.SdrDevice; 27 | import com.sdrtouch.core.devices.SdrDeviceProvider; 28 | import com.sdrtouch.tools.UsbPermissionHelper; 29 | 30 | import java.util.LinkedList; 31 | import java.util.List; 32 | import java.util.Set; 33 | 34 | import info.martinmarinov.rtlsdr.R; 35 | 36 | public class RtlSdrDeviceProvider implements SdrDeviceProvider { 37 | @Override 38 | public List listDevices(Context ctx, boolean forceRoot) { 39 | Set availableUsbDevices = UsbPermissionHelper.getAvailableUsbDevices(ctx, R.xml.rtl_sdr_device_filter); 40 | List devices = new LinkedList<>(); 41 | for (UsbDevice usbDevice : availableUsbDevices) devices.add(new RtlSdrDevice(ctx, usbDevice)); 42 | return devices; 43 | } 44 | 45 | @Override 46 | public String getName() { 47 | return "RtlSdr"; 48 | } 49 | 50 | @Override 51 | public boolean loadNativeLibraries() { 52 | try { 53 | System.loadLibrary("rtlSdrAndroid"); 54 | return true; 55 | } catch (Throwable t) { 56 | t.printStackTrace(); 57 | return false; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /rtlsdr/src/main/java/com/sdrtouch/rtlsdr/driver/RtlSdrException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.driver; 22 | 23 | import com.sdrtouch.rtlsdr.driver.enums.RtlSdrExceptionCode; 24 | 25 | import com.sdrtouch.core.exceptions.SdrException; 26 | import com.sdrtouch.rtlsdr.driver.enums.RtlSdrExceptionCode; 27 | import com.sdrtouch.tools.Log; 28 | 29 | public class RtlSdrException extends SdrException { 30 | public RtlSdrException(String exceptionCode) { 31 | super(RtlSdrExceptionCode.idFromExceptionCode(exceptionCode)); 32 | Log.appendLine("RtlSdrException: "+exceptionCode); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rtlsdr/src/main/java/com/sdrtouch/rtlsdr/driver/enums/RtlSdrExceptionCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.rtlsdr.driver.enums; 22 | 23 | import com.sdrtouch.core.UsedByJni; 24 | import com.sdrtouch.core.exceptions.SdrException; 25 | 26 | public enum RtlSdrExceptionCode { 27 | @UsedByJni rtls_sdr_Success(SdrException.EXIT_OK), 28 | @UsedByJni rtls_sdr_Fail(SdrException.EXIT_UNKNOWN); 29 | 30 | private final int code; 31 | 32 | RtlSdrExceptionCode(int code) { 33 | this.code = code; 34 | } 35 | 36 | public static int idFromExceptionCode(String exceptionCode) { 37 | for (RtlSdrExceptionCode code : values()) { 38 | if (code.name().equals(exceptionCode)) return code.code; 39 | } 40 | return SdrException.EXIT_UNKNOWN; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rtlsdr/src/main/res/xml/rtl_sdr_device_filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /sdrdrivertools/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /sdrdrivertools/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'info.martinmarinov.sdrdrivertools' 7 | compileSdk 34 8 | 9 | defaultConfig { 10 | minSdk 21 11 | targetSdk 34 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | } 28 | 29 | dependencies { 30 | 31 | implementation 'androidx.appcompat:appcompat:1.5.1' 32 | implementation 'com.google.android.material:material:1.6.1' 33 | testImplementation 'junit:junit:4.13.2' 34 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 35 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 36 | } -------------------------------------------------------------------------------- /sdrdrivertools/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/signalwareltd/rtl_tcp_andro-/08672ad9d4e72095bbe115dbbc920ecd90b8744f/sdrdrivertools/consumer-rules.pro -------------------------------------------------------------------------------- /sdrdrivertools/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /sdrdrivertools/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/core/SdrTcpArguments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.core; 22 | 23 | import static com.sdrtouch.tools.Check.stringLessThan; 24 | 25 | import com.sdrtouch.tools.ArgumentParser; 26 | 27 | import java.io.Serializable; 28 | 29 | public class SdrTcpArguments implements Serializable { 30 | private static final long serialVersionUID = 1L; 31 | private static final int MAX_STRING_LENGTH = 256; 32 | 33 | private static final int DEFAULT_GAIN = 24; 34 | private static final int DEFAULT_PPM = 0; 35 | private static final long DEFAULT_FREQUENCY = 100000000; 36 | private static final long DEFAULT_SAMPLING_RATE = 2048000; 37 | private static final int DEFAULT_BIAST = 0; 38 | 39 | private final int gain; 40 | private final long samplerateHz; 41 | private final long frequencyHz; 42 | private final String address; 43 | private final int port; 44 | private final int ppm; 45 | private final int biast; 46 | 47 | public static SdrTcpArguments fromString(String arguments) throws IllegalArgumentException { 48 | return new SdrTcpArguments(new ArgumentParser(arguments)); 49 | } 50 | 51 | private SdrTcpArguments(ArgumentParser arguments) { 52 | this.gain = arguments.getIntArgumentOrDefault("g", DEFAULT_GAIN); 53 | this.samplerateHz = arguments.getLongArgumentOrDefault("s", DEFAULT_SAMPLING_RATE); 54 | this.frequencyHz = arguments.getLongArgumentOrDefault("f", DEFAULT_FREQUENCY); 55 | this.address = stringLessThan(arguments.getStringArgument("a"), MAX_STRING_LENGTH); 56 | this.port = arguments.getIntArgument("p"); 57 | this.ppm = arguments.getIntArgumentOrDefault("P", DEFAULT_PPM); 58 | this.biast = arguments.getIntArgumentOrDefault("T", DEFAULT_BIAST); 59 | } 60 | 61 | public int getGain() { 62 | return gain; 63 | } 64 | 65 | public long getSamplerateHz() { 66 | return samplerateHz; 67 | } 68 | 69 | public long getFrequencyHz() { 70 | return frequencyHz; 71 | } 72 | 73 | public String getAddress() { 74 | return address; 75 | } 76 | 77 | public int getPort() { 78 | return port; 79 | } 80 | 81 | public int getPpm() { 82 | return ppm; 83 | } 84 | 85 | public int getBiasT() { return biast; } 86 | 87 | @Override 88 | public String toString() { 89 | return "SdrTcpArguments{" + 90 | "gain=" + gain + 91 | ", samplerateHz=" + samplerateHz + 92 | ", frequencyHz=" + frequencyHz + 93 | ", address='" + address + '\'' + 94 | ", port=" + port + 95 | ", ppm=" + ppm + 96 | ", biast=" + biast + 97 | '}'; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/core/UsedByJni.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.core; 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | 29 | /** 30 | * Marks methods that are invoked by JNI directly. 31 | * They should not be renamed or their signature changed. 32 | */ 33 | @Retention(RetentionPolicy.SOURCE) 34 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) 35 | public @interface UsedByJni { 36 | } 37 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/core/devices/SdrDevice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.core.devices; 22 | 23 | import android.content.Context; 24 | import com.sdrtouch.core.SdrTcpArguments; 25 | import com.sdrtouch.core.UsedByJni; 26 | 27 | import java.io.Serializable; 28 | import java.util.LinkedList; 29 | 30 | public abstract class SdrDevice implements Serializable { 31 | private static final long serialVersionUID = 6042726358096490615L; 32 | private final LinkedList listeners = new LinkedList<>(); 33 | protected final Context context; 34 | 35 | protected SdrDevice(Context context) { 36 | this.context = context; 37 | } 38 | 39 | /** 40 | * Each listener can only hear OnClosed once from this SdrDevice. As soon as there is a single listener, 41 | * the class becomes non-serializable! Keep it in mind! 42 | */ 43 | public void addOnStatusListener(OnStatusListener listener) { 44 | synchronized (listeners) { 45 | listeners.add(listener); 46 | } 47 | } 48 | 49 | /** 50 | * Always call this when the rtl-tcp is no longer running 51 | * @param e if the rtl-tcp stopped due to an exception or null if it was successful 52 | */ 53 | protected void announceOnClosed(Throwable e) { 54 | synchronized (listeners) { 55 | OnStatusListener listener; 56 | while ((listener = listeners.poll()) != null) listener.onClosed(e); 57 | } 58 | } 59 | 60 | /** 61 | * Always call this when the rtl-tcp is ready to accept connections 62 | */ 63 | @UsedByJni 64 | protected void announceOnOpen() { 65 | synchronized (listeners) { 66 | for (OnStatusListener listener: listeners) listener.onOpen(this); 67 | } 68 | } 69 | 70 | public abstract int[] getSupportedCommands(); 71 | 72 | /** 73 | * This should return as soon as possible. 74 | * Your implementation should notify the listers asynchronously if this has succeeded or not. 75 | * This method should not throw an exception! 76 | * @param sdrTcpArguments the startup arguments 77 | */ 78 | public abstract void openAsync(SdrTcpArguments sdrTcpArguments); 79 | 80 | /** 81 | * When anyone asks to close the rtl-tcp. This implementation doesn't need to block until the device is closed. 82 | * You must also call {@link #announceOnClosed(Throwable)} with a null argument to indicate successful closure. 83 | */ 84 | public abstract void close(); 85 | 86 | /** 87 | * Get a friendly name to be displayed to the user 88 | */ 89 | public abstract String getName(); 90 | 91 | /** 92 | * Note: This class is not serializable due to listeners rarely being serializable in real life. 93 | * 94 | * @author martinmarinov 95 | * 96 | */ 97 | public interface OnStatusListener { 98 | /** 99 | * When the rtl-tcp compatible service has been successfully started 100 | */ 101 | void onOpen(SdrDevice sdrDevice); 102 | 103 | /** 104 | * When the rtl-tcp compatible service has been destroyed. 105 | * @param e can be null if running was successfull and there was no error 106 | */ 107 | void onClosed(Throwable e); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/core/devices/SdrDeviceProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.core.devices; 22 | 23 | import android.content.Context; 24 | 25 | import java.util.List; 26 | 27 | public interface SdrDeviceProvider { 28 | List listDevices(Context ctx, boolean forceRoot); 29 | String getName(); 30 | boolean loadNativeLibraries(); 31 | } 32 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/AsyncFuture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import static com.sdrtouch.tools.Check.isTrue; 24 | 25 | import androidx.annotation.NonNull; 26 | 27 | import java.util.concurrent.ExecutionException; 28 | import java.util.concurrent.Future; 29 | import java.util.concurrent.TimeUnit; 30 | import java.util.concurrent.TimeoutException; 31 | 32 | /** 33 | * This is a future task that will block until result has been returned 34 | */ 35 | public class AsyncFuture implements Future { 36 | private final Object locker = new Object(); 37 | private V object; 38 | private boolean ready = false; 39 | 40 | @Override 41 | public boolean cancel(boolean mayInterruptIfRunning) { 42 | return false; 43 | } 44 | 45 | @Override 46 | public boolean isCancelled() { 47 | return false; 48 | } 49 | 50 | @Override 51 | public boolean isDone() { 52 | synchronized (locker) { 53 | return ready; 54 | } 55 | } 56 | 57 | @Override 58 | public V get() throws InterruptedException, ExecutionException { 59 | synchronized (locker) { 60 | locker.wait(); 61 | return object; 62 | } 63 | } 64 | 65 | @Override 66 | public V get(long timeout, @NonNull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { 67 | synchronized (locker) { 68 | locker.wait(unit.toMillis(timeout)); 69 | return object; 70 | } 71 | } 72 | 73 | public void setDone(V object) { 74 | synchronized (locker) { 75 | isTrue(!this.ready); 76 | this.object = object; 77 | this.ready = true; 78 | locker.notify(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/Check.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | public class Check { 24 | public static void isTrue(boolean condition) { 25 | if (!condition) throw new RuntimeException(); 26 | } 27 | 28 | public static T isNotNull(T object) { 29 | isTrue(object != null); 30 | return object; 31 | } 32 | 33 | public static T isNull(T object) { 34 | isTrue(object == null); 35 | return null; 36 | } 37 | 38 | public static String stringLessThan(String text, int max_length) { 39 | if (text != null && text.length() > max_length) throw new IllegalArgumentException("String cannot exceed "+max_length); 40 | return text; 41 | } 42 | 43 | private Check() {} 44 | } 45 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/CompletedFuture.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import java.util.concurrent.ExecutionException; 24 | import java.util.concurrent.Future; 25 | import java.util.concurrent.TimeUnit; 26 | import java.util.concurrent.TimeoutException; 27 | 28 | public class CompletedFuture implements Future { 29 | 30 | private final T result; 31 | 32 | public CompletedFuture(T result) { 33 | this.result = result; 34 | } 35 | 36 | @Override 37 | public boolean cancel(boolean mayInterruptIfRunning) { 38 | return false; 39 | } 40 | 41 | @Override 42 | public boolean isCancelled() { 43 | return false; 44 | } 45 | 46 | @Override 47 | public boolean isDone() { 48 | return true; 49 | } 50 | 51 | @Override 52 | public T get() throws InterruptedException, ExecutionException { 53 | return result; 54 | } 55 | 56 | @Override 57 | public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { 58 | return result; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import com.sdrtouch.core.UsedByJni; 24 | 25 | import java.util.HashSet; 26 | import java.util.Set; 27 | 28 | public abstract class Log { 29 | private final static StringBuilder log = new StringBuilder(); 30 | private final static Object locker = new Object(); 31 | private final static Set callbacks = new HashSet<>(); 32 | 33 | public static void appendLine(String format, Object ... args) { 34 | appendLine(String.format(format, args)); 35 | } 36 | 37 | @UsedByJni 38 | public static void appendLine(String what) { 39 | android.util.Log.d("RtlSdr", what); 40 | while (what.charAt(what.length()-1) == '\n') { 41 | what = what.substring(0, what.length()-1); 42 | } 43 | what+="\n"; 44 | synchronized (locker) { 45 | log.append(what); 46 | for (final Log.Callback callback : callbacks) callback.onChanged(); 47 | } 48 | } 49 | 50 | public static String getFullLog() { 51 | return log.toString(); 52 | } 53 | 54 | public static void clear() { 55 | synchronized (locker) { 56 | log.setLength(0); 57 | log.trimToSize(); 58 | for (final Log.Callback callback : callbacks) callback.onChanged(); 59 | } 60 | } 61 | 62 | public static void registerCallback(final Log.Callback callback) { 63 | synchronized (locker) { 64 | callbacks.add(callback); 65 | } 66 | } 67 | 68 | public static void unregisterCallback(final Log.Callback callback) { 69 | synchronized (locker) { 70 | callbacks.remove(callback); 71 | } 72 | } 73 | 74 | public interface Callback { 75 | void onChanged(); 76 | } 77 | 78 | private Log() {} 79 | } -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/StrRes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import android.content.res.Resources; 24 | 25 | public class StrRes { 26 | 27 | public static Resources res; 28 | 29 | public static String get(final int id, final Object ... args) { 30 | if (res == null) return ""; 31 | return String.format(res.getString(id), args); 32 | } 33 | 34 | private StrRes() {} 35 | } 36 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/UsbPermissionHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import android.content.Context; 24 | import android.content.res.Resources; 25 | import android.content.res.XmlResourceParser; 26 | import android.hardware.usb.UsbDevice; 27 | import android.hardware.usb.UsbManager; 28 | import android.util.AttributeSet; 29 | import android.util.Pair; 30 | import android.util.Xml; 31 | 32 | import org.xmlpull.v1.XmlPullParser; 33 | 34 | import java.util.HashMap; 35 | import java.util.HashSet; 36 | import java.util.Map.Entry; 37 | import java.util.Set; 38 | 39 | public class UsbPermissionHelper { 40 | 41 | public final static boolean isAndroidUsbSupported; 42 | 43 | static { 44 | isAndroidUsbSupported = isAndroidUsbSupported(); 45 | } 46 | 47 | private UsbPermissionHelper() {} 48 | 49 | private static boolean isAndroidUsbSupported() { 50 | try { 51 | Class.forName( "android.hardware.usb.UsbManager" ); 52 | return true; 53 | } catch( ClassNotFoundException e ) { 54 | return false; 55 | } 56 | } 57 | 58 | /** This method is safe to be called from old Android versions */ 59 | public static Set getAvailableUsbDevices(final Context ctx, int xmlResourceId) { 60 | Set usbDevices = new HashSet<>(); 61 | if (isAndroidUsbSupported) { 62 | final UsbManager manager = (UsbManager) ctx.getSystemService(Context.USB_SERVICE); 63 | 64 | final HashSet> allowed = getDeviceData(ctx.getResources(), xmlResourceId); 65 | final HashMap deviceList = manager.getDeviceList(); 66 | 67 | for (final Entry desc : deviceList.entrySet()) { 68 | UsbDevice candidate = desc.getValue(); 69 | final Pair candidatePair = new Pair<>(candidate.getVendorId(), candidate.getProductId()); 70 | if (allowed.contains(candidatePair)) usbDevices.add(candidate); 71 | } 72 | } 73 | return usbDevices; 74 | } 75 | 76 | private static HashSet> getDeviceData(final Resources resources, int xmlResourceId) { 77 | final HashSet> ans = new HashSet<>(); 78 | try { 79 | final XmlResourceParser xml = resources.getXml(xmlResourceId); 80 | 81 | xml.next(); 82 | int eventType; 83 | while ((eventType = xml.getEventType()) != XmlPullParser.END_DOCUMENT) { 84 | 85 | if (eventType == XmlPullParser.START_TAG) { 86 | if (xml.getName().equals("usb-device")) { 87 | final AttributeSet as = Xml.asAttributeSet(xml); 88 | final Integer vendorId = parseInt(as.getAttributeValue(null, "vendor-id")); 89 | final Integer productId = parseInt(as.getAttributeValue(null, "product-id")); 90 | ans.add(new Pair<>(vendorId, productId)); 91 | } 92 | } 93 | xml.next(); 94 | } 95 | } catch (Exception e) { 96 | e.printStackTrace(); 97 | } 98 | 99 | return ans; 100 | } 101 | 102 | private static Integer parseInt(String number) { 103 | if (number.startsWith("0x")) { 104 | return Integer.valueOf( number.substring(2), 16); 105 | } else { 106 | return Integer.valueOf( number, 10); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/java/com/sdrtouch/tools/UsbPermissionObtainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * rtl_tcp_andro is a library that uses libusb and librtlsdr to 3 | * turn your Realtek RTL2832 based DVB dongle into a SDR receiver. 4 | * It independently implements the rtl-tcp API protocol for native Android usage. 5 | * Copyright (C) 2022 by Signalware Ltd 6 | * 7 | * This program is free software: you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation, either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program. If not, see . 19 | */ 20 | 21 | package com.sdrtouch.tools; 22 | 23 | import static android.app.PendingIntent.FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT; 24 | import static android.app.PendingIntent.FLAG_MUTABLE; 25 | import static android.content.Context.RECEIVER_EXPORTED; 26 | 27 | import android.app.PendingIntent; 28 | import android.content.BroadcastReceiver; 29 | import android.content.Context; 30 | import android.content.Intent; 31 | import android.content.IntentFilter; 32 | import android.hardware.usb.UsbDevice; 33 | import android.hardware.usb.UsbDeviceConnection; 34 | import android.hardware.usb.UsbManager; 35 | import android.os.Build; 36 | 37 | import java.util.concurrent.Future; 38 | 39 | public class UsbPermissionObtainer { 40 | private static final String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION"; 41 | 42 | public static Future obtainFdFor(Context context, UsbDevice usbDevice) { 43 | int flags = 0; 44 | 45 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { 46 | flags = FLAG_MUTABLE | FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT; 47 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 48 | flags = FLAG_MUTABLE; 49 | } 50 | UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); 51 | if (!manager.hasPermission(usbDevice)) { 52 | AsyncFuture task = new AsyncFuture<>(); 53 | registerNewBroadcastReceiver(context, usbDevice, task); 54 | manager.requestPermission(usbDevice, PendingIntent.getBroadcast(context, 0, new Intent(ACTION_USB_PERMISSION), flags)); 55 | return task; 56 | } else { 57 | return new CompletedFuture<>(manager.openDevice(usbDevice)); 58 | } 59 | } 60 | 61 | private static void registerNewBroadcastReceiver(final Context context, final UsbDevice usbDevice, final AsyncFuture task) { 62 | BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { 63 | @Override 64 | public void onReceive(Context context, Intent intent) { 65 | String action = intent.getAction(); 66 | if (ACTION_USB_PERMISSION.equals(action)) { 67 | synchronized (this) { 68 | if (task.isDone()) { 69 | Log.appendLine("Permission already should be processed, ignoring."); 70 | return; 71 | } 72 | UsbManager manager = (UsbManager) context.getSystemService(Context.USB_SERVICE); 73 | UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); 74 | if (device.equals(usbDevice)) { 75 | if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) { 76 | if (!manager.hasPermission(device)) { 77 | Log.appendLine("Permissions were granted but can't access the device"); 78 | task.setDone(null); 79 | } else { 80 | Log.appendLine("Permissions granted and device is accessible"); 81 | task.setDone(manager.openDevice(device)); 82 | } 83 | } else { 84 | Log.appendLine("Extra permission was not granted"); 85 | task.setDone(null); 86 | } 87 | context.unregisterReceiver(this); 88 | } else { 89 | Log.appendLine("Got a permission for an unexpected device"); 90 | task.setDone(null); 91 | } 92 | } 93 | } else { 94 | Log.appendLine("Unexpected action"); 95 | task.setDone(null); 96 | } 97 | } 98 | }; 99 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { 100 | context.registerReceiver(broadcastReceiver, new IntentFilter(ACTION_USB_PERMISSION), RECEIVER_EXPORTED); 101 | } else { 102 | context.registerReceiver(broadcastReceiver, new IntentFilter(ACTION_USB_PERMISSION)); 103 | } 104 | } 105 | 106 | private UsbPermissionObtainer() {} 107 | } -------------------------------------------------------------------------------- /sdrdrivertools/src/main/res/values-nb/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Din Android-plattform er ikke støttet. Vennligst ta kontakt med oss for å fortelle oss mer om enheten din, sånn at vi kan støtte den i fremtiden. 4 | 5 | libusb-unntak %s 6 | Får ikke tilgang til enheten 7 | Unntaks-ID %d 8 | Ingen unntak :) 9 | Ukorrekte argumenter ble meldt inn! Vennligst sjekk sdr_tcp-bruksanvisningen! 10 | En ugyldig USB-filbeskriver ble videreformidlet gjennom Java. 11 | Ingen støttede enheter ble funnet (Sørg for at din USB-enhet er koblet til, at den får ordentlig med strøm, og at din mobil/nettbrett støtter USB-vertsmodus.) 12 | Enheten ble funnet, men kan ikke bli åpnet. Dette kan tyde på at din mobil/nettbrett ikke støtter USB OTG. 13 | Intern feil: Kan ikke starte tjenesten på nytt 14 | Intern feil: Kan ikke stoppe tjenesten 15 | Ukjent feil! 16 | Signalet ble fanget! 17 | Din Android-enhet yter ikke nok strøm til USB-enheten. Du må bruke en eksternt drevet USB-hub eller en eksternt drevet USB OTG-kabel. 18 | 19 | 20 | -------------------------------------------------------------------------------- /sdrdrivertools/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Your Android platform is not supported. Please get in touch with us to provide us more information about your device so we can support it in future. 4 | 5 | libusb exception %s 6 | Cannot access device 7 | Exception id %d 8 | No exception :) 9 | Wrong arguments were supplied! Please, check the sdr_tcp manual! 10 | Invalid USB file descriptor passed via Java. 11 | No compatible devices found (make sure your USB device is connected, properly powered and your phone/tablet supports USB host mode). 12 | Device was found but cannot be open. This may indicate that your phone/tablet does not support USB OTG 13 | Internal error: Cannot restart service 14 | Internal error: Cannot stop service 15 | Unknown error! 16 | Signal was caught! 17 | Your Android device does not provide enough power to the dongle. You must use an externally powered USB hub or an externally powered USB OTG cable. 18 | 19 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "rtl_tcp_andro" 16 | include ':app' 17 | include ':rtlsdr' 18 | include ':hackrf' 19 | include ':sdrdrivertools' 20 | --------------------------------------------------------------------------------