Skip to content

About

Reverse engineering guide for Sunlux ESL (Electronic Shelf Label) Access Points

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

Sunlux ESL (Electronic Shelf Label) Access Point — Reverse Engineering Guide

A complete guide to controlling Sunlux ESL price tags by reverse-engineering the AP's gateway firmware, MQTT protocol, and WebSocket server. This was done with zero documentation — everything was discovered through binary analysis and protocol sniffing.

Disclaimer: This guide is for educational and research purposes only. Only use this on devices you own or have explicit authorization to access. The authors are not responsible for any misuse.

Table of Contents


Hardware Overview

The Sunlux ESL Access Point (AP) is an ARM-based embedded Linux device that communicates with electronic shelf label tags over RF. The tags use tri-color e-paper displays (black, white, red).

  • CPU: ARM Cortex-A9 (i.MX series SoC)
  • OS: Embedded Linux (kernel with BusyBox userland)
  • RF Modules: 4x serial-connected RF transceivers (COM2, COM3, COM4, COM8)
  • Network: Ethernet (connmand for network management)
  • SSH: Dropbear SSH server on port 22

Tag Sizes Discovered

Display Size Resolution BMP File Size
1.54" 200 x 200 —
2.13" 250 x 122 4,062 bytes
2.13" (alt) 212 x 104 —
2.66" 296 x 152 —
2.9" 296 x 128 4,798 bytes
3.7" 416 x 240 —
4.2" 400 x 300 15,662 bytes
7.5" 800 x 480 —
10.2" 960 x 640 —

Getting Access

The AP runs Dropbear SSH with default root access (no password):

ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa root@<AP_IP>

Add to ~/.ssh/config for convenience:

Host esl-ap
    HostName 192.168.1.5
    User root
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedAlgorithms +ssh-rsa

Then just: ssh esl-ap


System Architecture

                                    ┌─────────────┐
                                    │  MQTT Broker │
                                    │ (cloud/local)│
                                    └──────┬───────┘
                                           │ port 1883
                                           │
┌──────────────┐   RF    ┌─────────────────┴────────────────────┐
│  ESL Tag     │◄────────│          Sunlux ESL AP               │
│  (e-paper)   │         │                                      │
│              │         │  ┌──────────┐    ┌──────────────┐    │
│  Black layer │         │  │ gateway  │    │ webSkServer  │    │
│  Red layer   │         │  │ :8081    │    │ :9999 (WS)   │    │
└──────────────┘         │  └──────────┘    └──────────────┘    │
                         │  4x RF modules (COM2,3,4,8)          │
                         └──────────────────────────────────────┘

Running Processes

Process Port Purpose
gateway 8081 Main ESL gateway — MQTT, RF, tag management
webSkServer 9999 WebSocket server for real-time communication

File Structure

/home/root/
├── application/
│   ├── gateway            # Main gateway binary (ARM ELF)
│   ├── webSkServer        # WebSocket server binary
│   ├── COM2/              # RF module 1 firmware
│   ├── COM3/              # RF module 2 firmware
│   ├── COM4/              # RF module 3 firmware
│   └── COM8/              # RF module 4 firmware
├── template/              # Tag display images (BMP files)
│   ├── {tagCode}-1.bmp           # Black layer (page 1)
│   ├── {tagCode}-2.bmp           # Red layer (page 2)
│   └── {tagCode}_AligWordTmp.bin # Raw pixel data sent to tag
├── config_script/
│   └── config-env.sh.bak  # Initial setup script
├── data/                  # (empty — DB is in-memory)
├── picture/               # Picture storage
├── firmware/              # Firmware storage
├── shell/                 # System scripts
└── test/
    └── status.txt

Configuration Files

/etc/run.conf — Runtime configuration:

# MQTT
MQTTSERURL=<your-broker-url>
MQTTSERPORT=1883
MQTTUSER=<your-username>
MQTTPASS=<your-password>
MQTTCLIENTID=<your-station-id>

