#!/bin/bash

BOARD=`which_board`
ENDPOINT_IP_MASTER="192.168.255.57"
ENDPOINT_IP_SLAVE="192.168.255.58"
ENDPOINT_IP_DEFAULT="localhost"
ENDPOINT_PORT_DEFAULT="61200"

if [ "${BOARD}" == "BOARD_FZM_MASTER" ]; then
  ENDPOINT_IP=${ENDPOINT_IP_MASTER}
elif [ "${BOARD}" == "BOARD_FZM_SLAVE" ]; then
  ENDPOINT_IP=${ENDPOINT_IP_SLAVE}
else
  ENDPOINT_IP=${ENDPOINT_IP_DEFAULT}
fi

if [ "${ENDPOINT_IP}" != "ENDPOINT_IP_DEFAULT" ]; then
  if [ "${1,,}" == "master" ]; then
    syncappmmiclient ${ENDPOINT_IP_MASTER} ${ENDPOINT_PORT_DEFAULT} ${@:2}
  elif [ "${1,,}" == "slave" ]; then
    syncappmmiclient ${ENDPOINT_IP_SLAVE} ${ENDPOINT_PORT_DEFAULT} ${@:2}
  else
    syncappmmiclient ${ENDPOINT_IP} ${ENDPOINT_PORT_DEFAULT} ${@}
  fi
else
  syncappmmiclient ${ENDPOINT_IP} ${ENDPOINT_PORT_DEFAULT} ${@}
fi
