AITT_OPT_SERVICE_ID, AITT_OPT_LOCATION_ID, AITT_OPT_ROOT_CA, AITT_OPT_CUSTOM_RW_FILE
return use_custom_broker;
}
-void AittOption::SetServiceID(const std::string& id)
+int AittOption::SetServiceID(const std::string& id)
{
- RET_IF(false == use_custom_broker);
+ RETV_IF(false == use_custom_broker, AITT_ERROR_NOT_SUPPORTED);
+
service_id = id;
+
+ return AITT_ERROR_NONE;
}
const char* AittOption::GetServiceID() const
return service_id.c_str();
}
-void AittOption::SetLocationID(const std::string& id)
+int AittOption::SetLocationID(const std::string& id)
{
- RET_IF(false == use_custom_broker);
+ RETV_IF(false == use_custom_broker, AITT_ERROR_NOT_SUPPORTED);
location_id = id;
+ return AITT_ERROR_NONE;
}
const char* AittOption::GetLocationID() const
return location_id.c_str();
}
-void AittOption::SetRootCA(const std::string& ca)
+int AittOption::SetRootCA(const std::string& ca)
{
- RET_IF(false == use_custom_broker);
+ RETV_IF(false == use_custom_broker, AITT_ERROR_NOT_SUPPORTED);
root_ca = ca;
+ return AITT_ERROR_NONE;
}
const char* AittOption::GetRootCA() const
return root_ca.c_str();
}
-void AittOption::SetCustomRWFile(const std::string& file)
+int AittOption::SetCustomRWFile(const std::string& file)
{
- RET_IF(false == use_custom_broker);
+ RETV_IF(false == use_custom_broker, AITT_ERROR_NOT_SUPPORTED);
custom_rw_file = file;
+ return AITT_ERROR_NONE;
}
const char* AittOption::GetCustomRWFile() const
bool GetCleanSession() const;
void SetUseCustomMqttBroker(bool val);
bool GetUseCustomMqttBroker() const;
- void SetServiceID(const std::string &id);
+ int SetServiceID(const std::string &id);
const char *GetServiceID() const;
- void SetLocationID(const std::string &id);
+ int SetLocationID(const std::string &id);
const char *GetLocationID() const;
- void SetRootCA(const std::string &ca);
+ int SetRootCA(const std::string &ca);
const char *GetRootCA() const;
- void SetCustomRWFile(const std::string &file);
+ int SetCustomRWFile(const std::string &file);
const char *GetCustomRWFile() const;
private:
AITT_OPT_CLEAN_SESSION = 2, /**< A Boolean value whether broker clean all message and
subscriptions on disconnect */
AITT_OPT_CUSTOM_BROKER = 3, /**< A Boolean value whether AITT uses a custom broker. */
+ AITT_OPT_SERVICE_ID =
+ 4, /**< Service ID of Custom broker. Must set after @a AITT_OPT_CUSTOM_BROKER */
+ AITT_OPT_LOCATION_ID =
+ 5, /**< Location ID of Custom broker. Must set after @a AITT_OPT_CUSTOM_BROKER */
+ AITT_OPT_ROOT_CA = 6, /**< Root CA of Custom broker. Must set after @a AITT_OPT_CUSTOM_BROKER */
+ AITT_OPT_CUSTOM_RW_FILE =
+ 7, /**< Custom read/write file path. Must set after @a AITT_OPT_CUSTOM_BROKER */
+
} aitt_option_e;
/**
case AITT_OPT_MY_IP:
handle->my_ip = value;
break;
+
case AITT_OPT_CLEAN_SESSION:
ret = _to_boolean(value, bool_val);
if (ret == AITT_ERROR_NONE)
handle->option.SetCleanSession(bool_val);
return ret;
+
case AITT_OPT_CUSTOM_BROKER:
ret = _to_boolean(value, bool_val);
if (ret == AITT_ERROR_NONE)
handle->option.SetUseCustomMqttBroker(bool_val);
return ret;
+
+ case AITT_OPT_SERVICE_ID:
+ return handle->option.SetServiceID(value);
+
+ case AITT_OPT_LOCATION_ID:
+ return handle->option.SetLocationID(value);
+
+ case AITT_OPT_ROOT_CA:
+ return handle->option.SetRootCA(value);
+
+ case AITT_OPT_CUSTOM_RW_FILE:
+ return handle->option.SetCustomRWFile(value);
+
default:
ERR("Unknown option(%d)", option);
return AITT_ERROR_INVALID_PARAMETER;
return (handle->option.GetCleanSession()) ? "true" : "false";
case AITT_OPT_CUSTOM_BROKER:
return (handle->option.GetUseCustomMqttBroker()) ? "true" : "false";
+ case AITT_OPT_SERVICE_ID:
+ return handle->option.GetServiceID();
+ case AITT_OPT_LOCATION_ID:
+ return handle->option.GetLocationID();
+ case AITT_OPT_ROOT_CA:
+ return handle->option.GetRootCA();
+ case AITT_OPT_CUSTOM_RW_FILE:
+ return handle->option.GetCustomRWFile();
default:
ERR("Unknown option(%d)", option);
}
EXPECT_EQ(ret, AITT_ERROR_NONE);
EXPECT_STREQ("true", aitt_option_get(option, AITT_OPT_CUSTOM_BROKER));
+ ret = aitt_option_set(option, AITT_OPT_SERVICE_ID, "service_id");
+ EXPECT_EQ(ret, AITT_ERROR_NONE);
+ EXPECT_STREQ("service_id", aitt_option_get(option, AITT_OPT_SERVICE_ID));
+
+ ret = aitt_option_set(option, AITT_OPT_LOCATION_ID, "location_id");
+ EXPECT_EQ(ret, AITT_ERROR_NONE);
+ EXPECT_STREQ("location_id", aitt_option_get(option, AITT_OPT_LOCATION_ID));
+
+ ret = aitt_option_set(option, AITT_OPT_ROOT_CA, "root_ca");
+ EXPECT_EQ(ret, AITT_ERROR_NONE);
+ EXPECT_STREQ("root_ca", aitt_option_get(option, AITT_OPT_ROOT_CA));
+
+ ret = aitt_option_set(option, AITT_OPT_CUSTOM_RW_FILE, "custom_rw_file");
+ EXPECT_EQ(ret, AITT_ERROR_NONE);
+ EXPECT_STREQ("custom_rw_file", aitt_option_get(option, AITT_OPT_CUSTOM_RW_FILE));
+
ret = aitt_option_set(option, AITT_OPT_CUSTOM_BROKER, nullptr);
EXPECT_EQ(ret, AITT_ERROR_NONE);
EXPECT_STREQ("false", aitt_option_get(option, AITT_OPT_CUSTOM_BROKER));
aitt_option_destroy(option);
}
+TEST(AITT_C_INTERFACE, option_set_Without_Custom_Anytime)
+{
+ aitt_option_h option = aitt_option_new();
+ ASSERT_NE(option, nullptr);
+
+ EXPECT_EQ(AITT_ERROR_NOT_SUPPORTED, aitt_option_set(option, AITT_OPT_SERVICE_ID, "service_id"));
+ EXPECT_EQ(AITT_ERROR_NOT_SUPPORTED,
+ aitt_option_set(option, AITT_OPT_LOCATION_ID, "location_id"));
+ EXPECT_EQ(AITT_ERROR_NOT_SUPPORTED, aitt_option_set(option, AITT_OPT_ROOT_CA, "root_ca"));
+ EXPECT_EQ(AITT_ERROR_NOT_SUPPORTED,
+ aitt_option_set(option, AITT_OPT_CUSTOM_RW_FILE, "custom_rw_file"));
+
+ aitt_option_destroy(option);
+}
+
TEST(AITT_C_INTERFACE, connect_disconnect_P_Anytime)
{
int ret;