Create Customized Render Data Server

Concept

The SyncSign displays and hubs usually connect to the SyncSign Cloud or On-Premise Server to fetch new information, then render on the screens.

However it’s also possible to customize the server endpoint, to fetch data right from your own server.

Server Setup

You should setup a HTTP/HTTPS web server, and provide two APIs:

  • Provide new data to show on the screen

  • Receive the render result report

Here is a simple Python example:

import uuid
import json
from flask import Flask, request, jsonify

app = Flask(__name__)
counter = 0

@app.route('/')
def index():
    return 'SyncSign Example Server'

def buildContent():
    """ Create the content to show on the eink screen.
        Reference: https://dev.sync-sign.com/hubsdk/guides/render_layout.html
        Returns:
            A dict(json) contains the render document.
    """
    return {
            "items": [
                {   "type": "TEXT",
                    "data": { "text": "HELLO WORLD #" + str(counter),
                            "font": "YANONE_KAFFEESATZ_44_B",
                            "block": {"x": 24, "y": 30, "w": 496, "h": 60}
                    }
                }
            ]
        }

@app.route('/renders/node/<string:nodeId>', methods=['GET'])
def rendersContent(nodeId):
    """ Route handler of reading render's content.
        Used to download the new content, if any.
        Args:
            nodeId: specify which node is requesting for new content.
        Returns:
            The response with renderId and content to remote peer.
    """
    global counter
    counter += 1
    if counter % 3 == 0:
        res = { "code": 204, "data": [] }  # Mock a situation when there is no new content to refresh
    else:
        renderId = str(uuid.uuid4())  # Generate a unique ID, to identify each content
        print("Generating new content for node:", nodeId, "using render ID:", renderId)
        res = { "code": 200,
                "data": [
                    {   "renderId": renderId,      # Must unique for each content
                        "nodeId": nodeId,          # Must include for remote peer
                        "isRendered": False,       # Set to False, means this is a new content
                        "content": buildContent()  # The layout document to show on the screen
                    }
                ]
            }
    return jsonify(res)

@app.route('/renders/id/<string:renderId>', methods=['PUT'])
def rendersReport(renderId):
    """ Route handler of receiving render's report.
        Used to report the rendering result.
        Args:
            renderId: report result for a previous unique ID.
        Returns:
            The empty response to remote peer.
    """
    # Receving render result report (renderId is the same as previous GET request)
    print('Render ID:', renderId, 'reported', "success" if request.get_json()["data"]["isRendered"] else "failure")
    res = { "code": 204 }
    return jsonify(res)


if __name__ == '__main__':
    app.run(host=("0.0.0.0"))
  • To setup the demo:

    • Install the Python 3.x environment in your system.

    • Install the package: pip3 install flask.

    • Run the server on command line: python3 example.py

    • Then, it creates a simple server on your computer, e.g., http://192.168.0.100:5000 , according to the LAN IP address of your computer.

    • Please make sure the firewall is turn off or allow inbound access to port 5000. And try to open the above URL on another computer in your LAN to validate.

Display Setup

At this point, only the 7.5 inch model has the built-in Wi-Fi and is able to connect to a customzied server directly. To setup the display to use your API server, please setup them to connect to the Wi-Fi first.

  • Now please get the display into “Setup Mode” by pressing the button on the right side, for about 8 seconds, then release.

  • Click [Trigger Refresh], then please check the [Enable customized data source URL]

  • Edit the content provider URL, e.g., http://192.168.0.100:5000/renders/node/<nodeId>

  • Edit the result report URL, e.g., http://192.168.0.100:5000/renders/id/<renderId> (The <nodeId> or <renderId> is the placeholder, just leave as it is, no need to replace with other value.)

  • Enable the timer interval or button trigger mode

  • Back to [ Home ] and click [ Exit and Sleep ]

  • Press the side button, or wait for the interval to see if the display can read the data and show on the screen.

Note

Please note shorter interval consumes more power. Ususally we suggest 30~60 minutes

Hub Setup (Not Available Yet)

To setup the hub to use the customized API server, please setup them to connect to the Wi-Fi/Ethernet first. Then open the web portal via http://<LAN IP Address of the Hub>.