Exemplo n.º 1
0
bool updateUltimarcBoard (json_object* jobj)
{
  bool ret = false;

  const char* prodstr = NULL;
  int version = 0;

  json_object* prodobj = NULL;
  json_object* verobj = NULL;

  if (json_object_object_get_ex(jobj, "product", &prodobj) &&
      json_object_get_type(prodobj) == json_type_string)
  {
    if (json_object_object_get_ex(jobj, "version", &verobj) &&
        json_object_get_type(verobj) == json_type_int)
    {
      prodstr = json_object_get_string(prodobj);
      version = json_object_get_int(verobj);

      if (isIPACConfig(prodstr, version, jobj))
      {
        log_info ("Updating IPAC2/MinIPAC board...");
        ret = updateBoardIPAC(jobj);
      }
      else if (isIPAC4Config(prodstr, version, jobj))
      {
        log_info ("Updating IPAC4 board...");
        ret = updateBoardIPAC4(jobj);
      }
      else if (isIPACUltimateConfig(prodstr, version, jobj))
      {
        log_info ("Updating IPAC Ultimate board...");
        ret = updateBoardIPacUltimate(jobj);
      }
      else if (isPACDriveConfig(prodstr, version, jobj))
      {
        log_info ("Updating PAC Drive board...");
        ret = updateBoardPacDrive(jobj);
      }
      else if (isPACLED64Config(prodstr, version, jobj))
      {
        log_info ("Updating PAC LED 64 board...");
        ret = updateBoardPacLED(jobj);
      }
      else if (isUltistikConfig(prodstr, version, jobj))
      {
        log_info ("Updating Ultistik board...");
        ret = updateBoardULTISTIK(jobj);
      }
    }
    else
    {
      if (json_object_object_get_ex(jobj, "version", &verobj))
      {
        log_err ("'version' is not defined as a integer");
      }
      else
      {
        log_err ("'version' is not defined in the configuration file");
      }
    }
  }
  else
  {
    if (json_object_object_get_ex(jobj, "product", &prodobj))
    {
      log_err ("'product' is not defined as a string");
    }
    else
    {
      log_err ("'product' is not defined in the configuration file");
    }
  }

  if (ret)
  {
    log_info ("Update done.\n");
  }
  else
  {
    log_info ("Update failed!\n");
  }

  json_object_put(jobj);
  return ret;
}
Exemplo n.º 2
0
int
ulWriteToBoard (json_object* bcfg, ulboard* board)
{
  int retCode = 0;

  if (bcfg && board)
  {
    if (board->type == ulboard_type_ipac2 ||
        board->type == ulboard_type_ipac4 ||
        board->type == ulboard_type_jpac ||
        board->type == ulboard_type_minipac)
    {
      retCode = updateBoardIPAC (bcfg, board);
    }
    else if (board->type == ulboard_type_ultimate)
    {
      log_info("Updating IPAC Ultimate board...");
      retCode = updateBoardIPacUltimate (bcfg);
    }
    else if (board->type == ulboard_type_pacDrive)
    {
      log_info("Updating PAC Drive board...");
      retCode = updateBoardPacDrive (bcfg);
    }
    else if (board->type == ulboard_type_pacLED)
    {
      log_info("Updating PAC LED 64 board...");
      retCode = updateBoardPacLED (bcfg);
    }
    else if (board->type == ulboard_type_ultistik)
    {
      log_info("Updating Ultistik board...");
      retCode = updateBoardULTISTIK (bcfg, board);
    }
    else if (board->type == ulboard_type_usbbutton)
    {
      log_info("Updating USBButton...");
      retCode = updateUSBButton (bcfg, board);
    }
    else if (board->type == ulboard_type_servostik)
    {
      log_info("Updating ServoStik...");
      retCode = updateServoStik (bcfg, board);
    }

    if (retCode)
    {
      log_info("Board update successful.");
    }
    else
    {
      log_info("Board update failed.");
    }
  }
  else
  {
    retCode = -1;
    log_info("Board update failed.");
  }

  return retCode;
}