# FTP (firmware updates)
FTPSERIP=<ftp-server>
FTPSERPORT=7021

# Paths
ROOTPATH=/home/root/
DATAPATH=data/
PICPATH=picture/
FIRMWAREPATH=firmware/

/etc/sys.conf — System identity:

SYSCODE=00000001
DEVCODE=P0000001

Tag Display Format

Each tag has a tri-color e-paper display with two image layers:

┌─────────────────────────┐
│                         │
│   ┌── Black Layer ──┐   │  ← {tagCode}-1.bmp
│   │ Product name    │   │     Updated via MQTT imageStr URL
│   │ Barcode         │   │
│   └─────────────────┘   │
│                         │
│   ┌── Red Layer ────┐   │  ← {tagCode}-2.bmp
│   │ Price: 15992    │   │     Must be replaced directly on AP
│   │ Discount: 20%   │   │
│   └─────────────────┘   │
│                         │
│   = Combined Display =  │  ← Both layers shown simultaneously
│                         │
└─────────────────────────┘
  • Page 1 (-1.bmp): Black pixels on white. Controlled via MQTT imageStr URL.
  • Page 2 (-2.bmp): Red pixels on white. Must be uploaded directly to the AP.
  • AligWordTmp.bin: Raw 1-bit pixel data (BMP without header), auto-generated by gateway.

MQTT Protocol

Broker Connection

import paho.mqtt.client as mqtt

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id='my-client')
client.username_pw_set('YOUR_MQTT_USER', 'YOUR_MQTT_PASS')
client.connect('your-mqtt-broker.example.com', 1883, 60)

Note: Your AP's MQTT broker URL, username, and password are in /etc/run.conf. You can change these to use your own private broker (recommended).

Topic Structure

All topics use the prefix /epts/ with a direction indicator:

Direction Pattern Description
Server → AP /epts/s2c/{stationId}/priceTag/update Push image update
Server → AP /epts/s2c/{stationId}/priceTag/flashLight Flash tag LED
Server → AP /epts/s2c/{stationId}/priceTag/upgrade Firmware upgrade
Server → AP /epts/s2c/{stationId}/GwAp/upgrade AP firmware upgrade
Server → AP /epts/s2c/{stationId}/reqServer Request server config
AP → Server /epts/c2s/station/{stationId}/priceTag Tag scan report
AP → Server /epts/c2s/station/{stationId}/info AP status info
AP → Server /epts/c2s/priceTag/update/received Update acknowledgment
AP → Server /epts/c2s/{stationId}/taskStatus Task queue status

The stationId is the AP's MQTT client ID (e.g., PG-42G), found in /etc/run.conf as MQTTCLIENTID.

Listening for Tag Reports

The AP periodically broadcasts which tags are in RF range:

import paho.mqtt.client as mqtt
import json

def on_message(client, userdata, msg):
    data = json.loads(msg.payload)
    if data.get('action') == 'priceTagInfo':
        print(f"Station: {data['stationNum']}")
        for tag in data.get('tags', []):
            print(f"  Tag: {tag['tagCode']}, RSSI: {tag['rssi']}")

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id='scanner')
client.username_pw_set('YOUR_MQTT_USER', 'YOUR_MQTT_PASS')
client.on_message = on_message
client.connect('your-mqtt-broker.example.com', 1883, 60)
client.subscribe('/epts/c2s/station/+/priceTag')
client.loop_forever()

Example tag report:

{
  "action": "priceTagInfo",
  "stationNum": "PG-42G",
  "tags": [
    {
      "tagCode": "32068233",
      "rssi": 52,
      "packetSn": 1,
      "flag": 3,
      "value0": 213,
      "value1": 1,
      "value2": 30,
      "value3": 1
    }
  ],
  "rangeTag": 1
}

Pushing an Image Update

The gateway downloads the image from a URL you provide:

import paho.mqtt.client as mqtt
import json

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id='updater')
client.username_pw_set('YOUR_MQTT_USER', 'YOUR_MQTT_PASS')
client.connect('your-mqtt-broker.example.com', 1883, 60)
client.loop_start()

update = json.dumps({
    "action": "priceTagUpdate",
    "tagCode": "32068233",
    "goodsId": "PRODUCT-001",
    "eptScreenSize": "2.13-250x122",
    "imageStr": "http://your-server:8080/image.bmp",
    "contents": "",
    "queueId": "update-001"
})

client.publish('/epts/s2c/PG-42G/priceTag/update', update)

Key fields:

Field Type Description
action string Must be "priceTagUpdate"
tagCode string Tag ID (printed on tag or discovered via scan)
goodsId string Product identifier (can be empty)
eptScreenSize string Screen size identifier (see table below)
imageStr string URL to a 1-bit BMP image (gateway downloads via wget)
contents string Template content (set empty to avoid text overlay)
queueId string Unique ID for tracking — returned in ACK

Important: imageStr is a URL, not base64 data! The gateway runs wget to download it. Your HTTP server must be reachable from the AP's network.

ACK response (on topic /epts/c2s/priceTag/update/received):

{
  "action": "eptUpdateReceived",
  "stationNum": "PG-42G",
  "queueId": "update-001",
  "packetSn": -1667205387
}

Flashing Tag LED

flash = json.dumps({
    "action": "priceTagFlashLight",
    "tagCode": "32068233",
    "colorLight": 1,
    "flashTimes": 5
})
client.publish('/epts/s2c/PG-42G/priceTag/flashLight', flash)

Screen Size Identifiers

These strings are hardcoded in the gateway firmware:

Display eptScreenSize value
1.54" 1.54-200x200
2.13" 2.13-250x122
2.13" (alt) 2.13-212x104
2.66" 2.66-296x152
2.9" 2.9-296x128
3.7" 3.7-416x240
4.2" 4.2-400x300
7.5" 7.5-800x480
10.2" 10.2-960x640

Image Format

Black Layer (Page 1)

Standard Windows BMP, 1-bit color depth (black and white):

from PIL import Image, ImageDraw, ImageFont

# Create a 2.13" tag image (250x122 stored as 122x250 in portrait)
img = Image.new('1', (122, 250), 1)  # 1 = white background
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('arial.ttf', 40)
draw.text((10, 80), 'Hello!', fill=0, font=font)  # 0 = black

img.save('tag_image.bmp', format='BMP')

Requirements:

  • Format: BMP
  • Color depth: 1-bit (monochrome)
  • Dimensions: Must match the tag's screen size
  • White pixel = no ink, Black pixel = black ink

Red Layer (Page 2)

Same format as page 1, but black pixels appear as red on the tag:

# Red layer — black pixels here will show as RED on the tag
red_layer = Image.new('1', (122, 250), 1)  # white = no red
draw = ImageDraw.Draw(red_layer)
draw.text((10, 10), 'SALE!', fill=0, font=font)  # This text will be RED

red_layer.save('tag_red.bmp', format='BMP')

To clear the red layer (no red content): create an all-white BMP.

AligWordTmp.bin

This file is auto-generated by the gateway. It's the raw pixel data from the BMP (header stripped):

AligWordTmp.bin = BMP file bytes[62:]  (everything after the 62-byte BMP header)

Size = ceil(width / 8) * height bytes. Do not edit this file manually — the gateway regenerates it.


Putting It All Together

Complete example to update a tag with custom black and red content:

#!/usr/bin/env python3
"""
Sunlux ESL Tag Updater
Updates both black and red layers of a tri-color e-paper tag.
"""

import paho.mqtt.client as mqtt
from PIL import Image, ImageDraw, ImageFont
from http.server import HTTPServer, BaseHTTPRequestHandler
import json, time, threading, subprocess, base64, io

