balena-io-examples / google-iot

Google Cloud IoT integration
Apache License 2.0
15 stars 8 forks source link

Minor fix on start.sh script #2

Closed tmigone closed 4 years ago

tmigone commented 5 years ago

It seems like IoT Core no longer accepts device ID's that start with a number, only letters. Solved it by adding a prefix to the DEVICE_UUID on line 43.

gcloud iot devices create 'balena-'$RESIN_DEVICE_UUID \ --project=$GOOGLE_IOT_PROJECT \ --region=$GOOGLE_IOT_REGION \ --registry=$GOOGLE_IOT_REGISTRY \ --public-key path=rsa-cert.pem,type=rs256

QuanTumli commented 5 years ago

@tomasmigone Thanks for the input! You also need to add the prefix to the NodeJS Script (index.js) in order to successfully publish messages for this device.

https://github.com/balena-io-projects/google-iot/blob/d7ff718e3a454a67dde1420217908cabe6777775/index.js#L11

New line should read:

const deviceId = 'balena-' + process.env.RESIN_DEVICE_UUID;
tmigone commented 4 years ago

Addressed in PR #4