Improved example plugins
This commit is contained in:
parent
3967a85ab0
commit
2da2fc26e7
|
@ -1,3 +1,7 @@
|
||||||
|
# This is a bare-minimum command plugin
|
||||||
|
# example that you can build upon to
|
||||||
|
# implement your own command plugins.
|
||||||
|
|
||||||
import RNS
|
import RNS
|
||||||
|
|
||||||
class BasicCommandPlugin(SidebandCommandPlugin):
|
class BasicCommandPlugin(SidebandCommandPlugin):
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# This plugin example fetches an XKCD comic
|
||||||
|
# from an external URL and returns it as an
|
||||||
|
# embedded image in an LXMF message.
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import RNS
|
import RNS
|
||||||
import requests
|
import requests
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
import RNS
|
# This plugin allows using GPSd as a location
|
||||||
import time
|
# telemetry provider on Linux systems.
|
||||||
import threading
|
|
||||||
|
|
||||||
# This plugin requires the "gpsdclient" pip
|
# This plugin requires the "gpsdclient" pip
|
||||||
# package to be installed on your system.
|
# package to be installed on your system.
|
||||||
# Install it with: pip install gpsdclient
|
# Install it with: pip install gpsdclient
|
||||||
|
|
||||||
|
import RNS
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
|
|
||||||
from gpsdclient import GPSDClient
|
from gpsdclient import GPSDClient
|
||||||
|
|
||||||
class GpsdLocationPlugin(SidebandTelemetryPlugin):
|
class GpsdLocationPlugin(SidebandTelemetryPlugin):
|
||||||
|
@ -50,19 +54,28 @@ class GpsdLocationPlugin(SidebandTelemetryPlugin):
|
||||||
RNS.log("Connected, streaming GPSd data", RNS.LOG_DEBUG)
|
RNS.log("Connected, streaming GPSd data", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
self.client_connected = True
|
self.client_connected = True
|
||||||
self.last_update = time.time()
|
|
||||||
self.latitude = result.get("lat", None)
|
|
||||||
self.longitude = result.get("lon", None)
|
|
||||||
self.altitude = result.get("altHAE", None)
|
|
||||||
self.speed = result.get("speed", None)
|
|
||||||
self.bearing = result.get("track", None)
|
|
||||||
|
|
||||||
epx = result.get("epx", None); epy = result.get("epy", None)
|
gpsd_latitude = result.get("lat", None)
|
||||||
epv = result.get("epv", None)
|
gpsd_longitude = result.get("lon", None)
|
||||||
if epx != None and epy != None and epv != None:
|
gpsd_altitude = result.get("altHAE", None)
|
||||||
self.accuracy = max(epx, epy, epv)
|
gpsd_speed = result.get("speed", None)
|
||||||
else:
|
gpsd_bearing = result.get("track", None)
|
||||||
self.accuracy = None
|
gpsd_required = [gpsd_latitude, gpsd_longitude, gpsd_altitude, gpsd_speed, gpsd_bearing]
|
||||||
|
|
||||||
|
if not None in gpsd_required:
|
||||||
|
self.last_update = time.time()
|
||||||
|
self.latitude = gpsd_latitude
|
||||||
|
self.longitude = gpsd_longitude
|
||||||
|
self.altitude = gpsd_altitude
|
||||||
|
self.speed = gpsd_speed
|
||||||
|
self.bearing = gpsd_bearing
|
||||||
|
|
||||||
|
epx = result.get("epx", None); epy = result.get("epy", None)
|
||||||
|
epv = result.get("epv", None)
|
||||||
|
if epx != None and epy != None and epv != None:
|
||||||
|
self.accuracy = max(epx, epy, epv)
|
||||||
|
else:
|
||||||
|
self.accuracy = None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Could not connect to local GPSd, retrying later", RNS.LOG_ERROR)
|
RNS.log("Could not connect to local GPSd, retrying later", RNS.LOG_ERROR)
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# This is a bare-minimum service plugin
|
||||||
|
# example that you can build upon to
|
||||||
|
# implement your own service plugins.
|
||||||
|
|
||||||
import RNS
|
import RNS
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
# This is a bare-minimum telemetry plugin
|
||||||
|
# example that you can build upon to
|
||||||
|
# implement your own telemetry plugins.
|
||||||
|
|
||||||
import RNS
|
import RNS
|
||||||
|
|
||||||
class BasicTelemetryPlugin(SidebandTelemetryPlugin):
|
class BasicTelemetryPlugin(SidebandTelemetryPlugin):
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# This plugin lets you remotely query and view a
|
# This plugin lets you remotely query and view a
|
||||||
# number of different image sources in Sideband.
|
# number of different image sources in Sideband,
|
||||||
|
# including remote or local webcams, video sources
|
||||||
|
# or images stored in a filesystem.
|
||||||
#
|
#
|
||||||
# This plugin requires the "pillow" pip package.
|
# This plugin requires the "pillow" pip package.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue