@@ -51,6 +51,16 @@ def __repr__(self):
51
51
r += ")"
52
52
return r
53
53
54
+ def module_available (self , excluded_bit : int ) -> bool :
55
+ """Check DeviceMetadata.excluded_modules to see if a module is available."""
56
+ meta = getattr (self .iface , "metadata" , None )
57
+ if meta is None :
58
+ return True
59
+ try :
60
+ return (meta .excluded_modules & excluded_bit ) == 0
61
+ except Exception :
62
+ return True
63
+
54
64
def showChannels (self ):
55
65
"""Show human readable description of our channels."""
56
66
print ("Channels:" )
@@ -441,6 +451,10 @@ def onResponseRequestRingtone(self, p):
441
451
def get_ringtone (self ):
442
452
"""Get the ringtone. Concatenate all pieces together and return a single string."""
443
453
logging .debug (f"in get_ringtone()" )
454
+ if not self .module_available (mesh_pb2 .EXTNOTIF_CONFIG ):
455
+ logging .warning ("External Notification module not present (excluded by firmware)" )
456
+ return None
457
+
444
458
if not self .ringtone :
445
459
p1 = admin_pb2 .AdminMessage ()
446
460
p1 .get_ringtone_request = True
@@ -462,6 +476,9 @@ def get_ringtone(self):
462
476
463
477
def set_ringtone (self , ringtone ):
464
478
"""Set the ringtone. The ringtone length must be less than 230 character."""
479
+ if not self .module_available (mesh_pb2 .EXTNOTIF_CONFIG ):
480
+ logging .warning ("External Notification module not present (excluded by firmware)" )
481
+ return None
465
482
466
483
if len (ringtone ) > 230 :
467
484
our_exit ("Warning: The ringtone must be less than 230 characters." )
@@ -512,6 +529,9 @@ def onResponseRequestCannedMessagePluginMessageMessages(self, p):
512
529
def get_canned_message (self ):
513
530
"""Get the canned message string. Concatenate all pieces together and return a single string."""
514
531
logging .debug (f"in get_canned_message()" )
532
+ if not self .module_available (mesh_pb2 .CANNEDMSG_CONFIG ):
533
+ logging .warning ("Canned Message module not present (excluded by firmware)" )
534
+ return None
515
535
if not self .cannedPluginMessage :
516
536
p1 = admin_pb2 .AdminMessage ()
517
537
p1 .get_canned_message_module_messages_request = True
@@ -537,6 +557,9 @@ def get_canned_message(self):
537
557
538
558
def set_canned_message (self , message ):
539
559
"""Set the canned message. The canned messages length must be less than 200 character."""
560
+ if not self .module_available (mesh_pb2 .CANNEDMSG_CONFIG ):
561
+ logging .warning ("Canned Message module not present (excluded by firmware)" )
562
+ return None
540
563
541
564
if len (message ) > 200 :
542
565
our_exit ("Warning: The canned message must be less than 200 characters." )
0 commit comments