# ── Configuration ──
AP_IP = "192.168.1.5"
AP_SSH = f"ssh root@{AP_IP}"  # configure SSH key/config as needed
MY_IP = "192.168.1.4"
HTTP_PORT = 8080
MQTT_BROKER = "your-mqtt-broker.example.com"  # check /etc/run.conf on your AP
MQTT_USER = "YOUR_MQTT_USER"       # check /etc/run.conf on your AP
MQTT_PASS = "YOUR_MQTT_PASS"       # check /etc/run.conf on your AP
STATION_ID = "PG-42G"

TAG_CODE = "32068233"
SCREEN_SIZE = "2.13-250x122"
WIDTH, HEIGHT = 122, 250


# ── Step 1: Create images ──

# Black layer (page 1)
black_img = Image.new('1', (WIDTH, HEIGHT), 1)
draw = ImageDraw.Draw(black_img)
font = ImageFont.truetype('arial.ttf', 30)
font_sm = ImageFont.truetype('arial.ttf', 14)
draw.text((5, 5), 'My Product', fill=0, font=font_sm)
draw.text((5, 80), '$9.99', fill=0, font=font)
black_img.save('black_layer.bmp', format='BMP')

# Red layer (page 2) — set to blank for no red, or add red content
red_img = Image.new('1', (WIDTH, HEIGHT), 1)  # all white = no red
# Uncomment to add red text:
# draw_red = ImageDraw.Draw(red_img)
# draw_red.text((5, 150), 'SALE!', fill=0, font=font)
red_img.save('red_layer.bmp', format='BMP')


# ── Step 2: Serve black layer via HTTP ──

bmp_data = open('black_layer.bmp', 'rb').read()

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-Type', 'image/bmp')
        self.end_headers()
        self.wfile.write(bmp_data)
    def log_message(self, *args):
        pass

server = HTTPServer(('0.0.0.0', HTTP_PORT), Handler)
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
print(f"HTTP server on :{HTTP_PORT}")


# ── Step 3: Upload red layer via SSH ──

b64 = base64.b64encode(open('red_layer.bmp', 'rb').read()).decode()
subprocess.run(
    f'echo {b64} | ssh root@{AP_IP} "base64 -d > /home/root/template/{TAG_CODE}-2.bmp"',
    shell=True, check=True
)
print("Red layer uploaded")


# ── Step 4: Push update via MQTT ──

ack_received = threading.Event()

def on_message(client, userdata, msg):
    data = json.loads(msg.payload)
    if data.get('stationNum') == STATION_ID and data.get('queueId') == 'my-update':
        print(f"ACK received! packetSn={data.get('packetSn')}")
        ack_received.set()

client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id='my-updater')
client.username_pw_set(MQTT_USER, MQTT_PASS)
client.on_message = on_message
client.connect(MQTT_BROKER, 1883, 60)
client.loop_start()
client.subscribe('/epts/c2s/priceTag/update/received')
time.sleep(2)

client.publish(f'/epts/s2c/{STATION_ID}/priceTag/update', json.dumps({
    "action": "priceTagUpdate",
    "tagCode": TAG_CODE,
    "goodsId": "",
    "eptScreenSize": SCREEN_SIZE,
    "imageStr": f"http://{MY_IP}:{HTTP_PORT}/image.bmp",
    "contents": "",
    "queueId": "my-update"
}))
print("Update published, waiting for ACK...")

ack_received.wait(timeout=15)
client.loop_stop()
server.shutdown()
print("Done! Tag will refresh on next wake cycle (usually under 2 minutes).")

WebSocket Server (Port 9999)

The webSkServer runs a WebSocket server. On connect it sends a greeting:

Say hi~ I am server,stationId:PG-42G

It sends periodic keepalive messages:

Tips keepLive from server fd/005 index/001 total/001 HH:MM:SS

The WebSocket server appears to be designed for real-time communication with a management app. Its full protocol was not fully reverse-engineered.


HTTP Server (Port 8081)

The gateway runs an HTTP server with these routes (discovered from binary strings):

Route Method Description
/ or /index.html GET Web management UI
/manager.html GET Manager page
/nav.html GET Navigation
/update.html GET Update page
/login POST Authentication
/favicon.ico GET Icon

