Differences
This shows you the differences between two versions of the page.
| misc:ovms:lvglstuff [2021/02/08 22:36] – created jaxx | misc:ovms:lvglstuff [2021/02/08 22:51] (current) – jaxx | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | Random Stuff to play around hasp-lvgl | + | ====== |
| + | |||
| + | Github [[https:// | ||
| + | |||
| + | Since I intend to have most of this running on embedded boards with OpenWRT for the ' | ||
| + | |||
| + | Let's be honest, uploading the jsonl file each time is a pain: | ||
| + | |||
| + | Try this: | ||
| + | |||
| + | <code bash> | ||
| + | curl ' | ||
| + | </ | ||
| + | |||
| + | Or, to minimize wear on the flash until you're happy, run this: | ||
| + | |||
| + | <file python up_showjssonl.py> | ||
| + | import sys,time | ||
| + | |||
| + | from umqttsimple import MQTTClient | ||
| + | import ubinascii | ||
| + | import micropython | ||
| + | |||
| + | # Put your own settings here obviously ;) | ||
| + | mqtt_server = ' | ||
| + | client_id = ' | ||
| + | topic_pub_base = b' | ||
| + | mqttuser = ' | ||
| + | mqttpass = ' | ||
| + | mqttkeepalive = 0 | ||
| + | state_stable = False | ||
| + | |||
| + | counter = 0 | ||
| + | |||
| + | def connect_and_subscribe(): | ||
| + | global client_id, mqtt_server, | ||
| + | client = MQTTClient(client_id, | ||
| + | client.connect() | ||
| + | print(' | ||
| + | state_stable = False | ||
| + | return client | ||
| + | |||
| + | def restart_and_reconnect(): | ||
| + | print(' | ||
| + | time.sleep_ms(50) | ||
| + | # | ||
| + | |||
| + | try: | ||
| + | client = connect_and_subscribe() | ||
| + | except OSError as e: | ||
| + | restart_and_reconnect() | ||
| + | |||
| + | try: | ||
| + | # Using readlines() | ||
| + | for i in range (0, 13): | ||
| + | print(" | ||
| + | client.publish(b' | ||
| + | time.sleep_ms(5) | ||
| + | file1 = open(' | ||
| + | jsonlines | ||
| + | count = 0 | ||
| + | for jsonl in jsonlines: | ||
| + | print(" | ||
| + | if len(jsonl.strip()) >0 : | ||
| + | count+=1 | ||
| + | client.publish(b' | ||
| + | time.sleep_ms(5) | ||
| + | |||
| + | # I use this to trigger actions from other scripts that watch this (reinjecting values to be precise) | ||
| + | client.publish(b' | ||
| + | except OSError as e: | ||
| + | restart_and_reconnect() | ||
| + | |||
| + | </ | ||