Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull initial Digirig support #382

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
<item>usb</item>
<item>tcpip</item>
</string-array>
<string-array name="p_afsk_e">
<item>@string/p_afsk_vox</item>
<item>@string/p_afsk_digirig</item>
</string-array>
<string-array name="p_afsk_ev">
<item>vox</item>
<item>digirig</item>
</string-array>
<string-array name="p_afsk_out_ev">
<item>0</item>
<item>2</item>
Expand Down
5 changes: 5 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
<string name="p_link_bt">Bluetooth SPP</string>
<string name="p_link_tcpip">TCP/IP</string>
<string name="p_link_usb">USB Serial</string>
<!-- array of AFSK modes -->
<string name="p_afsk_vox">VOX</string>
<string name="p_afsk_digirig">Digirig</string>
<!-- array of location sources -->
<string name="p_source_manual">Manual Position</string>
<string name="p_source_periodic">Periodic GPS/Network Position</string>
Expand Down Expand Up @@ -325,6 +328,8 @@
<string name="p_afsk_btsco">Bluetooth Headset</string>
<string name="p_afsk_btsco_summary">Use Bluetooth (SCO) headset for AFSK</string>
<string name="p_afsk_output">Audio Output</string>
<string name="p_afsk_ptt">Use Push-to-Talk</string>
<string name="p_afsk_pttport">Push-to-Talk Port</string>
<string-array name="p_afsk_out_e">
<item>Voice Call</item>
<item>Ringtone</item>
Expand Down
19 changes: 19 additions & 0 deletions res/xml/backend_digirig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory
android:title="@string/p_link_usb">

<de.duenndns.ListPreferenceWithValue
android:key="baudrate"
android:title="@string/p_serial_baudrate"
android:summary="@string/p_serial_baudrate_summary"
android:entries="@array/p_serial_baudrates"
android:entryValues="@array/p_serial_baudrates"
android:defaultValue="115200"
android:dialogTitle="@string/p_serial_baudrate" />

</PreferenceCategory>
</PreferenceScreen>

9 changes: 8 additions & 1 deletion res/xml/proto_afsk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@
android:summary="@string/p_afsk_prefix_summary"
android:dialogTitle="@string/p_afsk_prefix_entry" />

</PreferenceCategory>
<de.duenndns.ListPreferenceWithValue
android:defaultValue="vox"
android:dialogTitle="@string/p_link_entry"
android:entries="@array/p_afsk_e"
android:entryValues="@array/p_afsk_ev"
android:key="afsk"
android:title="@string/p_link" />
</PreferenceCategory>

</PreferenceScreen>

4 changes: 3 additions & 1 deletion src/BackendPrefs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import _root_.android.os.Bundle
import _root_.android.content.{Context, Intent, SharedPreferences}
import _root_.android.content.SharedPreferences.OnSharedPreferenceChangeListener
import _root_.android.preference.{CheckBoxPreference, Preference, PreferenceActivity, PreferenceManager}
import _root_.android.util.Log
import android.location.LocationManager
import android.preference.Preference.OnPreferenceClickListener
import android.widget.Toast
Expand All @@ -20,6 +21,7 @@ class BackendPrefs extends PreferenceActivity
addPreferencesFromResource(R.xml.backend)
addPreferencesFromResource(AprsBackend.prefxml_proto(prefs))
val additional_xml = AprsBackend.prefxml_backend(prefs)
Log.d("BackendPrefs", "DEBUG: prefs add xml " + additional_xml)
if (additional_xml != 0) {
addPreferencesFromResource(additional_xml)
hookPasscode()
Expand Down Expand Up @@ -67,7 +69,7 @@ class BackendPrefs extends PreferenceActivity
}

