Separate setting to enable/disable aprsis

aprs
sh123 2022-08-21 15:47:30 +03:00
rodzic 6153bc80ca
commit 4831244fb1
6 zmienionych plików z 24 dodań i 9 usunięć

Wyświetl plik

@ -305,7 +305,7 @@ public class AppWorker extends Thread {
@Override
protected void onReceiveLog(String logData) {
Log.i(TAG, "RX: " + logData);
Log.i(TAG, "RX-LOG: " + logData);
storeLogData(logData, false);
}
@ -342,7 +342,7 @@ public class AppWorker extends Thread {
@Override
protected void onTransmitLog(String logData) {
Log.i(TAG, "TX: " + logData);
Log.i(TAG, "TX-LOG: " + logData);
storeLogData(logData, true);
}

Wyświetl plik

@ -12,6 +12,7 @@ import com.radio.codec2talkie.protocol.aprs.tools.AprsIsData;
import com.radio.codec2talkie.protocol.message.TextMessage;
import com.radio.codec2talkie.protocol.position.Position;
import com.radio.codec2talkie.settings.PreferenceKeys;
import com.radio.codec2talkie.tools.DebugTools;
import com.radio.codec2talkie.tools.TextTools;
import com.radio.codec2talkie.transport.TcpIp;
import com.radio.codec2talkie.transport.Transport;
@ -97,11 +98,14 @@ public class AprsIs implements Protocol, Runnable {
}
@Override
public void sendData(String src, String dst, String path, byte[] dataPacket) throws IOException {
public void sendData(String src, String dst, String path, byte[] data) throws IOException {
if (_isSelfEnabled) {
// TODO, forward own data to APRS-IS
AprsIsData aprsIsData = new AprsIsData(src, dst, path, new String(data));
synchronized (_txQueue) {
_txQueue.put(aprsIsData.toString().getBytes());
}
}
_childProtocol.sendData(src, dst, path, dataPacket);
_childProtocol.sendData(src, dst, path, data);
}
@Override
@ -111,6 +115,7 @@ public class AprsIs implements Protocol, Runnable {
line = TextTools.getString(_rxQueue);
}
if (line.length() > 0) {
Log.d(TAG, "APRS-RX: " + DebugTools.bytesToDebugString(line.getBytes()));
AprsIsData aprsIsData = AprsIsData.fromString(line);
if (aprsIsData != null) {
_parentProtocolCallback.onReceiveData(aprsIsData.src, aprsIsData.dst, aprsIsData.path, aprsIsData.data.getBytes());
@ -299,7 +304,7 @@ public class AprsIs implements Protocol, Runnable {
synchronized (_txQueue) {
String line = TextTools.getString(_txQueue);
if (line.length() > 0) {
Log.v(TAG, "APRS-IS TX: " + line);
Log.d(TAG, "APRS-IS TX: " + DebugTools.bytesToDebugString(line.getBytes()));
try {
tcpIp.write(line.getBytes());
} catch (IOException e) {

Wyświetl plik

@ -97,6 +97,7 @@ public final class PreferenceKeys {
public static String APRS_LOCATION_SOURCE_SMART_MIN_TURN_ANGLE = "aprs_location_source_smart_min_turn_angle";
public static String APRS_LOCATION_SOURCE_SMART_TURN_SLOPE = "aprs_location_source_smart_turn_slope";
public static String APRS_IS_ENABLE="aprs_is_enable";
public static String APRS_IS_CODE = "aprs_is_code";
public static String APRS_IS_TCPIP_SERVER = "aprs_is_tcpip_server";
public static String APRS_IS_ENABLE_RX_GATE = "aprs_is_enable_rx_gate";

Wyświetl plik

@ -94,7 +94,6 @@ public class SettingsWrapper {
}
public static boolean isAprsIsEnabled(SharedPreferences sharedPreferences) {
return sharedPreferences.getBoolean(PreferenceKeys.APRS_IS_ENABLE_RX_GATE, false) ||
sharedPreferences.getBoolean(PreferenceKeys.APRS_IS_ENABLE_TX_GATE, false);
return sharedPreferences.getBoolean(PreferenceKeys.APRS_IS_ENABLE, false);
}
}

Wyświetl plik

@ -346,4 +346,6 @@
<string name="aprs_is_radius_summary">Receive APRS-IS packets from stations in this radius (km)</string>
<string name="aprs_is_filter_title">Packet filter</string>
<string name="aprs_is_filter_summary">Filter for incoming APRS-IS packets</string>
<string name="aprs_is_enable_title">Enable APRS-IS</string>
<string name="aprs_is_enable_summary">Enable APRS-IS internet gateway</string>
</resources>

Wyświetl plik

@ -285,12 +285,20 @@
app:defaultValue="false">
</SwitchPreference>
<SwitchPreference
app:key="aprs_is_enable"
app:title="@string/aprs_is_enable_title"
app:summary="@string/aprs_is_enable_summary"
app:dependency="aprs_enable"
app:defaultValue="false">
</SwitchPreference>
<Preference
android:key="aprs_is_settings"
android:title="@string/aprs_is_settings_title"
android:summary="@string/aprs_is_settings_summary"
app:fragment="com.radio.codec2talkie.settings.SettingsActivity$SettingsAprsIsFragment"
app:dependency="aprs_enable">
app:dependency="aprs_is_enable">
</Preference>
</PreferenceCategory>