Is it possible to subscribe to Azure IOT Edge Device - azure-iot-hub

Hopefully a simple question, but with all the reading I have done about IOT Edge Devices, I still cannot find an answer.
For my application, I would like to have a local offline view of all the data going into the edge device and an online view from a website. Is it possible to subscribe to all the events in the Edge Device, just like how I am able to subscribe to all the events in the IOT Hub?
Hopefully something like this
Device->IOTEdge->IOTHub->Website
_______________->Local View (offline)

From what I have seen I can use the components to create a website and do this.

If you need a local Azure IoT Edge webpage dashboard then look at Sander van de Velde blog for details and ideas. Sander has also a lot of other very good examples.
https://sandervandevelde.wordpress.com/2018/12/07/create-your-own-local-azure-iot-edge-dashboard/
https://sandervandevelde.wordpress.com/2018/04/20/visualizing-azure-iot-edge-using-local-dashboard/
You just need one nodejs module listening messages from edgeHub and sending messages using websocket connection. Then you can use same or another module to serve static webpage aka your dashboard. You can access this local dashboard from the same local network without any connection to internet. And you can also send your messages to upstream (IoTHub in cloud) and do the same there. I have used nodejs websocket locally in the edge and SignalR to stream data to cloud dashboards.

Related

How to keep streaming if initial client loses connection?

I'm working on an app that streams out multiple presenters via the Agora Live Streaming protocol. Everything works great so long as the person who started the live stream stays connected, however if they lose internet, the stream stops, even if other presenters are still online.
Is there a way to tell the live stream to keep going until "stop live streaming" is called (or all presenters are offline)? My code can handle updating the transcoding config (e.g. video layout) when they go offline.
After multiple discussions with Agora Support, it appears the answer is no, if only using the web SDK, however they are introducing a new server side feature to make this possible.
It's currently in beta, so you'll have to ask Agora Support to enable it for your account, but once you've done so you can create and update an RTMP converter via their server side API instead of relying on the client SDK to manage the stream: https://docs-preprod.agora.io/en/Interactive%20Broadcast/streaming_restful
I'm assuming you're using startLiveStreaming method using the Agora Web SDK. You can attach event listeners on all hosts to listen for primary host's online status, in case the primary host (the host that calls the start method) goes offline - a secondary host can call the start (and transcode) method.
You can also use Agora RTM to signal this status.

Send and receive iot-hub messages

I am working on a project based on the azure sphere kit where I want to control a motor from a web application. I managed to send the command to the iot hub and the build in monitor shows that the message is received by the iot hub. Now, my question is: How can I forward this message to the board? I have to mention that this is my first experience with the iot-hub so please dont judge me if it is a stupid question.:) Here is the confirmation that the message is received by the iothub
If you want to communicate with your Azure Sphere from Azure IoT Hub, you're talking about Cloud-to-device communication. There are three different ways to do this communication:
Direct Methods
Device Twin Desired Properties
Cloud-to-device (C2D) messages
Microsoft documented them here. This document also lists the different considerations for each of the three methods.
To forward the IoT Hub message that you mentioned in your question, a good start would be to write an Azure Function that listens to the IoT Hub output and send that to the device using one of the three methods above. You can find an example for the Azure Function IoT Hub trigger here
Adding few more detailed options in this scenario to the above responses.
Scenario 1: You may be interested in configuring your devices from your back-end service(s) as your web application. To synchronize state information between a device and an IoT hub, you use device twins. A desired property is set by a back-end application and read by a device. A reported property is set by a device and read by a back-end application. A tag is set by a back-end application and is never sent to a device. You use tags to organize your devices. Long-running commands intended to put the device into a certain desired state. For example, set the telemetry send interval to 30 minutes. This completes your E2E state synchronization scenario : Web-Application<=>IoT Device, Ref Link
Question: How can I forward this message to the board?
Scenario 2: You may be interested in direct method to control a device connected to your IoT hub. You can use direct methods to remotely change the behavior of devices connected to your IoT hub. Commands that require immediate confirmation, such as turning on a fan.
Requirements:
-->IoT Device: To receive the direct method calls, the applications running on IoT Device connect to a device-specific endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;DeviceId=MyNodeDevice;SharedAccessKey={YourSharedAccessKey}
-->Web-Application: To call a direct method on a device, your Web application connects to service-side endpoint on your IoT hub.
HostName={YourIoTHubName}.azure-devices.net;SharedAccessKeyName=service;SharedAccessKey={YourSharedAccessKey}
Direct Method calls: Points to be noted. Please visit the link: detailed comparison of the various cloud-to-device communication options.
The maximum direct method payload size is 128 KB.
Disconnected devices are not contacted. The solution back end is notified that the device is not connected.
Ref Link
If you need further help in this matter, please comment in the below section and we will be happy to help you on this forum.

