Package: samtecdeviceshare
Samtec Device Connect ServiceA Python 3 SDC conforming REST API to run on IoT devices that enables user discovery, viewing, and management.InstallationpipinstallsamtecdeviceshareRunningFirst ensure all environment variables are set correctly.
Note: To test locally for development ensure EMULATION and PYTHON_ENV are set.python-msamtecdeviceshare.serverEnvironment VariablesA number of environment variables are supported for configuration. These configurations can also be contained in a yaml/json configuration file specified usingSDC_CONFIGURATION_PATH. Env vars take precedence over the configuration file.SDC Server / GeneralThese variables are specific to this SDC service. The variables can also start with prefixSDC_.NameDescriptionDefaultREST_ADDRESSRest API Address0.0.0.0REST_PORTRest port47546ROOT_PATHAPI root path''PYTHON_ENVenum: development productionproductionEMULATIONUse emulated devices/ionullLOG_VERBOSEboolean verbose logsfalseApplicationThese variables are used to provide app info that will be shared by SDC.NameDescriptionDefaultAPP_NAMEName of appSDC AppAPP_VERSIONSemVer of app0.0.0APP_WEB_PORTEmbedded web app port80APP_IMG_PATHapp icon path{CURDIR}../static/img.pngAPP_LOG_PATHPath to store log filesdefault tempdir()APP_LOCK_PATHPath to update lock file.__sdc.lockWireless NetworksSDC can handle configuring N wireless networks. PrefixSDC_is required. Us integeriin 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.NameDescriptionDefaultSDC_WIFI[i]_SSIDWiFi SSIDnull*SDC_WIFI[i]_MODEenum: HOTSPOT CLIENT DISABLEDDISABLEDSDC_WIFI[i]_PASSWiFi passphrasenullSDC_WIFI[i]_IFACEWiFi hardware interfacenullSDC_WIFI[i]_DEFAULTUse as default for updatesFalseWired NetworksSDC can handle configuring N wired networks. PrefixSDC_is required. Us integeriin prefix for defining multiple networks.SDC_ETH[i]_IFACEorSDC_ETH[i]_REGEX_IFACEis 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 requiredre.fullmatch().NameDescriptionDefaultSDC_ETH[i]_IFACEInterface name (str)nullSDC_ETH[i]_REGEX_IFACEInterface name (regex)nullSDC_ETH[i]_METHODPrimary methodWiredConnectionMethod.autoSDC_ETH[i]_TIMEOUTTimeout of primary15SDC_ETH[i]_FALLBACKFallback methodnullSDC_ETH[i]_FALLBACK_TIMEOUTTimeout to get DHCP address-1BalenaRefer to Balenadocumentationfor list and description of variables.BALENA_SUPERVISOR_API_KEYBALENA_APP_IDBALENA_DEVICE_TYPEBALENABALENA_SUPERVISOR_ADDRESSBALENA_SUPERVISOR_HOSTBALENA_DEVICE_UUIDBALENA_API_KEYBALENA_APP_RELEASEBALENA_SUPERVISOR_VERSIONBALENA_APP_NAMEBALENA_DEVICE_NAME_AT_INITBALENA_HOST_OS_VERSIONBALENA_SUPERVISOR_PORTDevelopmentInstallinggitclonegit@bitbucket.org:samteccmd/samtecdeviceshare.gitsamtecdevicesharecdsamtecdeviceshare
poetryinstall--dev
poetryshellTestingFirst, run dummy Balena supervisor:bash./tests/dummy-supervisor.shNext, fire up REST server using uvicorn:EMULATION=1\PYTHON_ENV="development"\DEBUG=1\uvicornsamtecdeviceshare.server:app--reload--reload-dir./samtecdeviceshareInteractive API docswill be available:http://127.0.0.1:8000/docsUnit Testspylint--rcfile.pylintrcsamtecdeviceshare
pytest