For the complete documentation index, see llms.txt. This page is also available as Markdown.

Script preparation

The RUT951 script that requests update from the B3 SMS server and sends SMS can be downloaded from: https://icuscandinavia060.sharepoint.com/:u:/s/Technicalfile/IQBLvfNYRK6aR5kfklSZT2EpAdJyVcR3MHOhXsXwRdqv3lE?e=lBMVvG

The default RUT951 script is shown below. It must be modified before it is installed on the router.

#!/bin/sh

APIUniqueID="smskafou"
# If you are using Telia SIM with ICU APN you must use IP address - in other cases you need to use top domain.
API_URL="http://rqs.se/api/data/json.asp?id=$APIUniqueID"
#API_URL="http://10.50.33.14/api/data/json.asp?id=$APIUniqueID"
API_KEY="dZucDUygTFJvgCs7QRDx"
INTERVAL=60

while true; do
  # Get SIM/modem status
  OPERATOR=$(gsmctl --operator 2>/dev/null)
  RSSI=$(gsmctl -q 2>/dev/null | grep -o '[0-9-]*')
  ICCID=$(gsmctl --iccid 2>/dev/null)
  IMEI=$(gsmctl --imei 2>/dev/null)

  # Poll API for SMS instruction
  RESPONSE=$(curl -s -H "x-api-key: $API_KEY" "$API_URL")

  CODE=$(echo "$RESPONSE" | awk -F'"code"[[:space:]]*:[[:space:]]*"' '{print $2}' | awk -F'"' '{print $1}')

  SMSNR=""
  TEXT=""

  if [ "$CODE" = "99" ]; then
    logger -t poll_api "Received code 99 - no SMS to send"
  else
    SMSNR=$(echo "$RESPONSE" | awk -F'"smsnr"[[:space:]]*:[[:space:]]*"' '{print $2}' | awk -F'"' '{print $1}')
    TEXT=$(echo "$RESPONSE" | awk -F'"text"[[:space:]]*:[[:space:]]*"' '{print $2}' | awk -F'"' '{print $1}')

    if [ -n "$SMSNR" ]; then
      SAFE_TEXT=$(printf '%s' "$TEXT" | tr '"' "'")
      logger -t poll_api "Sending SMS to $SMSNR: $SAFE_TEXT"
      SMS_RESULT=$(gsmctl -S -s "$SMSNR $SAFE_TEXT" 2>&1)
      logger -t poll_api "gsmctl response: $SMS_RESULT"
    else
      logger -t poll_api "No SMS number found in response"
    fi
  fi

  POST_PAYLOAD=$(cat <<EOP
{
  "custId": "$APIUniqueID",
  "signal_rssi": "$RSSI",
  "operator": "$OPERATOR",
  "iccid": "$ICCID",
  "imei": "$IMEI"
}
EOP
)

  POST_RESULT=$(curl -s -X POST "$API_URL" \
    -H "x-api-key: $API_KEY" \
    -H "Content-Type: application/json" \
    -d "$POST_PAYLOAD")

  logger -t poll_api "POST response: $POST_RESULT"

  sleep "$INTERVAL"
done

There are two places were the script shall be modified:

Last updated