Azure webhook triggers a IoT Hub

I want to make a webhook that can be triggered by either get/post and triggers connected IoT devices to a WebSocket.
So, I thought Azure might help to automize this process, instead of writing everything from scratch and run it on a webserver.
I am very new in the Azure world, I found it very complicated to make it working on Azure.
Can you point me to any simple to make it work?
The first thing to do is to decide where you want to connect your devices to. Generally, you'll either use Azure IoT Hub or IoT Central (which uses an IoT Hub anyway). Your question doesn't include any details about your devices, or whether you're developing them yourself, but I'll assume you can connect to either.
If you go for Azure IoT Central, the easiest way to get a webhook going is to create a Logic App and link nodes together to trigger a Command to your device. You can use an HTTP request as the trigger, and use the built-in IoT Central node to trigger your command, example:
If you end up connecting your devices to IoT Hub, you can use Direct Methods, Cloud to Device messages or even Device Twins to communicate with your devices. You can leverage these by creating an Azure Function with an HTTP trigger, and you program the logic to call IoT Hub, which will communicate with your devices. There are a lot of samples on the web that show how to create Functions, or control your device remotely.
There are a lot of ways to go about your scenario, if you need some help from the Microsoft community, you can get a lot of help on Microsoft Q&A.
Update based on the comments:
In this case, the devices are connected to IoT Hub. You can use the Service SDK to run a job that fires a Direct Method to all currently connected devices. This doc describes the process.

How to connect non-programmable (no SDK) devices to IoT Hub

I am building an IoT solution based on devices that are not programmable (3rd party devices).
I can just configure the server they must connect to and I have the messaging (sending messages and receiving commands).
What is the best way to integrate them in an Azure IoT Solution (IoT Hub) ?
It looks like we can use Azure IoT Edge as Gateway (https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-edge/iot-edge-as-gateway.md) in a "Identity translation" pattern, but I still not figure out how to do it.
I also find Azure IoT Protocol Gateway (https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-protocol-gateway) that seems to do the job but it is not sufficiently clear for me what to do.
Thanks in advance for your help.
The question is which protocols your devices support and how configurable your devices are. For instance you might be able to talk MQTT directly to the IoT Hub without using the SDK: https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support#using-the-mqtt-protocol-directly-as-a-device
Same is possible for HTTP using the REST API directly: https://learn.microsoft.com/en-us/rest/api/iothub/device
If neither is an option then yes, you need some kind of gateway - like in the examples which you linked.

How to create a stun, turn and signaling server

Is there a simple guide from where I can start creating a stun / turn and signaling server ?
I spend over a week searching for those things and couldn't find any guide where I can say:
okay, I am on the right track now - this is clear.
So far, everything is so abstract without any examples.
This is what I'm trying to achieve: a simple video stream on my local network where I'll have a server with installed usb camera on it, and an application on my iis which will connect to the usb camera and stream it to the clients, and every time when a client opens the application, will see the video stream from the server camera.
Note: since I want to use it on my local network do I really need a stun/turn server, or is there a guide that shows how to avoid it ?
Media streamed over dedicated servers HTTP/HTTPS rarely needs a NAT traversal solution. Instead, just have your web server with camera attached, on the public Internet or behind your NAT with port-forwarding enabled.
There are LOTS of streaming media solutions available as open source, free downloads, or commercially sold. A good list is here:
https://en.wikipedia.org/wiki/List_of_streaming_media_systems