Skip to content

Commit

Permalink
MQTT message and control fix for RTSP flipped case (EliasKotlyar#911)
Browse files Browse the repository at this point in the history
* Update mqtt-status-interval.sh

* Update mqtt-control.sh

Updates the X and Y coordinate change mqtt messages according to flip state.

* Update mqtt-status-interval.sh

* Update mqtt-control.sh

* Update mqtt-control.sh

Fixed the mqtt message horizontal and vertical move commands.
  • Loading branch information
sendorm authored and jmtatsch committed Feb 3, 2019
1 parent 134ee4f commit 8d40d2c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
53 changes: 44 additions & 9 deletions firmware_mod/scripts/mqtt-control.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,37 @@ killall mosquitto_sub.bin 2> /dev/null

"${TOPIC}/motors/vertical/set up")
motor up
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status vertical)"
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;

"${TOPIC}/motors/vertical/set down")
motor down
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status vertical)"
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;

"${TOPIC}/motors/vertical/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status vertical)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_Y)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor down $(busybox expr $TARGET \* -1)
Expand All @@ -216,22 +233,40 @@ killall mosquitto_sub.bin 2> /dev/null
echo Requested $COMMAND is not a number
fi
;;

"${TOPIC}/motors/horizontal/set left")
motor left
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)"
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;

"${TOPIC}/motors/horizontal/set right")
motor right
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motor status horizontal)"
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$TARGET"
;;

"${TOPIC}/motors/horizontal/set "*)
COMMAND=$(echo "$line" | awk '{print $2}')
MOTORSTATE=$(motor status horizontal)
if [ -n "$COMMAND" ] && [ "$COMMAND" -eq "$COMMAND" ] 2>/dev/null; then
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
echo Changing motor from $COMMAND to $MOTORSTATE
TARGET=$(busybox expr $MOTORSTATE + $COMMAND - $MAX_X)
else
echo Changing motor from $MOTORSTATE to $COMMAND
TARGET=$(busybox expr $COMMAND - $MOTORSTATE)
fi
echo Moving $TARGET
if [ "$TARGET" -lt 0 ]; then
motor left $(busybox expr $TARGET \* -1)
Expand Down
16 changes: 14 additions & 2 deletions firmware_mod/scripts/mqtt-status-interval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,20 @@ do
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_send_mail status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_telegram ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_send_telegram status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_tracking status)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motor status vertical)"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motor status horizontal)"
MOTORSTATE=$(motor status vertical)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_Y - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
MOTORSTATE=$(motor status horizontal)
if [ `/system/sdcard/bin/setconf -g f` -eq 1 ]; then
TARGET=$(busybox expr $MAX_X - $MOTORSTATE)
else
TARGET=$MOTORSTATE
fi
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$TARGET"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}" ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -r -m "$(/system/sdcard/scripts/mqtt-status.sh)"
sleep $STATUSINTERVAL
done

0 comments on commit 8d40d2c

Please sign in to comment.