#!/bin/sh
# 手动解除声光报警
echo -en "Content-type: text/html; charset=utf-8\n\n"
#*****************************************************
source ../bin/env.sh

echo "{\"code\": \"success\"}"

# echo 0 > /usr/local/dev/do1

# 原始字符串
str=`sqlite3 /work/iot_cfg.db "select alarm from alarm;"`

# 移除逗号，生成连续字符序列
clean_str=${str//,/}

# 需要检查的位置列表（1、3、5、7）
positions="0 1 2 3"  # 索引从0开始，对应第1、3、5、7个字符

# 遍历位置并判断
for pos in $positions; do
    char="${clean_str:$pos:1}"  # 提取指定位置的字符
    if [[ "$char" == "1" ]]; then
        actual_pos=$((pos + 1))  # 转换为实际位置（从1计数）
        echo 0 > /usr/local/dev/do$actual_pos
    fi
done