summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PrySDR.xcodeproj/project.pbxproj10
-rw-r--r--PrySDR/main.swift2
-rw-r--r--Radio/HW/AirSpy/AirSpy.swift3
-rw-r--r--Radio/Utils/AirSpyIQ/main.swift2
-rw-r--r--Radio/Utils/BladeRFIQ/main.swift106
-rw-r--r--Utils/Version.swift2
6 files changed, 122 insertions, 3 deletions
diff --git a/PrySDR.xcodeproj/project.pbxproj b/PrySDR.xcodeproj/project.pbxproj
index 05e4d16..233a68b 100644
--- a/PrySDR.xcodeproj/project.pbxproj
+++ b/PrySDR.xcodeproj/project.pbxproj
@@ -744,6 +744,15 @@
);
target = 8D9A33432D0B0D8D009A4186 /* BladeRFIQ */;
};
+ 8D9A37F12D180D4C009A4186 /* Exceptions for "Utils" folder in "BladeRFIQ" target */ = {
+ isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
+ membershipExceptions = (
+ FileUtils.swift,
+ PathUtils.swift,
+ Version.swift,
+ );
+ target = 8D9A33432D0B0D8D009A4186 /* BladeRFIQ */;
+ };
8DD98C7C2CC6320C0062D678 /* Exceptions for "LA" folder in "PrySDR" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
@@ -860,6 +869,7 @@
8D4068302CF9BF360064C96D /* Exceptions for "Utils" folder in "RtlSdrIQ" target */,
8D40686D2CFDE4C10064C96D /* Exceptions for "Utils" folder in "AirSpyHFIQ" target */,
8D406AB52CFF0D1F0064C96D /* Exceptions for "Utils" folder in "AirSpyIQ" target */,
+ 8D9A37F12D180D4C009A4186 /* Exceptions for "Utils" folder in "BladeRFIQ" target */,
);
path = Utils;
sourceTree = "<group>";
diff --git a/PrySDR/main.swift b/PrySDR/main.swift
index d7941d1..74f3f67 100644
--- a/PrySDR/main.swift
+++ b/PrySDR/main.swift
@@ -13,5 +13,5 @@ import libairspyhf
import libbladerf
print("PrySDR")
-print("We will start soon on exploring things")
+print("We will start soon on exploring things \(software_version)")
diff --git a/Radio/HW/AirSpy/AirSpy.swift b/Radio/HW/AirSpy/AirSpy.swift
index 25f5b0b..61623c6 100644
--- a/Radio/HW/AirSpy/AirSpy.swift
+++ b/Radio/HW/AirSpy/AirSpy.swift
@@ -33,6 +33,9 @@ class AirSpy {
}
func getSampleRates() -> [UInt32] {
+
+ var ret: Int32 = 0
+
if sample_rates.count == 0 {
let nscount: UnsafeMutablePointer<UInt32> = .allocate(capacity: 1)
diff --git a/Radio/Utils/AirSpyIQ/main.swift b/Radio/Utils/AirSpyIQ/main.swift
index a643d5f..5cfb048 100644
--- a/Radio/Utils/AirSpyIQ/main.swift
+++ b/Radio/Utils/AirSpyIQ/main.swift
@@ -111,7 +111,9 @@ func rf_callback(_ transffer: UnsafeMutablePointer<airspy_transfer_t>?) -> Int32
}
let _ = device?.VGAGain(5)
+
let _ = device?.mixerGain(5)
+
let _ = device?.lnaGain(1)
let _ = device?.startRx(rf_callback)
diff --git a/Radio/Utils/BladeRFIQ/main.swift b/Radio/Utils/BladeRFIQ/main.swift
index a4f2ffe..cc748f2 100644
--- a/Radio/Utils/BladeRFIQ/main.swift
+++ b/Radio/Utils/BladeRFIQ/main.swift
@@ -9,6 +9,110 @@ import Foundation
import ArgumentParser
import libbladerf
-print("Hello, World!")
+//set the command line arguments
+struct CommandLineArgs: ParsableCommand {
+ @Argument var file:String = ""
+ @Option() var serial: UInt64 = 0
+ @Option(name:.shortAndLong) var samplerate: Int = 200000
+ @Option(name:.shortAndLong) var gain: Int = 0
+ @Option(name:.shortAndLong) var frequency: Int = 100000000
+ @Option(name:.shortAndLong) var nsamples: Int = 65536
+ @Flag(help:"Version \(software_version)") var version: Bool = false
+ @Flag(name: .shortAndLong) var verbose: Bool = false
+}
+let args = CommandLineArgs.parseOrExit()
+if (args.version) {
+ print("AirSpyIQ version \(software_version)")
+ exit(0)
+}
+
+//prepare file descriptor if args specify that
+let currentExePath = Process().currentDirectoryPath
+var fileDescriptor = FileManager.default
+var fileArgUrl:URL?
+var fileHandle:FileHandle?
+if (args.file != "") {
+ fileArgUrl = URL(fileURLWithFileSystemRepresentation: args.file, isDirectory: false, relativeTo: nil)
+ if (checkIfFileExists(args.file)) {
+ //remove file
+ do {
+ try fileDescriptor.removeItem(atPath: fileArgUrl!.path())
+ } catch {
+ print("Couldn't delete file that exists \(fileArgUrl!.path())")
+ }
+ }
+
+ //create file
+ fileDescriptor.createFile(atPath: fileArgUrl!.path(), contents: nil)
+ try fileHandle = FileHandle(forWritingTo: fileArgUrl!)
+ try fileHandle?.seekToEnd()
+}
+
+var version: bladerf_version = bladerf_version()
+bladerf_version(&version)
+print(version.describe!)
+
+var device: OpaquePointer?
+
+var ret: Int32
+
+ret = bladerf_open(&device,nil)
+print("ret=\(ret)")
+
+var actual_samplerate: UnsafeMutablePointer<bladerf_sample_rate> = .allocate(capacity: 1)
+
+ret = bladerf_set_sample_rate(device, 0, UInt32(args.samplerate), actual_samplerate)
+print("ret=\(ret)")
+
+ret = bladerf_set_frequency(device, 0, UInt64(args.frequency))
+print("ret=\(ret)")
+
+
+let NUM_SAMPLES=8192
+let SYNC_TIMEOUT=500
+ret = bladerf_sync_config(device, bladerf_channel_layout(0), BLADERF_FORMAT_SC16_Q11, 16, UInt32(NUM_SAMPLES), 8, UInt32(SYNC_TIMEOUT))
+print("ret=\(ret)")
+
+ret = bladerf_enable_module(device, 0, true)
+print("ret=\(ret)")
+
+
+
+let buf_ptr = UnsafeMutableRawPointer.allocate(byteCount: NUM_SAMPLES, alignment: 1)
+
+var total_samples:Int32=0
+//var count=100
+var done=false
+while (!done) {
+ ret = bladerf_sync_rx(device, buf_ptr, UInt32(NUM_SAMPLES), nil, UInt32(SYNC_TIMEOUT))
+ if (ret != 0) {
+ print("RX failed: \(ret)")
+ done=true
+ } else {
+ print("Received \(NUM_SAMPLES) bytes")
+
+ if let file = fileHandle {
+ let convertedData = Data(bytes: buf_ptr, count: NUM_SAMPLES)
+ do {
+ try file.write(contentsOf: convertedData)
+ } catch {
+ print("Cant dump data to file")
+ }
+ }
+
+ total_samples += Int32(NUM_SAMPLES)
+ if total_samples > args.nsamples {
+ done=true
+ }
+ }
+ //count -= 1
+ print("ret=\(ret)")
+}
+
+ret = bladerf_enable_module(device, 0, false)
+print("bladerf_enable_module ret=\(ret)")
+
+
+bladerf_close(device)
diff --git a/Utils/Version.swift b/Utils/Version.swift
index 740b861..d781baa 100644
--- a/Utils/Version.swift
+++ b/Utils/Version.swift
@@ -5,4 +5,4 @@
// Created by Jacky Jack on 02/12/2024.
//
-public let software_version = "2024.12"
+public let software_version = "2024.12-1"