This should mask the problem but it would be better to know where the code is getting a mode value of 0 from when it should be 0x80
sys.stderr.write("Mode <- %s\n" % MODE.lookup[mode | 0x80])
or we could try raising an exception which should give a traceback showing where the value of mode was set to zero.
def set_mode(self, mode):
""" Set the mode
:param mode: Set the mode. Use constants.MODE class
:return: New mode
"""
# the mode is backed up in self.mode
if mode == self.mode:
return mode
if mode==0:
raise Exception("Invalid mode value")
if self.verbose:
sys.stderr.write("Mode <- %s\n" % MODE.lookup[mode])
self.mode = mode
return self.spi.xfer([REG.LORA.OP_MODE | 0x80, mode])[1]
I find it hard to believe the Dragino RFM95’s are developing faults.