@@ -51,6 +51,16 @@ def __repr__(self):
5151 r += ")"
5252 return r
5353
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+
5464 def showChannels (self ):
5565 """Show human readable description of our channels."""
5666 print ("Channels:" )
@@ -441,6 +451,10 @@ def onResponseRequestRingtone(self, p):
441451 def get_ringtone (self ):
442452 """Get the ringtone. Concatenate all pieces together and return a single string."""
443453 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+
444458 if not self .ringtone :
445459 p1 = admin_pb2 .AdminMessage ()
446460 p1 .get_ringtone_request = True
@@ -462,6 +476,9 @@ def get_ringtone(self):
462476
463477 def set_ringtone (self , ringtone ):
464478 """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
465482
466483 if len (ringtone ) > 230 :
467484 our_exit ("Warning: The ringtone must be less than 230 characters." )
@@ -512,6 +529,9 @@ def onResponseRequestCannedMessagePluginMessageMessages(self, p):
512529 def get_canned_message (self ):
513530 """Get the canned message string. Concatenate all pieces together and return a single string."""
514531 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
515535 if not self .cannedPluginMessage :
516536 p1 = admin_pb2 .AdminMessage ()
517537 p1 .get_canned_message_module_messages_request = True
@@ -537,6 +557,9 @@ def get_canned_message(self):
537557
538558 def set_canned_message (self , message ):
539559 """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
540563
541564 if len (message ) > 200 :
542565 our_exit ("Warning: The canned message must be less than 200 characters." )
0 commit comments