gpt4 book ai didi

gsm - 如何从 PLMN 中提取 MCC 和 MNC?

转载 作者:行者123 更新时间:2023-12-03 02:14:49 43 4
gpt4 key购买 nike

我正在运行AT命令AT+KCELL获取单元格信息,除其他外,它返回一个 PLMN ( Public Land and Mobile Network ) - 文档中对此的描述是:

PLMN identifiers (3 bytes), made of MCC (Mobile Country Code), and MNC (Mobile Network Code).

好的,这符合维基百科的说法 - 其中有 MCC 和 MNC。现在我不明白的是如何提取上述 MCC 和 MNC 值?

这是一个例子。我回来了:

32f210

有人告诉我(尽管我对此持怀疑态度)这应该会导致:

MNC: 1
MCC: 232

但我一生都无法弄清楚如何从 PLMN 获取结果,那么我该如何解析它?

最佳答案

好吧,我已经发现了这一点,并想我会在这里添加一个答案,以防有其他不幸的灵魂必须这样做 - PDF 名为 GSM Technical Specification (第10.2.4节)包含答案,相关位是:

PLMN Contents: Mobile Country Code (MCC) followed by the Mobile Network Code (MNC). Coding: according to TS GSM 04.08 [14].

  • If storage for fewer than the maximum possible number n is required, the excess bytes shall be set to 'FF'. For instance, using 246 for the MCC and 81 for the MNC and if this is the first and only PLMN, the contents reads as follows: Bytes 1-3: '42' 'F6' '18' Bytes 4-6: 'FF' 'FF' 'FF' etc.

所以我的怀疑是错误的!

我需要从左侧读取,交换数字,因此前两个字节将是MCC,因此将是232f,MNC将是01,然后我只要丢弃 f,我就有 232 和 1!很高兴其中一个已排序。

例如,在 C# 中,您可以这样做:

string plmn = "whatever the plmn is";

string mcc = new string(plmn.Substring(0, 2).Reverse().ToArray())
+ new string(plmn.Substring(2, 2).Reverse().ToArray())
.Replace('f', ' ')
.Trim();

string mnc = new string(plmn.Substring(4, 2).Reverse().ToArray())
.Replace('f', ' ')
.Trim();

关于gsm - 如何从 PLMN 中提取 MCC 和 MNC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10345379/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com