mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-04 03:37:21 +00:00
Fixes to the Az-El message sent via socket to rotctld
This commit is contained in:
1 parent
18820b79f4
commit
e5e5fe7ee7
1 file changed
+8
-4
@@ -24,6 +24,7 @@ import com.rtbishop.look4sat.data.repository.PassesRepo
|
|||||||
import com.rtbishop.look4sat.data.repository.SatelliteRepo
|
import com.rtbishop.look4sat.data.repository.SatelliteRepo
|
||||||
import com.rtbishop.look4sat.di.IoDispatcher
|
import com.rtbishop.look4sat.di.IoDispatcher
|
||||||
import com.rtbishop.look4sat.utility.PrefsManager
|
import com.rtbishop.look4sat.utility.PrefsManager
|
||||||
|
import com.rtbishop.look4sat.utility.round
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
@@ -76,12 +77,15 @@ class PolarViewModel @Inject constructor(
|
|||||||
if (rotatorPrefs != null) {
|
if (rotatorPrefs != null) {
|
||||||
runCatching {
|
runCatching {
|
||||||
withContext(ioDispatcher) {
|
withContext(ioDispatcher) {
|
||||||
val client = Socket(rotatorPrefs.first, rotatorPrefs.second)
|
val socket = Socket(rotatorPrefs.first, rotatorPrefs.second)
|
||||||
val writer = client.getOutputStream()
|
val writer = socket.getOutputStream().bufferedWriter()
|
||||||
while (isActive) {
|
while (isActive) {
|
||||||
val satPos = satPass.predictor.getSatPos(Date())
|
val satPos = satPass.predictor.getSatPos(Date())
|
||||||
val message = "\\set_pos ${satPos.azimuth} ${satPos.elevation}"
|
val azimuth = Math.toDegrees(satPos.azimuth).round(1)
|
||||||
writer?.write(message.toByteArray())
|
val elevation = Math.toDegrees(satPos.elevation).round(1)
|
||||||
|
writer.write("\\set_pos $azimuth $elevation")
|
||||||
|
writer.newLine()
|
||||||
|
writer.flush()
|
||||||
delay(1000)
|
delay(1000)
|
||||||
}
|
}
|
||||||
writer.close()
|
writer.close()
|
||||||
|
|||||||
Reference in new issue
Block a user