Add a gateway device in Google Cloud Platform (GCP) using IoT Cloud Tester


Gateway devices connect its client devices to the Google Cloud Platform. Gateway devices can authenticate and send data on behalf of its client devices.

IoT Cloud Tester  application provides an easy interface to create gateway devices in Google Cloud platform.

To create a gateway in Google Cloud project,

  • Select the project.
  • In the 'Gateways' tab, select the region, registry and press 'Add Gateway'.
  • Gateway ID is automatically generated but that can be changed.

Following information are required to create a gateway device in Google Cloud,

  • Gateway ID
  • Project ID
  • Cloud Region
  • Registry

To create a gateway in GCP, a post request is made to the below URL. IoT Cloud Tester tool generates the device key for the Gateway and includes it as a post parameter.

Request sent to GCP to create new device registry.

POST:https://cloudiot.googleapis.com/v1/projects/iot-cloud-tutorial/locations/asia-east1/registries/reg_193129/devices

{

"credentials" : [ {

"publicKey" : {

"format" : "RSA_PEM",

"key" : "-----BEGIN PUBLIC KEY-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiYG3gcPCuQZlrhb8M+tQ\r\nxPuQCMQokHFuLJB8OCcM84Q7WCCu+x3rXvFR1i6XMqLVg+b4RdsrNn9Ln1Cr9f8S\r\ne48gcwbNbu0Q24LWUkdgiLhMEVj4llpVYBmxB91/b+8VIZzVzqNjdKoZC9c0s\r\nrtyb0Knm85fxFGcmgJxITSo/JOEYIc+E3h66reG+eJrNAQCnuGADqhm816Q/4xzh\r\nVqXawxhQa+5g1tDrGdbyaPkpNW/ioO8sQUE2Yx2Rcxm85hkQBywThs1kfxylh\r\nhRH9YLbMpt270wK40ALfT8ibRBfa9kL9xMwBAvk4VckkipuR4vhnZQGmdwYLlq4W\r\n1wIDAQAB\r\n-----END PUBLIC KEY-----\r\n"

}

} ],

"gatewayConfig" : {

"gatewayAuthMethod" : "ASSOCIATION_ONLY",

"gatewayType" : "GATEWAY"

},

"id" : "gw_32110"

}

Response for GCP for gateway creation. 

{

"config" : {

"cloudUpdateTime" : "2021-05-05T06:20:56.063326Z",

"version" : 1

},

"credentials" : [ {

"expirationTime" : "1970-01-01T00:00:00Z",

"publicKey" : {

"format" : "RSA_PEM",

"key" : "-----BEGIN PUBLIC KEY-----\r\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiYG3gcPCuQZlrhb8M+tQ\r\nxPuQCMQokHFuLJB8OCcM84Q7WCCu+x3rXvFR1i6XMqLVg+b4RdsrNn9Ln1Cr9f8S\r\ne48gcwbNbu0Q24LVu0oUkdgiLhMEVj4llpVYBmxB91/b+8VIZzVzqNjdKoZC9c0s\r\nrtybm85fxFGcmgJxITSo/JOEYIc+E3h66reG+eJrNAQCnuGADqhm816Q/4xzh\r\nVqXawxbkVhQa+5g1tDrGdbyaPkpNW/ioO8sQUE2Yx2Rcxm85hkQBywThs1kfdsdslh\r\nhRH9YLbMpt270wK40ALfT8ibRBfa9kL9xMwBAvk4VckkipuR4vhnZQGmdwYLlq4W\r\n1wIDAQAB\r\n-----END PUBLIC KEY-----\r\n"

}

} ],

"gatewayConfig" : {

"gatewayAuthMethod" : "ASSOCIATION_ONLY",

"gatewayType" : "GATEWAY"

},

"id" : "gw_32110",

"name" : "projects/iot-cloud-tutorial/locations/asia-east1/registries/reg_193129/devices/3145477801942776",

"numId" : 3145477801942776

}



The added gateway can be viewed in the Google Cloud console.

https://console.cloud.google.com/iot/locations/asia-east1/registries/reg_193129/gateways?project=iot-cloud-tutorial