LabVIEW-Open-Source / LV-MQTT-Broker

Native LabVIEW MQTT Broker Server
Other
47 stars 13 forks source link

Sending data to AWS IoT Core #183

Closed MiguelMar98 closed 7 months ago

MiguelMar98 commented 7 months ago

Hello,

I followed the guide on how to connect to IoT Core through LabVIEW and now I can send message to my thing's shadow. Connection is good. I have some questions regarding how to format the data being published.

I'm monitoring my test topic with the test client on IoT Core and I can see my data but there is this formatting issue..

Test Client Format

This is how the message is being displayed if I publish directly from the test client:

Test Client Format OK

I've tried sending the data straight from a string constant, integer constant, variant data type but with all of those I'm getting the same result.

This is my block diagram, I know that IoT Core sends data on a JSON format, is that the issue with the formatting problem?

Block Diagram

Thank you

MiguelMar98 commented 7 months ago

Oh SORRY I just realised this is meant to be on the Clietn Page not the broker

francois-normandin commented 7 months ago

@MiguelMar98

The method you use to Publish your data is serializing the variant as a flattened LabVIEW string... this is the reason why you see a few funny characters. Here, you have two choices. Either you define a serializer (JSON in this case) or you use the Publish Raw method to send bytes that you have serialized beforehand.

In this video, around the 12th minute, I demonstrate how to change your serializer. Around the 14th minute, this is where I select a different default serializer. https://www.youtube.com/watch?v=Y-jrwyfD9DU

image

Alternatively, instead of publishing with the Variant payload, use this method instead: image

All-in-all, you can use any of these methodologies:

image

francois-normandin commented 7 months ago

This is the serializer you probably want. https://www.vipm.io/package/labview_open_source_project_lib_serializer_jki_json/

MiguelMar98 commented 7 months ago

Thank you again! Using the serializer worked. image

image