我有以下背景:
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
答案 0 :(得分:1)
您可以使用regexp命令从字符串中提取数字。
这样的事情,也许是:
regexp {Current RSSI = ([^ ]+)} $the_data match rssi
如果找到字符串,那将返回1
,因此您可以使用这样的条件语句:
if {[regexp ...]} {
# the match was found
...
}
根据您的数据,rssi
应包含字符串"-95"
。然后,您可以将其转换为整数并使用它来计算字符串。
答案 1 :(得分:0)
您填充两个变量: - 匹配,其中包含总匹配字符串,即“当前RSSI = -95” - rssi,它只包含regexp括号中的子括号,即-95。