From 7f26a2d06410fd3a2768612b9c9daf869778e480 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Tue, 3 Jan 2023 00:51:50 -0500 Subject: Repurpose into gRPC service Repurpose repository into a spiritual successor of the previous binding. The backend code is retained behind a new gRPC API defined in protos/radio.proto. The simpler synchronous gRPC API had been used for expediency, this may warrant revisiting to rework into an async or callback API based server instead. As well, authentication has been left until some consensus on an approach can be worked out. Bug-AGL: SPEC-4665 Signed-off-by: Scott Murray Change-Id: I28b122ce6e0ecfc7504aa08b90394cb1b9e22976 (cherry picked from commit dd23c157bdba1b25bbb50cdb99a60aa597735f43) --- binding/convenience/convenience.c | 309 -------------------------------------- 1 file changed, 309 deletions(-) delete mode 100644 binding/convenience/convenience.c (limited to 'binding/convenience/convenience.c') diff --git a/binding/convenience/convenience.c b/binding/convenience/convenience.c deleted file mode 100644 index ae1e24b..0000000 --- a/binding/convenience/convenience.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (C) 2014 by Kyle Keen - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* a collection of user friendly tools - * todo: use strtol for more flexible int parsing - * */ - -#include -#include -#include - -#ifndef _WIN32 -#include -#else -#include -#include -#include -#define _USE_MATH_DEFINES -#endif - -#include - -#include "rtl-sdr.h" - -double atofs(char *s) -/* standard suffixes */ -{ - char last; - size_t len; - double suff = 1.0; - len = strlen(s); - last = s[len-1]; - s[len-1] = '\0'; - switch (last) { - case 'g': - case 'G': - suff *= 1e3; - /*@fallthrough@*/ - case 'm': - case 'M': - suff *= 1e3; - /*@fallthrough@*/ - case 'k': - case 'K': - suff *= 1e3; - suff *= atof(s); - s[len-1] = last; - return suff; - } - s[len-1] = last; - return atof(s); -} - -double atoft(char *s) -/* time suffixes, returns seconds */ -{ - char last; - size_t len; - double suff = 1.0; - len = strlen(s); - last = s[len-1]; - s[len-1] = '\0'; - switch (last) { - case 'h': - case 'H': - suff *= 60; - /*@fallthrough@*/ - case 'm': - case 'M': - suff *= 60; - /*@fallthrough@*/ - case 's': - case 'S': - suff *= atof(s); - s[len-1] = last; - return suff; - } - s[len-1] = last; - return atof(s); -} - -double atofp(char *s) -/* percent suffixes */ -{ - char last; - size_t len; - double suff = 1.0; - len = strlen(s); - last = s[len-1]; - s[len-1] = '\0'; - switch (last) { - case '%': - suff *= 0.01; - suff *= atof(s); - s[len-1] = last; - return suff; - } - s[len-1] = last; - return atof(s); -} - -int nearest_gain(rtlsdr_dev_t *dev, int target_gain) -{ - int i, r, err1, err2, count, nearest; - int* gains; - r = rtlsdr_set_tuner_gain_mode(dev, 1); - if (r < 0) { - fprintf(stderr, "WARNING: Failed to enable manual gain.\n"); - return r; - } - count = rtlsdr_get_tuner_gains(dev, NULL); - if (count <= 0) { - return 0; - } - gains = malloc(sizeof(int) * count); - count = rtlsdr_get_tuner_gains(dev, gains); - nearest = gains[0]; - for (i=0; i= 0 && device < device_count) { - fprintf(stderr, "Using device %d: %s\n", - device, rtlsdr_get_device_name((uint32_t)device)); - return device; - } - /* does string exact match a serial */ - for (i = 0; i < device_count; i++) { - rtlsdr_get_device_usb_strings(i, vendor, product, serial); - if (strcmp(s, serial) != 0) { - continue;} - device = i; - fprintf(stderr, "Using device %d: %s\n", - device, rtlsdr_get_device_name((uint32_t)device)); - return device; - } - /* does string prefix match a serial */ - for (i = 0; i < device_count; i++) { - rtlsdr_get_device_usb_strings(i, vendor, product, serial); - if (strncmp(s, serial, strlen(s)) != 0) { - continue;} - device = i; - fprintf(stderr, "Using device %d: %s\n", - device, rtlsdr_get_device_name((uint32_t)device)); - return device; - } - /* does string suffix match a serial */ - for (i = 0; i < device_count; i++) { - rtlsdr_get_device_usb_strings(i, vendor, product, serial); - offset = strlen(serial) - strlen(s); - if (offset < 0) { - continue;} - if (strncmp(s, serial+offset, strlen(s)) != 0) { - continue;} - device = i; - fprintf(stderr, "Using device %d: %s\n", - device, rtlsdr_get_device_name((uint32_t)device)); - return device; - } - fprintf(stderr, "No matching devices found.\n"); - return -1; -} - -// vim: tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab -- cgit 1.2.3-korg