"Invalid gcp.key" from Mongoose OS when connecting ESP32 to Google Cloud Platform

Ingrid

I am trying to connect my ESP32 device to Google Cloud Platform (GCP) with Mongoose OS. I am new to Mongoose OS, but have got as far as to build and flash code as well as connection to wifi. But I get problems when I add info to the mos.yml file to connect to GCP. This is the error:

mgos.gcp.c:361 Invalid gcp.key (0xffffc200)

I have created my key pair with the following commands:

openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem
openssl ec -in ec_private.pem -pubout -out ec_public.pem

This is my mos.yml:

author: HiMinds.com
description: Test application for connecting to Google IoT Core via MQTT-bridge
version: 0.1
arch: esp32

libs_version: ${mos.version}
modules_version: ${mos.version}
mongoose_os_version: ${mos.version}

# Optional. List of tags for online search.
tags:

  - js
  - c

# List of files / directories with C sources. No slashes at the end of dir names.
sources:
  - src

# List of dirs. Files from these dirs will be copied to the device filesystem
filesystem:
  - fs

config_schema:
  - ["pins", "o", {title: "Pins layout"}]
  - ["pins.button", "i", 0, {title: "Button GPIO pin"}]
  - ["pins.button_pull_up", "b", true, {title: "True if button is pulled up when inactive"}]
  - ["pins.led", "i", 5, {title: "LED GPIO pin"}]
  - ["wifi.ap.enable", false]
  - ["wifi.sta.enable", true]
  - ["wifi.sta.ssid", "my_SSID"]
  - ["wifi.sta.pass", "my_password"]
  - ["device.id", "esp32"]
  - ["mqtt.enable.", true]
  - ["mqtt.server", "mqtt.googleapis.com:8883"]
  - ["mqtt.ssl_ca_cert", "roots.pem"]
  - ["gcp.enable", true]
  - ["gcp.project", "project_name"]
  - ["gcp.region", "europe-west1"]
  - ["gcp.registry", "registry_name"]
  - ["gcp.device", "esp32"]
  - ["gcp.key", "ec_private.pem"]
  - ["provision.max_state", 3]

libs:
 # - origin: https://github.com/mongoose-os-libs/ca-bundle
  - origin: https://github.com/mongoose-os-libs/core
  - origin: https://github.com/mongoose-os-libs/provision
  - origin: https://github.com/mongoose-os-libs/rpc-service-config
  - origin: https://github.com/mongoose-os-libs/rpc-service-fs
  - origin: https://github.com/mongoose-os-libs/rpc-service-gpio
  - origin: https://github.com/mongoose-os-libs/rpc-uart

  #IoT 
  - origin: https://github.com/mongoose-os-libs/adc
  - origin: https://github.com/mongoose-os-libs/mjs
  - origin: https://github.com/mongoose-os-libs/mqtt
  - origin: https://github.com/mongoose-os-libs/wifi
  - origin: https://github.com/mongoose-os-libs/gcp
  - origin: https://github.com/mongoose-os-libs/sntp

# Used by the mos tool to catch mos binaries incompatible with this file format
manifest_version: 2017-09-29

What am I missing?

