kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
TCPInterface (for accessing the native-simulator) kinda works
rodzic
9e42634402
commit
04f4a2a342
|
@ -51,6 +51,9 @@ class RadioInterfaceService : Service(), Logging {
|
||||||
|
|
||||||
const val DEVADDR_KEY = "devAddr2" // the new name for devaddr
|
const val DEVADDR_KEY = "devAddr2" // the new name for devaddr
|
||||||
|
|
||||||
|
/// We keep this var alive so that the following factory objects get created and not stripped during the android build
|
||||||
|
private val factories = arrayOf<InterfaceFactory>(BluetoothInterface, SerialInterface, TCPInterface, MockInterface, NopInterface)
|
||||||
|
|
||||||
/// This is public only so that SimRadio can bootstrap our message flow
|
/// This is public only so that SimRadio can bootstrap our message flow
|
||||||
fun broadcastReceivedFromRadio(context: Context, payload: ByteArray) {
|
fun broadcastReceivedFromRadio(context: Context, payload: ByteArray) {
|
||||||
val intent = Intent(RECEIVE_FROMRADIO_ACTION)
|
val intent = Intent(RECEIVE_FROMRADIO_ACTION)
|
||||||
|
|
|
@ -54,23 +54,24 @@ class TCPInterface(service: RadioInterfaceService, private val address: String)
|
||||||
override fun connect() {
|
override fun connect() {
|
||||||
//here you must put your computer's IP address.
|
//here you must put your computer's IP address.
|
||||||
//here you must put your computer's IP address.
|
//here you must put your computer's IP address.
|
||||||
val addr = InetAddress.getByName(address)
|
|
||||||
|
|
||||||
debug("TCP connecting to $address")
|
|
||||||
|
|
||||||
//create a socket to make the connection with the server
|
|
||||||
|
|
||||||
//create a socket to make the connection with the server
|
|
||||||
val port = 4403
|
|
||||||
val s = Socket(addr, port)
|
|
||||||
s.tcpNoDelay = true
|
|
||||||
socket = s
|
|
||||||
outStream = BufferedOutputStream(s.getOutputStream())
|
|
||||||
inStream = BufferedInputStream(s.getInputStream())
|
|
||||||
|
|
||||||
// No need to keep a reference to this thread - it will exit when we close inStream
|
// No need to keep a reference to this thread - it will exit when we close inStream
|
||||||
thread(start = true, isDaemon = true, name = "TCP reader") {
|
thread(start = true, isDaemon = true, name = "TCP reader") {
|
||||||
try {
|
try {
|
||||||
|
val a = InetAddress.getByName(address)
|
||||||
|
debug("TCP connecting to $address")
|
||||||
|
|
||||||
|
//create a socket to make the connection with the server
|
||||||
|
val port = 4403
|
||||||
|
val s = Socket(a, port)
|
||||||
|
s.tcpNoDelay = true
|
||||||
|
socket = s
|
||||||
|
outStream = BufferedOutputStream(s.getOutputStream())
|
||||||
|
inStream = s.getInputStream()
|
||||||
|
|
||||||
|
// Note: we call the super method FROM OUR NEW THREAD
|
||||||
|
super.connect()
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
val c = inStream.read()
|
val c = inStream.read()
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
|
@ -84,6 +85,5 @@ class TCPInterface(service: RadioInterfaceService, private val address: String)
|
||||||
}
|
}
|
||||||
debug("Exiting TCP reader")
|
debug("Exiting TCP reader")
|
||||||
}
|
}
|
||||||
super.connect()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -276,7 +276,8 @@ class BTScanModel(app: Application) : AndroidViewModel(app), Logging {
|
||||||
warn("No bluetooth adapter. Running under emulation?")
|
warn("No bluetooth adapter. Running under emulation?")
|
||||||
|
|
||||||
val testnodes = listOf(
|
val testnodes = listOf(
|
||||||
DeviceListEntry("Simulated interface", "m", true),
|
DeviceListEntry("Included simulator", "m", true),
|
||||||
|
DeviceListEntry("Complete simulator", "t10.0.2.2", true),
|
||||||
DeviceListEntry(context.getString(R.string.none), "n", true)
|
DeviceListEntry(context.getString(R.string.none), "n", true)
|
||||||
/* Don't populate fake bluetooth devices, because we don't want testlab inside of google
|
/* Don't populate fake bluetooth devices, because we don't want testlab inside of google
|
||||||
to try and use them.
|
to try and use them.
|
||||||
|
|
Ładowanie…
Reference in New Issue