Note: The web pages are served from /mnt/nfs/ which is typically empty (NFS not mounted). The HTTP server responds but returns empty pages.


Useful Commands

Find your AP's station ID

ssh esl-ap "cat /etc/run.conf | grep MQTTCLIENTID"

List all tag template files

ssh esl-ap "ls /home/root/template/ | sed 's/-[12]\.bmp//; s/_AligWordTmp\.bin//' | sort -u"

Check tag image dimensions

ssh esl-ap "base64 /home/root/template/{tagCode}-1.bmp" | base64 -d | python3 -c "
import struct, sys
h = sys.stdin.buffer.read(54)
w = struct.unpack('<i', h[18:22])[0]
ht = struct.unpack('<i', h[22:26])[0]
print(f'{w}x{ht}')
"

Monitor all MQTT traffic

pip install paho-mqtt
python3 -c "
import paho.mqtt.client as mqtt, json
def on_msg(c, u, m):
    print(f'{m.topic}: {m.payload[:200].decode()}')
c = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
c.username_pw_set('epts', '123456')
c.on_message = on_msg
c.connect('your-mqtt-broker.example.com', 1883)
c.subscribe('/epts/#')
c.loop_forever()
"

Transfer a file to/from the AP (no SCP/SFTP)

# Upload
base64 local_file.bmp | ssh esl-ap "base64 -d > /remote/path/file.bmp"

# Download
ssh esl-ap "base64 /remote/path/file.bmp" | base64 -d > local_file.bmp

Limitations & Notes

  1. imageStr is a URL, not base64: The gateway downloads the image with wget. Your server must be reachable from the AP.

  2. MQTT only updates the black layer (page 1): The red layer (page 2) cannot be updated via MQTT. You must upload it directly to the AP filesystem.

  3. No SCP/SFTP: The AP uses Dropbear SSH which doesn't include an SFTP server. Use base64 pipe for file transfer.

  4. AP clock is not synced: The AP has no NTP. File timestamps may be unreliable.

  5. Tags sleep between updates: After pushing an update, the tag will refresh on its next wake cycle (typically 1-2 minutes). The e-paper display blinks during refresh.

  6. Database is in-memory: The gateway uses SQLite in-memory. Tag associations are lost on reboot.

  7. The contents field: Appears in the database schema but its exact rendering format was not fully decoded. Setting it to empty string prevents unwanted text overlay.

  8. Shared MQTT broker: The factory-default broker may be shared across multiple installations. You could see traffic from other devices. Switch to a private broker by editing /etc/run.conf.


How This Was Reverse-Engineered

  1. SSH access — The AP has default root SSH access (Dropbear, no password)
  2. Binary string extraction — Used Python regex to extract readable strings from gateway and webSkServer ARM ELF binaries
  3. MQTT sniffing — Connected to the same MQTT broker and subscribed to /epts/# to observe all traffic
  4. Protocol reconstruction — Identified JSON field names, topic patterns, and message formats from binary strings
  5. Trial and error — Tested various imageStr formats (base64, raw pixels, URLs) until discovering the gateway uses wget to download images
  6. E-paper layer discovery — Realized tags use tri-color displays when the user reported red text overlay that persisted despite black layer updates

Tools Used

  • Python 3 with paho-mqtt and Pillow (PIL)
  • SSH (for AP access)
  • Binary string analysis (Python re module — no strings command on the AP)

Contributing

If you discover additional protocol details, tag types, or the format of the contents field, please open an issue or PR!

Legal

Reverse engineering for interoperability is protected in many jurisdictions (EU Software Directive, US DMCA interoperability exceptions). This guide documents publicly observable protocol behavior of hardware the author owns. No encryption or DRM was circumvented.

This guide is provided for educational and research purposes. Only use on devices you own or have authorization to test. Use responsibly.

About

Reverse engineering guide for Sunlux ESL (Electronic Shelf Label) Access Points

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors