Skip to content

Instantly share code, notes, and snippets.

@combs
Created August 23, 2023 15:51
Show Gist options
  • Save combs/23c81ebf9646539a667080a6ce3a9f74 to your computer and use it in GitHub Desktop.
Save combs/23c81ebf9646539a667080a6ce3a9f74 to your computer and use it in GitHub Desktop.
import requests, time, os, sys
# https://github.com/atc1441/E-Paper_Pricetags/tree/main/Custom_PriceTag_AccesPoint
# This script helps you probe for the ideal "Frequency Offset" setting.
address = "http://esl.local/"
username = "admin"
password = "admin"
serial = (sys.argv[1] if len(sys.argv) >= 2 else None) or "JC10062805B"
desired = (sys.argv[2] if len(sys.argv) >= 3 else None) or 123
def set_wakeup_channel_EU():
response = requests.post(address + "set_wu_channel?freq=4", auth=(username, password))
return response.status_code
def set_wakeup_channel_US():
response = requests.post(address + "set_wu_channel?freq=35", auth=(username, password))
return response.status_code
def set_offset(offset):
response = requests.post(address + "set_freq_offset?offset=" + str(offset), auth=(username, password))
return response.status_code
def activate(serial, desired):
response = requests.post(address + "activate_display?serial=" + str(serial) + "&id=" + str(desired), auth=(username, password))
return response.status_code
def recover(serial):
response = requests.post(address + "recover_display?serial=" + str(serial), auth=(username, password))
return response.status_code
def wake_and_full_sync():
response = requests.post(address + "set_mode?mode=wusync", auth=(username, password))
return response.status_code
def get_status():
response = requests.get(address + "get_mode", auth=(username, password))
return response.text.split("<br>")
attempts = list(range(0,45)) + list(range(45,60)) + list(reversed(range(-127, 0))) + list(range(60,127))
happy = False
set_wakeup_channel_US()
for offset in attempts:
print("Trying", offset, "for serial", serial, "to set ID", desired)
set_offset(offset)
wake_and_full_sync()
statuses = get_status()
status = statuses[-1]
while status != "mode Idle":
statuses = get_status()
status = statuses[-1]
time.sleep(0.2)
time.sleep(2)
recover(serial)
statuses = get_status()
status = statuses[-1]
prev = status
print(status)
while status != "mode Idle":
time.sleep(0.2)
statuses = get_status()
status = statuses[-1]
if statuses[-1] != prev:
print(status)
prev = status
if status not in ["mode Wakeup", "mode Wakeup Reset", "mode Wakeup Activation", "mode Activation", "mode Idle", "mode Sync", "mode Full Sync"]:
happy = True
break
activate(serial, desired)
time.sleep(1)
statuses = get_status()
status = statuses[-1]
prev = status
print(status)
idles = 0
while idles < 5:
if status == "mode Idle":
idles += 1
time.sleep(0.2)
s = get_status()
status = s[-1]
if status != prev:
print(status)
prev = status
if status not in ["mode Wakeup", "mode Wakeup Reset", "mode Wakeup Activation", "mode Activation", "mode Idle", "mode Sync", "mode Full Sync"]:
happy = True
break
print(statuses[-2])
if statuses[-2] != "last answer: No data received so far":
happy = True
for item in statuses:
if "Activation" in item:
if item not in ["Activation: timeout", "Activation: started", "mode Wakeup Activation", "mode Activation"]:
print(item)
happy = True
if happy:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment