Skip to content

Nz sf region - #985

Open
NomDeTom wants to merge 7 commits into
meshtastic:masterfrom
NomDeTom:nz-sf-region
Open

Nz sf region#985
NomDeTom wants to merge 7 commits into
meshtastic:masterfrom
NomDeTom:nz-sf-region

Conversation

@NomDeTom

@NomDeTom NomDeTom commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Adds a new region specifically for New Zealand to allow the ShortFast preset generally in use there to be the "default" from the start. ANZ is still available for legacy users.

Checklist before merging

  • All top level messages commented
  • All enum members have unique descriptions

Summary by CodeRabbit

  • New Features
    • Added support for the New Zealand 915–928 MHz LoRa region option, including compatibility with the Short Fast modem preset.
    • Reception timestamps can now explicitly indicate when a timestamp is unavailable, distinguishing that state from a valid zero timestamp.
    • Expanded supported region configuration capacity to accommodate the new regional option.

claude and others added 3 commits July 11, 2026 08:24
Adds a new RegionCode enum value NZ_SF = 38 that uses the same
frequency band as ANZ, intended for the Short Fast modem preset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016CZ7bDuPL67jJS1D7RV9oB
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016CZ7bDuPL67jJS1D7RV9oB
@CLAassistant

CLAassistant commented Jul 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updates protocol schemas with the NZ_915 region code, a matching region-group capacity increase, and explicit presence semantics for MeshPacket.rx_time.

Changes

Protocol schema updates

Layer / File(s) Summary
Add NZ_915 region support
meshtastic/config.proto, meshtastic/mesh.options
Adds NZ_915 = 38 for New Zealand’s 915–928 MHz band and increases the region_groups limit to 39.
Add rx_time presence semantics
meshtastic/mesh.proto
Changes MeshPacket.rx_time to optional fixed32, distinguishing an absent timestamp from epoch zero.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: thebentern, caveman99, jp-bennett

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the New Zealand Short Fast region change, which is the primary objective of the pull request.
Description check ✅ Passed The description explains the New Zealand region change and completes the checklist, but it retains the placeholder related issue URL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@meshtastic/config.proto`:
- Around line 993-998: Increase the max_count for
LoRaRegionPresetMap.region_groups in mesh.options from 38 to 39 to accommodate
RegionCode.NZ_924, then regenerate the protobuf bindings.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 489e2958-1f85-4bc1-be6d-625d60b197a4

📥 Commits

Reviewing files that changed from the base of the PR and between da2fc41 and 341b5af.

📒 Files selected for processing (1)
  • meshtastic/config.proto

Comment thread meshtastic/config.proto Outdated
@coderabbitai coderabbitai Bot mentioned this pull request Jul 19, 2026
2 tasks

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@meshtastic/config.proto`:
- Around line 995-998: Update LoRaRegionPresetMap.region_groups in mesh.proto to
include NZ_915 with default_preset set to SHORT_FAST, and increase the
region_groups entry limit in mesh.options if necessary to accommodate the new
mapping. Ensure clients can validate unsupported preset combinations for this
region.

In `@meshtastic/mesh.proto`:
- Line 1819: Coordinate the rx_time explicit-presence change across all
consumers: update writers and readers to use the generated presence API,
regenerate NanoPB bindings so has_rx_time is available, and add round-trip
coverage distinguishing an absent value from a present value of 0. Ensure these
updates are complete before merging the protobuf schema change.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9ff867d8-fc69-4396-8792-d70322a6a1a9

📥 Commits

Reviewing files that changed from the base of the PR and between 341b5af and a5bd918.

📒 Files selected for processing (3)
  • meshtastic/config.proto
  • meshtastic/mesh.options
  • meshtastic/mesh.proto

Comment thread meshtastic/config.proto
Comment on lines +995 to +998
* New Zealand 915MHz-928MHz
* Same band as ANZ, for use with the Short Fast modem preset
*/
NZ_915 = 38;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C 4 '\bNZ_915\b|\bSHORT_FAST\b|\bLoRaRegionPresetMap\b|\bregion_groups\b' . || true

Repository: meshtastic/protobufs

Length of output: 5823


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== config.proto around NZ_915 and presets =="
sed -n '960,1060p' meshtastic/config.proto

echo
echo "== mesh.proto LoRaPresetGroup block =="
sed -n '245,330p' meshtastic/config.proto | sed -n '2790,2840p' meshtastic/mesh.proto

echo
echo "== all RegionCode values =="
python3 - <<'PY'
from pathlib import Path
import re
p = Path('meshtastic/config.proto')
text = p.read_text()
m = re.search(r"enum\s+RegionCode\s*\{([^}]+)\}", text, re.S)
if not m:
    print("REGION_CODE_NOT_FOUND")
    raise SystemExit
