#!/bin/sh
# 批量配置设备转义信息
#
echo -en "Content-type: text/html; charset=utf-8\n\n"
#*****************************************************
source ../bin/env.sh
db="../bin/db"
jsoner="../bin/jsoner"
msg="../bin/msg"
dbFile="/work/iot_cfg.db"


read content
 
#echo $content > log

startChn=`$jsoner $content passcode0`
if [ $? -ne 0 ]
then
	echo "{\"code\": \"error\"}" 
	exit
fi
endChn=`$jsoner $content passcode1`
if [ $? -ne 0 ]
then
	echo "{\"code\": \"error\"}" 
	exit
fi

ids=`$jsoner $content devIds`
if [ $? -ne 0 ]
then
	echo "{\"code\": \"error\"}" 
fi


dictType=`$jsoner $content dictType`
if [ $? -eq 0 ]
then
	sqlite3 $dbFile "update escape set dictType=$dictType where id in ($ids) and passcode>=$startChn and passcode<=$endChn"
	if [ $? -ne 0 ]
	then
		echo "{\"code\": \"error\"}"
		echo "dictType exec error " >> log
		exit
	fi
fi

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

