mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-26 15:30:18 +00:00
Improved support for ESP32-based RNodes
This commit is contained in:
parent
485558cd6b
commit
0a4dd64434
@ -223,7 +223,7 @@ class RNodeInterface(Interface):
|
|||||||
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
||||||
RNS.log("Aborting RNode startup", RNS.LOG_ERROR)
|
RNS.log("Aborting RNode startup", RNS.LOG_ERROR)
|
||||||
self.serial.close()
|
self.serial.close()
|
||||||
raise IOError("RNode interface did not pass validation")
|
raise IOError("RNode interface did not pass configuration validation")
|
||||||
|
|
||||||
|
|
||||||
def initRadio(self):
|
def initRadio(self):
|
||||||
@ -245,7 +245,7 @@ class RNodeInterface(Interface):
|
|||||||
written = self.serial.write(kiss_command)
|
written = self.serial.write(kiss_command)
|
||||||
if written != len(kiss_command):
|
if written != len(kiss_command):
|
||||||
raise IOError("An IO error occurred while restarting device")
|
raise IOError("An IO error occurred while restarting device")
|
||||||
sleep(2);
|
sleep(2.25);
|
||||||
|
|
||||||
def setFrequency(self):
|
def setFrequency(self):
|
||||||
c1 = self.frequency >> 24
|
c1 = self.frequency >> 24
|
||||||
@ -293,13 +293,14 @@ class RNodeInterface(Interface):
|
|||||||
raise IOError("An IO error occurred while configuring coding rate for "+self(str))
|
raise IOError("An IO error occurred while configuring coding rate for "+self(str))
|
||||||
|
|
||||||
def setRadioState(self, state):
|
def setRadioState(self, state):
|
||||||
|
self.state = state
|
||||||
kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_RADIO_STATE])+bytes([state])+bytes([KISS.FEND])
|
kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_RADIO_STATE])+bytes([state])+bytes([KISS.FEND])
|
||||||
written = self.serial.write(kiss_command)
|
written = self.serial.write(kiss_command)
|
||||||
if written != len(kiss_command):
|
if written != len(kiss_command):
|
||||||
raise IOError("An IO error occurred while configuring radio state for "+self(str))
|
raise IOError("An IO error occurred while configuring radio state for "+self(str))
|
||||||
|
|
||||||
def validateRadioState(self):
|
def validateRadioState(self):
|
||||||
RNS.log("Validating radio configuration for "+str(self)+"...", RNS.LOG_VERBOSE)
|
RNS.log("Wating for radio configuration validation for "+str(self)+"...", RNS.LOG_VERBOSE)
|
||||||
sleep(0.25);
|
sleep(0.25);
|
||||||
if (self.frequency != self.r_frequency):
|
if (self.frequency != self.r_frequency):
|
||||||
RNS.log("Frequency mismatch", RNS.LOG_ERROR)
|
RNS.log("Frequency mismatch", RNS.LOG_ERROR)
|
||||||
@ -313,6 +314,9 @@ class RNodeInterface(Interface):
|
|||||||
if (self.sf != self.r_sf):
|
if (self.sf != self.r_sf):
|
||||||
RNS.log("Spreading factor mismatch", RNS.LOG_ERROR)
|
RNS.log("Spreading factor mismatch", RNS.LOG_ERROR)
|
||||||
self.validcfg = False
|
self.validcfg = False
|
||||||
|
if (self.state != self.r_state):
|
||||||
|
RNS.log("Radio state mismatch", RNS.LOG_ERROR)
|
||||||
|
self.validcfg = False
|
||||||
|
|
||||||
if (self.validcfg):
|
if (self.validcfg):
|
||||||
return True
|
return True
|
||||||
@ -453,10 +457,11 @@ class RNodeInterface(Interface):
|
|||||||
self.updateBitrate()
|
self.updateBitrate()
|
||||||
elif (command == KISS.CMD_RADIO_STATE):
|
elif (command == KISS.CMD_RADIO_STATE):
|
||||||
self.r_state = byte
|
self.r_state = byte
|
||||||
# if self.r_state:
|
if self.r_state:
|
||||||
# RNS.log(str(self)+" Radio reporting state is online ("+RNS.hexrep([self.r_state])+")", RNS.LOG_DEBUG)
|
pass
|
||||||
# else:
|
#RNS.log(str(self)+" Radio reporting state is online", RNS.LOG_DEBUG)
|
||||||
# RNS.log(str(self)+" Radio reporting state is offline ("+RNS.hexrep([self.r_state])+")", RNS.LOG_DEBUG)
|
else:
|
||||||
|
RNS.log(str(self)+" Radio reporting state is offline", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
elif (command == KISS.CMD_RADIO_LOCK):
|
elif (command == KISS.CMD_RADIO_LOCK):
|
||||||
self.r_lock = byte
|
self.r_lock = byte
|
||||||
@ -501,10 +506,13 @@ class RNodeInterface(Interface):
|
|||||||
elif (command == KISS.CMD_ERROR):
|
elif (command == KISS.CMD_ERROR):
|
||||||
if (byte == KISS.ERROR_INITRADIO):
|
if (byte == KISS.ERROR_INITRADIO):
|
||||||
RNS.log(str(self)+" hardware initialisation error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
RNS.log(str(self)+" hardware initialisation error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
||||||
|
raise IOError("Radio initialisation failure")
|
||||||
elif (byte == KISS.ERROR_INITRADIO):
|
elif (byte == KISS.ERROR_INITRADIO):
|
||||||
RNS.log(str(self)+" hardware TX error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
RNS.log(str(self)+" hardware TX error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
||||||
|
raise IOError("Hardware transmit failure")
|
||||||
else:
|
else:
|
||||||
RNS.log(str(self)+" hardware error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
RNS.log(str(self)+" hardware error (code "+RNS.hexrep(byte)+")", RNS.LOG_ERROR)
|
||||||
|
raise IOError("Unknown hardware failure")
|
||||||
elif (command == KISS.CMD_RESET):
|
elif (command == KISS.CMD_RESET):
|
||||||
if (byte == 0xF8):
|
if (byte == 0xF8):
|
||||||
if self.platform == KISS.PLATFORM_ESP32:
|
if self.platform == KISS.PLATFORM_ESP32:
|
||||||
@ -540,7 +548,7 @@ class RNodeInterface(Interface):
|
|||||||
self.online = False
|
self.online = False
|
||||||
RNS.log("A serial port error occurred, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("A serial port error occurred, the contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
RNS.log("The interface "+str(self)+" experienced an unrecoverable error and is now offline.", RNS.LOG_ERROR)
|
RNS.log("The interface "+str(self)+" experienced an unrecoverable error and is now offline.", RNS.LOG_ERROR)
|
||||||
|
|
||||||
if RNS.Reticulum.panic_on_interface_error:
|
if RNS.Reticulum.panic_on_interface_error:
|
||||||
RNS.panic()
|
RNS.panic()
|
||||||
|
|
||||||
@ -564,5 +572,5 @@ class RNodeInterface(Interface):
|
|||||||
RNS.log("Reconnected serial port for "+str(self))
|
RNS.log("Reconnected serial port for "+str(self))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "RNodeInterface["+self.name+"]"
|
return "RNodeInterface["+str(self.name)+"]"
|
||||||
|
|
||||||
|
@ -541,8 +541,6 @@ class Reticulum:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("The interface \""+name+"\" could not be created. Check your configuration file for errors!", RNS.LOG_ERROR)
|
RNS.log("The interface \""+name+"\" could not be created. Check your configuration file for errors!", RNS.LOG_ERROR)
|
||||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
# TODO: Remove
|
|
||||||
raise e
|
|
||||||
RNS.panic()
|
RNS.panic()
|
||||||
else:
|
else:
|
||||||
RNS.log("The interface name \""+name+"\" was already used. Check your configuration file for errors!", RNS.LOG_ERROR)
|
RNS.log("The interface name \""+name+"\" was already used. Check your configuration file for errors!", RNS.LOG_ERROR)
|
||||||
|
@ -109,6 +109,11 @@ def rand():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def hexrep(data, delimit=True):
|
def hexrep(data, delimit=True):
|
||||||
|
try:
|
||||||
|
iter(data)
|
||||||
|
except TypeError:
|
||||||
|
data = [data]
|
||||||
|
|
||||||
delimiter = ":"
|
delimiter = ":"
|
||||||
if not delimit:
|
if not delimit:
|
||||||
delimiter = ""
|
delimiter = ""
|
||||||
|
Loading…
Reference in New Issue
Block a user