code: def add_callback(self, name, func):
          
  
          if name == 'on_scan':
              events = ['device_seen']
              def callback(_conn_string, _conn_id, _name, event):
                  func(self.id, event, event.get('validity_period', 60))
          elif name == 'on_report':
              events = ['report', 'broadcast']
              def callback(_conn_string, conn_id, _name, event):
                  func(conn_id, event)
          elif name == 'on_trace':
              events = ['trace']
              def callback(_conn_string, conn_id, _name, event):
                  func(conn_id, event)
          elif name == 'on_disconnect':
              events = ['disconnection']
              def callback(_conn_string, conn_id, _name, _event):
                  func(self.id, conn_id)
          else:
              raise ArgumentError("Unknown callback type {}".format(name))
  
          self._adapter.register_monitor([None], events, callback)
docs: Add a callback when device events happen.
  
          Args:
              name (str): currently support 'on_scan' and 'on_disconnect'
              func (callable): the function that should be called