我正在尝试使用 Mongoose OS 将我的 ESP32 设备连接到 Google Cloud Platform (GCP)。我是 Mongoose OS 的新手,但已经完成了构建和闪存代码以及连接到 wifi 的工作。但是当我将信息添加到 mos.yml 文件以连接到 GCP 时出现问题。这是错误:
mgos.gcp.c:361 gcp.key 无效 (0xffffc200)
我使用以下命令创建了我的密钥对:
openssl ecparam -genkey -name prime256v1 -noout -out ec_private.pem
openssl ec -in ec_private.pem -pubout -out ec_public.pem
这是我的 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
我错过了什么?
我已经运行mos put full_path_to_key/ec_private.pem
将密钥发送到设备,这仅在我从“mos.yml”发出 GCP 行时才有效。在重建和刷新包括 GCP 行的新代码后,我是否需要再次发送密钥?我还发送了一个下载的根证书文件“roots.pem”(但实际上还没有读到应该将此文件发送到设备的任何地方)。
我也不确定密钥文件(和roots.pem文件)的路径是否应该是我计算机上的完整路径,或者它们是否引用设备本身上的文件并且仅使用没有路径的文件名就足够了。但是,这些选项都不起作用。
附带说明一下,即使在 mos.yml 中没有 GCP 信息,我也会收到此错误,如果这可能与此有关:
MJS 错误:无法执行文件“api_aws.js”:无法读取文件“api_aws.js”