@@ -214,18 +214,30 @@ class Signal(object):
214
214
def __init__ (
215
215
self ,
216
216
mode = None ,
217
- rssi_dbm = None ):
217
+ rssi_dbm = None ,
218
+ ecio_dbm = None ,
219
+ csq = None ):
218
220
self ._mode = "none" if mode is None else mode
219
221
self ._rssi_dbm = 0 if rssi_dbm is None else rssi_dbm
222
+ self ._ecio_dbm = 0.0 if ecio_dbm is None else ecio_dbm
223
+ self ._csq = 0 if csq is None else csq
220
224
221
225
@property
222
226
def mode (self ):
223
227
return self ._mode
224
228
229
+ @property
230
+ def csq (self ):
231
+ return self ._csq
232
+
225
233
@property
226
234
def rssi_dbm (self ):
227
235
return self ._rssi_dbm
228
236
237
+ @property
238
+ def ecio_dbm (self ):
239
+ return self ._ecio_dbm
240
+
229
241
230
242
class CellularLocation (object ):
231
243
def __init__ (
@@ -248,6 +260,20 @@ def lac(self):
248
260
return self ._lac
249
261
250
262
263
+ class CellularNumber (object ):
264
+ def __init__ (
265
+ self ,
266
+ number = None ):
267
+ if not isinstance (number , str ):
268
+ raise ValueError
269
+
270
+ self ._number = number
271
+
272
+ @property
273
+ def number (self ):
274
+ return self ._number
275
+
276
+
251
277
class CellMgmt (object ):
252
278
"""
253
279
cell_mgmt utilty wrapper
@@ -263,6 +289,10 @@ class CellMgmt(object):
263
289
r"DNS=([0-9\. ]*)\n" )
264
290
_signal_regex = re .compile (
265
291
r"^([\S]+) (-[0-9]+) dbm\n$" )
292
+ _signal_adv_regex = re .compile (
293
+ r"^CSQ: ([0-9]+)\n"
294
+ r"RSSI: ([\S]+) (-[0-9]+) dBm\n"
295
+ r"EcIo: ([\S]+) (-[0-9.]+) dBm\n" )
266
296
_m_info_regex = re .compile (
267
297
r"^Module=([\S ]+)\n"
268
298
r"WWAN_node=([\S]+)\n"
@@ -286,6 +316,9 @@ class CellMgmt(object):
286
316
r"[\n\t ]*PUK1 retries: '([0-9]+)'\n"
287
317
)
288
318
319
+ _number_regex = re .compile (
320
+ r"^([^\n]*)[\n]{0,1}" )
321
+
289
322
_at_response_ok_regex = re .compile (
290
323
r"^[\r\n]*([+\S\s :]*)[\r\n]+OK[\r\n]*$" )
291
324
_at_response_err_regex = re .compile (
@@ -475,6 +508,54 @@ def signal(self):
475
508
# signal out of range
476
509
return Signal ()
477
510
511
+ @critical_section
512
+ @handle_error_return_code
513
+ @retry_on_busy
514
+ def signal_adv (self ):
515
+ """Returns an instance of Signal."""
516
+
517
+ _logger .debug ("cell_mgmt signal_adv" )
518
+
519
+ output = self ._cell_mgmt ("signal_adv" )
520
+ output = str (output )
521
+
522
+ if self ._invoke_period_sec != 0 :
523
+ sleep (self ._invoke_period_sec )
524
+
525
+ match = CellMgmt ._signal_adv_regex .match (output )
526
+ if match :
527
+ return Signal (
528
+ csq = int (match .group (1 )),
529
+ mode = match .group (2 ),
530
+ rssi_dbm = int (match .group (3 )),
531
+ ecio_dbm = float (match .group (5 )))
532
+
533
+ _logger .warning ("unexpected output: " + output )
534
+ # signal out of range
535
+ return Signal ()
536
+
537
+ @critical_section
538
+ @handle_error_return_code
539
+ @retry_on_busy
540
+ def number (self ):
541
+ """Returns an instance of CellularNumber."""
542
+
543
+ _logger .debug ("cell_mgmt number" )
544
+
545
+ output = self ._cell_mgmt ("number" )
546
+ output = str (output )
547
+
548
+ if self ._invoke_period_sec != 0 :
549
+ sleep (self ._invoke_period_sec )
550
+
551
+ match = CellMgmt ._number_regex .match (output )
552
+ if match :
553
+ return CellularNumber (
554
+ number = match .group (1 ))
555
+
556
+ _logger .warning ("unexpected output: " + output )
557
+ return CellularNumber ()
558
+
478
559
@critical_section
479
560
def status (self ):
480
561
"""
0 commit comments