我正在按照https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-monitoring-notifications-with-azure- 中所述的说明使用 Azure 逻辑应用程序创建 IoT 远程监控和通知-逻辑应用程序。
遥测模拟器(Java 使用 com.microsoft.azure.sdk.iot -> iot-device-client -> 1.14.0 版本)
public class SimulatedDevice {
// The device connection string to authenticate the device with your IoT hub.
// Using the Azure CLI:
// az iot hub device-identity show-connection-string --hub-name {YourIoTHubName}
// --device-id MyJavaDevice --output table
private static String connString = "#ConnectionString";
private static IotHubClientProtocol protocol = IotHubClientProtocol.AMQPS;
private static DeviceClient client;
// Specify the telemetry to send to your IoT hub.
private static class TelemetryDataPoint {
public double temperature;
public double humidity;
public String isTrue = "true";
// Serialize object to JSON format.
public String serialize() {
Gson gson = new Gson();
return gson.toJson(this);
}
}
// Print the acknowledgement received from IoT Hub for the telemetry message
// sent.
private static class EventCallback implements IotHubEventCallback {
public void execute(IotHubStatusCode status, Object context) {
System.out.println("IoT Hub responded to message with status: " + status.name());
if (context != null) {
synchronized (context) {
context.notify();
}
}
}
}
对于 QueryString - temperatureAlert = "true" - 一切正常。但是对于查询字符串 - $body.temperature > 30 - 那么我没有收到任何消息。
眼眸繁星
相关分类