Skip to content

TRMNL local server to simulate the cloud service locally to serve own BMP's directly

Notifications You must be signed in to change notification settings

ohAnd/trmnlServer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TRMNL - Local Web Server

Overview

'TRMNL Local Web Server' is a local web server designed to serve local content (BMP image) to a TRMNL client e-ink display. It simulates the TRMNL cloud server (https://usetrmnl.app/). The server is built using Flask and supports serving BMP images, logging requests, and updating configuration settings.

Very small change in Firmware of TRMNL needed.

original: #define API_BASE_URL "https://trmnl.app"

change to: #define API_BASE_URL "https://<your_ip>:83"

Features

  • Serve BMP Images: Provides endpoints to serve BMP images.
  • manipulate BMP Images: provide an adpated new image with the collected data from client (wifi strength, battery state)
  • API for Display: Endpoint to retrieve display information and update settings.
  • Logging: Logs requests with timestamps and context.
  • Configuration Management: Allows updating and retrieving configuration settings via API.
  • Firmware Update: Placeholder for firmware update functionality.

Home Screen

Home Screen

Home Screen

Home Screen

Endpoints

Serve BMP Images

  • GET /image/screen.bmp

    • Serves the BMP image from the configured path.
    • Logs the request with timestamp and context.
  • GET /image/screen1.bmp

    • Serves the BMP image from the configured path.
    • Logs the request with timestamp and context.

API for Display

  • GET /api/display
    • Retrieves display information including image URL, refresh rate, and firmware update status.
    • Logs the request with headers and URL.
    • Responds with a JSON containing status, image URL, refresh rate, and other settings.

Logging

  • POST /api/log
    • Logs the content of the request.
    • Responds with a JSON indicating the log status.

Configuration Management

  • GET /settings

    • Retrieves the current configuration settings including image path and refresh time.
    • Responds with a JSON containing the configuration settings.
  • POST /settings/refreshtime

    • Updates the refresh time in the configuration.
    • Responds with a JSON indicating the success or error status.
  • POST /settings/imagepath

    • Updates the image path in the configuration.
    • Responds with a JSON indicating the success or error status.

Server Logs

  • GET /server/log
    • Retrieves the last 30 lines from the log file.
    • Responds with the logs as plain text.

Battery Data

  • GET /server/battery
    • Retrieves battery data from the client database.
    • Supports filtering by date range.
    • Responds with a JSON containing the battery data.

Configuration

The server uses a config.yaml file for configuration. If the file does not exist, it will be created with default values.

  • image_path: Path to the BMP image to be served.
  • refresh_time: Refresh time for the display.

Installation

Manual Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/trmnlServer.git
    cd trmnlServer
  2. Install dependencies:

    pip install -r requirements.txt

  3. Run the server: python trmnlServer.py

Installation Using install.sh

To install the server as a system service using the provided install.sh script, follow these steps:

  1. Clone the repository:

    git clone https://github.com/yourusername/trmnlServer.git
    cd trmnlServer
    
  2. Make the script executable:

    chmod +x install.sh

  3. Run the script to install the service:

    sudo bash install.sh -doit

  4. Run the script to uninstall the service:

    sudo bash install.sh -uninstall

Running as a System Service

To run the server as a system service, use the provided install.sh script.

  1. Start Service

    service trmnlServer start

  2. Uninstall the Service

    service trmnlServer stop

  3. Get Status of the Service

    service trmnlServer status

About

TRMNL local server to simulate the cloud service locally to serve own BMP's directly

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published