Compare commits

...

4 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire
3ee8c14787
Merge 5c6ee07d66 into 1c56385473 2024-09-29 11:06:41 +02:00
Mark Qvist
1c56385473 Added display blanking timeout configuration to rnodeconf 2024-09-29 02:35:44 +02:00
Mark Qvist
787af92ade Added option to configure NeoPixel intensity to rnodeconf 2024-09-27 20:07:04 +02:00
Tristan Brice Velloza Kildaire
5c6ee07d66 TCPInterface
- When connect(s, Bool)` is called construct a socket that supports both address families
2024-09-05 00:07:35 +02:00
2 changed files with 41 additions and 1 deletions

View File

@ -200,7 +200,7 @@ class TCPClientInterface(Interface):
if initial: if initial:
RNS.log("Establishing TCP connection for "+str(self)+"...", RNS.LOG_DEBUG) RNS.log("Establishing TCP connection for "+str(self)+"...", RNS.LOG_DEBUG)
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.socket = socket.socket(socket.AF_INET|socket.AF_INET6, socket.SOCK_STREAM)
self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT) self.socket.settimeout(TCPClientInterface.INITIAL_CONNECT_TIMEOUT)
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
self.socket.connect((self.target_ip, self.target_port)) self.socket.connect((self.target_ip, self.target_port))

View File

@ -81,7 +81,9 @@ class KISS():
CMD_BLINK = 0x30 CMD_BLINK = 0x30
CMD_RANDOM = 0x40 CMD_RANDOM = 0x40
CMD_DISP_INT = 0x45 CMD_DISP_INT = 0x45
CMD_NP_INT = 0x65
CMD_DISP_ADR = 0x63 CMD_DISP_ADR = 0x63
CMD_DISP_BLNK = 0x64
CMD_BT_CTRL = 0x46 CMD_BT_CTRL = 0x46
CMD_BT_PIN = 0x62 CMD_BT_PIN = 0x62
CMD_BOARD = 0x47 CMD_BOARD = 0x47
@ -637,6 +639,20 @@ class RNode():
if written != len(kiss_command): if written != len(kiss_command):
raise IOError("An IO error occurred while sending display intensity command to device") raise IOError("An IO error occurred while sending display intensity command to device")
def set_display_blanking(self, blanking_timeout):
data = bytes([blanking_timeout & 0xFF])
kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_DISP_BLNK])+data+bytes([KISS.FEND])
written = self.serial.write(kiss_command)
if written != len(kiss_command):
raise IOError("An IO error occurred while sending display blanking timeout command to device")
def set_neopixel_intensity(self, intensity):
data = bytes([intensity & 0xFF])
kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_NP_INT])+data+bytes([KISS.FEND])
written = self.serial.write(kiss_command)
if written != len(kiss_command):
raise IOError("An IO error occurred while sending NeoPixel intensity command to device")
def set_display_address(self, address): def set_display_address(self, address):
data = bytes([address & 0xFF]) data = bytes([address & 0xFF])
kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_DISP_ADR])+data+bytes([KISS.FEND]) kiss_command = bytes([KISS.FEND])+bytes([KISS.CMD_DISP_ADR])+data+bytes([KISS.FEND])
@ -1261,8 +1277,11 @@ def main():
parser.add_argument("-p", "--bluetooth-pair", action="store_true", help="Put device into bluetooth pairing mode") parser.add_argument("-p", "--bluetooth-pair", action="store_true", help="Put device into bluetooth pairing mode")
parser.add_argument("-D", "--display", action="store", metavar="i", type=int, default=None, help="Set display intensity (0-255)") parser.add_argument("-D", "--display", action="store", metavar="i", type=int, default=None, help="Set display intensity (0-255)")
parser.add_argument("-t", "--timeout", action="store", metavar="s", type=int, default=None, help="Set display timeout in seconds, 0 to disable")
parser.add_argument("--display-addr", action="store", metavar="byte", type=str, default=None, help="Set display address as hex byte (00 - FF)") parser.add_argument("--display-addr", action="store", metavar="byte", type=str, default=None, help="Set display address as hex byte (00 - FF)")
parser.add_argument("--np", action="store", metavar="i", type=int, default=None, help="Set NeoPixel intensity (0-255)")
parser.add_argument("--freq", action="store", metavar="Hz", type=int, default=None, help="Frequency in Hz for TNC mode") parser.add_argument("--freq", action="store", metavar="Hz", type=int, default=None, help="Frequency in Hz for TNC mode")
parser.add_argument("--bw", action="store", metavar="Hz", type=int, default=None, help="Bandwidth in Hz for TNC mode") parser.add_argument("--bw", action="store", metavar="Hz", type=int, default=None, help="Bandwidth in Hz for TNC mode")
parser.add_argument("--txp", action="store", metavar="dBm", type=int, default=None, help="TX power in dBm for TNC mode") parser.add_argument("--txp", action="store", metavar="dBm", type=int, default=None, help="TX power in dBm for TNC mode")
@ -3168,6 +3187,27 @@ def main():
RNS.log("Setting display intensity to "+str(di)) RNS.log("Setting display intensity to "+str(di))
rnode.set_display_intensity(di) rnode.set_display_intensity(di)
if isinstance(args.timeout, int):
di = args.timeout
if di < 0:
di = 0
if di > 255:
di = 255
if di == 0:
RNS.log("Disabling display blanking")
else:
RNS.log("Setting display timeout to "+str(di))
rnode.set_display_blanking(di)
if isinstance(args.np, int):
di = args.np
if di < 0:
di = 0
if di > 255:
di = 255
RNS.log("Setting NeoPixel intensity to "+str(di))
rnode.set_neopixel_intensity(di)
if isinstance(args.display_addr, str): if isinstance(args.display_addr, str):
set_addr = False set_addr = False
try: try: