Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Register device on Google IoI Core failed on Windows 10

StephenPStephenP United Kingdom

Yesterday I did a new install of Mongoose and google cloud IoT core on windows 10.

All appeared to go well, the following information was obtained from gcloud

Google Cloud SDK [178.0.0]

Platform: [Windows, x86_64] ('Windows', 'Lenovo-PC', '10', '10.0.15063', 'AMD64', 'Intel64 Family 6 Model 69 Stepping 1, GenuineIntel')
Python Version: [2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]]
Python Location: [C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe]
Site Packages: [Disabled]

Installation Root: [C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk]
Installed Components:
core: [2017.10.30]
beta: [2017.09.15]
gsutil: [4.28]
bq: [2.0.27]
Cloud SDK on PATH: [True]
Kubectl on PATH: [False]

Installation Properties: [C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\properties]
User Config Directory: [C:\Users\Stephen\AppData\Roaming\gcloud]
Active Configuration Name: [default]
Active Configuration Path: [C:\Users\Stephen\AppData\Roaming\gcloud\configurations\config_default]

Account: [stephenpeacock.stimulatingpix@gmail.com]
Project: [iot-roberto-proto]

Current Properties:
[core]
project: [iot-roberto-proto]
account: [stephenpeacock.stimulatingpix@gmail.com]
disable_usage_reporting: [False]

Logs Directory: [C:\Users\Stephen\AppData\Roaming\gcloud\logs]
Last Log File: [C:\Users\Stephen\AppData\Roaming\gcloud\logs\2017.11.06\14.05.05.887000.log]

git: [git version 2.6.2.windows.1]
ssh: [NOT AVAILABLE]

I was able to view my project in the google cloud IoT core console.

Then I tried to register my device, using the following command in the MOS termial

gcp-iot-setup --gcp-project iot-roberto-proto --gcp-region europe-west1 --gcp-registry iot-registry

The following was displayed

[Nov 6 17:43:28.999] Connecting to the device...
[Nov 6 17:43:29.327] esp32 30AEA40CE2A0 running iot-kit
[Nov 6 17:43:29.952] Wrote gcp-esp32_0CE2A0.priv.pem
[Nov 6 17:43:29.967] Wrote gcp-esp32_0CE2A0.pub.pem
[Nov 6 17:43:29.967] (Re)creating the cloud device...
[Nov 6 17:44:02.468] gcloud device deletion:
Server Error: {"error":"gcloud device create: : exit status 1"}

The device was not registered in the google cloud IoT core console.

I ran the same command again, and the following was displayed

Nov 6 17:47:08.284] Connecting to the device...
[Nov 6 17:47:08.597] esp32 30AEA40CE2A0 running iot-kit
[Nov 6 17:47:09.081] gcp-esp32_0CE2A0.priv.pem gcp-esp32_0CE2A0.pub.pem exist, skipping generation
[Nov 6 17:47:09.081] (Re)creating the cloud device...
[Nov 6 17:47:11.268] gcloud device deletion:
Server Error: {"error":"gcloud device create: : exit status 1"

Again the device was not registered in the google cloud IoT core console.

I found a number of logs in
C:\Users\Stephen\AppData\Roaming\gcloud\logs\2017.11.06

Each run of the command produced 2 log files, which I have attached.

The first log 'failed' because in could not find the device.
The second log failed because it could not find the key file

InvalidKeyFileError: Could not read key file [gcp-esp32_0CE2A0.pub.pem]:

[Errno 2] No such file or directory: 'gcp-esp32_0CE2A0.pub.pem'
2017-11-06 17:44:04,030 ERROR root (gcloud.beta.iot.devices.create) Could not read key file [gcp-esp32_0CE2A0.pub.pem]:

[Errno 2] No such file or directory: 'gcp-esp32_0CE2A0.pub.pem'
2017-11-06 17:44:04,062 DEBUG root Metrics reporting process started...

The key files were created in the following path

C:\Users\Stephen\AppData\Local\VirtualStore\Program Files (x86)\Google\Cloud SDK

I have examined the other logs from the installation and they appear to be OK.

Can I register the device in the google cloud IoT core console ????

Comments

  • StephenPStephenP United Kingdom

    3rd time lucky !!

    I reconnected my device, flashed iot-kitesp32-1.19.5 , and setup my wifi correctly

    and run the terminal command

    gcp-iot-setup --gcp-project iot-roberto-proto --gcp-region europe-west1 --gcp-registry iot-registry

    The following was displayed

    [Nov 7 12:59:45.007] Connecting to the device...
    [Nov 7 12:59:45.319] esp32 30AEA40CE2A0 running iot-kit
    [Nov 7 12:59:45.819] Wrote gcp-esp32_0CE2A0.priv.pem
    [Nov 7 12:59:45.835] Wrote gcp-esp32_0CE2A0.pub.pem
    [Nov 7 12:59:45.835] (Re)creating the cloud device...
    [Nov 7 13:00:17.163] gcloud device deletion:
    [Nov 7 13:00:19.851] Uploading key...
    Server Error: {"error":"failed to upload gcp-esp32_0CE2A0.priv.pem: The handle is invalid."}

    But when I refreshed the google cloud IoT core console
    the device esp32_0CE2A0 was registered with communication allowed

    The .pem do not appear to have been recreated.

    I have attached the 2 log files it created.

  • StephenPStephenP United Kingdom

    Update !!

    The .pem files have appeared in the following path

    C:\Program Files (x86)\Google\Cloud SDK

  • StephenPStephenP United Kingdom

    did you try to register the device in DOS command prompt or MOS terminal ???

    gooD question, I can not sleep

    Thanked by 1Pourush1
  • Pourush1Pourush1 Pennsylvania

    Hi,

    Can you tell me how did you solve this error? I am in the same situation.

    I tried to register my device, using the following command in the MOS termial

    mos gcp-iot-setup --gcp-project pourush0123 --gcp-region us-central1 --gcp-registry iot-registry

    The following was displayed

    2018-02-12 01:12:51,132 DEBUG root Loaded Command Group: ['gcloud', 'beta', 'iot']
    2018-02-12 01:12:51,132 DEBUG root Loaded Command Group: ['gcloud', 'beta', 'iot', 'devices']
    2018-02-12 01:12:51,454 DEBUG root Loaded Command Group: ['gcloud', 'beta', 'iot', 'devices', 'create']
    2018-02-12 01:12:51,470 DEBUG root Running [gcloud.beta.iot.devices.create] with arguments: [--project: "pourush0123", --public-key: "[{'path': 'gcp-esp32_30844C.pub.pem', 'type': 'es256'}]", --region: "us-central1", --registry: "iot-registry", DEVICE: "esp32_30844C"]
    2018-02-12 01:12:51,486 DEBUG root (gcloud.beta.iot.devices.create) Could not read key file [gcp-esp32_30844C.pub.pem]:

    [Errno 2] No such file or directory: 'gcp-esp32_30844C.pub.pem'
    Traceback (most recent call last):
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\cli.py", line 797, in Execute
    resources = calliope_command.Run(cli=self, args=args)
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\calliope\backend.py", line 757, in Run
    resources = command_instance.Run(args)
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\surface\iot\devices\create.py", line 45, in Run
    messages=client.messages)
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\iot\util.py", line 235, in ParseCredentials
    key.get('expiration-time'), messages=messages))
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\iot\util.py", line 178, in ParseCredential
    contents = _ReadKeyFileFromPath(path)
    File "C:\Users\Pourush\AppData\Local\Google\Cloud SDK\google-cloud-sdk\lib\googlecloudsdk\command_lib\iot\util.py", line 171, in _ReadKeyFileFromPath
    path, err))
    InvalidKeyFileError: Could not read key file [gcp-esp32_30844C.pub.pem]:

    [Errno 2] No such file or directory: 'gcp-esp32_30844C.pub.pem'
    2018-02-12 01:12:51,486 ERROR root (gcloud.beta.iot.devices.create) Could not read key file [gcp-esp32_30844C.pub.pem]:

    [Errno 2] No such file or directory: 'gcp-esp32_30844C.pub.pem'
    2018-02-12 01:12:51,621 DEBUG root Metrics reporting process started...

    I have attached the log file.

  • StephenPStephenP United Kingdom

    Hi Pourush,
    I would not say I have 'solved' the problem.
    I tried to find my log files from November, but unfortunately they are no longer there.
    I think I may have started a DOS command prompt with Administrator privilege and run the MOS command in the DOS window.
    When my device was created in the Google cloud platform, the command returned an error Status.
    If you log into your Google Cloud Console Dashboard, and click on the activity tab, you should see a list of all your activity within the Google Cloud Platform.
    You might be able to identify the cause of the problem from there.

    Best of luck !!!

    Thanked by 1Loïc
Sign In or Register to comment.