-
My goal is: Use MQTT.pub to publish a payload to a device telemetry event to GCP (a cloud function registers the event)
-
My actions are:
On Mongoose OS side:
let res = MQTT.pub(’/devices/’ + Cfg.get(‘device.id’) + ‘/events’ , JSON.stringify({ a: 1, b: 2 }), 1);
print(‘Published msg:’, res ? ‘yes’ : ‘no’);
On GCP Cloud Function side:
module.exports = functions.region(‘europe-west1’).pubsub.topic(‘bg-topics’).onPublish(async (message, context) => {
console.log('TEST: ’ + JSON.stringify(message));
- The result I see is:
In the GCP cloud function console, I don’t see the payload, only this:
“TEST: {“data”:“XXXXX”,“attributes”:{“deviceId”:“XXXX_XXXXX”,“deviceNumId”:“2831456XXX”,“deviceRegistryId”:“bg-registry”,“deviceRegistryLocation”:“europe-west1”,“projectId”:“XXXX”,“subFolder”:”"}}"
So the payload (message.json) is missing here.
- My expectation & question is:
Why?
Thanks!