for line in m.group(1).splitlines():
    s=line.strip()
    if not s or s.startswith('/*') or s.startswith('*'):
        continue
    print(s)
PY

echo
echo "== repo-wide NZ_915 occurrences =="
rg -n '\bNZ_915\b' . || true

echo
echo "== preset/region map definitions in proto files =="
rg -n 'LoRaRegionPresetMap|LoRaRegionPresets|LoRaPresetGroup|region_groups|LoRaVersion' meshtastic meshtastic_proto meshtastic.proto *.proto 2>/dev/null || true

Repository: meshtastic/protobufs

Length of output: 6450


Add NZ_915 to the region-preset map contract.

NZ_915 = 38 is a valid new region value, but meshtastic/mesh.proto still has no LoRaRegionPresetMap.region_groups entry for it, and meshtastic/mesh.options caps only the map at 39 entries. Add the NZ_915 preset-group mapping with default_preset = SHORT_FAST so clients can reject unsupported preset combinations, or leave clear documentation that region_groups has no entry for this region.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@meshtastic/config.proto` around lines 995 - 998, Update
LoRaRegionPresetMap.region_groups in mesh.proto to include NZ_915 with
default_preset set to SHORT_FAST, and increase the region_groups entry limit in
mesh.options if necessary to accommodate the new mapping. Ensure clients can
validate unsupported preset combinations for this region.

Comment thread meshtastic/mesh.proto
* clock becomes available, before the phone ever sees it - "absent" is not guaranteed
* permanent, only "not yet known at last observation".
*/
optional fixed32 rx_time = 7;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

# Expect: the generator and schema-compatibility policy are identified.
rg --hidden -n -C 5 \
  'protoc|nanopb|proto3_optional|breaking|cardinality' \
  -g '!.git' .

# Expect: all rx_time writers and readers use presence-aware APIs.
rg --hidden -n -C 6 \
  'rx_time|has_rx_time|HasField.*rx_time|ClearField.*rx_time' \
  -g '!.git' .

Repository: meshtastic/protobufs

Length of output: 35149


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== buf.yaml =="
cat -n buf.yaml

echo "== workflow breaking/lint snippets =="
sed -n '1,80p' .github/workflows/pull_request.yml | cat -n

echo "== mesh proto rx_time and ServiceEnvelope context =="
sed -n '1730,1825p;2130,2195p' meshtastic/mesh.proto | cat -n

echo "== top-level proto options for proto3_optional / explicit presence config =="
rg -n -C 3 'proto3_optional|syntax = "proto3"|breaking|except:' meshtastic *.proto options build.gradle* .gradle* 2>/dev/null || true

Repository: meshtastic/protobufs

Length of output: 12718


🌐 Web query:

NanoPB proto3 optional generated has field has_rx_time

💡 Result:

In NanoPB, a has_ field (such as has_rx_time) is generated when a field is explicitly marked as optional in your .proto file, even when using proto3 syntax [1][2]. Under standard proto3 behavior, singular fields do not typically generate a has_ flag because they rely on default values [2][3]. However, if you use the explicit optional keyword introduced in Protocol Buffers 3.12, NanoPB will recognize this and generate a corresponding has_ boolean field in the C code [2][4]. This has_ field allows you to explicitly track whether the value is present or absent, regardless of whether its value is the default (e.g., zero) [1][4]. If your generated code contains has_rx_time, it confirms that the field rx_time was defined with the optional label in your .proto file (e.g., optional uint32 rx_time = 1;) [2][4]. In projects like Meshtastic, this pattern is intentionally used to distinguish between a valid time value and a missing or "not-present" state [4].

Citations:


Coordinate the explicit-presence migration with downstream generated bindings.

meshtastic/mesh.proto:1819 is valid explicit presence, but this breaks existing implicit-presence clients and generated APIs. Update writers/readers with the generated presence API, regenerate NanoPB bindings with has_rx_time, and add round-trip tests for absent vs present 0 before the breaking protobuf change is merged.

🧰 Tools
🪛 GitHub Check: build

[failure] 1819-1819:
Field "7" with name "rx_time" on message "MeshPacket" changed cardinality from "optional with implicit presence" to "optional with explicit presence".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@meshtastic/mesh.proto` at line 1819, Coordinate the rx_time explicit-presence
change across all consumers: update writers and readers to use the generated
presence API, regenerate NanoPB bindings so has_rx_time is available, and add
round-trip coverage distinguishing an absent value from a present value of 0.
Ensure these updates are complete before merging the protobuf schema change.

Source: Linters/SAST tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants