Changes

m
Fixed the line break for Example 1 - Final
Line 86: Line 86:  
After that, it checks if the value stored in the '''‘value’''' variable is equal to 0. If it is, the '''‘ubus’''' command is used to call the '''‘ioman.gpio.onewire’''' service and execute the ‘update’ command, which updates the ‘value’ parameter to 1.
 
After that, it checks if the value stored in the '''‘value’''' variable is equal to 0. If it is, the '''‘ubus’''' command is used to call the '''‘ioman.gpio.onewire’''' service and execute the ‘update’ command, which updates the ‘value’ parameter to 1.
 
[[File:Networking trb user scripts cli code explanation2.png|border|class=tlt-border]]
 
[[File:Networking trb user scripts cli code explanation2.png|border|class=tlt-border]]
      
This line sets the ‘BASE_DIR’ variable to the base directory for 1-wire devices.
 
This line sets the ‘BASE_DIR’ variable to the base directory for 1-wire devices.
    
[[File:Networking trb user scripts cli code explanation3.png|border|class=tlt-border]]
 
[[File:Networking trb user scripts cli code explanation3.png|border|class=tlt-border]]
      
This line sets up a ‘for’ loop to iterate through all directories in ‘$BASE_DIR’ that start with ’28-‘, which is the prefix for 1-wire temperature sensors.
 
This line sets up a ‘for’ loop to iterate through all directories in ‘$BASE_DIR’ that start with ’28-‘, which is the prefix for 1-wire temperature sensors.
Line 98: Line 96:     
[[File:Networking trb user scripts cli code explanation4.png|border|class=tlt-border]]
 
[[File:Networking trb user scripts cli code explanation4.png|border|class=tlt-border]]
      
This block reads the temperature data from the device file '''‘$sensor_dir/w1_slave’''' and extracts the raw temperature value using '''‘grep’''' and '''‘awk’'''. The temperature value is encoded as an integer.
 
This block reads the temperature data from the device file '''‘$sensor_dir/w1_slave’''' and extracts the raw temperature value using '''‘grep’''' and '''‘awk’'''. The temperature value is encoded as an integer.
Line 104: Line 101:  
Which then converts the raw temperature value to degrees Celsius by dividing it by 1000 and then formatting it with two decimal places using '''‘printf’'''. The resulting temperature value is stored in the '''‘temp’''' variable.
 
Which then converts the raw temperature value to degrees Celsius by dividing it by 1000 and then formatting it with two decimal places using '''‘printf’'''. The resulting temperature value is stored in the '''‘temp’''' variable.
   −
[[File:Networking trb user scripts cli code explanation5.png|left|border|class=tlt-border]]
+
[[File:Networking trb user scripts cli code explanation5.png|border|class=tlt-border]]
 
  −
 
  −
 
  −
 
  −
 
      
These lines define the URL of the server to which the temperature data will be sent and the payload data that will be sent with each request. The payload includes the '''‘sensor_id’''' and '''‘temp’''' variables, formatted as a JSON object.
 
These lines define the URL of the server to which the temperature data will be sent and the payload data that will be sent with each request. The payload includes the '''‘sensor_id’''' and '''‘temp’''' variables, formatted as a JSON object.
   −
[[File:Networking trb user scripts cli code explanation6.png|left]]
+
[[File:Networking trb user scripts cli code explanation6.png|border|class=tlt-border]]
 
  −
 
  −
 
  −
 
  −
 
      
This line uses the '''‘curl’''' command to send an HTTP POST request to the server specified by '''‘$SERVER_URL’'''. The '''‘-X POST’''' option specifies that the request should be a POST request, and the '''‘-H “Content-Type: application/json”’''' option specifies that the payload data is in JSON format. The '''‘-d “$PAYLOAD”’''' option specifies the payload data to be sent with the request.
 
This line uses the '''‘curl’''' command to send an HTTP POST request to the server specified by '''‘$SERVER_URL’'''. The '''‘-X POST’''' option specifies that the request should be a POST request, and the '''‘-H “Content-Type: application/json”’''' option specifies that the payload data is in JSON format. The '''‘-d “$PAYLOAD”’''' option specifies the payload data to be sent with the request.
   −
[[File:Networking trb user scripts cli code explanation7.png|left]]
+
[[File:Networking trb user scripts cli code explanation7.png|border|class=tlt-border]]
 
  −
 
  −
 
  −
 
  −
 
  −
 
      
=== Output ===
 
=== Output ===
[[File:Networking trb user scripts HTTP listener screenshot.png|left|800x800px]]
+
[[File:Networking trb user scripts HTTP listener screenshot.png|800x800px|border|class=tlt-border]]]
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
  −
 
      
Run the script by entering the file path of the file or '''./<filename>.sh''' if you are in the same directory.
 
Run the script by entering the file path of the file or '''./<filename>.sh''' if you are in the same directory.

Navigation menu