Update rstp/rpc scripts to use standard network libraries

This commit is contained in:
Kwabena W. Agyeman 2021-10-16 13:40:03 -07:00
parent 97713e0baa
commit a4858015c4
16 changed files with 282 additions and 148 deletions

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -7,7 +7,7 @@
import image, network, omv, rpc, sensor, struct, time
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or LAN/WLAN.
##############################################################
# Choose the interface you wish to control an OpenMV Cam over.

View File

@ -12,7 +12,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.

View File

@ -14,7 +14,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or WiFi.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -64,21 +64,21 @@ interface = rpc.rpc_uart_slave(baudrate=115200)
#
# interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs
@ -127,7 +127,7 @@ def person_detection(data):
# data is unused
def qrcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_qrcodes()
if not codes: return bytes() # No detections.
@ -139,7 +139,7 @@ def qrcode_detection(data):
# data is unused
def all_qrcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_qrcodes()
if not codes: return bytes() # No detections.
@ -177,7 +177,7 @@ def all_apriltag_detection(data):
# data is unused
def datamatrix_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_datamatrices()
if not codes: return bytes() # No detections.
@ -189,7 +189,7 @@ def datamatrix_detection(data):
# data is unused
def all_datamatrix_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((320, 240))
codes = sensor.snapshot().find_datamatrices()
if not codes: return bytes() # No detections.
@ -202,7 +202,7 @@ def all_datamatrix_detection(data):
# data is unused
def barcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((sensor.width(), sensor.height()//8))
codes = sensor.snapshot().find_barcodes()
if not codes: return bytes() # No detections.
@ -213,7 +213,7 @@ def barcode_detection(data):
# data is unused
def all_barcode_detection(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing((sensor.width(), sensor.height()//8))
codes = sensor.snapshot().find_barcodes()
if not codes: return bytes() # No detections.
@ -244,7 +244,7 @@ def color_detection(data):
#
# data is unused
def jpeg_snapshot(data):
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
return sensor.snapshot().compress(quality=90).bytearray()

View File

@ -0,0 +1,79 @@
# RTSP Video Server
#
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
import network, omv, rtsp, sensor, time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
# Turn off the frame buffer connection to the IDE from the OpenMV Cam side.
#
# This needs to be done when manually compressing jpeg images at higher quality
# so that the OpenMV Cam does not try to stream them to the IDE using a fall back
# mechanism if the JPEG image is too large to fit in the IDE JPEG frame buffer on the OpenMV Cam.
omv.disable_fb(True)
# Setup Network Interface
network_if = network.LAN()
network_if.active(True)
network_if.ifconfig('dhcp')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#
# `pathname` is the name of the stream resource the client wants. You can ignore this if it's not
# needed. Otherwise, you can use it to determine what image object to return. By default the path
# name will be "/".
#
# `session` is random number that will change when a new connection is established. You can use
# session with a dictionary to differentiate different accesses to the same file name.
def setup_callback(pathname, session):
print("Opening \"%s\" in session %d" % (pathname, session))
def play_callback(pathname, session):
print("Playing \"%s\" in session %d" % (pathname, session))
def pause_callback(pathname, session): # VLC only pauses locally. This is never called.
print("Pausing \"%s\" in session %d" % (pathname, session))
def teardown_callback(pathname, session):
print("Closing \"%s\" in session %d" % (pathname, session))
server.register_setup_cb(setup_callback)
server.register_play_cb(play_callback)
server.register_pause_cb(pause_callback)
server.register_teardown_cb(teardown_callback)
# Track the current FPS.
clock = time.clock()
# Called each time a new frame is needed.
def image_callback(pathname, session):
clock.tick()
img = sensor.snapshot()
# Markup image and/or do various things.
print(clock.fps())
return img
# Stream does not return. It will call `image_callback` when it needs to get an image object to send
# to the remote rtsp client connecting to the server.
server.stream(image_callback)

View File

@ -0,0 +1,79 @@
# RTSP Video Server
#
# This example shows off how to stream video over RTSP with your OpenMV Cam.
#
# You can use a program like VLC to view the video stream by connecting to the
# OpenMV Cam's IP address.
import network, omv, rtsp, sensor, time
# RTP MJPEG streaming works using JPEG images produced by the OV2640/OV5640 camera modules.
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
# Turn off the frame buffer connection to the IDE from the OpenMV Cam side.
#
# This needs to be done when manually compressing jpeg images at higher quality
# so that the OpenMV Cam does not try to stream them to the IDE using a fall back
# mechanism if the JPEG image is too large to fit in the IDE JPEG frame buffer on the OpenMV Cam.
omv.disable_fb(True)
# Setup Network Interface
network_if = network.WLAN(network.STA_IF)
network_if.active(True)
network_if.connect('your-ssid', 'your-password')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#
# `pathname` is the name of the stream resource the client wants. You can ignore this if it's not
# needed. Otherwise, you can use it to determine what image object to return. By default the path
# name will be "/".
#
# `session` is random number that will change when a new connection is established. You can use
# session with a dictionary to differentiate different accesses to the same file name.
def setup_callback(pathname, session):
print("Opening \"%s\" in session %d" % (pathname, session))
def play_callback(pathname, session):
print("Playing \"%s\" in session %d" % (pathname, session))
def pause_callback(pathname, session): # VLC only pauses locally. This is never called.
print("Pausing \"%s\" in session %d" % (pathname, session))
def teardown_callback(pathname, session):
print("Closing \"%s\" in session %d" % (pathname, session))
server.register_setup_cb(setup_callback)
server.register_play_cb(play_callback)
server.register_pause_cb(pause_callback)
server.register_teardown_cb(teardown_callback)
# Track the current FPS.
clock = time.clock()
# Called each time a new frame is needed.
def image_callback(pathname, session):
clock.tick()
img = sensor.snapshot()
# Markup image and/or do various things.
print(clock.fps())
return img
# Stream does not return. It will call `image_callback` when it needs to get an image object to send
# to the remote rtsp client connecting to the server.
server.stream(image_callback)

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -20,7 +20,7 @@ sensor.skip_frames(time = 2000)
omv.disable_fb(True)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over USB or WIFI.
# allowing your OpenMV Cam to be controlled over USB or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -30,21 +30,21 @@ omv.disable_fb(True)
#
interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -7,7 +7,7 @@
import image, network, omv, rpc, sensor, struct, time
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to control over CAN, I2C, SPI, UART, or LAN/WLAN.
##############################################################
# Choose the interface you wish to control an OpenMV Cam over.

View File

@ -12,7 +12,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or WIFI.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.

View File

@ -14,7 +14,7 @@ sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
# The RPC library above is installed on your OpenMV Cam and provides mutliple classes for
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or WiFi.
# allowing your OpenMV Cam to be controlled over CAN, I2C, SPI, UART, USB VCP, or LAN/WLAN.
################################################################
# Choose the interface you wish to control your OpenMV Cam over.
@ -64,21 +64,21 @@ interface = rpc.rpc_uart_slave(baudrate=115200)
#
# interface = rpc.rpc_usb_vcp_slave()
# Uncomment the below line to setup your OpenMV Cam for control over WiFi.
# Uncomment the below line to setup your OpenMV Cam for control over the lan.
#
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to route traffic to.
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# network_if = network.LAN()
# network_if.active(True)
# network_if.ifconfig('dhcp')
#
# interface = rpc.rpc_wifi_slave(ssid="",
# ssid_key="",
# ssid_security=network.WINC.WPA_PSK,
# port=0x1DBA,
# mode=network.WINC.MODE_STA,
# static_ip=None)
# interface = rpc.rpc_network_slave(network_if)
# Uncomment the below line to setup your OpenMV Cam for control over the wlan.
#
# network_if = network.WLAN(network.STA_IF)
# network_if.active(True)
# network_if.connect('your-ssid', 'your-password')
#
# interface = rpc.rpc_network_slave(network_if)
################################################################
# Call Backs

View File

@ -26,19 +26,15 @@ sensor.set_framesize(sensor.UXGA)
omv.disable_fb(True)
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to listen to (554).
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# Setup Network Interface
server = rtsp.rtsp_server(ssid="",
ssid_key="",
ssid_security=network.WINC.WPA_PSK,
port=554,
mode=network.WINC.MODE_STA,
static_ip=None)
network_if = network.LAN()
network_if.active(True)
network_if.ifconfig('dhcp')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#

View File

@ -11,6 +11,8 @@ import network, omv, rtsp, sensor, time
# Not all programs (e.g. VLC) implement the full JPEG standard for decoding any JPEG image
# in RTP packets. Images JPEG compressed by the OpenMV Cam internally may not display.
# FFPLAY will correctly handle JPEGs produced by OpenMV software.
sensor.reset()
sensor.set_pixformat(sensor.JPEG) # Only supported by the OV2640/OV5640.
@ -24,19 +26,15 @@ sensor.set_framesize(sensor.UXGA)
omv.disable_fb(True)
# * ssid - WiFi network to connect to.
# * ssid_key - WiFi network password.
# * ssid_security - WiFi security.
# * port - Port to listen to (554).
# * mode - Regular or access-point mode.
# * static_ip - If not None then a tuple of the (IP Address, Subnet Mask, Gateway, DNS Address)
# Setup Network Interface
server = rtsp.rtsp_server(ssid="",
ssid_key="",
ssid_security=network.WINC.WPA_PSK,
port=554,
mode=network.WINC.MODE_STA,
static_ip=None)
network_if = network.WLAN(network.STA_IF)
network_if.active(True)
network_if.connect('your-ssid', 'your-password')
# Setup RTSP Server
server = rtsp.rtsp_server(network_if)
# For the call back functions below:
#

View File

@ -557,7 +557,7 @@ class rpc_usb_vcp_slave(rpc_slave):
def put_bytes(self, data, timeout_ms): # protected
self.__usb_vcp.send(data, timeout=timeout_ms)
class rpc_wifi_master(rpc_master):
class rpc_network_master(rpc_master):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:
@ -587,17 +587,11 @@ class rpc_wifi_master(rpc_master):
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, ip, port=0x1DBA, mode=network.WINC.MODE_STA, static_ip=None): # private
def __init__(self, network_if, port=0x1DBA): # private
self._udp_limit = 1400
self._timeout_scale = 10
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__slave_addr = (ip, port)
self.__tcp__socket = None
@ -708,7 +702,7 @@ class rpc_wifi_master(rpc_master):
except OSError: self.__close_tcp_socket()
if l: raise OSError # Stop Stream.
class rpc_wifi_slave(rpc_slave):
class rpc_network_slave(rpc_slave):
def __valid_tcp_socket(self): # private
if self.__tcp__socket is None:
@ -734,17 +728,11 @@ class rpc_wifi_slave(rpc_slave):
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, port=0x1DBA, mode=network.WINC.MODE_STA, static_ip=None): # private
def __init__(self, network_if, port=0x1DBA): # private
self._udp_limit = 1400
self._timeout_scale = 10
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__master_addr = None
self.__tcp__socket = None

View File

@ -37,15 +37,9 @@ class rtsp_server:
self.__udp__socket.close()
self.__udp__socket = None
def __init__(self, ssid, ssid_key, ssid_security, port=554, mode=network.WINC.MODE_STA, static_ip=None): # private
self.__winc = network.WINC(mode=mode)
if mode == network.WINC.MODE_STA:
if static_ip is not None: self.__winc.ifconfig(static_ip)
self.__winc.connect(ssid, key=ssid_key, security=ssid_security)
if not self.__winc.isconnected(): raise OSError("Failed to connect to network!")
elif mode == network.WINC.MODE_AP: self.__winc.start_ap(ssid, key=ssid_key, security=ssid_security)
else: raise ValueError("Invalid mode")
self.__myip = self.__winc.ifconfig()[0]
def __init__(self, network_if, port=554): # private
self.__network = network_if
self.__myip = self.__network.ifconfig()[0]
self.__myaddr = (self.__myip, port)
self.__tcp__socket = None
self.__udp__socket = None