override def onSharedPreferenceChanged(sp: SharedPreferences, key : String) {
if (key == "proto" || key == "link" || key == "aprsis") {
if (key == "proto" || key == "link" || key == "aprsis" || key == "afsk") {
setPreferenceScreen(null)
loadXml()
}
Expand Down
3 changes: 3 additions & 0 deletions src/PrefsWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class PrefsWrapper(val context : Context) {
R.array.p_conntype_ev, R.array.p_conntype_e)
val link = AprsBackend.defaultProtoInfo(this).link
link match {
case "afsk" => "%s, %s".format(proto, getListItemName(link, AprsBackend.DEFAULT_CONNTYPE, R.array.p_afsk_ev, R.array.p_afsk_e))
case "aprsis" => "%s, %s".format(proto, getListItemName(link, AprsBackend.DEFAULT_CONNTYPE, R.array.p_aprsis_ev, R.array.p_aprsis_e))
case "link" => "%s, %s".format(proto, getListItemName(link, AprsBackend.DEFAULT_CONNTYPE, R.array.p_link_ev, R.array.p_link_e))
case _ => proto
Expand Down Expand Up @@ -102,6 +103,8 @@ class PrefsWrapper(val context : Context) {

def getProto() = getString("proto", "aprsis")
def getAfskHQ() = getBoolean("afsk.hqdemod", true)
def getAfskRTS() = getBoolean("afsk.ptt", false)
def getPTTPort() = getString("afsk.pttport", "")
def getAfskBluetooth() = getBoolean("afsk.btsco", false) && getAfskHQ()
def getAfskOutput() = if (getAfskBluetooth()) AudioManager.STREAM_VOICE_CALL else getStringInt("afsk.output", 0)
}
30 changes: 24 additions & 6 deletions src/backend/AprsBackend.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package org.aprsdroid.app

import android.Manifest
import android.os.Build
import _root_.android.util.Log
import _root_.net.ab0oo.aprs.parser.APRSPacket

import _root_.java.io.{InputStream, OutputStream}

object AprsBackend {
val TAG = "AprsBackend"
/** "Modular" system to connect to an APRS backend.
* The backend config consists of three items backed by prefs values:
* - *proto* inside the connection ("aprsis", "afsk", "kiss", "tnc2", "kenwood") - ProtoInfo class
Expand Down Expand Up @@ -65,7 +68,7 @@ object AprsBackend {
Set(),
CAN_XMIT,
PASSCODE_REQUIRED),
"afsk" -> new BackendInfo(
"vox" -> new BackendInfo(
(s, p) => new AfskUploader(s, p),
0,
Set(Manifest.permission.RECORD_AUDIO),
Expand Down Expand Up @@ -94,7 +97,14 @@ object AprsBackend {
R.xml.backend_usb,
Set(),
CAN_DUPLEX,
PASSCODE_NONE)
PASSCODE_NONE),
"digirig" -> new BackendInfo(
(s, p) => new DigiRig(s, p),
R.xml.backend_digirig,
Set(Manifest.permission.RECORD_AUDIO),
CAN_DUPLEX,
PASSCODE_NONE
)
)

class ProtoInfo(
Expand All @@ -108,8 +118,8 @@ object AprsBackend {
(s, is, os) => new AprsIsProto(s, is, os),
R.xml.proto_aprsis, "aprsis"),
"afsk" -> new ProtoInfo(
null,
R.xml.proto_afsk, null),
(s, is, os) => new AfskProto(s, is, os),
R.xml.proto_afsk, "afsk"),
"kiss" -> new ProtoInfo(
(s, is, os) => new KissProto(s, is, os),
R.xml.proto_kiss, "link"),
Expand All @@ -119,7 +129,7 @@ object AprsBackend {
"kenwood" -> new ProtoInfo(
(s, is, os) => new KenwoodProto(s, is, os),
R.xml.proto_kenwood, "link")
);
)
def defaultProtoInfo(p : String) : ProtoInfo = {
proto_collection.get(p) match {
case Some(pi) => pi
Expand All @@ -130,7 +140,15 @@ object AprsBackend {

def defaultBackendInfo(prefs : PrefsWrapper) : BackendInfo = {
val pi = defaultProtoInfo(prefs)
val link = if (pi.link != null) { prefs.getString(pi.link, DEFAULT_LINK) } else { prefs.getProto() }
var link = ""
if (pi.link != null) {
link = prefs.getString(pi.link, DEFAULT_LINK)
Log.d(TAG, "DEBUG: pi.link (" + pi.link + ") != null : " + link)
} else {
link = prefs.getProto()
Log.d(TAG, "DEBUG: pi.link == null : " + link)
}

backend_collection.get(link) match {
case Some(bi) => bi
case None => backend_collection(DEFAULT_CONNTYPE)
Expand Down
Loading