code: public String registerDevice(Device device) throws ApiException, IOException {
          boolean alreadySet = this.deviceId != null;
          // If device ID is set and not explicitly asking for a different one, return current ID.
          if (alreadySet && (device == null || this.deviceId.equals(device.getId()))) {
              setDeviceId(this.deviceId);
              return this.deviceId;
          }
  
          // Make sure to unset before attempting, so as not to reuse old ID if it fails.
          this.deviceId = null;
  
          DeviceService.Add req = prepareDeviceRequest(device);
          String id = req.execute().getId();
          setDeviceId(id);
          return this.deviceId;
      }
docs: Registers a device with the same parameters as the provided {@link Device}. This call is
  <b>BLOCKING</b> and should not be called on UI threads. It will make a network call and not
  return until it finishes. If device is null, a new {@link Device} with a random ID and name
  will be generated and its ID returned. If the client already has a device ID set, a null
  device parameter will return the current ID.
  
  @param device A {@link Device} to be registered with iobeam. If ID is not set, a random one
  will be assigned. Its name will also be randomly generated if unassigned, or
  set to the ID if ID is provided but not name.
  @return The device ID associated with this client.
  @throws ApiException Thrown if the iobeam client is not initialized or there are problems
  writing the device ID.
  @throws IOException  Thrown if network errors occur while trying to register.