I have run mos put full_path_to_key/ec_private.pem to send the key to the device, which works only when I emit the GCP lines from my "mos.yml". Would I need to send the key again after rebuilding and flashing new code including GCP lines? I have also sent a downloaded roots certificate file "roots.pem" (but haven't actually read anywhere that you should send this file to the device).

I am also unsure of if the paths to the key file (and roots.pem file) should be the full ones on my computer, or if they refer to the files on the device itself and it is enough with only the filename without path. None of the options work though.

As a side note, I also get this error, even without the GCP info in mos.yml, if this could have anything to do with it:

MJS error: failed to exec file "api_aws.js": failed to read file "api_aws.js"

Ingrid

So, it turned out I didn't need to set all that GCP info info in "mos.yml", but it was set for me when running

mos gcp-iot-setup --gcp-project YOUR_PROJECT_ID --gcp-region YOUR_REGION --gcp-registry YOUR_REGISTRY

If I tried running this command with the GCP info in mos.yml, I had an error message

Error: write /dev/ttyUSB0: file already closed

So I had to remove the GCP info, then run the command, and the connection was setup!

The key file was generated when running the above command, so no need to transfer it to the device. The roots certificate file also seemed to be handled by the command.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Connecting to An External (outside of Google Cloud Platform) PostgreSQL db from Google Cloud Run

From Dev

ENOENT when connecting to Google Cloud SQL from App Engine

From Java

Error when connecting Spring with Google Cloud SQL

From Dev

Switch ON/OFF Relay from MQTT flespi using mongoose (javascript) + ESP32

From Dev

TypeError when connecting to Google Cloud BigQuery from Apache Beam Dataflow in Python?

From Dev

How to download table from Google Cloud Platform

From Dev

Get token from google cloud platform in salesforce

From Dev

Google cloud platform support plan from API

From Dev

Accessing Google cloud platform from China

From Dev

Connecting to Cloud SQL from Google Cloud Function using Python and SQLAlchemy

From Dev

ESP32 SSL connection works when CA Certificate is a constant, but not when read from a file

From Dev

Google Cloud SQL not connecting

From Dev

ESP32 was connecting earlier but is not connecting to WiFi now with the same code

From Dev

Flutter blue plus library, when trying to read a characteristics from esp32 driver getting PlatformException

From Dev

Connecting Mongoose on Google App Engine

From Dev

Accessing GCP Memorystore from Google Cloud Platform Cloud Shell

From Dev

Deprecation warning when connecting to mongoose

From Dev

Connecting to Google Cloud SQL from App Engine: access denied

From

Trouble connecting to Google Cloud SQL server from deployed app

From Dev

Issue Connecting to Mssql Instance From Google Cloud Function

From Dev

Google Cloud Platform architecture

From Dev

Google Cloud Platform with Firebase

From Dev

Authentication in Google Cloud Platform

From Dev

I need help connecting an ESP32 to Cumulocity

From Dev

How to send from ESP32 to Arduino?

From Dev

DNS when hosting a static website on Google Cloud Platform bucket

From Dev

Unable to run startup script when creating instance on Google Cloud Platform

From Dev

How to access Cloud Platform for a Google Apps Script when the link is missing

From Dev

How to lock state file when using Google Cloud Platform?

Related Related

  1. 1

    Connecting to An External (outside of Google Cloud Platform) PostgreSQL db from Google Cloud Run

  2. 2

    ENOENT when connecting to Google Cloud SQL from App Engine

  3. 3

    Error when connecting Spring with Google Cloud SQL

  4. 4

    Switch ON/OFF Relay from MQTT flespi using mongoose (javascript) + ESP32

  5. 5

    TypeError when connecting to Google Cloud BigQuery from Apache Beam Dataflow in Python?

  6. 6

    How to download table from Google Cloud Platform

  7. 7

    Get token from google cloud platform in salesforce

  8. 8

    Google cloud platform support plan from API

  9. 9

    Accessing Google cloud platform from China

  10. 10

    Connecting to Cloud SQL from Google Cloud Function using Python and SQLAlchemy

  11. 11

    ESP32 SSL connection works when CA Certificate is a constant, but not when read from a file

  12. 12

    Google Cloud SQL not connecting

  13. 13

    ESP32 was connecting earlier but is not connecting to WiFi now with the same code

  14. 14

    Flutter blue plus library, when trying to read a characteristics from esp32 driver getting PlatformException

  15. 15

    Connecting Mongoose on Google App Engine

  16. 16

    Accessing GCP Memorystore from Google Cloud Platform Cloud Shell

  17. 17

    Deprecation warning when connecting to mongoose

  18. 18

    Connecting to Google Cloud SQL from App Engine: access denied

  19. 19

    Trouble connecting to Google Cloud SQL server from deployed app

  20. 20

    Issue Connecting to Mssql Instance From Google Cloud Function

  21. 21

    Google Cloud Platform architecture

  22. 22

    Google Cloud Platform with Firebase

  23. 23

    Authentication in Google Cloud Platform

  24. 24

    I need help connecting an ESP32 to Cumulocity

  25. 25

    How to send from ESP32 to Arduino?

  26. 26

    DNS when hosting a static website on Google Cloud Platform bucket

  27. 27

    Unable to run startup script when creating instance on Google Cloud Platform

  28. 28

    How to access Cloud Platform for a Google Apps Script when the link is missing

  29. 29

    How to lock state file when using Google Cloud Platform?

HotTag

Archive