GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bitengine-hub-zigbee-ncp/docs/tx-power.md at main · bitEngineTech/bitengine-hub-zigbee-ncp

Expand file tree

/

tx-power.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
210 lines (163 loc) · 10.6 KB
/

tx-power.md

Copy path

File metadata and controls

210 lines (163 loc) · 10.6 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Zigbee transmit power and radio region

Who sets the power

The Zigbee host sets the MG24's transmit power, not the hub:

  • ZHA (zigpy / bellows) writes the power over EZSP at every start. Without configuration zigpy uses 8 dBm. With this firmware, bellows first asks the NCP for the recommended power for the country configured in Home Assistant, and uses that.
  • Zigbee2MQTT (ember) writes its own transmit_power setting (default 5 dBm). It does not ask the NCP.

The hub firmware has no Zigbee power setting and never writes a power value. What this NCP adds is an upper limit (cap) per region: it answers ZHA's question honestly and clamps whatever any host writes. It never raises the power above what the host asked for.

How the cap is computed

The NCP keeps two independent region declarations:

Declaration Who makes it How
host ZHA The country set in Home Assistant (Settings → System → General → Country), sent with XNCP GET_TX_POWER_INFO (0x0008)
gateway The hub The region chosen in the hub's web UI (Settings → Radio Region), sent with the private XNCP command 0x7001

Each country code maps to a class:

