Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02a8732318 | ||
|
|
b1e2301ea1 | ||
|
|
0d8a8b35f0 | ||
|
|
d686cf71fc |
No files matched your search
@@ -10,6 +10,7 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-release:
|
build-and-release:
|
||||||
@@ -58,7 +59,7 @@ jobs:
|
|||||||
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
|
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
|
||||||
TAG_NAME="${GITHUB_REF_NAME}"
|
TAG_NAME="${GITHUB_REF_NAME}"
|
||||||
else
|
else
|
||||||
BASE_VERSION="$(git describe --tags --abbrev=0 2>/dev/null || echo v1.7.0)"
|
BASE_VERSION="$(git describe --tags --abbrev=0 --exclude '*-b*' 2>/dev/null || echo v1.7.0)"
|
||||||
TAG_NAME="${BASE_VERSION}-b${GITHUB_RUN_NUMBER}-${SHORT_SHA}"
|
TAG_NAME="${BASE_VERSION}-b${GITHUB_RUN_NUMBER}-${SHORT_SHA}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -87,14 +88,16 @@ jobs:
|
|||||||
cp ".pio/build/${PIO_ENV}/firmware.bin" "dist/OpenMQTTGateway-${PIO_ENV}-${TAG_NAME}.bin"
|
cp ".pio/build/${PIO_ENV}/firmware.bin" "dist/OpenMQTTGateway-${PIO_ENV}-${TAG_NAME}.bin"
|
||||||
ls -lA dist
|
ls -lA dist
|
||||||
|
|
||||||
- name: Create Gitea Release and Upload Binaries
|
- name: Create Gitea Release and Publish Package
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GITEA_PKG_TOKEN: ${{ secrets.GITEATOKEN }}
|
||||||
PIO_ENV: ${{ steps.prep.outputs.pio_env }}
|
PIO_ENV: ${{ steps.prep.outputs.pio_env }}
|
||||||
TAG_NAME: ${{ steps.prep.outputs.tag_name }}
|
TAG_NAME: ${{ steps.prep.outputs.tag_name }}
|
||||||
SHORT_SHA: ${{ steps.prep.outputs.short_sha }}
|
SHORT_SHA: ${{ steps.prep.outputs.short_sha }}
|
||||||
run: |
|
run: |
|
||||||
python3 - << 'EOF'
|
python3 - << 'EOF'
|
||||||
|
import base64
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -103,7 +106,10 @@ jobs:
|
|||||||
|
|
||||||
server_url = os.environ["GITHUB_SERVER_URL"].rstrip("/")
|
server_url = os.environ["GITHUB_SERVER_URL"].rstrip("/")
|
||||||
repo = os.environ["GITHUB_REPOSITORY"]
|
repo = os.environ["GITHUB_REPOSITORY"]
|
||||||
|
owner, repo_name = repo.split("/", 1)
|
||||||
|
actor = os.environ.get("GITHUB_ACTOR") or owner
|
||||||
token = os.environ["GITEA_TOKEN"]
|
token = os.environ["GITEA_TOKEN"]
|
||||||
|
pkg_token = os.environ.get("GITEA_PKG_TOKEN") or token
|
||||||
tag_name = os.environ["TAG_NAME"]
|
tag_name = os.environ["TAG_NAME"]
|
||||||
sha = os.environ["GITHUB_SHA"]
|
sha = os.environ["GITHUB_SHA"]
|
||||||
short_sha = os.environ["SHORT_SHA"]
|
short_sha = os.environ["SHORT_SHA"]
|
||||||
@@ -153,7 +159,12 @@ jobs:
|
|||||||
release_id = data["id"]
|
release_id = data["id"]
|
||||||
print(f"Created release ID {release_id} for tag {tag_name}")
|
print(f"Created release ID {release_id} for tag {tag_name}")
|
||||||
|
|
||||||
# Upload firmware binaries in dist/
|
# Upload firmware binary to Release and Gitea Package Registry
|
||||||
|
# Note: Gitea's Generic Package Registry upload router is at /api/packages/ (not /api/v1/packages/)
|
||||||
|
package_name = f"{repo_name}-{pio_env}"
|
||||||
|
pkg_base = f"{server_url}/api/packages/{owner}/generic/{package_name}/{tag_name}"
|
||||||
|
basic_auth = base64.b64encode(f"{actor}:{pkg_token}".encode("utf-8")).decode("ascii")
|
||||||
|
|
||||||
for filename in sorted(os.listdir("dist")):
|
for filename in sorted(os.listdir("dist")):
|
||||||
if filename in existing_assets:
|
if filename in existing_assets:
|
||||||
del_req = urllib.request.Request(
|
del_req = urllib.request.Request(
|
||||||
@@ -163,12 +174,33 @@ jobs:
|
|||||||
)
|
)
|
||||||
urllib.request.urlopen(del_req).close()
|
urllib.request.urlopen(del_req).close()
|
||||||
filepath = os.path.join("dist", filename)
|
filepath = os.path.join("dist", filename)
|
||||||
print(f"Uploading {filename}...")
|
print(f"Uploading {filename} to Release...")
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
"curl", "--fail", "-sS", "-X", "POST",
|
"curl", "--fail", "-sS", "-o", "/dev/null", "-X", "POST",
|
||||||
"-H", f"Authorization: token {token}",
|
"-H", f"Authorization: token {token}",
|
||||||
"-F", f"attachment=@{filepath}",
|
"-F", f"attachment=@{filepath}",
|
||||||
f"{api_base}/releases/{release_id}/assets?name={filename}"
|
f"{api_base}/releases/{release_id}/assets?name={filename}"
|
||||||
], check=True)
|
], check=True)
|
||||||
print(f"Uploaded {filename} successfully.")
|
print(f"Uploaded {filename} to Release successfully.")
|
||||||
|
|
||||||
|
# Publish to Gitea Generic Package Registry (delete existing file first if re-running)
|
||||||
|
pkg_file_url = f"{pkg_base}/{filename}"
|
||||||
|
try:
|
||||||
|
del_pkg_req = urllib.request.Request(
|
||||||
|
pkg_file_url,
|
||||||
|
headers={"Authorization": f"Basic {basic_auth}"},
|
||||||
|
method="DELETE",
|
||||||
|
)
|
||||||
|
urllib.request.urlopen(del_pkg_req).close()
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code != 404:
|
||||||
|
raise
|
||||||
|
print(f"Publishing {filename} to Gitea Package {package_name}/{tag_name}...")
|
||||||
|
subprocess.run([
|
||||||
|
"curl", "--fail", "-sS", "-o", "/dev/null", "-X", "PUT",
|
||||||
|
"--user", f"{actor}:{pkg_token}",
|
||||||
|
"--upload-file", filepath,
|
||||||
|
pkg_file_url,
|
||||||
|
], check=True)
|
||||||
|
print(f"Published {filename} to Gitea Package Registry successfully.")
|
||||||
EOF
|
EOF
|
||||||
+17
-3
@@ -1041,12 +1041,13 @@ build_flags =
|
|||||||
'-DZgatewayRTL_433="rtl_433"'
|
'-DZgatewayRTL_433="rtl_433"'
|
||||||
'-DZradioSX127x="SX127x"'
|
'-DZradioSX127x="SX127x"'
|
||||||
; *** ssd1306 Display Options ***
|
; *** ssd1306 Display Options ***
|
||||||
; '-DZdisplaySSD1306="HELTEC_SSD1306"'
|
'-DZdisplaySSD1306="HELTEC_SSD1306"'
|
||||||
; '-DLOG_TO_OLED=false' ; Enable log to OLED
|
; '-DLOG_TO_OLED=false' ; Enable log to OLED
|
||||||
; '-DJSON_TO_OLED=true'
|
; '-DJSON_TO_OLED=true'
|
||||||
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
|
; '-DLOG_LEVEL_OLED=LOG_LEVEL_NOTICE'
|
||||||
; '-DDISPLAY_IDLE_LOGO=true'
|
'-DJSON_TO_OLED=true'
|
||||||
; '-DDISPLAY_BRIGHTNESS=20'
|
'-DDISPLAY_IDLE_LOGO=true'
|
||||||
|
'-DDISPLAY_BRIGHTNESS=20'
|
||||||
; '-DDISPLAY_METRIC=false'
|
; '-DDISPLAY_METRIC=false'
|
||||||
custom_description = Gateway using RTL_433_ESP and RadioLib
|
custom_description = Gateway using RTL_433_ESP and RadioLib
|
||||||
custom_hardware = ESP32 HELTEC LORA32 V2
|
custom_hardware = ESP32 HELTEC LORA32 V2
|
||||||
@@ -1056,6 +1057,19 @@ extra_scripts =
|
|||||||
${env.extra_scripts}
|
${env.extra_scripts}
|
||||||
scripts/enable_rtl433_decoders.py
|
scripts/enable_rtl433_decoders.py
|
||||||
custom_rtl_433_enable_decoders = esa_energy
|
custom_rtl_433_enable_decoders = esa_energy
|
||||||
|
custom_rtl_433_disable_decoders =
|
||||||
|
skylink_motion
|
||||||
|
acurite_rain_896
|
||||||
|
acurite_th
|
||||||
|
acurite_txr
|
||||||
|
acurite_986
|
||||||
|
acurite_606
|
||||||
|
acurite_00275rm
|
||||||
|
acurite_590tx
|
||||||
|
acurite_01185m
|
||||||
|
rainpoint
|
||||||
|
rainpoint_hcs012arf
|
||||||
|
wec2103
|
||||||
|
|
||||||
[env:heltec-rtl_433-fsk]
|
[env:heltec-rtl_433-fsk]
|
||||||
platform = ${com.esp32_platform}
|
platform = ${com.esp32_platform}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Re-enable rtl_433_ESP decoders that are disabled by default in the library.
|
# Configure rtl_433_ESP decoders (enable or disable specific protocols).
|
||||||
#
|
#
|
||||||
# Newer rtl_433_ESP releases mark some decoders with `.disabled = 1` (e.g.
|
# Newer rtl_433_ESP releases mark some decoders with `.disabled = 1` (e.g.
|
||||||
# `esa_energy` since v0.6.x) and there is no build flag to turn them back on.
|
# `esa_energy` since v0.6.x) and enable many noisy OOK decoders by default.
|
||||||
# This script patches the decoder definitions inside the downloaded library in
|
# This script patches the decoder definitions inside the downloaded library in
|
||||||
# .pio/libdeps/<env>/ before compilation.
|
# .pio/libdeps/<env>/ before compilation.
|
||||||
#
|
#
|
||||||
@@ -10,6 +10,9 @@
|
|||||||
# ${env.extra_scripts}
|
# ${env.extra_scripts}
|
||||||
# scripts/enable_rtl433_decoders.py
|
# scripts/enable_rtl433_decoders.py
|
||||||
# custom_rtl_433_enable_decoders = esa_energy
|
# custom_rtl_433_enable_decoders = esa_energy
|
||||||
|
# custom_rtl_433_disable_decoders =
|
||||||
|
# skylink_motion
|
||||||
|
# acurite_rain_896
|
||||||
#
|
#
|
||||||
# Must run as a normal (post) script: lib_deps are installed while the platform
|
# Must run as a normal (post) script: lib_deps are installed while the platform
|
||||||
# builder script runs, so a "pre:" script would not find the library on a clean
|
# builder script runs, so a "pre:" script would not find the library on a clean
|
||||||
@@ -22,23 +25,23 @@ import re
|
|||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
|
|
||||||
def enable_decoders(libdeps_dir, decoders):
|
def patch_decoders(libdeps_dir, enable_decoders, disable_decoders):
|
||||||
"""Patch `.disabled = N` to `.disabled = 0` for the given r_device names.
|
"""Patch `.disabled` for the given r_device names in rtl_433_ESP."""
|
||||||
|
|
||||||
Returns a dict decoder -> status ("enabled", "already enabled", "not found").
|
|
||||||
"""
|
|
||||||
device_files = glob.glob(
|
device_files = glob.glob(
|
||||||
os.path.join(libdeps_dir, "**", "src", "rtl_433", "devices", "*.c"),
|
os.path.join(libdeps_dir, "**", "src", "rtl_433", "devices", "*.c"),
|
||||||
recursive=True,
|
recursive=True,
|
||||||
)
|
)
|
||||||
result = {name: "not found" for name in decoders}
|
enable_status = {name: "not found" for name in enable_decoders}
|
||||||
|
disable_status = {name: "not found" for name in disable_decoders}
|
||||||
|
|
||||||
for path in device_files:
|
for path in device_files:
|
||||||
with open(path, "r", encoding="utf-8", newline="") as f:
|
with open(path, "r", encoding="utf-8", newline="") as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
changed = False
|
changed = False
|
||||||
for name in decoders:
|
|
||||||
|
for name in enable_decoders:
|
||||||
block_re = re.compile(
|
block_re = re.compile(
|
||||||
r"(r_device\s+const\s+" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
|
r"(r_device\s+(?:const\s+)?" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
|
||||||
re.DOTALL,
|
re.DOTALL,
|
||||||
)
|
)
|
||||||
match = block_re.search(content)
|
match = block_re.search(content)
|
||||||
@@ -51,23 +54,63 @@ def enable_decoders(libdeps_dir, decoders):
|
|||||||
if count:
|
if count:
|
||||||
content = content[: match.start(2)] + new_body + content[match.end(2) :]
|
content = content[: match.start(2)] + new_body + content[match.end(2) :]
|
||||||
changed = True
|
changed = True
|
||||||
result[name] = "enabled"
|
enable_status[name] = "enabled"
|
||||||
else:
|
else:
|
||||||
result[name] = "already enabled"
|
enable_status[name] = "already enabled"
|
||||||
|
|
||||||
|
for name in disable_decoders:
|
||||||
|
block_re = re.compile(
|
||||||
|
r"(r_device\s+(?:const\s+)?" + re.escape(name) + r"\s*=\s*\{)(.*?)(\};)",
|
||||||
|
re.DOTALL,
|
||||||
|
)
|
||||||
|
match = block_re.search(content)
|
||||||
|
if not match:
|
||||||
|
continue
|
||||||
|
body = match.group(2)
|
||||||
|
if re.search(r"\.disabled\s*=\s*[1-9]\d*", body):
|
||||||
|
disable_status[name] = "already disabled"
|
||||||
|
continue
|
||||||
|
if re.search(r"\.disabled\s*=\s*0\b", body):
|
||||||
|
new_body = re.sub(r"(\.disabled\s*=\s*)0\b", r"\g<1>1", body)
|
||||||
|
else:
|
||||||
|
nl = "\r\n" if "\r\n" in body else "\n"
|
||||||
|
new_body, count = re.subn(
|
||||||
|
r"([ \t]*\.fields\s*=)",
|
||||||
|
r" .disabled = 1," + nl + r"\g<1>",
|
||||||
|
body,
|
||||||
|
count=1,
|
||||||
|
)
|
||||||
|
if not count:
|
||||||
|
new_body = body + " .disabled = 1," + nl
|
||||||
|
content = content[: match.start(2)] + new_body + content[match.end(2) :]
|
||||||
|
changed = True
|
||||||
|
disable_status[name] = "disabled"
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
with open(path, "w", encoding="utf-8", newline="") as f:
|
with open(path, "w", encoding="utf-8", newline="") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
return result
|
|
||||||
|
return enable_status, disable_status
|
||||||
|
|
||||||
|
|
||||||
decoders = env.GetProjectOption("custom_rtl_433_enable_decoders", "").split()
|
enable_list = env.GetProjectOption("custom_rtl_433_enable_decoders", "").split()
|
||||||
if decoders:
|
disable_list = env.GetProjectOption("custom_rtl_433_disable_decoders", "").split()
|
||||||
|
|
||||||
|
if enable_list or disable_list:
|
||||||
libdeps_dir = os.path.join(env.subst("$PROJECT_LIBDEPS_DIR"), env.subst("$PIOENV"))
|
libdeps_dir = os.path.join(env.subst("$PROJECT_LIBDEPS_DIR"), env.subst("$PIOENV"))
|
||||||
status = enable_decoders(libdeps_dir, decoders)
|
enable_status, disable_status = patch_decoders(libdeps_dir, enable_list, disable_list)
|
||||||
for name, state in status.items():
|
for name, state in enable_status.items():
|
||||||
print("rtl_433_ESP decoder %s: %s" % (name, state))
|
print("rtl_433_ESP decoder %s: %s" % (name, state))
|
||||||
missing = [name for name, state in status.items() if state == "not found"]
|
for name, state in disable_status.items():
|
||||||
|
print("rtl_433_ESP decoder %s: %s" % (name, state))
|
||||||
|
missing = [
|
||||||
|
name
|
||||||
|
for name, state in list(enable_status.items()) + list(disable_status.items())
|
||||||
|
if state == "not found"
|
||||||
|
]
|
||||||
if missing:
|
if missing:
|
||||||
print("Error: rtl_433_ESP decoder(s) not found in %s: %s" % (libdeps_dir, ", ".join(missing)))
|
print(
|
||||||
|
"Error: rtl_433_ESP decoder(s) not found in %s: %s"
|
||||||
|
% (libdeps_dir, ", ".join(missing))
|
||||||
|
)
|
||||||
env.Exit(1)
|
env.Exit(1)
|
||||||
|
|
||||||
Reference in new issue
Block a user