Description
An associated API is available to be invoked on the Milesight Gateway. User can follow the steps below to test the related API by Postman.
Requirement
- Milesight Gateway
- A Windows system computer
- Postman Software
Configuration
Step 1. Download the API command json file at the end of this article.
Step 2. First download and install Postman software from below link by browser: https://www.postman.com/downloads/
Open Postman, click File > Import > Upload File to download and import the API command file.
Step 3. After importing it, we can see the Collection interface generate an API LW_ file .
Step 4. When you click on the first authentication commands , we will get detailed information about the commands in the right text box.
Step 5. Authenticate and obtain a token key.
The IP address of this test gateway is 192.168.23.164, there is a sensor activated on this gateway, here is all its information:
Device name: WS525
Device EUI: 24E124148B137836
Application name: cloud
Change {{LW_IP}} to gateway IP address, click Send, we will receive a token key response soon.
Step 6. Click the eye icon in the upper right corner to create an environment to save all parameter values.
Click Add to create a new environment, name this environment.
Fill in the name and values of all variables as below, then click Save.
IP_LW: The IP address of the gateway, here 192.168.23.164.
takeen: Paste the associated content copied during the login authentication step.
Dev_eui: Sensor EUI enabled in the gateway.
dev_name: name of the sensor device created in the gateway.
app_name: name of the application of this sensor used in the gateway to activate it.
You have finished creating an environment file in the upper right corner.
Step 7. Choose the environment created in step 6, when other commands on the left are chosen, user can click Submit to get response directly.
Example:
1) Get_Devices_ByName
2) Add_Device_Queue
We can send the downlink command associated with the sensor through this API. Click Add_Device_Queue > Body , we can get the related downlink content here:
- confirmed: false or true. When you choose true, the end device will respond to the server with a packet of ACK messages after receiving this downlink command. Otherwise, he won't answer it.
- data: The downlink command to control the corresponding device, obtain it from the user guide or manufacturer of the respective device.
- dev EUI: Paste the device EUI.
- fPort: Port on which LoRaWAN devices receive downlinks. You can check this from the user guide of the respective sensor or the manufacturer. For Milesight terminals, the port is 85 by default.
Here we modify the body content as below to change the reporting interval of WS525 to 1 min:
Then click Send. If we access the gateway web GUI, this time navigate to Network Server > Packets. We will see the gateway receive the downlink packet, then we will soon get an ACK response from the sensor.
Note: The user can obtain the associated downlink command from the sensor manufacturer. Remember to convert the downlink command to Base64 formatted data content first. You can convert the downlink data format form below on the website: https://conv.darkbyte.ru/