Skip to content

Instantly share code, notes, and snippets.

@zhangyoufu
Created December 28, 2025 02:48
Show Gist options
  • Select an option

  • Save zhangyoufu/74f68fe4cd33b55f9697b86d2be25123 to your computer and use it in GitHub Desktop.

Select an option

Save zhangyoufu/74f68fe4cd33b55f9697b86d2be25123 to your computer and use it in GitHub Desktop.
find country code in regdb-wireless
#!/usr/bin/env python3
from typing import Optional, TypeAlias
import dbparse
import enum
class Flags(enum.IntFlag):
NO_OFDM = 1<<0
NO_CCK = 1<<1
NO_INDOOR = 1<<2
NO_OUTDOOR = 1<<3
DFS = 1<<4
PTP_ONLY = 1<<5
PTMP_ONLY = 1<<6
NO_IR = 1<<7
NO_HT40 = 1<<10
AUTO_BW = 1<<11
Interval: TypeAlias = tuple[int, int]
def intersect(a: Interval, b: Interval) -> Optional[Interval]:
if b[0] > a[1] or a[0] > b[1]:
return None
return max(a[0], b[0]), min(a[1], b[1])
FREQ_OF_INTEREST = (5170, 5330)
# FREQ_OF_INTEREST = (5330, 5490)
# FREQ_OF_INTEREST = (5490, 5650)
# FREQ_OF_INTEREST = (5735, 5895)
p = dbparse.DBParser()
countries = p.parse(open('db.txt', 'r', encoding='utf-8'))
for country_id, country in countries.items():
print(country_id.decode())
for permission in country._permissions:
freqband = permission.freqband
if intersect((freqband.start, freqband.end), FREQ_OF_INTEREST):
print(freqband, permission.power._as_tuple(), 'WmmRule' if permission.wmmrule is not None else '', repr(Flags(permission.flags)))
@zhangyoufu
Copy link
Author

zhangyoufu commented Dec 28, 2025

5GHz 160MHz (not 80+80) w/o DFS

CC   Ch.   Tx Flags
ID  36-64  23 NO-OUTDOOR
RU  36-64  20 NO-OUTDOOR
GT 100-128 23 NO-OUTDOOR
PA 100-128 30
ZA 100-128 30

@zhangyoufu
Copy link
Author

2.4GHz 40MHz w/ high TxPower

AU <FreqBand 2400.000 - 2483.500 @ 40.000> (0.0, 36.020599913279625)  <Flags: 0>
HK <FreqBand 2400.000 - 2483.500 @ 40.000> (0.0, 36.0)  <Flags: 0>
NZ <FreqBand 2400.000 - 2483.500 @ 40.000> (0.0, 36.0)  <Flags: 0>
PA <FreqBand 2400.000 - 2483.500 @ 40.000> (0.0, 36.0)  <Flags: 0>

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