//ipAddress
ipAddress = json_get_string_from_obj(inputObj, SA_CONFIG_NETWORKDATA_IPADDRESS);
if (ipAddress != NULL) {
- memcpy(staticInfo->ipAddress, ipAddress, MIN(strlen(ipAddress), sizeof(staticInfo->ipAddress)-1));
+ _D("ipaddress = %s", ipAddress);
+ memcpy(staticInfo->ipAddress, ipAddress, strlen(ipAddress));
free(ipAddress);
ipAddress = NULL;
-
}
//netmask
}
}
-/* Sample Config */
-/*{"version":"0.1","wifi":{"ssid":"XXXX","password":"XXXXXX","enabled":true,"dhcpEnabled":true,"ipAddress":"127.0.0.1","netmask":"127.0.0.1","defaultGateway":"127.0.0.1","primaryDNSServer":"127.0.0.1","secondaryDNSServer":"127.0.0.1"},"ethernet":{"enabled":false,"dhcpEnabled":true,"ipAddress":"127.0.0.1","netmask":"127.0.0.1","defaultGateway":"127.0.0.1","primaryDnsServer":"127.0.0.1","secondaryDnsServer":"127.0.0.1"},"httpProxyHost":"127.0.0.1","httpProxyPort":8080}*/
+#define FLAG_FILE_SYSTEM "/etc/setup-adaptor/system_executed"
+#define FLAG_FILE_ETH "/etc/setup-adaptor/ethernet_executed"
+#define FLAG_FILE_WIFI "/etc/setup-adaptor/wifi_executed"
+
+void sa_inputfile_remove(void)
+{
+ if (remove(CONFIG_FILE) != 0) {
+ _E("Can't remove file{%s}! %s", CONFIG_FILE, strerror(errno));
+ }
+ else {
+ _D("file removed successfully..{%s}", CONFIG_FILE);
+ }
+}
+
+void sa_inputfile_clear_completion_flag(void)
+{
+ if (remove(FLAG_FILE_SYSTEM) == 0) {
+ _D("file removed successfully..{%s}", FLAG_FILE_SYSTEM);
+ }
+ if (remove(FLAG_FILE_ETH) == 0) {
+ _D("file removed successfully..{%s}", FLAG_FILE_ETH);
+ }
+ if (remove(FLAG_FILE_WIFI) == 0) {
+ _D("file removed successfully..{%s}", FLAG_FILE_WIFI);
+ }
+}
+
+void sa_inputfile_set_completion_flag(sa_file_config_e config_type)
+{
+ int fd;
+
+ switch(config_type)
+ {
+ case SA_FILE_CONFIG_SYSTEM:
+ fd = creat(FLAG_FILE_SYSTEM, NULL);
+ break;
+ case SA_FILE_CONFIG_ETHERNET:
+ fd = creat(FLAG_FILE_ETH, NULL);
+ break;
+ case SA_FILE_CONFIG_WIFI:
+ fd = creat(FLAG_FILE_WIFI, NULL);
+ break;
+ default:
+ _E("unknown parameter (%d)", config_type);
+ break;
+ }
+
+ if(fd == -1) {
+ _E("Can't create file for (%d)! %s", config_type, strerror(errno));
+ }
+}
+
+// return TRUE if set
+gboolean sa_inputfile_get_completion_flag(sa_file_config_e config_type)
+{
+ int ret = 0;
+
+ switch(config_type)
+ {
+ case SA_FILE_CONFIG_SYSTEM:
+ ret = access(FLAG_FILE_SYSTEM, 0);
+ break;
+ case SA_FILE_CONFIG_ETHERNET:
+ ret = access(FLAG_FILE_ETH, 0);
+ break;
+ case SA_FILE_CONFIG_WIFI:
+ ret = access(FLAG_FILE_WIFI, 0);
+ break;
+ case SA_FILE_CONFIG_ALL:
+ ret = access(FLAG_FILE_SYSTEM, 0);
+ if(ret == 0) {
+ ret = access(FLAG_FILE_ETH, 0);
+ }
+ if(ret == 0) {
+ ret = access(FLAG_FILE_WIFI, 0);
+ }
+ break;
+ default:
+ _E("unknown parameter (%d)", config_type);
+ break;
+ }
+ if (ret == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
if (info == NULL) {
return SA_ERROR_INVALID_PARAMETER;
+ } else {
+ if (info->wifi != NULL) {
+ _D("----------- wifi info -----------");
+ _D("info|wifi|enabled(%d)", info->wifi->enabled);
+ _D("info|wifi|dhcpEnabled(%d)", info->wifi->dhcpEnabled);
+ _D("info|wifi|ssid(%s)", info->wifi->ssid);
+ _D("info|wifi|password(%s)", info->wifi->password);
+ if (info->wifi->staticInfo != NULL) {
+ _D("info|wifi|staticInfo|ipAddress(%s)", info->wifi->staticInfo->ipAddress);
+ _D("info|wifi|staticInfo|netmask(%s)", info->wifi->staticInfo->netmask);
+ _D("info|wifi|staticInfo|defaultGateway(%s)", info->wifi->staticInfo->defaultGateway);
+ _D("info|wifi|staticInfo|primaryDnsServer(%s)", info->wifi->staticInfo->primaryDnsServer);
+ _D("info|wifi|staticInfo|secondaryDnsServer(%s)", info->wifi->staticInfo->secondaryDnsServer);
+ }
+ }
+
+ if (info->eth != NULL) {
+ _D("----------- ethernet info -----------");
+ _D("info|eth|enabled(%d)", info->eth->enabled);
+ _D("info|eth|dhcpEnabled(%d)", info->eth->dhcpEnabled);
+ if (info->eth->staticInfo != NULL) {
+ _D("info|eth|staticInfo|ipAddress(%s)", info->eth->staticInfo->ipAddress);
+ _D("info|eth|staticInfo|netmask(%s)", info->eth->staticInfo->netmask);
+ _D("info|eth|staticInfo|defaultGateway(%s)", info->eth->staticInfo->defaultGateway);
+ _D("info|eth|staticInfo|primaryDnsServer(%s)", info->eth->staticInfo->primaryDnsServer);
+ _D("info|eth|staticInfo|secondaryDnsServer(%s)", info->eth->staticInfo->secondaryDnsServer);
+ }
+ }
}
-
-
if (info->eth != NULL) {
// decide whether it will be set according to policy
- if (info->eth->enabled == TRUE){
+ if ( (info->eth->enabled == TRUE) && !sa_inputfile_get_completion_flag(SA_FILE_CONFIG_ETHERNET) ){
retEth = __ethernet_connect_main(info->eth);
_D("return ethernet [%d]", retEth);
}
// 2. if it is connected, read detail info
ret = __network_connect(network);
- // need to delay to sync with setting...
- sleep(2);
- ret = __network_get_state(&conn_state, &conn_type);
- if (ret == SA_ERROR_NONE) {
- _D("Device Network : T[%s] S[%s]", __print_network_type(conn_type), __print_connection_state(conn_state));
- }
-
return ret;
-}
+}