Skip to main content
. 2025 Jul 30;25(15):4701. doi: 10.3390/s25154701
Listing 3. Share: service temperature_alert.
temperature_alert = Service.new("2.5.8.3.1", -- declaration service
  function(temp, threshold) -- function
  --send temp and threshold to daemon and receive result value
  end,
  function() -- daemon
    local temp_check = Feature.new(
      "2.5.8.4.*", --RExp
      function(temp, threshold)
        return temp >= threshold
    end --postcondition
     )
    --receive parameters from function using inner protocol
    local alert, ok = temp_check.call(temp, threshold)
    --send result value alert to function using inner protocol
  end,
  function(temp, threshold)
    return temp >= -50 and
    temp <= 150 and
    threshold > 0
  end
) --precondition
deviceA = Share.new(myIp)
deviceA.attach(temperature_alert)