Google Cloud IoT Core wird am 16. August 2023 eingestellt. Weitere Informationen erhalten Sie von Ihrem Google Cloud-Account-Management-Team.

Geräteverknüpfung mit Gateway aufheben

Bindung des Geräts an das Gateway aufheben

Codebeispiel

Node.js

Weitere Informationen finden Sie in der Cloud IoT Core Node.js-Referenzdokumentation.

Für die Authentifizierung bei Cloud IoT Core richten Sie Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

// const cloudRegion = 'us-central1';
// const deviceId = 'my-unauth-device';
// const gatewayId = 'my-gateway';
// const projectId = 'adjective-noun-123';
// const registryId = 'my-registry';

console.log(`Unbinding device: ${deviceId}`);

const iot = require('@google-cloud/iot');
const iotClient = new iot.v1.DeviceManagerClient({
  // optional auth parameters.
});

async function unbindDeviceFromGateway() {
  // Construct request
  const regPath = iotClient.registryPath(projectId, cloudRegion, registryId);

  const unbindRequest = {
    parent: regPath,
    deviceId: deviceId,
    gatewayId: gatewayId,
  };

  await iotClient.unbindDeviceFromGateway(unbindRequest);
  console.log(`Unbound ${deviceId} from`, gatewayId);
}

unbindDeviceFromGateway();

Nächste Schritte

Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie unter Google Cloud-Beispielbrowser.