diff --git a/news_to_ismas b/news_to_ismas index 4e00788..53f7eb6 100755 --- a/news_to_ismas +++ b/news_to_ismas @@ -1 +1,60 @@ # !/bin/bash - + +source ./log_helpers + +if [ ${news_to_ismas_sourced:-1} = "1" ]; then # include only once + readonly APISM_DB_PORT=7777 + news_to_ismas () { + local data="#M=APISM#C=CMD_EVENT#J= + { + \"REASON\":\"SW_UP\", + \"Timestamp\":\"$(date +%Y-%m-%dT%T.000%z)\", + \"EVENT\":\"$1\", + \"EVENTSTATE\":1, + \"PARAMETER\":\"Testdaten\" + }" + echo $((echo "$data"; sleep 1) | nc localhost $APISM_DB_PORT) + } + + reset_update_trigger () { + news_to_ismas "U0002" + return $? + } + + # only for testing + set_updates_available () { + news_to_ismas "U99" + return $? + } + + update_started () { + news_to_ismas "U0010" + return $? + } + + update_in_progress () { + news_to_ismas "U0011" + return $? + } + + update_finished () { + news_to_ismas "U0012" + return $? + } + + update_failed () { + news_to_ismas "U0003" + return $? + } + + update_success () { + news_to_ismas "U0001" + return $? + } + + set_update_active () { + reset_update_trigger + return $? + } + +fi