From 713abb68e973ad41f8c5f10d77e315b69a1e7e56 Mon Sep 17 00:00:00 2001 From: Itay Sharoni <110981018+Itay-Sharoni@users.noreply.github.com> Date: Thu, 27 Aug 2026 11:29:53 +0300 Subject: [PATCH] remove the elrs handset address distinction --- src/SCRIPTS/CRSFSimulator/csrfsimulator.lua | 1 - src/SCRIPTS/ELRS/crsf.lua | 11 +++++------ src/SCRIPTS/ELRS/crsf_session.lua | 10 ++++------ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/SCRIPTS/CRSFSimulator/csrfsimulator.lua b/src/SCRIPTS/CRSFSimulator/csrfsimulator.lua index 88b9a4d..b15d030 100644 --- a/src/SCRIPTS/CRSFSimulator/csrfsimulator.lua +++ b/src/SCRIPTS/CRSFSimulator/csrfsimulator.lua @@ -99,7 +99,6 @@ local CRSF = { ADDRESS_HANDSET = 0xEA, -- EdgeTX's official handset address ADDRESS_RX = 0xEC, ADDRESS_TX = 0xEE, - ADDRESS_HANDSET_ELRS = 0xEF, -- ELRS-custom Lua device address, not standard CRSF -- Field types0 UINT8 = 0, diff --git a/src/SCRIPTS/ELRS/crsf.lua b/src/SCRIPTS/ELRS/crsf.lua index 62f5839..a792099 100644 --- a/src/SCRIPTS/ELRS/crsf.lua +++ b/src/SCRIPTS/ELRS/crsf.lua @@ -27,7 +27,6 @@ CRSF.CONST = { ADDRESS_HANDSET = 0xEA, -- EdgeTX's official handset address ADDRESS_RX = 0xEC, ADDRESS_TX = 0xEE, - ADDRESS_HANDSET_ELRS = 0xEF, -- ELRS-custom Lua device address, not standard CRSF -- Frame types FRAMETYPE_DEVICE_PING = 0x28, @@ -257,10 +256,10 @@ function CRSF:decodeElrsStatus(data) } end ---- ELRS 1.x signature: an inbound PARAMETER_WRITE addressed to the official --- handset address from the TX module. 3.x+ answers on ADDRESS_HANDSET_ELRS and --- never writes to the handset. Reads data[1] (the destination) deliberately -- --- unlike the decoders above, which leave gating on the source to the caller. +--- ELRS 1.x signature: an inbound PARAMETER_WRITE addressed to the handset +-- from the TX module; 3.x+ never writes to the handset. Reads data[1] (the +-- destination) deliberately -- unlike the decoders above, which leave gating +-- on the source to the caller. -- @param data array of byte values -- @return true when the frame matches the 1.x signature, nil otherwise function CRSF:isElrsV1Frame(data) @@ -280,7 +279,7 @@ end --- Request ELRS status from the TX module (PARAMETER_WRITE with fieldId=0). -- The module answers with an ELRS_STATUS frame carrying its warning flags. function CRSF:requestElrsStatus() - CRSF.push(CRSF.CONST.FRAMETYPE_PARAMETER_WRITE, { CRSF.CONST.ADDRESS_TX, CRSF.CONST.ADDRESS_HANDSET_ELRS, 0, 0 }) + CRSF.push(CRSF.CONST.FRAMETYPE_PARAMETER_WRITE, { CRSF.CONST.ADDRESS_TX, CRSF.CONST.ADDRESS_HANDSET, 0, 0 }) end --- Send a COMMAND bind request. Addressed to the TX module it enters bind diff --git a/src/SCRIPTS/ELRS/crsf_session.lua b/src/SCRIPTS/ELRS/crsf_session.lua index a422e0d..f0aded8 100644 --- a/src/SCRIPTS/ELRS/crsf_session.lua +++ b/src/SCRIPTS/ELRS/crsf_session.lua @@ -36,7 +36,7 @@ CRSFSession.__index = CRSFSession --- Create a session. -- @param opts table with: -- deviceId target device address (default ADDRESS_TX) --- handsetId reply-to address (default ADDRESS_HANDSET_ELRS) +-- handsetId reply-to address (default ADDRESS_HANDSET) -- responseTimeout fixed read-retry deadline in ticks; when omitted it is -- derived per device: 50 for the local ELRS TX, 500 for -- remote devices relayed over the air link @@ -56,7 +56,7 @@ function CRSFSession.new(opts) return setmetatable({ -- Public facts deviceId = opts.deviceId or crsf.CONST.ADDRESS_TX, - handsetId = opts.handsetId or crsf.CONST.ADDRESS_HANDSET_ELRS, + handsetId = opts.handsetId or crsf.CONST.ADDRESS_HANDSET, deviceName = nil, isElrsTx = nil, fieldsCount = 0, @@ -137,7 +137,6 @@ function CRSFSession:setDevice(device) self.deviceName = device.name self.fieldsCount = device.fieldCount self.isElrsTx = device.isElrs and device.id == crsf.CONST.ADDRESS_TX or nil - self.handsetId = self.isElrsTx and crsf.CONST.ADDRESS_HANDSET_ELRS or crsf.CONST.ADDRESS_HANDSET local st = self.status st.flags = 0 st.connected = nil @@ -669,9 +668,8 @@ function CRSFSession:tick() if self._trackStatus and now > self._nextStatusAt then if self.isElrsTx then - -- isElrsTx guarantees deviceId/handsetId are ADDRESS_TX and - -- ADDRESS_HANDSET_ELRS here (see setDevice), the addressing - -- requestElrsStatus() hardcodes. + -- isElrsTx guarantees deviceId is ADDRESS_TX here (see setDevice), + -- the addressing requestElrsStatus() hardcodes. crsf:requestElrsStatus() else self.status.receivedPackets = nil