Remove APRS callsign setting; connect to APRS-IS with SVX callsign, keep only coords
This commit is contained in:
@@ -96,20 +96,18 @@ class MainActivity : Activity(), SvxService.Listener {
|
|||||||
// ---------- APRS метеостанции (экспериментально) ----------
|
// ---------- APRS метеостанции (экспериментально) ----------
|
||||||
private var aprsMeteo: AprsMeteo? = null
|
private var aprsMeteo: AprsMeteo? = null
|
||||||
private var lastMeteo: String? = null
|
private var lastMeteo: String? = null
|
||||||
private var lastAprsCall = ""
|
|
||||||
private var lastAprsCoords = ""
|
private var lastAprsCoords = ""
|
||||||
|
|
||||||
private fun startAprsMeteo() {
|
private fun startAprsMeteo() {
|
||||||
aprsMeteo?.stop()
|
aprsMeteo?.stop()
|
||||||
aprsMeteo = null
|
aprsMeteo = null
|
||||||
val call = Prefs.aprsCallsign(this).trim()
|
|
||||||
if (call.isEmpty()) return
|
|
||||||
val coords = Prefs.aprsCoords(this)
|
val coords = Prefs.aprsCoords(this)
|
||||||
.split(',')
|
.split(',')
|
||||||
.mapNotNull { it.trim().toDoubleOrNull() }
|
.mapNotNull { it.trim().toDoubleOrNull() }
|
||||||
.take(2)
|
.take(2)
|
||||||
.let { if (it.size == 2) it[0] to it[1] else null }
|
.let { if (it.size == 2) it[0] to it[1] else null }
|
||||||
aprsMeteo = AprsMeteo(call, coords) { wx ->
|
if (coords == null) return
|
||||||
|
aprsMeteo = AprsMeteo(coords) { wx ->
|
||||||
lastMeteo = wx
|
lastMeteo = wx
|
||||||
lblSubtitle.text = wx
|
lblSubtitle.text = wx
|
||||||
}.also { it.start() }
|
}.also { it.start() }
|
||||||
@@ -224,7 +222,6 @@ class MainActivity : Activity(), SvxService.Listener {
|
|||||||
|
|
||||||
refreshUi()
|
refreshUi()
|
||||||
startAprsMeteo()
|
startAprsMeteo()
|
||||||
lastAprsCall = Prefs.aprsCallsign(this).trim()
|
|
||||||
lastAprsCoords = Prefs.aprsCoords(this).trim()
|
lastAprsCoords = Prefs.aprsCoords(this).trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,10 +246,8 @@ class MainActivity : Activity(), SvxService.Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
refreshUi()
|
refreshUi()
|
||||||
val aprsCall = Prefs.aprsCallsign(this).trim()
|
|
||||||
val aprsCoords = Prefs.aprsCoords(this).trim()
|
val aprsCoords = Prefs.aprsCoords(this).trim()
|
||||||
if (aprsCall != lastAprsCall || aprsCoords != lastAprsCoords) {
|
if (aprsCoords != lastAprsCoords) {
|
||||||
lastAprsCall = aprsCall
|
|
||||||
lastAprsCoords = aprsCoords
|
lastAprsCoords = aprsCoords
|
||||||
startAprsMeteo()
|
startAprsMeteo()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class SettingsActivity : Activity() {
|
|||||||
private lateinit var inputAuthKey: EditText
|
private lateinit var inputAuthKey: EditText
|
||||||
private lateinit var inputTg: EditText
|
private lateinit var inputTg: EditText
|
||||||
private lateinit var inputGroups: EditText
|
private lateinit var inputGroups: EditText
|
||||||
private lateinit var inputAprsCallsign: EditText
|
|
||||||
private lateinit var inputAprsCoords: EditText
|
private lateinit var inputAprsCoords: EditText
|
||||||
private var currentProfile = 0
|
private var currentProfile = 0
|
||||||
|
|
||||||
@@ -38,11 +37,9 @@ class SettingsActivity : Activity() {
|
|||||||
inputAuthKey = findViewById(R.id.input_auth_key)
|
inputAuthKey = findViewById(R.id.input_auth_key)
|
||||||
inputTg = findViewById(R.id.input_tg)
|
inputTg = findViewById(R.id.input_tg)
|
||||||
inputGroups = findViewById(R.id.input_groups)
|
inputGroups = findViewById(R.id.input_groups)
|
||||||
inputAprsCallsign = findViewById(R.id.input_aprs_callsign)
|
|
||||||
inputAprsCoords = findViewById(R.id.input_aprs_coords)
|
inputAprsCoords = findViewById(R.id.input_aprs_coords)
|
||||||
val chkNodeToasts = findViewById<CheckBox>(R.id.chk_node_toasts)
|
val chkNodeToasts = findViewById<CheckBox>(R.id.chk_node_toasts)
|
||||||
chkNodeToasts.isChecked = Prefs.nodeToastsEnabled(this)
|
chkNodeToasts.isChecked = Prefs.nodeToastsEnabled(this)
|
||||||
inputAprsCallsign.setText(Prefs.aprsCallsign(this))
|
|
||||||
inputAprsCoords.setText(Prefs.aprsCoords(this))
|
inputAprsCoords.setText(Prefs.aprsCoords(this))
|
||||||
|
|
||||||
val profileNames = (1..Prefs.PROFILE_COUNT)
|
val profileNames = (1..Prefs.PROFILE_COUNT)
|
||||||
@@ -94,7 +91,6 @@ class SettingsActivity : Activity() {
|
|||||||
Prefs.saveProfile(this, currentProfile, profile)
|
Prefs.saveProfile(this, currentProfile, profile)
|
||||||
Prefs.setActiveProfile(this, currentProfile)
|
Prefs.setActiveProfile(this, currentProfile)
|
||||||
Prefs.setNodeToastsEnabled(this, chkNodeToasts.isChecked)
|
Prefs.setNodeToastsEnabled(this, chkNodeToasts.isChecked)
|
||||||
Prefs.setAprsCallsign(this, inputAprsCallsign.text.toString())
|
|
||||||
Prefs.setAprsCoords(this, inputAprsCoords.text.toString())
|
Prefs.setAprsCoords(this, inputAprsCoords.text.toString())
|
||||||
toast(getString(R.string.saved))
|
toast(getString(R.string.saved))
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ import java.net.Socket
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Экспериментально: приём метеостанций с APRS-IS (aprs2.net) в радиусе 250 км
|
* Экспериментально: приём метеостанций с APRS-IS (aprs2.net) в радиусе 250 км
|
||||||
* от позывного (фильтр b/) или от координат (фильтр r/). Весь код — в этом
|
* от координат (фильтр r/). Весь код — в этом файле, удаляется вместе с
|
||||||
* файле, удаляется вместе с вызовом в MainActivity и полями в настройках.
|
* вызовом в MainActivity и полями в настройках.
|
||||||
*/
|
*/
|
||||||
class AprsMeteo(
|
class AprsMeteo(
|
||||||
private val callsign: String,
|
|
||||||
private val coords: Pair<Double, Double>?,
|
private val coords: Pair<Double, Double>?,
|
||||||
private val onWeather: (String) -> Unit
|
private val onWeather: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
@@ -59,11 +58,12 @@ class AprsMeteo(
|
|||||||
val filter = if (coords != null) {
|
val filter = if (coords != null) {
|
||||||
"r/${coords.first}/${coords.second}/250"
|
"r/${coords.first}/${coords.second}/250"
|
||||||
} else {
|
} else {
|
||||||
"b/$callsign/250"
|
// Координаты не заданы — функция отключена (MainActivity не запускает)
|
||||||
|
"b/$APRS_CALL/250"
|
||||||
}
|
}
|
||||||
// ВАЖНО: без "vers" — сервер пользователя (T2SPB/T2APATITY)
|
// ВАЖНО: без "vers" — сервер пользователя (T2SPB/T2APATITY)
|
||||||
// не принимает фильтр и молчит; с "vers" — фильтр игнорируется
|
// не принимает фильтр и молчит; с "vers" — фильтр игнорируется
|
||||||
val login = "user $callsign pass ${passcode(callsign)} " +
|
val login = "user $APRS_CALL pass ${passcode(APRS_CALL)} " +
|
||||||
"filter $filter\r\n"
|
"filter $filter\r\n"
|
||||||
sock.getOutputStream().write(login.toByteArray())
|
sock.getOutputStream().write(login.toByteArray())
|
||||||
sock.getOutputStream().flush()
|
sock.getOutputStream().flush()
|
||||||
@@ -148,8 +148,9 @@ class AprsMeteo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
// Сначала сервер пользователя; если он не отдаёт трафик (аплинк
|
// Позывной для подключения к APRS-IS (SVX). Сначала сервер пользователя;
|
||||||
// молчит), переходим на публичный aprs2.net
|
// если он не отдаёт трафик (аплинк молчит), переходим на публичный aprs2.net
|
||||||
|
private const val APRS_CALL = "SVX"
|
||||||
private val APRS_HOSTS = listOf("rotate.radiorubka.org", "rotate.aprs2.net")
|
private val APRS_HOSTS = listOf("rotate.radiorubka.org", "rotate.aprs2.net")
|
||||||
private const val APRS_PORT = 14580
|
private const val APRS_PORT = 14580
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,15 +129,7 @@ object Prefs {
|
|||||||
|
|
||||||
// ---------- APRS метеостанции (экспериментально) ----------
|
// ---------- APRS метеостанции (экспериментально) ----------
|
||||||
|
|
||||||
/** Позывной для APRS (пусто = функция выключена). */
|
/** Координаты "lat,lon" (пусто = функция выключена). */
|
||||||
fun aprsCallsign(context: Context): String =
|
|
||||||
sp(context).getString("aprs_callsign", "") ?: ""
|
|
||||||
|
|
||||||
fun setAprsCallsign(context: Context, callsign: String) {
|
|
||||||
sp(context).edit().putString("aprs_callsign", callsign.trim()).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Координаты "lat,lon" (пусто = фильтр b/ по позывному). */
|
|
||||||
fun aprsCoords(context: Context): String =
|
fun aprsCoords(context: Context): String =
|
||||||
sp(context).getString("aprs_coords", "") ?: ""
|
sp(context).getString("aprs_coords", "") ?: ""
|
||||||
|
|
||||||
|
|||||||
@@ -182,26 +182,6 @@
|
|||||||
android:textSize="13sp"
|
android:textSize="13sp"
|
||||||
android:layout_marginBottom="12dp" />
|
android:layout_marginBottom="12dp" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/pref_aprs_callsign"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:textSize="15sp" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/input_aprs_callsign"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
android:inputType="text"
|
|
||||||
android:textColor="@color/text_primary"
|
|
||||||
android:textColorHint="@color/text_secondary"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:background="@drawable/bg_input"
|
|
||||||
android:padding="12dp"
|
|
||||||
android:hint="@string/pref_aprs_callsign_hint" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
@@ -17,8 +17,6 @@
|
|||||||
<string name="pref_node_toasts">Всплывающее уведомление о подключении/отключении узлов</string>
|
<string name="pref_node_toasts">Всплывающее уведомление о подключении/отключении узлов</string>
|
||||||
<string name="pref_aprs_label">Метеостанции (APRS)</string>
|
<string name="pref_aprs_label">Метеостанции (APRS)</string>
|
||||||
<string name="pref_aprs_hint">Экспериментально: принимает метеостанции в радиусе 250 км. Последняя станция показывается вместо строки сервера на главном экране.</string>
|
<string name="pref_aprs_hint">Экспериментально: принимает метеостанции в радиусе 250 км. Последняя станция показывается вместо строки сервера на главном экране.</string>
|
||||||
<string name="pref_aprs_callsign">APRS позывной</string>
|
|
||||||
<string name="pref_aprs_callsign_hint">например UA1ZBE-1</string>
|
|
||||||
<string name="pref_aprs_coords">Координаты (широта, долгота) — необязательно</string>
|
<string name="pref_aprs_coords">Координаты (широта, долгота) — необязательно</string>
|
||||||
<string name="pref_aprs_coords_hint">например 60.00, 30.00</string>
|
<string name="pref_aprs_coords_hint">например 60.00, 30.00</string>
|
||||||
<string name="toast_node_joined">Подключился: %1$s%2$s</string>
|
<string name="toast_node_joined">Подключился: %1$s%2$s</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user