c# - How to send basic "Event" Measurement IOT Central (C#)
问题描述
I am struggling to get "Event" type measurements into the IOT central app. I have successfully gotten Telemetry, State, and Location working as far as measurements go. However, when I call SendEventAsync() from my C# app and pass in my event ("shutdown"), I never see any updates for Event in my app.
What is the proper syntax for this type of event?
Currently trying:
Code snippets:
using Microsoft.Azure.Devices.Client;
var eventString = "shutdown";
await Client.SendEventAsync(new Message(Encoding.ASCII.GetBytes(eventString)));
解决方案
Based on the Set up a device template, the Events are the measurement type of the device stream pipeline data, so they are in the name=value format. Specifically for the Event measurements the format is represented as:
nameOfTheEvent = value
where, the value is the string type and can be used for additional info of the event, e.g. reason for shutdown, etc.
In your scenario, the following code snippet shows a message for sending a shutdown event to the Azure IoT Central:
var message = new Message(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { shutdown = "User exited", })));
推荐阅读
- java - 无法通过java中的QueryBuilder将json插入cassandra
- plsql - gsource_nm VARCHAR2(1024) := '$Source: /var/opt/pat/iisi/src/plsql/p_autoeph_hpe.sql,v $';
- python - python xlrd属性错误
- docker - 在 docker 容器中找不到文件
- c++ - TensorFlow c++ API 在 session->run() 上崩溃
- r - 是否可以定义内容根文件夹?
- javascript - 根据输入值更改 href 目标
- jasper-reports - 当我尝试传递我的报告连接时,为什么我无法转换为 net.sf.jasperreports.engine.JRDataSource?
- python - 为给定位置创建房地产价格指数
- javascript - 按间隔对对象数组进行分组