"Day 26/30: Gateway Mode vs. Field Mode — and Why Every Site Needs at Least One Gateway"

two device icons labeled gateway mode and sensor mode

Yesterday I could describe the SQC485Iv2 as a whole system but I hadn't actually understood the role split yet. Today Wei walked me through gateway mode versus field/sensor mode, and it clarified something I'd been fuzzy on since I first read about the product: why a node isn't just "a node," it's a node running one of two distinct jobs.

Field mode (called CLIENT role under the hood, since the firmware is Meshtastic-based) is the one I'd already half-understood from the architecture piece yesterday — this is the normal role for a node sitting out at an actual sensor site. It polls its local RS485 bus on its own schedule and reports what it collects over the mesh. Most nodes in a deployment are probably running this role, out at whatever physical locations have RS485 devices that need polling.

Gateway mode (CLIENT_MUTE role) is the one that took me longer to get my head around, and it's the part I actually found interesting. A gateway node listens to the whole mesh and caches the latest reading from every device on every other node's bus — so it's building up a live picture of the entire site, not just its own local bus. Then, when a downstream Modbus master polls it — say a customer's existing SCADA system — the gateway answers instantly over RS485 in the same protocol, straight from that cache. It doesn't go fetch a fresh reading over the mesh in response to the poll; it answers from what it already has.

That "from cache" detail is what took me a minute to appreciate. A SCADA poll cycle expects a response in a tight window — it's not going to wait multiple seconds for a request to hop across a mesh and back. So the gateway has to already know the answer before it's asked. The part I like: there's a staleness check on that cache, so if a reading has aged out past some threshold, the gateway returns a proper Modbus exception response instead of quietly handing back a number that might be minutes or hours old. That's the difference between "system correctly reports it doesn't have fresh data" and "system lies to you with a stale number," which matters a lot if someone's making a control decision off that data.

The other thing that clicked today: why a site needs at least one gateway node at all. If every node is running field mode, nothing on the mesh is capable of answering a downstream Modbus master the way it expects — a customer's SCADA speaking Modbus RTU has no idea what a mesh even is, it just expects a normal RS485 reply. The gateway is the translation point between "mesh of sensor nodes" and "existing customer Modbus infrastructure."

There's also a addressing choice on the gateway I want to flag as something I only understand at a surface level so far: transparent addressing, where the gateway answers under each remote sensor's own original Modbus slave address (so it's a drop-in — no change needed to an existing poll list), versus aggregated addressing, where several sensors' readings live under one shared slave address at different register offsets, which is apparently useful when adding a single device to a SCADA config is much less painful than adding many. I get the concept but I haven't seen a real config of either one yet — that's on my list to ask Amy about, since she's the one who'd know what customers actually pick in practice and why.

兩個裝置圖示標示 gateway mode 與 sensor mode

昨天我已經能把 SQC485Iv2 講成一個完整系統,但角色的區分我其實還沒真正搞懂。今天 Wei 帶我過了一遍 gateway mode 跟 field/sensor mode 的差異,也釐清了一件我從一開始讀這個產品資料就模糊的事:node 不是只有「一種 node」,而是同一台裝置在跑兩種完全不同工作內容的其中一種。

Field mode(底層叫 CLIENT role,因為韌體是 Meshtastic-based)是我昨天寫架構那篇時已經半懂的角色——這是部署在實際感測站點的 node 的正常角色。它按自己的排程去 poll 本地的 RS485 bus,然後把收集到的資料透過 mesh 回報出去。一個部署裡大多數 node 應該都是跑這個角色,散布在各個有 RS485 裝置要被 poll 的實體位置。

Gateway mode(CLIENT_MUTE role)是我比較花時間才搞懂的部分,也是我覺得真正有趣的地方。Gateway node 會監聽整個 mesh,把「mesh 上每一台其他 node 的 bus 上、每一個裝置」的最新讀數都快取下來——所以它建立起來的是整個場域的即時全貌,不只是自己本地那條 bus。接著,當下游的 Modbus master(例如客戶既有的 SCADA 系統)來 poll 它時,gateway 會用同一套協定,直接從那份 cache 立即透過 RS485 回應。它不會在收到 poll 之後才跑去 mesh 上抓一筆新的讀數;它是用手上已經有的東西回答。

「從 cache 回答」這個細節我花了一點時間才體會到重要性。SCADA 的 poll 週期預期回應要在很短的時間窗內完成——它不會等好幾秒讓一個請求在 mesh 上跳來跳去再跳回來。所以 gateway 必須在被問之前,就已經知道答案。我特別喜歡的一點是:這份 cache 有 staleness check(過期檢查),如果某筆讀數已經超過某個時間門檻沒更新,gateway 會回傳正規的 Modbus exception 回應,而不是悄悄塞回一個可能已經是幾分鐘、甚至幾小時前的舊數字。「系統正確地回報自己沒有新資料」跟「系統拿舊數字騙你」是完全不同的兩件事,如果有人要拿這筆資料做控制決策,這個差異非常重要。

今天另一個想通的地方是:為什麼一個場域至少需要一台 gateway node。如果所有 node 都跑 field mode,mesh 上就沒有任何東西能照下游 Modbus master 期待的方式回應——客戶那邊講 Modbus RTU 的 SCADA 根本不知道什麼是 mesh,它就只期待收到一個正常的 RS485 回覆。Gateway 就是「感測 node 的 mesh」跟「客戶既有 Modbus 基礎設施」之間的翻譯點。

Gateway 上還有一個定址選擇,我想先說清楚自己目前只懂表面:transparent(透明) 定址,gateway 用每個遠端感測器原本自己的 Modbus slave address 來回答(等於是即插即用,不用改動既有的 poll list);跟 aggregated(聚合) 定址,多個感測器的讀數放在同一個共用的 slave address 下、用不同的 register offset 區分,據說這在「幫 SCADA 設定加一台裝置」遠比「加很多台裝置」輕鬆的情境下很有用。概念我懂,但實際的設定我都還沒真的看過——這是我列進待問 Amy 清單裡的問題,因為她應該最清楚客戶實務上都怎麼選、為什麼這樣選。