QuecManager BETA 1.0.6
- Resolved IMEI Mangling Issue - Optimized Logging and AT Operations: Centralized logging to smd7 and redirected all AT operations to smd11 to prevent request conflicts. - Introduced Cell Locking Scheduler - Fixed SMS Inbox Loading Issue: Addressed a bug where the SMS inbox would get stuck during loading. - Enhanced Speedtest Output: Updated speed test results to display values with two decimal points when reaching GBps speeds. - Changed Link Speed from "Unknown!" to "-" when link is not active - Added 5 second cooldown to speedtest Co-Authored-By: Russel Yasol <73575327+dr-dolomite@users.noreply.github.com>
This commit is contained in:
@@ -36,18 +36,13 @@ if [ ! -f "$CONFIG_FILE" ]; then
|
||||
fi
|
||||
|
||||
# Get AT_PORT with debug logging
|
||||
# Get AT_PORT with debug logging
|
||||
AT_PORT=$(head -n 2 "$CONFIG_FILE" | tail -n 1 | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
|
||||
AT_PORT=$(head -n 1 "$CONFIG_FILE" | cut -d'=' -f2 | tr -d ' \n\r' | sed 's|^dev/||')
|
||||
echo "Raw config line: $(head -n 1 "$CONFIG_FILE")" >> "$DEBUG_LOG"
|
||||
echo "Extracted AT_PORT: '$AT_PORT'" >> "$DEBUG_LOG"
|
||||
|
||||
# List available devices for debugging
|
||||
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
|
||||
|
||||
if [ -z "$AT_PORT" ]; then
|
||||
echo "AT_PORT is empty" >> "$DEBUG_LOG"
|
||||
echo '{"error": "Failed to read AT_PORT from config"}'
|
||||
exit 1
|
||||
output_error "Failed to read AT_PORT from config"
|
||||
fi
|
||||
|
||||
# Check if AT_PORT exists
|
||||
@@ -55,8 +50,7 @@ if [ ! -c "/dev/$AT_PORT" ]; then
|
||||
echo "AT_PORT device not found: /dev/$AT_PORT" >> "$DEBUG_LOG"
|
||||
echo "Available smd devices:" >> "$DEBUG_LOG"
|
||||
ls -l /dev/smd* >> "$DEBUG_LOG" 2>&1
|
||||
echo '{"error": "AT_PORT device not found"}'
|
||||
exit 1
|
||||
output_error "AT_PORT device not found"
|
||||
fi
|
||||
|
||||
# Write the command directly to the input file
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Configuration
|
||||
CONFIG_FILE="/etc/cell_lock_schedule.conf"
|
||||
STATUS_FILE="/tmp/cell_lock_status"
|
||||
CELL_LOCK_SCRIPT="/usr/bin/set_cell_lock.sh"
|
||||
|
||||
# Function to create set_cell_lock.sh script
|
||||
create_cell_lock_script() {
|
||||
# Only create the script if it doesn't exist
|
||||
if [ ! -f "$CELL_LOCK_SCRIPT" ]; then
|
||||
cat >"$CELL_LOCK_SCRIPT" <<'EOL'
|
||||
#!/bin/sh
|
||||
ACTION=$1
|
||||
LTE_PARAMS=$2
|
||||
NR5G_PARAMS=$3
|
||||
|
||||
case "$ACTION" in
|
||||
enable)
|
||||
# Enable LTE lock if parameters exist
|
||||
if [ -n "$LTE_PARAMS" ]; then
|
||||
echo "AT+QNWLOCK=\"common/4g\",$LTE_PARAMS" | atinout - /dev/smd11 -
|
||||
fi
|
||||
|
||||
# Enable NR5G lock if parameters exist
|
||||
if [ -n "$NR5G_PARAMS" ]; then
|
||||
echo "AT+QNWLOCK=\"common/5g\",$NR5G_PARAMS" | atinout - /dev/smd11 -
|
||||
fi
|
||||
;;
|
||||
|
||||
disable)
|
||||
# Disable LTE lock
|
||||
echo 'AT+QNWLOCK="common/4g",0' | atinout - /dev/smd11 -
|
||||
|
||||
# Disable NR5G lock
|
||||
echo 'AT+QNWLOCK="common/5g",0' | atinout - /dev/smd11 -
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Invalid action"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Restart network registration to apply changes
|
||||
echo "AT+COPS=2" | atinout - /dev/smd11 -
|
||||
sleep 2
|
||||
echo "AT+COPS=0" | atinout - /dev/smd11 -
|
||||
exit 0
|
||||
EOL
|
||||
|
||||
# Make the script executable
|
||||
chmod +x "$CELL_LOCK_SCRIPT"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to remove set_cell_lock.sh script
|
||||
remove_cell_lock_script() {
|
||||
if [ -f "$CELL_LOCK_SCRIPT" ]; then
|
||||
rm "$CELL_LOCK_SCRIPT"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to urldecode
|
||||
urldecode() {
|
||||
echo -e "$(echo "$1" | sed 's/+/ /g;s/%\([0-9A-F][0-9A-F]\)/\\x\1/g')"
|
||||
}
|
||||
|
||||
# Function to convert HH:MM to cron format
|
||||
convert_to_cron_time() {
|
||||
echo "$1" | awk -F: '{print $2, $1}'
|
||||
}
|
||||
|
||||
# Function to save configuration
|
||||
save_config() {
|
||||
echo "START_TIME=$1" >"$CONFIG_FILE"
|
||||
echo "END_TIME=$2" >>"$CONFIG_FILE"
|
||||
echo "ENABLED=1" >>"$CONFIG_FILE"
|
||||
}
|
||||
|
||||
# Function to disable scheduling
|
||||
disable_scheduling() {
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
sed -i 's/ENABLED=1/ENABLED=0/' "$CONFIG_FILE"
|
||||
fi
|
||||
# Remove any existing cron jobs
|
||||
crontab -l | grep -v "set_cell_lock.sh" | crontab -
|
||||
# Remove the set_cell_lock.sh script
|
||||
remove_cell_lock_script
|
||||
}
|
||||
|
||||
# Function to get current status
|
||||
get_status() {
|
||||
if [ -f "$CONFIG_FILE" ]; then
|
||||
ENABLED=$(grep "ENABLED=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
START_TIME=$(grep "START_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
END_TIME=$(grep "END_TIME=" "$CONFIG_FILE" | cut -d'=' -f2)
|
||||
|
||||
echo "Status: 200 OK"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"enabled\":$ENABLED,\"start_time\":\"$START_TIME\",\"end_time\":\"$END_TIME\"}"
|
||||
else
|
||||
echo "Status: 200 OK"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"enabled\":0,\"start_time\":\"\",\"end_time\":\"\"}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle POST requests
|
||||
if [ "$REQUEST_METHOD" = "POST" ]; then
|
||||
# Read POST data
|
||||
read -r POST_DATA
|
||||
|
||||
# Check if disabling is requested
|
||||
echo "$POST_DATA" | grep -q "disable=true"
|
||||
if [ $? -eq 0 ]; then
|
||||
disable_scheduling
|
||||
echo "Status: 200 OK"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"status\":\"success\",\"message\":\"Scheduling disabled\"}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract start and end times
|
||||
START_TIME=$(echo "$POST_DATA" | grep -o 'start_time=[^&]*' | cut -d'=' -f2)
|
||||
END_TIME=$(echo "$POST_DATA" | grep -o 'end_time=[^&]*' | cut -d'=' -f2)
|
||||
|
||||
# Decode times
|
||||
START_TIME=$(urldecode "$START_TIME")
|
||||
END_TIME=$(urldecode "$END_TIME")
|
||||
|
||||
# Validate times
|
||||
if [ -z "$START_TIME" ] || [ -z "$END_TIME" ]; then
|
||||
echo "Status: 400 Bad Request"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"error\":\"Missing start or end time\"}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create set_cell_lock.sh script
|
||||
create_cell_lock_script
|
||||
|
||||
# Convert times to cron format
|
||||
CRON_START=$(convert_to_cron_time "$START_TIME")
|
||||
CRON_END=$(convert_to_cron_time "$END_TIME")
|
||||
|
||||
# Save configuration
|
||||
save_config "$START_TIME" "$END_TIME"
|
||||
|
||||
# Check current cell lock status and get parameters
|
||||
LTE_STATUS=$(echo 'AT+QNWLOCK="common/4g"' | atinout - /dev/smd11 -)
|
||||
NR5G_STATUS=$(echo 'AT+QNWLOCK="common/5g"' | atinout - /dev/smd11 -)
|
||||
|
||||
# Extract LTE parameters if locked
|
||||
LTE_PARAMS=$(echo "$LTE_STATUS" | grep -o '"common/4g",[^[:space:]]*' | cut -d',' -f2-)
|
||||
NR5G_PARAMS=$(echo "$NR5G_STATUS" | grep -o '"common/5g",[^[:space:]]*' | cut -d',' -f2-)
|
||||
|
||||
# Create temporary file for new crontab
|
||||
TEMP_CRON=$(mktemp)
|
||||
|
||||
# Get existing crontab entries (excluding our script)
|
||||
crontab -l 2>/dev/null | grep -v "set_cell_lock.sh" >"$TEMP_CRON"
|
||||
|
||||
# Add new entries
|
||||
echo "$CRON_START * * * $CELL_LOCK_SCRIPT enable \"$LTE_PARAMS\" \"$NR5G_PARAMS\"" >>"$TEMP_CRON"
|
||||
echo "$CRON_END * * * $CELL_LOCK_SCRIPT disable" >>"$TEMP_CRON"
|
||||
|
||||
# Install new crontab
|
||||
crontab "$TEMP_CRON"
|
||||
rm "$TEMP_CRON"
|
||||
|
||||
echo "Status: 200 OK"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"status\":\"success\",\"message\":\"Scheduling enabled\"}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Parse query string for GET requests
|
||||
if [ "$REQUEST_METHOD" = "GET" ]; then
|
||||
QUERY_STRING=$(echo "$QUERY_STRING" | sed 's/&/\n/g')
|
||||
for param in $QUERY_STRING; do
|
||||
case "$param" in
|
||||
status=*)
|
||||
get_status
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
# If no valid request is made
|
||||
echo "Status: 400 Bad Request"
|
||||
echo "Content-Type: application/json"
|
||||
echo ""
|
||||
echo "{\"error\":\"Invalid request\"}"
|
||||
exit 1
|
||||
@@ -5,4 +5,4 @@ echo "Content-Type: application/json"
|
||||
echo
|
||||
|
||||
# Read the JSON file and get only the last entry using jq
|
||||
jq 'last' /tmp/signal_graphs/data_usage.json
|
||||
jq 'last' /www/signal_graphs/data_usage.json
|
||||
@@ -5,7 +5,7 @@ echo "Content-Type: application/json"
|
||||
echo ""
|
||||
|
||||
# Directory where JSON files are stored (adjust as needed)
|
||||
JSON_DIR="/tmp/signal_graphs/"
|
||||
JSON_DIR="/www/signal_graphs/"
|
||||
|
||||
# Function to safely read JSON file
|
||||
read_json_file() {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Ensure the directory exists
|
||||
LOGDIR="/tmp/signal_graphs"
|
||||
LOGDIR="/www/signal_graphs"
|
||||
mkdir -p "$LOGDIR"
|
||||
|
||||
# Maximum number of entries
|
||||
MAX_ENTRIES=10
|
||||
|
||||
# Interval between logs (in seconds)
|
||||
INTERVAL=25
|
||||
INTERVAL=15
|
||||
|
||||
# Function to clean and extract actual output from atinout
|
||||
clean_atinout_output() {
|
||||
@@ -66,7 +66,7 @@ log_data_usage() {
|
||||
TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# Run the AT command and capture its output, then clean it
|
||||
DATA_OUTPUT=$(echo "AT+QGDCNT?;+QGDNRCNT?" | atinout - /dev/smd7 - | clean_atinout_output)
|
||||
DATA_OUTPUT=$(echo "AT+QGDCNT?;+QGDNRCNT?" | atinout - /dev/smd11 - | clean_atinout_output)
|
||||
|
||||
# Ensure the file exists and is a valid JSON array
|
||||
if [ ! -s "$LOGFILE" ]; then
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script to configure SMS text mode on a modem device
|
||||
# Usage: ./sms_config.sh
|
||||
|
||||
# Check if atinout is installed
|
||||
if ! command -v atinout &> /dev/null; then
|
||||
echo "Error: atinout is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the device exists
|
||||
if [ ! -c "/dev/smd11" ]; then
|
||||
echo "Error: Device /dev/smd11 not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Send AT command to set SMS text mode
|
||||
if ! echo "AT+CMGF=1" | atinout - /dev/smd11 -; then
|
||||
echo "Error: Failed to send AT command"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Successfully configured SMS text mode"
|
||||
Reference in New Issue
Block a user