Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

By request, implementors wanting to create a custom endpoint server are provided source code for a sample TPS (Third Party server Server) implementation that can successfully interface with a CWM and OKE. The source code files are in the ./tps directory of the Connectware repository. https://github.com/Powerhouse-Dynamics/connectware/tree/master

The example server implementation is written in Python using the Flask framework. The Waitress package provides a WSGI interface to the NGINX web server.

...

  1. Launch a server instance running Linux (such as a recent Debiakn Debian distribution)

  2. As necessary open TCP port 443 on the server instance.

  3. Install NGINX

sudo apt install nginx

  1. Install Python 3

sudo apt install python3

  1. Install Flask and supporting Python packages. For convenience, a copy of the get-pip.py installer script is included in the tps directory.

python3 get-pip.py

pip install -U Flask

pip install waitress

  1. Create a self-signed Server SSL certificate (cert.pem) and key (key.pem)

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes

  1. Create an tps directory and copy the following files to that directory: key.pem, cert.pem, app.py, cwcrc16.py

  2. Copy the file "default" to /etc/nginx/sites-enabled and edit so that the ssl_certificate and ssl_certificate_key paths to cert.pem and key.pem are correct, and the server_name value reflects the DNS name associated with the server.

  3. Restart NGINX

sudo /etc/init.d/nginx restart

10.   Run the OK server example in a terminal window.

python3 app.py

 11. Using a browser enter the following URL https://dnsnameofyourserver/pull

The browser will issue a server certificate warning, accept the server certificate. If the server is setup successfully then the browser will display {"pull":false}.

  1. From an OKE configure the 3 custom endpoints with the DNS name of the server. The CWM will begin communicating with the server, and output will be displayed on the terminal window running the app.py service.

...

Note: The CWM2 firmware must be at version 130 or later before proceeding with any configuration described in this section. Earlier versions of firmware will not work as expected if configured to communicate with custom server endpoints.

Using the OKE Simulator , or an OKE device the CWM custom endpoints can be configured over a USB or serial connection. Please update to the latest version of the OKE simulator in the Connectware repository, this version will have the ability to configure Custom Endpoints enabled by default.

Info

When custom endpoints are configured, the CWM will no longer communicate through a SAP. It's WiFi configuration must be set manually, or the Ethernet connection can be used.

Use the OKE Simulator '3' command to set a custom WiFi network configuration, or plug in the Ethernet cable to use Ethernet.

The OKE Simulator 'c' command iterates over and requests the currently configured custom endpoint settings one at a time. Only when all three custom endpoints are configured will the CWM2 attempt to communicate to the TPS server.

The OKE Simulator 'p', '>', and '<'commands allow the configuration of the provision, push, and pull endpoints. When using the TPS example all the endpoints will have the same configuration. The configuration should be the DNS name or IP address of the TPS server without any decoration, paths, or arguments. For example, a valid endpoint would be:

...