From 99c7ec02fd04355d7ab824b72ca98c7219fd6a1a Mon Sep 17 00:00:00 2001 From: Doug McLain Date: Sat, 18 Mar 2023 21:03:25 -0400 Subject: [PATCH] Various fixups --- DroidStar.pro | 6 +++- android/AndroidManifest.xml | 8 ++--- android/src/main/java/USBSerialWrapper.java | 9 +++++ dcs.cpp | 2 +- dmr.cpp | 2 +- droidstar.cpp | 38 ++++++++++++--------- iax.cpp | 2 +- m17.cpp | 2 +- main.qml | 5 --- nxdn.cpp | 7 ++-- p25.cpp | 2 +- ref.cpp | 2 +- xrf.cpp | 2 +- ysf.cpp | 2 +- 14 files changed, 50 insertions(+), 39 deletions(-) diff --git a/DroidStar.pro b/DroidStar.pro index ea0ba14..5447171 100644 --- a/DroidStar.pro +++ b/DroidStar.pro @@ -1,5 +1,9 @@ QT += quick quickcontrols2 network multimedia -android:QT += androidextras + +equals(QT_MAJOR_VERSION, 5){ + android:QT += androidextras + } + unix:!ios:QT += serialport CONFIG += c++11 LFLAGS += diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 5ec4085..f9b1b19 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/android/src/main/java/USBSerialWrapper.java b/android/src/main/java/USBSerialWrapper.java index 1bd74c1..47ef8c2 100644 --- a/android/src/main/java/USBSerialWrapper.java +++ b/android/src/main/java/USBSerialWrapper.java @@ -18,6 +18,8 @@ package DroidStar; import java.util.Arrays; import java.util.List; +import android.content.Intent; +import android.app.PendingIntent; import android.content.Context; import android.hardware.usb.UsbManager; import android.hardware.usb.UsbDeviceConnection; @@ -40,6 +42,10 @@ public class USBSerialWrapper implements SerialInputOutputManagerTest.Listener { UsbSerialPort m_port; SerialInputOutputManagerTest usbIoManager; + private static final String ACTION_USB_PERMISSION = "org.dudetronics.droidstar.USB_PERMISSION"; + //private final ArrayBlockingQueue queuedPermissions = new ArrayBlockingQueue<>(100); + //private volatile boolean processingPermission = false; + //private PendingUsbPermission currentPendingPermission; public USBSerialWrapper() { this.id = counter; @@ -146,6 +152,9 @@ public class USBSerialWrapper implements SerialInputOutputManagerTest.Listener { if (connection == null) { // add UsbManager.requestPermission(driver.getDevice(), ..) handling here + + PendingIntent mPendingIntent = PendingIntent.getBroadcast(c, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE); + manager.requestPermission(driver.getDevice(), mPendingIntent); return "No connection, need permission?"; } diff --git a/dcs.cpp b/dcs.cpp index 01c5af1..97803d9 100755 --- a/dcs.cpp +++ b/dcs.cpp @@ -378,7 +378,7 @@ void DCS::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/dmr.cpp b/dmr.cpp index ebd9f42..84205a3 100755 --- a/dmr.cpp +++ b/dmr.cpp @@ -459,7 +459,7 @@ void DMR::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/droidstar.cpp b/droidstar.cpp index 270b895..377e137 100644 --- a/droidstar.cpp +++ b/droidstar.cpp @@ -116,6 +116,7 @@ void DroidStar::reset_connect_status() process_connect(); } } + #endif void DroidStar::discover_devices() @@ -255,14 +256,6 @@ void DroidStar::process_connect() MicPermission::check_permission(); #endif - if( (m_callsign.size() < 4) || - (m_dmrid < 250000) || - (m_callsign != m_dmrids[m_dmrid])) - { - emit connect_status_changed(4); - return; - } - if(m_protocol == "REF"){ m_refname = m_saved_refhost; } @@ -644,7 +637,7 @@ void DroidStar::process_settings() m_latitude = m_settings->value("DMRLAT", "0").toString().simplified(); m_longitude = m_settings->value("DMRLONG", "0").toString().simplified(); m_location = m_settings->value("DMRLOC").toString().simplified(); - m_description = m_settings->value("DMRDESC", "DroidStar").toString().simplified(); + m_description = m_settings->value("DMRDESC", "").toString().simplified(); m_freq = m_settings->value("DMRFREQ", "438800000").toString().simplified(); m_url = m_settings->value("DMRURL", "www.qrz.com").toString().simplified(); m_swid = m_settings->value("DMRSWID", "20200922").toString().simplified(); @@ -1410,14 +1403,27 @@ void DroidStar::update_data(Mode::MODEINFO info) } QString t = QDateTime::fromMSecsSinceEpoch(info.ts).toString("yyyy.MM.dd hh:mm:ss.zzz"); - if(info.stream_state == Mode::STREAM_NEW){ - emit update_log(t + " " + m_protocol + " RX started id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); - } - if(info.stream_state == Mode::STREAM_END){ - emit update_log(t + " " + m_protocol + " RX ended id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); + if((m_protocol == "DMR") || (m_protocol == "P25") || (m_protocol == "NXDN")){ + if(info.stream_state == Mode::STREAM_NEW){ + emit update_log(t + " " + m_protocol + " RX started id: " + " srcid: " + QString::number(info.srcid) + " dstid: " + QString::number(info.dstid)); + } + if(info.stream_state == Mode::STREAM_END){ + emit update_log(t + " " + m_protocol + " RX ended id: " + " srcid: " + QString::number(info.srcid) + " dstid: " + QString::number(info.dstid)); + } + if(info.stream_state == Mode::STREAM_LOST){ + emit update_log(t + " " + m_protocol + " RX lost id: " + " srcid: " + QString::number(info.srcid) + " dstid: " + QString::number(info.dstid)); + } } - if(info.stream_state == Mode::STREAM_LOST){ - emit update_log(t + " " + m_protocol + " RX lost id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); + else{ + if(info.stream_state == Mode::STREAM_NEW){ + emit update_log(t + " " + m_protocol + " RX started id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); + } + if(info.stream_state == Mode::STREAM_END){ + emit update_log(t + " " + m_protocol + " RX ended id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); + } + if(info.stream_state == Mode::STREAM_LOST){ + emit update_log(t + " " + m_protocol + " RX lost id: " + QString::number(info.streamid, 16) + " src: " + info.src + " dst: " + info.gw2); + } } emit update_data(); } diff --git a/iax.cpp b/iax.cpp index ee3ed30..f064994 100644 --- a/iax.cpp +++ b/iax.cpp @@ -798,7 +798,7 @@ void IAX::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/m17.cpp b/m17.cpp index 4423cb0..c9bc2ff 100755 --- a/m17.cpp +++ b/m17.cpp @@ -746,7 +746,7 @@ void M17::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[ttscnt*2] / 2; + pcm[i] = tts_audio->samples[ttscnt*2] / 8; ttscnt++; } } diff --git a/main.qml b/main.qml index fa9dccb..ed6312c 100644 --- a/main.qml +++ b/main.qml @@ -40,11 +40,6 @@ ApplicationWindow { palette.windowText: "white" palette.highlight: "steelblue" - MessageDialog { - id: idcheckDialog - title: "Invalid credentials" - text: "A valid callsign and DMR ID are required to use Dudestar on any mode, and they must match. If you have entered a valid DMR ID that matches the entered callsign, and you are still seeing this message, then you either have to click update ID files button or wait until your DMR ID is added to the ID file and try again." - } MessageDialog { id: errorDialog title: "Error" diff --git a/nxdn.cpp b/nxdn.cpp index 20e2188..ebf6398 100755 --- a/nxdn.cpp +++ b/nxdn.cpp @@ -255,7 +255,7 @@ void NXDN::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } @@ -305,13 +305,14 @@ void NXDN::send_frame() temp_nxdn = get_frame(); txdata.append((char *)temp_nxdn, 43); m_udp->writeDatagram(txdata, m_address, m_modeinfo.port); - - fprintf(stderr, "SEND:%d: ", txdata.size()); +#ifdef DEBUG + fprintf(stderr, "SEND:%lli: ", txdata.size()); for(int i = 0; i < txdata.size(); ++i){ fprintf(stderr, "%02x ", (uint8_t)txdata.data()[i]); } fprintf(stderr, "\n"); fflush(stderr); +#endif } else{ fprintf(stderr, "NXDN TX stopped\n"); diff --git a/p25.cpp b/p25.cpp index 2e57a1a..e472a2e 100755 --- a/p25.cpp +++ b/p25.cpp @@ -246,7 +246,7 @@ void P25::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/ref.cpp b/ref.cpp index 6b4b85e..c610e47 100755 --- a/ref.cpp +++ b/ref.cpp @@ -430,7 +430,7 @@ void REF::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/xrf.cpp b/xrf.cpp index e399397..dc997a1 100755 --- a/xrf.cpp +++ b/xrf.cpp @@ -383,7 +383,7 @@ void XRF::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } } diff --git a/ysf.cpp b/ysf.cpp index 67be252..fc3ae1b 100755 --- a/ysf.cpp +++ b/ysf.cpp @@ -738,7 +738,7 @@ void YSF::transmit() pcm[i] = 0; } else{ - pcm[i] = tts_audio->samples[m_ttscnt*2] / 2; + pcm[i] = tts_audio->samples[m_ttscnt*2] / 8; m_ttscnt++; } }