mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-01 19:33:28 -05:00
some operations should be allowed before isConnected (autobug)
This commit is contained in:
@@ -273,24 +273,31 @@ class MeshService : Service(), Logging {
|
||||
get() = (if (connectionState == ConnectionState.CONNECTED) radio.serviceP else null)
|
||||
?: throw RadioNotConnectedException()
|
||||
|
||||
/// Send a command/packet to our radio. But cope with the possiblity that we might start up
|
||||
/// before we are fully bound to the RadioInterfaceService
|
||||
private fun sendToRadio(p: ToRadio.Builder) {
|
||||
/** Send a command/packet to our radio. But cope with the possiblity that we might start up
|
||||
before we are fully bound to the RadioInterfaceService
|
||||
@param requireConnected set to false if you are okay with using a partially connected device (i.e. during startup)
|
||||
*/
|
||||
private fun sendToRadio(p: ToRadio.Builder, requireConnected: Boolean = true) {
|
||||
val b = p.build().toByteArray()
|
||||
|
||||
if (SoftwareUpdateService.isUpdating)
|
||||
throw IsUpdatingException()
|
||||
|
||||
connectedRadio.sendToRadio(b)
|
||||
if (requireConnected)
|
||||
connectedRadio.sendToRadio(b)
|
||||
else {
|
||||
val s = radio.serviceP ?: throw RadioNotConnectedException()
|
||||
s.sendToRadio(b)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a mesh packet to the radio, if the radio is not currently connected this function will throw NotConnectedException
|
||||
*/
|
||||
private fun sendToRadio(packet: MeshPacket) {
|
||||
private fun sendToRadio(packet: MeshPacket, requireConnected: Boolean = true) {
|
||||
sendToRadio(ToRadio.newBuilder().apply {
|
||||
this.packet = packet
|
||||
})
|
||||
}, requireConnected)
|
||||
}
|
||||
|
||||
private fun updateMessageNotification(message: DataPacket) =
|
||||
@@ -1510,13 +1517,13 @@ class MeshService : Service(), Logging {
|
||||
private fun requestRadioConfig() {
|
||||
sendToRadio(newMeshPacketTo(myNodeNum).buildAdminPacket(wantResponse = true) {
|
||||
getRadioRequest = true
|
||||
})
|
||||
}, requireConnected = false)
|
||||
}
|
||||
|
||||
private fun requestChannel(channelIndex: Int) {
|
||||
sendToRadio(newMeshPacketTo(myNodeNum).buildAdminPacket(wantResponse = true) {
|
||||
getChannelRequest = channelIndex + 1
|
||||
})
|
||||
}, requireConnected = false)
|
||||
}
|
||||
|
||||
private fun setChannel(channel: ChannelProtos.Channel) {
|
||||
|
||||
Reference in New Issue
Block a user