Class Countries Recommended / cap
CE The CEPT/ETSI list from Nabu Casa's table (below), plus the alias EU 10 dBm
FCC US, CA 19 dBm
UNKNOWN Every other code, including ZZ ("Other region" in the hub's menu) 8 dBm
NONE Not declared does not take part
  • Effective cap = the lower of the caps of the declared classes. If neither side has declared anything, the cap is 10 dBm.
  • Answer to ZHA = the lower of the table value for the country ZHA asked about and the gateway's cap; recommended and maximum are the same value.
  • The stricter declaration always wins, so no combination of disagreeing declarations can raise the power. Country codes are case-insensitive.
  • Both declarations are stored in NVM3 (one 8-byte object in the user key domain, key 0x7B01) and written only when a class changes, so repeated declarations do not wear the flash. They are loaded during stack initialization, so the cap is in force before any host connects.

The four values are the only tunables, in ncp/tx_power_table.h: BE_TXP_CE_DBM (10), BE_TXP_FCC_DBM (19), BE_TXP_UNKNOWN_DBM (8) and BE_TXP_DEFAULT_CAP_DBM (10). There is no country code that lifts the cap.

These values are configuration defaults, not a statement that a particular installation complies with local radio regulations. Check the 2.4 GHz rules where the hub is used.

How the cap is enforced

A host's power value can reach the radio through three paths: EZSP setRadioPower, the radioTxPower parameter of formNetwork, and the value the stack restores from its tokens at boot.

  1. Clamp. The linker wraps sli_zigbee_stack_set_radio_power (-Wl,--wrap=sli_zigbee_stack_set_radio_power), so the EZSP setRadioPower handler always goes through min(requested, cap). The SDK sources are not modified. build_ncp.sh disassembles every build to confirm the handler really calls the wrapper.
  2. Backstop. While joined to a network, the main loop checks every 200 ms whether the stack's radio power is above the cap and sets it back if so. This covers the paths the wrapper cannot reach (network formation and restored tokens).
  3. Count. Every clamp increments a counter (clamped_count, since NCP power-up).

setRadioPower still returns success: the EZSP command only returns a status, so the host assumes its requested value. ZHA is not affected (it asked first and writes a value within the cap). Zigbee2MQTT shows the value you configured, not the effective one; check the cap on the hub instead.

Region table and its source

The CE list is copied entry for entry from Nabu Casa's silabs-firmware-builder (src/zigbee_ncp/extension/xncp_common_extension/src/tx_power.c at commit c9fa1d66d0063a5f838fdc4a6e5d0c11211d1b24). The transcript is kept in ncp/ref/nabucasa_tx_power_2026-09-15.txt, and python3 ncp/check_table.py verifies that every upstream entry is present in ncp/tx_power_table.c as CE with 10/10, and that the only additions are EU, US and CA. Keeping the list identical means that, for these countries, ZHA behaves on this hub as it does on Home Assistant's own adapters.

Group Codes
EU member states AT BE BG HR CY CZ DK EE FI FR DE GR HU IE IT LV LT LU MT NL PL PT RO SK SI ES SE
EEA IS LI NO
Aligned with RED / ETSI CH GB TR AL BA GE MD ME MK RS UA
Other CEPT AD AZ MC SM VA
Added here (CE) EU — alias sent by the hub's "European Union / United Kingdom / other ETSI regions" menu entry
Added here (FCC) US, CA

Countries missing from the upstream table get 8/8 there; this firmware does the same (UNKNOWN), except for US and CA, which get 19/19.

Setting and reading the region

ZHA

Set the country in Home Assistant. bellows asks the NCP at every start and applies the recommended value; no YAML is needed. If the hub's region is set as well, the stricter one applies — set both to the same place.

Zigbee2MQTT

Zigbee2MQTT does not ask. Set the hub's region, then configure the power you want in Zigbee2MQTT:

advanced:
  transmit_power: 19   # example; anything above the cap is clamped in the NCP

The hub

Web UI: Settings → Radio Region → Save and apply. The menu offers Not set (clears the declaration), European Union / United Kingdom / other ETSI regions (EU), United States (US), Canada (CA) and Other region (ZZ).

curl -u ":<password>" http://<hub-ip>/api/v1/radio/region
curl -u ":<password>" -X POST -d '{"region":"US"}' http://<hub-ip>/api/v1/radio/region
curl -u ":<password>" -X POST -d '{"region":null}' http://<hub-ip>/api/v1/radio/region   # clear
  • GET returns region (or null), declared and menu. Only codes from menu are accepted.
  • Applying needs exclusive use of the UART: the hub disconnects the Zigbee host, sends 0x7001 and restarts the MG24 once. Zigbee is offline for up to about a minute; ZHA and Zigbee2MQTT reconnect by themselves. The POST response contains applied ("now", or "deferred" if the MG24 was busy, e.g. during an update — the region is then sent at the next boot), the resulting NCP state under zigbee, and thread_tx_dbm: the hub also sets its own Thread radio's power from the same region.
  • The hub also sends its region when it re-reads the NCP at boot.

Reading the effective state

GET /api/v1/zigbee/status contains a tx_power object:

Field Meaning
ncp_xncp false: the NCP firmware has no XNCP, the region applies to Thread only — update the NCP
class, cap_dbm Effective class and cap (classes: 0 NONE, 1 UNKNOWN, 2 CE, 3 FCC)
requested_dbm The power value stored in the stack; always ≤ cap. A stored setting, not a measurement
host_class, host_region What ZHA declared
gw_class, gw_region What the hub declared
clamped_count How often a host asked for more than the cap
read_uptime_s, cached When the snapshot was taken; cached: true means it comes from an earlier boot

This is a snapshot taken when the hub last talked to the NCP itself (at boot or when the region was applied). While a Zigbee host is connected the UART belongs to the host, so the hub cannot refresh it.

Compatibility

Hub firmware NCP firmware Behaviour
Without region support With XNCP (this repository) Only the host declaration exists: ZHA gets per-country values, Zigbee2MQTT is capped at the 10 dBm default
With region support Without XNCP The hub reports ncp_xncp: false; the region applies to Thread only
With region support With XNCP As described on this page

XNCP wire format

XNCP frames travel in the payload (up to 119 bytes) of the standard EZSP command customFrame (0x0047). The envelope follows Nabu Casa's format byte for byte, so bellows' client works unchanged:

request:  <cmd_id lo> <cmd_id hi> <0x00> <payload…>
response: <rsp_id lo> <rsp_id hi> <status> <payload…>      rsp_id = cmd_id | 0x8000

Status is the low byte of sl_status_t: 0x00 OK, 0x21 invalid parameter, 0x2D not found. An unknown command is answered with rsp_id = 0xFFFF and status 0x2D, which bellows treats as "not supported".

ID Request payload Response payload
0x0000 GET_SUPPORTED_FEATURES — u32 bitmap, little endian: 0x000000A8 = BUILD_STRING (bit 3), CHIP_INFO (bit 5), TX_POWER_INFO (bit 7)
0x0003 GET_BUILD_STRING — Raw ASCII, no length prefix: bitEngine-xncp/1.0 <revision> <date> nvm3c=<n>
0x0005 GET_CHIP_INFO ignored u32 RAM size (262144) + u8 length + part number (EFR32MG24B020F1536IM40)
0x0008 GET_TX_POWER_INFO 2-byte country code i8 recommended + i8 maximum (dBm)
0x7000 get power state — 11-byte state (below)
0x7001 set gateway region 2-byte code, or empty to clear 11-byte state (below)
0x7002 NVM3 statistics ignored 15 bytes, read-only; layout in ncp/bitengine_xncp.h, decoder in nvm3_stats.py

Private commands use 0x7000–0x70FF, outside the range used by Nabu Casa's firmware. 0x7002 is not advertised in the feature bitmap. The XNCP information callback reports manufacturer ID 0x0000 and version 0x0100.

State returned by 0x7000 / 0x7001:

Byte Field
0 Effective class (0 NONE, 1 UNKNOWN, 2 CE, 3 FCC)
1 Effective cap, i8 dBm
2 Requested power stored in the stack, i8 dBm
3 Host class
4 Gateway class
5–6 Host country code (two spaces if none)
7–8 Gateway country code (two spaces if none)
9–10 Clamp count, u16 little endian

Examples (more in ncp/test_host/vectors.txt, which the host-side tests replay in order):

GET_TX_POWER_INFO "US"     req 08 00 00 55 53   rsp 08 80 00 13 13     (19 / 19)
GET_TX_POWER_INFO "DE"     req 08 00 00 44 45   rsp 08 80 00 0A 0A     (10 / 10)
GET_TX_POWER_INFO "JP"     req 08 00 00 4A 50   rsp 08 80 00 08 08     (8 / 8)
get power state            req 00 70 00         rsp 00 F0 00 00 0A 08 00 00 20 20 20 20 00 00
                           (nothing declared: class NONE, cap 10, stack at 8 dBm, no codes, 0 clamps)
set gateway region "US"    req 01 70 00 55 53
clear gateway region       req 01 70 00
unknown command            req 09 00 00         rsp FF FF 2D

GET_TX_POWER_INFO records a host declaration in NVM3 as a side effect, and 0x7001 changes the gateway declaration. Diagnostic tools should not send either casually; ncp_probe.py only sends the read-only 0x7002.

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.