//------------------------------------------------------------------------------------------------------------------------ private void OnAzureIOTHubThingRxMessage(string partition, string data) { DebugEx.TraceLog("On Azure IOT Hub MessageRx"); //deserialize message var payload = data.FromJSON() as Newtonsoft.Json.Linq.JObject; //check name with deviceid if (payload["name"].ToString() != ActiveCfg.AzureInfo.AzureDeviceName) { return; } foreach (var th in Things) { try { //TODO: scan all things and send one batch port event message to the YodiwoCloud //is there any value for the specific thing var y = payload[th.Name]; //send porteventmessage proxyNode.SetState(th, th.Ports[0], y.ToString()); } catch (Exception ex) { DebugEx.TraceError(ex.Message); } } }
//------------------------------------------------------------------------------------------------------------------------ private void OnMqttThingRxMessage(string eventName, string data) { DebugEx.TraceLog("On Mqtt Message Received"); //deserialize message var payload = data.FromJSON() as Newtonsoft.Json.Linq.JObject; //IOTF Compatible json formats var x = payload["d"]; //check name with deviceid if (x["name"].ToString() != ActiveCfg.IBMInfo.IOTFDeviceName) { return; } foreach (var th in Things) { try { //TODO: scan all things and send one batch port event message to the YodiwoCloud //is there any value for the specific thing var y = x[th.Name]; //send porteventmessage proxyNode.SetState(th, th.Ports[0], y.ToString()); } catch (Exception ex) { DebugEx.TraceError(ex.Message); } } }
//------------------------------------------------------------------------------------------------------------------------ private void OnMqttThingRxMessage(string data, string eventName) { try { DebugEx.TraceLog("On Mqtt Message Received"); //deserialize message var payload = data.FromJSON() as Newtonsoft.Json.Linq.JObject; //AWS Compatible json formats var reported = payload["state"]; var datapayload = reported["reported"]; foreach (var th in Things) { try { //TODO: scan all things and send one batch port event message to the YodiwoCloud //is there any value for the specific thing var y = datapayload[th.Name]; //send porteventmessage proxyNode.SetState(th, th.Ports[0], y.ToString()); } catch (Exception ex) { DebugEx.TraceError(ex.Message); } } } catch (Exception ex) { DebugEx.TraceError(ex.Message); } }
//------------------------------------------------------------------------------------------------------------------------ private void OnAzureIOTHubThingRxMessage(string partition, string data) { DebugEx.TraceLog("On Azure IOT Hub MessageRx"); //deserialize message var payload = data.FromJSON <AzureIOTPayoad>(); var th = Things.Find(i => i.Name == payload.ThingName); if (payload.ThingName == "RotaryAngleSensor") { proxyNode.SetState(th, th.Ports[0], payload.RotaryAngleSensor.ToString()); } else if (payload.ThingName == "Light") { proxyNode.SetState(th, th.Ports[0], payload.Light.ToString()); } else if (payload.ThingName == "Button") { proxyNode.SetState(th, th.Ports[0], payload.Button.ToString()); } //check name with deviceid #if false if (payload["name"].ToString() != ActiveCfg.AzureInfo.AzureDeviceName) { return; } foreach (var th in Things) { try { //TODO: scan all things and send one batch port event message to the YodiwoCloud //is there any value for the specific thing var sensor = payload[] var y = payload[th.Name]; //send porteventmessage proxyNode.SetState(th, th.Ports[0], y.ToString()); } catch (Exception ex) { DebugEx.TraceError(ex.Message); } #endif } }
private void Accelerometer_Shaken(Accelerometer sender, AccelerometerShakenEventArgs args) { try { node.SetState(Helper.AccelerometerThing.Ports[4], "true"); } catch (Exception ex) { } }