kopia lustrzana https://github.com/ge0rg/aprsdroid
added UDP packet transmitter
rodzic
1a4402a9f6
commit
f3ae403f68
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="p_conntype_e">
|
||||
<item>UDP port 8080</item>
|
||||
<item>HTTP POST</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_conntype_ev">
|
||||
<item>udp</item>
|
||||
<item>http</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
|
@ -14,6 +14,9 @@
|
|||
<string name="p_passcode_summary">APRS-IS validation passcode</string>
|
||||
<string name="p_passcode_entry">Enter the passcode for your call</string>
|
||||
<string name="p__network">Networking</string>
|
||||
<string name="p_conntype">Connection Protocol</string>
|
||||
<string name="p_conntype_summary">Choose UDP (port 8080) or HTTP POST (URL)</string>
|
||||
<string name="p_conntype_entry">Choose the connection protocol</string>
|
||||
<string name="p_host">Server</string>
|
||||
<string name="p_host_summary">APRS-IS server (port 8080) to send beacons</string>
|
||||
<string name="p_host_entry">Enter the APRS-IS server hostname</string>
|
||||
|
|
|
@ -64,7 +64,10 @@ class AprsService extends Service with LocationListener {
|
|||
i.putExtra(LOCATION, location)
|
||||
val packet = AprsPacket.formatLoc(prefs.getString("callsign", null), location)
|
||||
try {
|
||||
new AprsHttpPost(prefs).update(packet)
|
||||
if (prefs.getString("conntype", "udp") == "udp")
|
||||
new AprsUdp(prefs).update(packet)
|
||||
else
|
||||
new AprsHttpPost(prefs).update(packet)
|
||||
i.putExtra(PACKET, packet)
|
||||
} catch {
|
||||
case e : Exception => i.putExtra(PACKET, e.getMessage())
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package de.duenndns.aprsdroid
|
||||
|
||||
import _root_.android.content.SharedPreferences
|
||||
import _root_.android.location.Location
|
||||
import _root_.android.preference.PreferenceManager
|
||||
import _root_.android.util.Log
|
||||
import _root_.java.net.{InetAddress, DatagramSocket, DatagramPacket}
|
||||
|
||||
class AprsUdp(prefs : SharedPreferences) extends AprsIsUploader(prefs) {
|
||||
val TAG = "AprsUdp"
|
||||
lazy val socket = new DatagramSocket()
|
||||
|
||||
def start() {
|
||||
}
|
||||
|
||||
def update(packet : String) {
|
||||
val login = "user " + prefs.getString("callsign", null) +
|
||||
" pass " + prefs.getString("passcode", null) + " vers APRSdroid beta"
|
||||
var hostname = prefs.getString("host", null)
|
||||
val addr = InetAddress.getByName(hostname)
|
||||
val pbytes = (login + "\r\n" + packet + "\r\n").getBytes()
|
||||
socket.send(new DatagramPacket(pbytes, pbytes.length, addr, 8080))
|
||||
Log.d(TAG, "update(): sent " + packet + " to " + hostname)
|
||||
}
|
||||
|
||||
def stop() {
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue