fix bugs found via simulator

pull/257/head
Kevin Hester 2021-03-04 09:08:29 +08:00
rodzic aa79ee4335
commit 81e76bfc51
6 zmienionych plików z 38 dodań i 31 usunięć

Wyświetl plik

@ -102,8 +102,8 @@ interface IMeshService {
/// Returns true if the device address actually changed, or false if no change was needed
boolean setDeviceAddress(String deviceAddr);
/// Get basic device hardware info about our connected radio. Will never return NULL. Will throw
/// RemoteException if no my node info is available
/// Get basic device hardware info about our connected radio. Will never return NULL. Will return NULL
/// if no my node info is available (i.e. it will not throw an exception)
MyNodeInfo getMyNodeInfo();
/// Start updating the radios firmware

Wyświetl plik

@ -846,8 +846,10 @@ class MainActivity : AppCompatActivity(), Logging,
val allMsgs = service.oldMessages
val msgs =
allMsgs.filter { p -> p.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE }
debug("Service provided ${msgs.size} messages and myNodeNum ${service.myNodeInfo?.myNodeNum}")
model.myNodeInfo.value = service.myNodeInfo
model.myNodeInfo.value = service.myNodeInfo // Note: this could be NULL!
debug("Service provided ${msgs.size} messages and myNodeNum ${model.myNodeInfo.value?.myNodeNum}")
model.messagesState.setMessages(msgs)
val connectionState =
MeshService.ConnectionState.valueOf(service.connectionState())
@ -857,7 +859,6 @@ class MainActivity : AppCompatActivity(), Logging,
if (connectionState != MeshService.ConnectionState.CONNECTED)
updateNodesFromDevice()
// We won't receive a notify for the initial state of connection, so we force an update here
onMeshConnectionChanged(connectionState)
} catch (ex: RemoteException) {
@ -866,9 +867,11 @@ class MainActivity : AppCompatActivity(), Logging,
model.isConnected.value =
MeshService.ConnectionState.valueOf(service.connectionState())
}
finally {
connectionJob = null
}
debug("connected to mesh service, isConnected=${model.isConnected.value}")
connectionJob = null
}
}

Wyświetl plik

@ -139,8 +139,8 @@ class UIViewModel(private val app: Application) : AndroidViewModel(app), Logging
}
}
/// hardware info about our local device
val myNodeInfo = object : MutableLiveData<MyNodeInfo>(null) {}
/// hardware info about our local device (can be null)
val myNodeInfo = object : MutableLiveData<MyNodeInfo?>(null) {}
override fun onCleared() {
super.onCleared()

Wyświetl plik

@ -765,6 +765,7 @@ class MeshService : Service(), Logging {
if (fromNodeNum == myNodeNum) {
when (a.variantCase) {
AdminProtos.AdminMessage.VariantCase.GET_RADIO_RESPONSE -> {
debug("Admin: received radioConfig")
radioConfig = a.getRadioResponse
requestChannel(0) // Now start reading channels
}
@ -774,19 +775,18 @@ class MeshService : Service(), Logging {
if (mi != null) {
val ch = a.getChannelResponse
channels[ch.index] = ch
debug("Received channel ${ch.index}")
debug("Admin: Received channel ${ch.index}")
if (ch.index + 1 < mi.maxChannels) {
if(ch.hasSettings()) {
// Not done yet, request next channel
requestChannel(ch.index + 1)
}
/* if(ch.index == 0) {
// We allow the app to start as soon as we've received the primary channel, we'll keep fetching other channels in the background
else {
debug("We've received the primary channel, allowing rest of app to start...")
onHasSettings()
} */
}
} else {
debug("Received all channels")
debug("Received max channels, starting app")
onHasSettings()
}
}
@ -1629,9 +1629,7 @@ class MeshService : Service(), Logging {
doFirmwareUpdate()
}
override fun getMyNodeInfo(): MyNodeInfo = toRemoteExceptions {
this@MeshService.myNodeInfo ?: throw RadioNotConnectedException("No MyNodeInfo")
}
override fun getMyNodeInfo(): MyNodeInfo? = this@MeshService.myNodeInfo
override fun getMyId() = toRemoteExceptions { myNodeID }

Wyświetl plik

@ -156,24 +156,11 @@ class MockInterface(private val service: RadioInterfaceService) : Logging, IRadi
hwModel = "Sim"
messageTimeoutMsec = 5 * 60 * 1000
firmwareVersion = service.getString(R.string.cur_firmware_version)
numBands = 13
maxChannels = 8
}.build()
},
// RadioConfig
/* MeshProtos.FromRadio.newBuilder().apply {
radio = RadioConfigProtos.RadioConfig.newBuilder().apply {
preferences = RadioConfigProtos.RadioConfig.UserPreferences.newBuilder().apply {
region = RadioConfigProtos.RegionCode.TW
// FIXME set critical times?
}.build()
/* channel = ChannelProtos.ChannelSettings.newBuilder().apply {
// we just have an empty listing so that the default channel works
}.build() */
}.build()
}, */
// Fake NodeDB
makeNodeInfo(MY_NODE, 32.776665, -96.796989), // dallas
makeNodeInfo(MY_NODE + 1, 32.960758, -96.733521), // richardson

Wyświetl plik

@ -19,6 +19,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.RadioButton
import android.widget.Toast
@ -583,6 +584,22 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
}
}
private val regionSpinnerListener = object : AdapterView.OnItemSelectedListener{
override fun onItemSelected(
parent: AdapterView<*>,
view: View,
position: Int,
id: Long
) {
val item = parent.getItemAtPosition(position)
//TODO("Not yet implemented")
}
override fun onNothingSelected(parent: AdapterView<*>?) {
//TODO("Not yet implemented")
}
}
/// Setup the ui widgets unrelated to BLE scanning
private fun initCommonUI() {
@ -592,6 +609,8 @@ class SettingsFragment : ScreenFragment("Settings"), Logging {
regionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
// spinner.adapter = regionAdapter
spinner.onItemSelectedListener = regionSpinnerListener
model.ownerName.observe(viewLifecycleOwner, { name ->
binding.usernameEditText.setText(name)
})