Skip to content

Commit

Permalink
Change readme description to remove webrtc
Browse files Browse the repository at this point in the history
  • Loading branch information
glennerichall committed Mar 3, 2024
1 parent 52fc88e commit 2293531
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,11 @@

See [ZupFe](https://zupfe.velor.ca)

![img_3.png](img_3.png)

## Setup

Install via the bundled [Plugin Manager](https://docs.octoprint.org/en/master/bundledplugins/pluginmanager.html)
or manually by downloading this archive:

[Zupfe For Octoprint on GitHub](https://github.com/glennerichall/OctoPrint-Zupfe/archive/master.zip)

### To have a direct connection to your printer

ZupFe uses WebRTC to establish a direct connection to OctoPrint instance. For some reason, aiortc package
in OctoPi is missing `libsrtp2`. An error message can be seen in logs (you must enable
debug logs for *octoprint.plugins.zupfe*) with the following:

*Loading aiortc failed with error: libsrtp2.so.1: cannot open shared object file: No such file or directory*

Consequently, you won't see the direct link icon in *Preferences*

![img_1.png](img_1.png)

- Ssh to your octopi instance
- Run the following command to install missing library:


sudo apt install libsrtp2-1

You should now see the direct link in *Preference*, and all communications with your OctoPrint instance will be
direct without transiting through ZupFe servers (if available, normally on same LAN).

![img.png](img.png)
Binary file added img_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion octoprint_zupfe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def __init__(self):
self._progress_manager = None
self._temperature_manager = None

@property
def version(self):
# TODO get the version from setup.py
return "o.0.1.0"

@property
def host(self):
return self._host
Expand Down Expand Up @@ -249,5 +254,5 @@ def __plugin_load__():
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.sent": __plugin_implementation__.on_gcode_sent,
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information,
}
13 changes: 10 additions & 3 deletions octoprint_zupfe/backend/backend_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from octoprint_zupfe.backend.backend_actions_base import BackendActionBase
from octoprint_zupfe.constants import URL_PRINTER_TITLE, \
URL_PRINTER_STATUS, URL_PRINTER_EVENT, URL_PRINTER_LINK, \
URL_PRINTERS, URL_PRINTER_SNAPSHOT
URL_PRINTERS, URL_PRINTER_SNAPSHOT, URL_PRINTER_VERSION
from octoprint_zupfe.exceptions import NotFoundException, AuthRequiredException, UnAuthorizedException
from octoprint_zupfe.transport.request import request_put

Expand All @@ -15,9 +15,10 @@ class BackendActions(BackendActionBase):
def __init__(self, backend):
super().__init__(backend)

async def new_octo_id(self):
async def new_octo_id(self, version):
url = self.get_url(URL_PRINTERS)
response = await self.post(url)
data = {'version': version}
response = await self.post(url, data=data)
instance = await response.json()
octo_id = instance['uuid']
api_key = instance['apiKey']
Expand All @@ -41,6 +42,12 @@ async def set_printer_title(self, title):
response = await self.post(url, data=data)
await response.close()

async def set_plugin_version(self, version):
url = self.get_url(URL_PRINTER_VERSION)
data = {'version': version}
response = await self.post(url, data=data)
await response.close()

async def check_uuid(self):
try:
await self.get_link_status()
Expand Down
4 changes: 4 additions & 0 deletions octoprint_zupfe/backend/backend_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def update_status_if_changed(plugin):
linked = link_status['linked'] == 'linked'
linked_in_settings = plugin.settings.get_bool('linked')
plugin.settings.save_if_updated('linked', linked)

if linked_in_settings and not linked:
plugin.frontend.emitOctoprintUnlinked()
elif not linked_in_settings and linked:
Expand All @@ -30,6 +31,9 @@ async def update_status_if_changed(plugin):
plugin.logger.debug(f'Printer name changed from {link_status["name"]} to {title}')
await plugin.actions.set_printer_title(title)

if link_status['version'] != plugin.version:
plugin.logger.debug(f'Printer plugin version changed from {link_status["version"]} to {plugin.version}')
await plugin.actions.set_plugin_version(plugin.version)

async def notify_power_state_changed(plugin):
printer = plugin.printer
Expand Down
1 change: 1 addition & 0 deletions octoprint_zupfe/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
URL_PRINTER_SNAPSHOT = "URL_PRINTER_SNAPSHOT"
URL_PRINTER_STATUS = "URL_PRINTER_STATUS"
URL_PRINTER_TITLE = "URL_PRINTER_TITLE"
URL_PRINTER_VERSION = "URL_PRINTER_VERSION"
URL_PRINTER_WRITE_STREAM = "URL_PRINTER_WRITE_STREAM"
URL_PROFILE = "URL_PROFILE"
URL_PUBLISH_EVENT = "URL_PUBLISH_EVENT"
Expand Down
2 changes: 1 addition & 1 deletion octoprint_zupfe/loops/snapshots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging

logger = logging.getLogger("PRINTERS.plugins.zupfe.snapshots")
logger = logging.getLogger("octoprint.plugins.zupfe")


async def wait_until_next_day():
Expand Down
2 changes: 1 addition & 1 deletion octoprint_zupfe/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def validate_api_key():
while not uuid_valid:
if octo_id is None:
plugin.logger.debug('No octoid, asking for a new one')
instance = await plugin.actions.new_octo_id()
instance = await plugin.actions.new_octo_id(plugin.version)
plugin.logger.debug('Got a new octoid')
octo_id = instance['uuid']
api_key = instance['apiKey']
Expand Down
1 change: 1 addition & 0 deletions octoprint_zupfe/static/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const URL_PRINTER_READ_STREAM = "URL_PRINTER_READ_STREAM"
const URL_PRINTER_SNAPSHOT = "URL_PRINTER_SNAPSHOT"
const URL_PRINTER_STATUS = "URL_PRINTER_STATUS"
const URL_PRINTER_TITLE = "URL_PRINTER_TITLE"
const URL_PRINTER_VERSION = "URL_PRINTER_VERSION"
const URL_PRINTER_WRITE_STREAM = "URL_PRINTER_WRITE_STREAM"
const URL_PROFILE = "URL_PROFILE"
const URL_PUBLISH_EVENT = "URL_PUBLISH_EVENT"
Expand Down
11 changes: 7 additions & 4 deletions octoprint_zupfe/transport/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ def __init__(self, backend_ws_url, on_message,
self._api_key = None
self._octo_id = None

# Create a custom SSL context that allows self-signed certificates
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
# Create a custom SSL context that allows self-signed certificates for development purpose
if "localhost" in backend_ws_url:
logger.debug(f"Enabling websocket self-signed certificates")
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE

# websocket.enableTrace(True)

self._backend_ws_url = backend_ws_url
Expand Down
6 changes: 6 additions & 0 deletions octoprint_zupfe/wrappers/webcam_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ async def take_snapshot(self):
if self.can_snapshot:
config = self._webcam.config

config = {
'flip_h': config.flipH,
'flip_v': config.flipV,
'rotate_90': config.rotate90
}

if self._webcam.config.compat is not None:
snapshot_url = self.snapshot_url
response = await request_get(snapshot_url, max_retries=1)
Expand Down

0 comments on commit 2293531

Please sign in to comment.