Merge branch 'meshtastic:master' into osmdroid-phase3

pull/505/head
PWRxPSYCHO 2022-10-12 13:13:11 -04:00 zatwierdzone przez GitHub
commit a7868c3025
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
5 zmienionych plików z 56 dodań i 80 usunięć

Wyświetl plik

@ -72,20 +72,12 @@ interface IMeshService {
List<NodeInfo> getNodes();
/// This method is only intended for use in our GUI, so the user can set radio options
/// It returns a DeviceConfig protobuf.
byte []getDeviceConfig();
/// It sets a Config protobuf via admin packet
void setConfig(in byte []payload);
/// This method is only intended for use in our GUI, so the user can set radio options
/// It sets a DeviceConfig protobuf
void setDeviceConfig(in byte []payload);
/// This method is only intended for use in our GUI, so the user can set radio options
/// It returns a ChannelSet protobuf.
byte []getChannels();
/// This method is only intended for use in our GUI, so the user can set radio options
/// It sets a ChannelSet protobuf
void setChannels(in byte []payload);
/// It sets a Channel protobuf via admin packet
void setChannel(in byte []payload);
/// Send Shutdown admin packet to nodeNum
void requestShutdown(in int idNum);

Wyświetl plik

@ -94,7 +94,6 @@ class UIViewModel @Inject constructor(
private val _channels = MutableStateFlow(ChannelSet())
val channels: StateFlow<ChannelSet> = _channels
val channelSet get() = channels.value.protobuf
private val _quickChatActions = MutableStateFlow<List<QuickChatAction>>(emptyList())
val quickChatActions: StateFlow<List<QuickChatAction>> = _quickChatActions
@ -271,48 +270,76 @@ class UIViewModel @Inject constructor(
inline fun updateDeviceConfig(crossinline body: (Config.DeviceConfig) -> Config.DeviceConfig) {
val data = body(config.device)
setDeviceConfig(config { device = data })
setConfig(config { device = data })
}
inline fun updatePositionConfig(crossinline body: (Config.PositionConfig) -> Config.PositionConfig) {
val data = body(config.position)
setDeviceConfig(config { position = data })
setConfig(config { position = data })
}
inline fun updatePowerConfig(crossinline body: (Config.PowerConfig) -> Config.PowerConfig) {
val data = body(config.power)
setDeviceConfig(config { power = data })
setConfig(config { power = data })
}
inline fun updateNetworkConfig(crossinline body: (Config.NetworkConfig) -> Config.NetworkConfig) {
val data = body(config.network)
setDeviceConfig(config { network = data })
setConfig(config { network = data })
}
inline fun updateDisplayConfig(crossinline body: (Config.DisplayConfig) -> Config.DisplayConfig) {
val data = body(config.display)
setDeviceConfig(config { display = data })
setConfig(config { display = data })
}
inline fun updateLoraConfig(crossinline body: (Config.LoRaConfig) -> Config.LoRaConfig) {
val data = body(config.lora)
setDeviceConfig(config { lora = data })
setConfig(config { lora = data })
}
inline fun updateBluetoothConfig(crossinline body: (Config.BluetoothConfig) -> Config.BluetoothConfig) {
val data = body(config.bluetooth)
setDeviceConfig(config { bluetooth = data })
setConfig(config { bluetooth = data })
}
// Set the radio config (also updates our saved copy in preferences)
fun setDeviceConfig(config: Config) {
meshService?.deviceConfig = config.toByteArray()
fun setConfig(config: Config) {
meshService?.setConfig(config.toByteArray())
}
/// Convert the channels array to and from [AppOnlyProtos.ChannelSet]
private var _channelSet: AppOnlyProtos.ChannelSet
get() = channels.value.protobuf
set(value) {
val asChannels = value.settingsList.mapIndexed { i, c ->
channel {
role = if (i == 0) ChannelProtos.Channel.Role.PRIMARY
else ChannelProtos.Channel.Role.SECONDARY
index = i
settings = c
}
}
debug("Sending channels to device")
asChannels.forEach {
meshService?.setChannel(it.toByteArray())
}
viewModelScope.launch {
channelSetRepository.clearSettings()
channelSetRepository.addAllSettings(value)
}
val newConfig = config { lora = value.loraConfig }
if (config.lora != newConfig.lora) setConfig(newConfig)
}
val channelSet get() = _channelSet
/// Set the radio config (also updates our saved copy in preferences)
fun setChannels(c: ChannelSet) {
fun setChannels(channelSet: ChannelSet) {
debug("Setting new channels!")
meshService?.channels = c.protobuf.toByteArray()
this._channelSet = channelSet.protobuf
}
/// our name in hte radio

Wyświetl plik

@ -100,7 +100,7 @@ class BluetoothInterface(
val BTM_SERVICE_UUID: UUID = UUID.fromString("6ba1b218-15a8-461f-9fa8-5dcae273eafd")
val BTM_FROMRADIO_CHARACTER: UUID =
UUID.fromString("8ba2bcc2-ee02-4a55-a531-c525c5e454d5")
UUID.fromString("2c55e69e-4993-11ed-b878-0242ac120002")
val BTM_TORADIO_CHARACTER: UUID =
UUID.fromString("f75c76d2-129e-4dad-a1dd-7866124401e7")
val BTM_FROMNUM_CHARACTER: UUID =

Wyświetl plik

@ -94,9 +94,6 @@ class MeshService : Service(), Logging {
class NodeNumNotFoundException(id: Int) : NodeNotFoundException("NodeNum not found $id")
class IdNotFoundException(id: String) : NodeNotFoundException("ID not found $id")
class NoDeviceConfigException(message: String = "No radio settings received (is our app too old?)") :
RadioNotConnectedException(message)
/** We treat software update as similar to loss of comms to the regular bluetooth service (so things like sendPosition for background GPS ignores the problem */
class IsUpdatingException :
RadioNotConnectedException("Operation prohibited during firmware update")
@ -117,7 +114,7 @@ class MeshService : Service(), Logging {
/** The minimmum firmware version we know how to talk to. We'll still be able to talk to 1.0 firmwares but only well enough to ask them to firmware update
*/
val minDeviceVersion = DeviceVersion("1.3.41")
val minDeviceVersion = DeviceVersion("1.3.43")
}
enum class ConnectionState {
@ -466,36 +463,6 @@ class MeshService : Service(), Logging {
/// Admin channel index
private var adminChannelIndex: Int = 0
/// Convert the channels array into a ChannelSet
private var channelSet: AppOnlyProtos.ChannelSet
get() {
// this is never called
return AppOnlyProtos.ChannelSet.getDefaultInstance()
}
set(value) {
val asChannels = value.settingsList.mapIndexed { i, c ->
ChannelProtos.Channel.newBuilder().apply {
role =
if (i == 0) ChannelProtos.Channel.Role.PRIMARY else ChannelProtos.Channel.Role.SECONDARY
index = i
settings = c
}.build()
}
debug("Sending channels to device")
asChannels.forEach {
setChannel(it)
}
serviceScope.handledLaunch {
channelSetRepository.clearSettings()
channelSetRepository.addAllSettings(value)
}
val newConfig = config { lora = value.loraConfig }
if (localConfig.lora != newConfig.lora) sendDeviceConfig(newConfig)
}
/// Generate a new mesh packet builder with our node as the sender, and the specified node num
private fun newMeshPacketTo(idNum: Int) = MeshPacket.newBuilder().apply {
if (myNodeInfo == null)
@ -1475,15 +1442,13 @@ class MeshService : Service(), Logging {
/** Send our current radio config to the device
*/
private fun sendDeviceConfig(c: ConfigProtos.Config) {
private fun setConfig(config: ConfigProtos.Config) {
if (deviceVersion < minDeviceVersion) return
debug("Setting new radio config!")
sendToRadio(newMeshPacketTo(myNodeNum).buildAdminPacket {
setConfig = c
setConfig = config
})
// Update our cached copy
setLocalConfig(c)
setLocalConfig(config) // Update our cached copy
}
/**
@ -1698,23 +1663,14 @@ class MeshService : Service(), Logging {
}
}
override fun getDeviceConfig(): ByteArray = toRemoteExceptions {
this@MeshService.localConfig.toByteArray()
?: throw NoDeviceConfigException()
}
override fun setDeviceConfig(payload: ByteArray) = toRemoteExceptions {
override fun setConfig(payload: ByteArray) = toRemoteExceptions {
val parsed = ConfigProtos.Config.parseFrom(payload)
sendDeviceConfig(parsed)
setConfig(parsed)
}
override fun getChannels(): ByteArray = toRemoteExceptions {
channelSet.toByteArray()
}
override fun setChannels(payload: ByteArray?) = toRemoteExceptions {
val parsed = AppOnlyProtos.ChannelSet.parseFrom(payload)
channelSet = parsed
override fun setChannel(payload: ByteArray?) = toRemoteExceptions {
val parsed = ChannelProtos.Channel.parseFrom(payload)
setChannel(parsed)
}
override fun getNodes(): MutableList<NodeInfo> = toRemoteExceptions {

Wyświetl plik

@ -314,10 +314,11 @@ class ChannelFragment : ScreenFragment("Channel"), Logging {
// No matter what apply the speed selection from the user
val newLoRaConfig = loRaConfig {
region = model.region
txEnabled = model.txEnabled
usePreset = true
modemPreset = newModemPreset
region = model.region
txEnabled = model.txEnabled
txPower = model.config.lora.txPower
}
val humanName = Channel(newSettings, newLoRaConfig).humanName