kopia lustrzana https://github.com/ge0rg/aprsdroid
add parseHostPort utility function
rodzic
9dfb374096
commit
8fef181969
|
@ -27,7 +27,7 @@ object AprsPacket {
|
|||
val minFrac = minDec % 100
|
||||
(deg, min, minFrac, letter)
|
||||
}
|
||||
|
||||
|
||||
def formatLat(c : Double) : String = {
|
||||
val (deg, min, minFrac, letter) = splitCoord(c)
|
||||
"%02d%02d.%02d%c".format(deg, min, minFrac, "NS"(letter))
|
||||
|
@ -76,4 +76,12 @@ object AprsPacket {
|
|||
def formatLogin(callsign : String, ssid : String, passcode : String) : String = {
|
||||
"user " + formatCallSsid(callsign, ssid) + " pass " + passcode + " vers APRSdroid 0.1"
|
||||
}
|
||||
|
||||
def parseHostPort(hostport : String, defaultport : Int) : (String, Int) = {
|
||||
val splits = hostport.split(":")
|
||||
if (splits.length == 2)
|
||||
return (splits(0), splits(1).toInt)
|
||||
else
|
||||
return (splits(0), defaultport)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,10 @@ class UdpUploader extends AprsIsUploader {
|
|||
}
|
||||
|
||||
def update(host : String, login : String, packet : String) : String = {
|
||||
val addr = InetAddress.getByName(host)
|
||||
val (h, port) = AprsPacket.parseHostPort(host, 8080)
|
||||
val addr = InetAddress.getByName(h)
|
||||
val pbytes = (login + "\r\n" + packet + "\r\n").getBytes()
|
||||
socket.send(new DatagramPacket(pbytes, pbytes.length, addr, 8080))
|
||||
socket.send(new DatagramPacket(pbytes, pbytes.length, addr, port))
|
||||
Log.d(TAG, "update(): sent '" + packet + "' to " + host)
|
||||
"UDP OK"
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue