我有以下上下文:
Radio power mode = ON
Current Band = GSM 900, Channel Number = 63
Current RSSI = -95 dBm
Band Selected = Auto
Number of nearby cells = 1
Cell 1
Primary Scrambling Code = 0x1C4
RSCP = -115 dBm, ECIO = -16 dBm
我需要从"当前RSSI"行中提取值,并根据以下列表进行检查:
- > -60 dBM = Solid
- <= –60 to 74 dBm = Very strong signal
- <= –75 to 89 dBm = Strong signal
- <= –90 to 109 dBm = Fair signal
- <= –110 dBm = Unusable signal
您可以使用 regexp 命令从字符串中提取数字。
像这样的东西,也许:
regexp {Current RSSI = ([^ ]+)} $the_data match rssi
如果找到字符串,这将返回1
,因此您可以使用如下条件语句:
if {[regexp ...]} {
# the match was found
...
}
给定您的数据,rssi
应包含字符串"-95"
。然后,您可以将其转换为整数并使用它来计算字符串。
填充两个变量: - 匹配,其中包含总匹配字符串,即"当前RSSI = -95" - RSSI,它只包含正则表达式中括号中的订阅,即 -95。