code: def add_device(dev):
      
      global DEV_IDX, DEFAULT_DEV
      with DEV_LOCK:
          for idx in range(len(DEVS)):
              test_dev = DEVS[idx]
              if test_dev.dev_name_short == dev.dev_name_short:
                  # This device is already in our list. Delete the old one
                  if test_dev is DEFAULT_DEV:
                      DEFAULT_DEV = None
                  del DEVS[idx]
                  break
          if find_device_by_name(dev.name):
              # This name is taken - make it unique
              dev.name += '-%d' % DEV_IDX
          dev.name_path = '/' + dev.name + '/'
          DEVS.append(dev)
          DEV_IDX += 1
          if DEFAULT_DEV is None:
              DEFAULT_DEV = dev
docs: Adds a device to the list of devices we know about.