Skip to main content

Handles a variety of common routines for SDC-based applications

Project description

Samtec Device Connect Service

A Python 3 SDC conforming REST API to run on IoT devices that enables user discovery, viewing, and management.

Installation

pip install samtecdeviceshare

Running

First ensure all environment variables are set correctly. Note: To test locally for development ensure EMULATION and PYTHON_ENV are set.

python -m samtecdeviceshare.server

Environment Variables

A number of environment variables are supported for configuration. These configurations can also be contained in a yaml/json configuration file specified using SDC_CONFIGURATION_PATH. Env vars take precedence over the configuration file.

SDC Server / General

These variables are specific to this SDC service. The variables can also start with prefix SDC_.

Name Description Default
REST_ADDRESS Rest API Address 0.0.0.0
REST_PORT Rest port 47546
ROOT_PATH API root path ''
PYTHON_ENV enum: development production production
EMULATION Use emulated devices/io null
LOG_VERBOSE boolean verbose logs false

Application

These variables are used to provide app info that will be shared by SDC.

Name Description Default
APP_NAME Name of app SDC App
APP_VERSION SemVer of app 0.0.0
APP_WEB_PORT Embedded web app port 80
APP_IMG_PATH app icon path {CURDIR}../static/img.png
APP_LOG_PATH Path to store log files default tempdir()
APP_LOCK_PATH Path to update lock file .__sdc.lock

Wireless Networks

SDC can handle configuring N wireless networks. Prefix SDC_ is required. Us integer i in prefix for defining multiple networks. A network can optionally be defined default. This will be primary method used to handle updates and will be exposed through REST API.

Name Description Default
SDC_WIFI[i]_SSID WiFi SSID null*
SDC_WIFI[i]_MODE enum: HOTSPOT CLIENT DISABLED DISABLED
SDC_WIFI[i]_PASS WiFi passphrase null
SDC_WIFI[i]_IFACE WiFi hardware interface null
SDC_WIFI[i]_DEFAULT Use as default for updates False

Wired Networks

SDC can handle configuring N wired networks. Prefix SDC_ is required. Us integer i in prefix for defining multiple networks. SDC_ETH[i]_IFACE or SDC_ETH[i]_REGEX_IFACE is required with the latter supporting regex matching. Be careful defining multiple networks with generic regular expression. Most Linux distros follow a predictable naming scheme for interfaces.. When searching for interfaces, a fullmatch is required re.fullmatch().

Name Description Default
SDC_ETH[i]_IFACE Interface name (str) null
SDC_ETH[i]_REGEX_IFACE Interface name (regex) null
SDC_ETH[i]_METHOD Primary method WiredConnectionMethod.auto
SDC_ETH[i]_TIMEOUT Timeout of primary 15
SDC_ETH[i]_FALLBACK Fallback method null
SDC_ETH[i]_FALLBACK_TIMEOUT Timeout to get DHCP address -1

Balena

Refer to Balena documentation for list and description of variables.

  • BALENA_SUPERVISOR_API_KEY
  • BALENA_APP_ID
  • BALENA_DEVICE_TYPE
  • BALENA
  • BALENA_SUPERVISOR_ADDRESS
  • BALENA_SUPERVISOR_HOST
  • BALENA_DEVICE_UUID
  • BALENA_API_KEY
  • BALENA_APP_RELEASE
  • BALENA_SUPERVISOR_VERSION
  • BALENA_APP_NAME
  • BALENA_DEVICE_NAME_AT_INIT
  • BALENA_HOST_OS_VERSION
  • BALENA_SUPERVISOR_PORT

Development

Installing

git clone git@bitbucket.org:samteccmd/samtecdeviceshare.git samtecdeviceshare
cd samtecdeviceshare
poetry install --dev
poetry shell

Testing

First, run dummy Balena supervisor:

bash ./tests/dummy-supervisor.sh

Next, fire up REST server using uvicorn:

EMULATION=1 \
PYTHON_ENV="development" \
DEBUG=1 \
uvicorn samtecdeviceshare.server:app --reload --reload-dir ./samtecdeviceshare

Interactive API docs will be available: http://127.0.0.1:8000/docs

Unit Tests

pylint --rcfile .pylintrc samtecdeviceshare
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

samtecdeviceshare-2.9.1a1.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

samtecdeviceshare-2.9.1a1-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file samtecdeviceshare-2.9.1a1.tar.gz.

File metadata

  • Download URL: samtecdeviceshare-2.9.1a1.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1039-aws

File hashes

Hashes for samtecdeviceshare-2.9.1a1.tar.gz
Algorithm Hash digest
SHA256 712e05724336fae6e72f8784d2d5544f1b9304afcc81e56c3539e99913ec527e
MD5 58fba555bfac849897115a5e8d229905
BLAKE2b-256 e45d3bc35b1a57e682a639c6b1bdee7b96c7d2860f83bd3e6b057a5fdb6e52d8

See more details on using hashes here.

File details

Details for the file samtecdeviceshare-2.9.1a1-py3-none-any.whl.

File metadata

  • Download URL: samtecdeviceshare-2.9.1a1-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1039-aws

File hashes

Hashes for samtecdeviceshare-2.9.1a1-py3-none-any.whl
Algorithm Hash digest
SHA256 4d81dcb2df2fa6da82997258ec06195d0e8c05e9f19963d2d45a3eae15ff4e86
MD5 28a292bd3d65874faecdf5bd03bcea39
BLAKE2b-256 64a5632a1e400d40a62d40fac202c2082f486b16bdd8dea719fc73f707d84798

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page