#!/usr/bin/env bash
#  （设备上报压测）
# ===== Broker 配置 =====
BROKER="your.mqtt.server.ip"
PORT=1883

# ===== 设备配置（纯数字 IMEI）=====
START_IMEI=862538065276000
COUNT=1000        # 设备数量
INTERVAL=10       # 每台设备上报间隔（秒）

echo "Start MQTT pressure test: $COUNT devices, interval=${INTERVAL}s"

for ((i=0; i<COUNT; i++)); do
  (
    DEVICE=$((START_IMEI + i))
    while true; do
      mosquitto_pub -h "$BROKER" -p "$PORT" \
        -t "dtu/${DEVICE}/up" \
        -m '{"jm1g":0,"jm2g":0,"jbg":0,"jm3g":0,"jm2k":0,"jm3k":0,"jbk":0,"jm1k":0}'
      sleep "$INTERVAL"
    done
  ) &
done

wait
