"Day 3/30: LoRaWAN Classes A, B, and C — Picking Your Power/Latency Tradeoff"

three device icons labeled Class A, Class B and Class C

Today's topic was LoRaWAN's three device classes — A, B, and C. Before today I assumed "class" meant something like a device tier or a feature set. It's actually simpler and more specific than that: it's about when the device is willing to listen for downlink messages, and that turns out to be one of the biggest levers on battery life.

Class A is the baseline. Every LoRaWAN device supports it — it's mandatory, not optional. The pattern is: the device transmits an uplink whenever it has something to say, and then opens two short receive windows immediately after, in case the network wants to send something back down. Outside of those two brief windows, the radio is off. This is about as power-efficient as it gets, because the device controls when it listens — it's not sitting there burning power waiting for a message that might never come. The catch is latency: if the network wants to reach the device, it has to wait until that device's next uplink before it gets a chance to deliver anything. For a sensor that only reports once an hour, that could mean an hour of delay for a downlink command.

Class B builds on top of Class A by adding scheduled receive windows — "ping slots" — synchronized to a beacon broadcast from the gateway. So instead of the network only being able to reach the device right after an uplink, it now also gets predictable extra chances to deliver a downlink between uplinks, on a known schedule. That means better, more predictable downlink latency than Class A, at the cost of some extra power for those additional listen windows and for staying beacon-synchronized in the first place.

Class C is the other extreme: the receiver is essentially always on, except for the brief moment the device itself is transmitting. This gives the lowest possible downlink latency — the network can reach the device almost any time — but it costs a lot of power, since the radio is listening nearly continuously. As I understand it, Class C is really only practical for devices that don't have to worry about battery budget — mains-powered gear, basically.

Putting myself in the shoes of a battery-powered field sensor — which is basically what a lot of our own hardware has to be — the choice is pretty obvious: Class A. You're not expecting frequent downlink commands, you want the device to last months or years on a battery, and an occasional hour or so of downlink latency is a totally acceptable tradeoff. Class C would drain a battery-powered node in a fraction of the time. Class B sits in an interesting middle ground I want to understand better — I can imagine use cases where you need somewhat responsive downlink (like remote reconfiguration) but still care about power, though I haven't worked through a concrete example yet.

Tomorrow I'm moving from LoRaWAN into something closer to what Siliqs actually ships: Meshtastic, and how mesh networking is a genuinely different model from the gateway-based LoRaWAN topology I've been reading about this week.

三個裝置圖示分別標示 Class A、Class B、Class C

今天的主題是 LoRaWAN 的三種裝置 class——A、B、C。在今天之前我一直以為「class」大概是裝置等級或功能組合之類的東西。實際上它比我想的更單純、也更具體:講的是「裝置願意在什麼時候聽 downlink 訊息」,而這件事其實是影響電池續航力最大的因素之一。

Class A 是基本款。每一台 LoRaWAN 裝置都支援——這是強制規定,不是選配。它的模式是:裝置有話要說的時候發一次 uplink,發完之後立刻開兩個很短的接收窗口,看網路端要不要順便回點什麼下來。除了這兩個短暫的窗口之外,radio 是關著的。這幾乎是功耗效率的極致,因為是裝置自己決定什麼時候要聽——它不會傻傻坐在那邊耗電等一個可能永遠不會來的訊息。代價是延遲:如果網路端想聯絡裝置,得等到那台裝置「下一次」發 uplink 才有機會把東西送下去。對一個一小時才回報一次的感測器來說,這可能代表 downlink 指令要等上一小時才會被收到。

Class B 是在 Class A 之上加上排程好的接收窗口——「ping slot」——跟 gateway 廣播出來的 beacon 訊號同步。這樣一來,網路端就不再只能在裝置發完 uplink 之後那一瞬間聯絡到它,而是在兩次 uplink 之間也有已知排程的額外機會可以送 downlink。這代表比 Class A 更好、更可預期的 downlink 延遲,但代價是那些額外的聆聽窗口跟維持 beacon 同步本身都要多耗一些電。

Class C 是另一個極端:接收端基本上是一直開著的,只有裝置自己在發射的那一瞬間例外。這給了理論上最低的 downlink 延遲——網路幾乎隨時都能聯絡到裝置——但代價是耗電量很大,因為 radio 幾乎是不間斷地在聽。照我目前的理解,Class C 大概只有在裝置不用煩惱電池預算的情況下才實際可行——基本上就是市電供電的設備。

把自己放在電池供電現場感測器的位置想——這基本上就是我們自家很多硬體的處境——答案其實蠻明顯的:Class A。你不會期待頻繁的 downlink 指令,你希望裝置能靠電池撐好幾個月甚至好幾年,偶爾一小時左右的 downlink 延遲是完全可以接受的取捨。Class C 大概會在很短時間內就把電池供電節點的電力耗光。Class B 則落在一個我還想再多了解一點的有趣中間地帶——我可以想像一些需要 downlink 稍微即時一點(例如遠端重新設定)、但同時還是很在意功耗的使用情境,不過還沒想出一個具體的例子。

明天要從 LoRaWAN 轉到跟 Siliqs 實際出貨的東西更接近的題目:Meshtastic,以及 mesh networking 為什麼跟我這禮拜一直在讀的、以 gateway 為中心的 LoRaWAN 拓樸是真的不一樣的模型。