Changes

no edit summary
Line 200: Line 200:     
==Direct methods configuration==
 
==Direct methods configuration==
Direct method is a term that describes process where some action is called from the Azure IoT Hub to a specific device identity. The receiving device executes certain actions and returns an answer back to the Azure portal. Let's see how it works on our devices.  
+
A direct method refers to a process where an action is initiated from the Azure IoT Hub to a specific device identity. The receiving device executes certain actions and returns a response back to the Azure portal. Let's see how this works on our devices.
 +
 
 +
By default, all configuration instances will have this option disabled. To enable it, navigate on the router WebUI to Services -> Cloud Solutions -> Azure IoT Hub and press the edit button on the specific instance. There, you will see the "Enable Direct Methods" button, which you need to press.
   −
By default, all configurations instances will have this option disabled. To enabled it, you should navigate on router WebUI to Services -> Cloud Solutions -> Azure IoT Hub and press edit button on specific instance. There, you will be able to see "Enable Direct Methods" button, which you need to press.
   
[[File:Azure RutOSconf 19.png|border|class=tlt-border]]
 
[[File:Azure RutOSconf 19.png|border|class=tlt-border]]
   −
For testing and demonstration purposes we will use Azure IoT explorer application. The Azure IoT explorer is a graphical tool for interacting with devices connected to your IoT hub. If you are not familiar with it, you can follow this Microsoft installation and usage guide https://learn.microsoft.com/en-us/azure/iot/howto-use-iot-explorer
+
For testing and demonstration purposes, we will use the Azure IoT Explorer application. The Azure IoT Explorer is a graphical tool for interacting with devices connected to your IoT hub. If you are not familiar with it, you can follow this Microsoft installation and usage guide https://learn.microsoft.com/en-us/azure/iot/howto-use-iot-explorer
   −
After enabling the Direct Method feature manually, go to Azure IoT Explorer, select proper device indentity and head to direct methods tab. All our RUT devices supports api_call direct method, which exposes the API interface to be used from the Azure side. In this example, we will call simple get request to retrieve I/O status of the device. Full documentation of Teltonika devices API can be found here https://developers.teltonika-networks.com/
+
After enabling the Direct Method feature, go to Azure IoT Explorer, select the appropriate device identity, and navigate to the Direct Methods tab. All our RUT devices support the api_call direct method, which exposes the API interface to be used from the Azure side. In this example, we will make a simple GET request to retrieve the I/O status of the device. Full documentation of Teltonika devices API can be found here https://developers.teltonika-networks.com/
   −
In the Azure IoT explorer direct method tab you can see Payload field. It expects to have JSON formatted information.
+
In the Azure IoT Explorer Direct Method tab, you will see a Payload field. It expects to receive JSON-formatted information.
    
[[File:Azure RutOSconf 20.png|border|class=tlt-border]]
 
[[File:Azure RutOSconf 20.png|border|class=tlt-border]]
API call expects at least two parameters. The first one is called "method". This needs to have an integer value between zero and three, which corresponds to API method type - either "get", "out", "post", "delete". The second one is endpoint which expects a string value of the API endpoint. In this case we will call the /io/status endpoint.
+
 
 +
The API call expects at least two parameters. The first one is called "method," which needs to have an integer value between zero and three, corresponding to the API method type - either "get", "out", "post", or "delete". The second parameter is "endpoint," which expects a string value of the API endpoint. In this case, we will call the /io/status endpoint.
 +
 
 
[[File:Azure RutOSconf 22.1.png|border|class=tlt-border]]
 
[[File:Azure RutOSconf 22.1.png|border|class=tlt-border]]
   −
After pressing "Invoke Method" button, we can a response from the device.  
+
After pressing the "Invoke Method" button, you will see the response from the device.
 +
 
 
[[File:Azure RutOSconf 21.png|border|class=tlt-border]]
 
[[File:Azure RutOSconf 21.png|border|class=tlt-border]]
 +
 +
The response you see is a standard response as specified in our API documentation.
 +
 +
To determine the appropriate payload and method to use, we provide an additional file currently called "teltonikaGenericDevice.json." This file is written in Digital Twin Definition Language (DTDL). It is similar to SNMP MIB documents by design, as it also describes device capabilities. In this file, you can see that it supports the api_call method, which accepts three values. The request body is optional, as some methods, such as the GET method, may not require it. INSERT FILES!
 +
 +
The IoT Explorer can be configured to parse DTDL files and display them to the user. Let's configure it:
 +
 +
===IoT plug and Play configuration===
 +
 +
To configure it, navigate to the "IoT Plug and Play components" tab on the IoT Explorer. Initially, there may be an error stating that it did not retrieve an interface model. To resolve this, click on the "Configure" button. You will then be able to add a local folder by pressing the "Add" button.
 +
 +
[[File:Azure RutOSconf 23.png|border|class=tlt-border]]
 +
 +
In the specified folder, you must have provided ".json" files. After adding the local folder, press the "Save" button.
 +
 +
After saving these settings, return to the device identity Plug and Play tab. Now, you will be able to see two components with model IDs named "genericDevice" and "deviceInformation". The generic device will display the DTDL interface description.
 +
 +
[[File:Azure RutOSconf 24.png|border|class=tlt-border]]
 +
 +
In the upper toolbar, select the "Commands" tab. There you will see that IoT Explorer has parsed the API call method and created three new fields. Now, we can try to call the same I/O status method that we called previously.
 +
 +
[[File:Azure RutOSconf 25.png|border|class=tlt-border]]
 +
 +
We can see that some information was correctly retrieved from the router, and everything works without any issues. This method makes it much easier to work with API calls from the Azure side.
    
==Checking if Data reaches Azure IoT Hub==
 
==Checking if Data reaches Azure IoT Hub==