void ConfigSoftApWillStart(mico_Context_t * const inContext ) { OSStatus err; mico_uart_config_t uart_config; mico_stop_timer(&_Led_EL_timer); mico_deinit_timer( &_Led_EL_timer ); mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL); mico_start_timer(&_Led_EL_timer); sppProtocolInit(inContext); /*UART receive thread*/ uart_config.baud_rate = inContext->flashContentInRam.appConfig.USART_BaudRate; uart_config.data_width = DATA_WIDTH_8BIT; uart_config.parity = NO_PARITY; uart_config.stop_bits = STOP_BITS_1; uart_config.flow_control = FLOW_CONTROL_DISABLED; ring_buffer_init ( (ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, UART_BUFFER_LENGTH ); MicoUartInitialize( UART_FOR_APP, &uart_config, (ring_buffer_t *)&rx_buffer ); err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART Recv", uartRecv_thread, STACK_SIZE_UART_RECV_THREAD, (void*)inContext ); require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the uart recv thread.") ); if(inContext->flashContentInRam.appConfig.localServerEnable == true){ err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Server", localTcpServer_thread, STACK_SIZE_LOCAL_TCP_SERVER_THREAD, (void*)inContext ); require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the local server thread.") ); } exit: return; }
void mico_system_delegate_config_success( mico_config_source_t source ) { config_delegate_log_trace(); #ifdef USE_MiCOKit_EXT char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'}; #endif config_delegate_log( "Wi-Fi configed by: %d", source ); MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED); #ifdef USE_MiCOKit_EXT memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1); if(CONFIG_BY_AIRKISS == source){ snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Airkiss success "); }else if(CONFIG_BY_SOFT_AP == source){ snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"SoftAP success "); }else if(CONFIG_BY_WAC == source){ snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"WAC success "); }else if( (CONFIG_BY_EASYLINK_V2 == source) || (CONFIG_BY_EASYLINK_PLUS == source) || (CONFIG_BY_EASYLINK_MINUS == source) ){ snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Easylink success"); }else{ snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Unknown "); } OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line); OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)" "); OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)" "); #endif return; }
OSStatus ConfigIncommingJsonMessage( const char *input, mico_Context_t * const inContext ) { OSStatus err = kNoErr; json_object *new_obj; config_delegate_log_trace(); new_obj = json_tokener_parse(input); require_action(new_obj, exit, err = kUnknownErr); config_delegate_log("Recv config object=%s", json_object_to_json_string(new_obj)); mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex); json_object_object_foreach(new_obj, key, val) { if(!strcmp(key, "Device Name")){ strncpy(inContext->flashContentInRam.micoSystemConfig.name, json_object_get_string(val), maxNameLen); }else if(!strcmp(key, "RF power save")){ inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "MCU power save")){ inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Bonjour")){ inContext->flashContentInRam.micoSystemConfig.bonjourEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Wi-Fi")){ strncpy(inContext->flashContentInRam.micoSystemConfig.ssid, json_object_get_string(val), maxSsidLen); inContext->flashContentInRam.micoSystemConfig.channel = 0; memset(inContext->flashContentInRam.micoSystemConfig.bssid, 0x0, 6); inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; memcpy(inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.user_key, maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = inContext->flashContentInRam.micoSystemConfig.user_keyLength; }else if(!strcmp(key, "Password")){ inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; strncpy(inContext->flashContentInRam.micoSystemConfig.key, json_object_get_string(val), maxKeyLen); strncpy(inContext->flashContentInRam.micoSystemConfig.user_key, json_object_get_string(val), maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); inContext->flashContentInRam.micoSystemConfig.user_keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); }else if(!strcmp(key, "DHCP")){ inContext->flashContentInRam.micoSystemConfig.dhcpEnable = json_object_get_boolean(val); }else if(!strcmp(key, "IP address")){ strncpy(inContext->flashContentInRam.micoSystemConfig.localIp, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "Net Mask")){ strncpy(inContext->flashContentInRam.micoSystemConfig.netMask, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "Gateway")){ strncpy(inContext->flashContentInRam.micoSystemConfig.gateWay, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "DNS Server")){ strncpy(inContext->flashContentInRam.micoSystemConfig.dnsServer, json_object_get_string(val), maxIpLen); }/*else if(!strcmp(key, "Baurdrate")){ inContext->flashContentInRam.appConfig.fogcloudConfig.USART_BaudRate = json_object_get_int(val); } */else if(!strcmp(key, "loginId")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.loginId, json_object_get_string(val), MAX_SIZE_LOGIN_ID); } else if(!strcmp(key, "devpasswd")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.devPasswd, json_object_get_string(val), MAX_SIZE_DEV_PASSWD); } else if(!strcmp(key, "userToken")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.userToken, json_object_get_string(val), MAX_SIZE_USER_TOKEN); }else{ } } json_object_put(new_obj); mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex); exit: return err; }
void ConfigSoftApWillStart(mico_Context_t * const inContext ) { OSStatus err; sppProtocolInit(inContext); PlatformUartInitialize(inContext); err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART Recv", uartRecv_thread, 0x500, (void*)inContext ); require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the uart recv thread.") ); if(inContext->flashContentInRam.appConfig.localServerEnable == true){ err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Server", localTcpServer_thread, 0x200, (void*)inContext ); require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the local server thread.") ); } exit: return; }
OSStatus ConfigIncommingJsonMessage( const char *input, mico_Context_t * const inContext ) { OSStatus err = kNoErr; json_object *new_obj; config_delegate_log_trace(); new_obj = json_tokener_parse(input); require_action(new_obj, exit, err = kUnknownErr); config_delegate_log("Recv config object=%s", json_object_to_json_string(new_obj)); mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex); json_object_object_foreach(new_obj, key, val) { if(!strcmp(key, "Device Name")){ strncpy(inContext->flashContentInRam.micoSystemConfig.name, json_object_get_string(val), maxNameLen); }else if(!strcmp(key, "RF power save")){ inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "MCU power save")){ inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Bonjour")){ inContext->flashContentInRam.micoSystemConfig.bonjourEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Wi-Fi")){ strncpy(inContext->flashContentInRam.micoSystemConfig.ssid, json_object_get_string(val), maxSsidLen); inContext->flashContentInRam.micoSystemConfig.channel = 0; memset(inContext->flashContentInRam.micoSystemConfig.bssid, 0x0, 6); inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; memcpy(inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.user_key, maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = inContext->flashContentInRam.micoSystemConfig.user_keyLength; }else if(!strcmp(key, "Password")){ inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; strncpy(inContext->flashContentInRam.micoSystemConfig.key, json_object_get_string(val), maxKeyLen); strncpy(inContext->flashContentInRam.micoSystemConfig.user_key, json_object_get_string(val), maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); inContext->flashContentInRam.micoSystemConfig.user_keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); }else if(!strcmp(key, "Connect SPP Server")){ inContext->flashContentInRam.appConfig.remoteServerEnable = json_object_get_boolean(val); }else if(!strcmp(key, "SPP Server")){ strncpy(inContext->flashContentInRam.appConfig.remoteServerDomain, json_object_get_string(val), 64); }else if(!strcmp(key, "SPP Server Port")){ inContext->flashContentInRam.appConfig.remoteServerPort = json_object_get_int(val); }else if(!strcmp(key, "Baurdrate")){ inContext->flashContentInRam.appConfig.USART_BaudRate = json_object_get_int(val); } } json_object_put(new_obj); mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex); inContext->flashContentInRam.micoSystemConfig.configured = allConfigured; MICOUpdateConfiguration(inContext); exit: return err; }
OSStatus getMVDOTARequestData(const char *input, MVDOTARequestData_t *OTAData) { OSStatus err = kUnknownErr; json_object *new_obj; config_delegate_log_trace(); new_obj = json_tokener_parse(input); require_action(new_obj, exit, err = kUnknownErr); config_delegate_log("Recv OTA request object=%s", json_object_to_json_string(new_obj)); json_object_object_foreach(new_obj, key, val) { if(!strcmp(key, "login_id")){ strncpy(OTAData->loginId, json_object_get_string(val), MAX_SIZE_LOGIN_ID); } else if(!strcmp(key, "dev_passwd")){ strncpy(OTAData->devPasswd, json_object_get_string(val), MAX_SIZE_DEV_PASSWD); } else { } } json_object_put(new_obj); err = kNoErr; exit: return err; }
OSStatus ConfigCreateReportJsonMessage( mico_Context_t * const inContext ) { OSStatus err = kNoErr; config_delegate_log_trace(); char name[50], *tempString; OTA_Versions_t versions; char rfVersion[50]; char *rfVer = NULL, *rfVerTemp = NULL; wlan_driver_version( rfVersion, 50 ); rfVer = strstr(rfVersion, "version "); config_delegate_log("RF version=%s", rfVersion); if(rfVer) rfVer = rfVer + strlen("version "); rfVerTemp = rfVer; for(rfVerTemp = rfVer; *rfVerTemp != ' '; rfVerTemp++); *rfVerTemp = 0x0; if(inContext->flashContentInRam.micoSystemConfig.configured == wLanUnConfigured){ /*You can upload a specific menu*/ } mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex); snprintf(name, 50, "%s(%c%c%c%c%c%c)",MODEL, inContext->micoStatus.mac[9], inContext->micoStatus.mac[10], inContext->micoStatus.mac[12], inContext->micoStatus.mac[13], inContext->micoStatus.mac[15], inContext->micoStatus.mac[16]); versions.fwVersion = FIRMWARE_REVISION; versions.hdVersion = HARDWARE_REVISION; versions.protocol = PROTOCOL; versions.rfVersion = NULL; json_object *sectors, *sector, *subMenuSectors, *subMenuSector, *mainObject; sectors = json_object_new_array(); require( sectors, exit ); err = MICOAddTopMenu(&mainObject, name, sectors, versions); require_noerr(err, exit); /*Sector 1*/ sector = json_object_new_array(); require( sector, exit ); err = MICOAddSector(sectors, "MICO SYSTEM", sector); require_noerr(err, exit); /*name cell*/ err = MICOAddStringCellToSector(sector, "Device Name", inContext->flashContentInRam.micoSystemConfig.name, "RW", NULL); require_noerr(err, exit); //Bonjour switcher cell err = MICOAddSwitchCellToSector(sector, "Bonjour", inContext->flashContentInRam.micoSystemConfig.bonjourEnable, "RW"); require_noerr(err, exit); //RF power save switcher cell err = MICOAddSwitchCellToSector(sector, "RF power save", inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable, "RW"); require_noerr(err, exit); //MCU power save switcher cell err = MICOAddSwitchCellToSector(sector, "MCU power save", inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable, "RW"); require_noerr(err, exit); /*sub menu*/ subMenuSectors = json_object_new_array(); require( subMenuSectors, exit ); err = MICOAddMenuCellToSector(sector, "Detail", subMenuSectors); require_noerr(err, exit); subMenuSector = json_object_new_array(); require( subMenuSector, exit ); err = MICOAddSector(subMenuSectors, "", subMenuSector); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "Firmware Rev.", FIRMWARE_REVISION, "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "Hardware Rev.", HARDWARE_REVISION, "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "MICO OS Rev.", system_lib_version(), "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "RF Driver Rev.", rfVer, "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "Model", MODEL, "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "Manufacturer", MANUFACTURER, "RO", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(subMenuSector, "Protocol", PROTOCOL, "RO", NULL); require_noerr(err, exit); subMenuSector = json_object_new_array(); err = MICOAddSector(subMenuSectors, "WLAN", subMenuSector); require_noerr(err, exit); tempString = DataToHexStringWithColons( (uint8_t *)inContext->flashContentInRam.micoSystemConfig.bssid, 6 ); err = MICOAddStringCellToSector(subMenuSector, "BSSID", tempString, "RO", NULL); require_noerr(err, exit); free(tempString); err = MICOAddNumberCellToSector(subMenuSector, "Channel", inContext->flashContentInRam.micoSystemConfig.channel, "RO", NULL); require_noerr(err, exit); switch(inContext->flashContentInRam.micoSystemConfig.security){ case SECURITY_TYPE_NONE: err = MICOAddStringCellToSector(subMenuSector, "Security", "Open system", "RO", NULL); break; case SECURITY_TYPE_WEP: err = MICOAddStringCellToSector(subMenuSector, "Security", "WEP", "RO", NULL); break; case SECURITY_TYPE_WPA_TKIP: err = MICOAddStringCellToSector(subMenuSector, "Security", "WPA TKIP", "RO", NULL); break; case SECURITY_TYPE_WPA_AES: err = MICOAddStringCellToSector(subMenuSector, "Security", "WPA AES", "RO", NULL); break; case SECURITY_TYPE_WPA2_TKIP: err = MICOAddStringCellToSector(subMenuSector, "Security", "WPA2 TKIP", "RO", NULL); break; case SECURITY_TYPE_WPA2_AES: err = MICOAddStringCellToSector(subMenuSector, "Security", "WPA2 AES", "RO", NULL); break; case SECURITY_TYPE_WPA2_MIXED: err = MICOAddStringCellToSector(subMenuSector, "Security", "WPA2 MIXED", "RO", NULL); break; default: err = MICOAddStringCellToSector(subMenuSector, "Security", "Auto", "RO", NULL); break; } require_noerr(err, exit); if(inContext->flashContentInRam.micoSystemConfig.keyLength == maxKeyLen){ /*This is a PMK key, generated by user key in WPA security type*/ tempString = calloc(maxKeyLen+1, 1); require_action(tempString, exit, err=kNoMemoryErr); memcpy(tempString, inContext->flashContentInRam.micoSystemConfig.key, maxKeyLen); err = MICOAddStringCellToSector(subMenuSector, "PMK", tempString, "RO", NULL); require_noerr(err, exit); free(tempString); } else{ err = MICOAddStringCellToSector(subMenuSector, "KEY", inContext->flashContentInRam.micoSystemConfig.user_key, "RO", NULL); require_noerr(err, exit); } /*DHCP cell*/ err = MICOAddSwitchCellToSector(subMenuSector, "DHCP", inContext->flashContentInRam.micoSystemConfig.dhcpEnable, "RO"); require_noerr(err, exit); /*Local cell*/ err = MICOAddStringCellToSector(subMenuSector, "IP address", inContext->micoStatus.localIp, "RO", NULL); require_noerr(err, exit); /*Netmask cell*/ err = MICOAddStringCellToSector(subMenuSector, "Net Mask", inContext->micoStatus.netMask, "RO", NULL); require_noerr(err, exit); /*Gateway cell*/ err = MICOAddStringCellToSector(subMenuSector, "Gateway", inContext->micoStatus.gateWay, "RO", NULL); require_noerr(err, exit); /*DNS server cell*/ err = MICOAddStringCellToSector(subMenuSector, "DNS Server", inContext->micoStatus.dnsServer, "RO", NULL); require_noerr(err, exit); /*Sector 3*/ sector = json_object_new_array(); require( sector, exit ); err = MICOAddSector(sectors, "WLAN", sector); require_noerr(err, exit); err = MICOAddStringCellToSector(sector, "Wi-Fi", inContext->flashContentInRam.micoSystemConfig.ssid, "RW", NULL); require_noerr(err, exit); err = MICOAddStringCellToSector(sector, "Password", inContext->flashContentInRam.micoSystemConfig.user_key, "RW", NULL); require_noerr(err, exit); /*Sector 4*/ sector = json_object_new_array(); require( sector, exit ); err = MICOAddSector(sectors, "SPP Remote Server", sector); require_noerr(err, exit); // SPP protocol remote server connection enable err = MICOAddSwitchCellToSector(sector, "Connect SPP Server", inContext->flashContentInRam.appConfig.remoteServerEnable, "RW"); require_noerr(err, exit); //Seerver address cell err = MICOAddStringCellToSector(sector, "SPP Server", inContext->flashContentInRam.appConfig.remoteServerDomain, "RW", NULL); require_noerr(err, exit); //Seerver port cell err = MICOAddNumberCellToSector(sector, "SPP Server Port", inContext->flashContentInRam.appConfig.remoteServerPort, "RW", NULL); require_noerr(err, exit); /*Sector 5*/ sector = json_object_new_array(); require( sector, exit ); err = MICOAddSector(sectors, "MCU IOs", sector); require_noerr(err, exit); /*UART Baurdrate cell*/ json_object *selectArray; selectArray = json_object_new_array(); require( selectArray, exit ); json_object_array_add(selectArray, json_object_new_int(9600)); json_object_array_add(selectArray, json_object_new_int(19200)); json_object_array_add(selectArray, json_object_new_int(38400)); json_object_array_add(selectArray, json_object_new_int(57600)); json_object_array_add(selectArray, json_object_new_int(115200)); err = MICOAddNumberCellToSector(sector, "Baurdrate", inContext->flashContentInRam.appConfig.USART_BaudRate, "RW", selectArray); require_noerr(err, exit); inContext->micoStatus.easylink_report = mainObject; mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex); exit: return err; }
OSStatus ConfigIncommingJsonMessage( const char *input, mico_Context_t * const inContext ) { OSStatus err = kNoErr; json_object *new_obj; config_delegate_log_trace(); #ifdef USE_MiCOKit_EXT char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'}; char server_ip[16] = {0}; memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1); snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"FTC... "); OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line); memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1); snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", inet_ntoa(server_ip,inContext->flashContentInRam.micoSystemConfig.easylinkServerIP)); OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line); memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1); snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%16s", (uint8_t*)"Config set..."); OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line); #endif new_obj = json_tokener_parse(input); require_action(new_obj, exit, err = kUnknownErr); config_delegate_log("Recv config object=%s", json_object_to_json_string(new_obj)); mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex); json_object_object_foreach(new_obj, key, val) { if(!strcmp(key, "Device Name")){ strncpy(inContext->flashContentInRam.micoSystemConfig.name, json_object_get_string(val), maxNameLen); }else if(!strcmp(key, "RF power save")){ inContext->flashContentInRam.micoSystemConfig.rfPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "MCU power save")){ inContext->flashContentInRam.micoSystemConfig.mcuPowerSaveEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Bonjour")){ inContext->flashContentInRam.micoSystemConfig.bonjourEnable = json_object_get_boolean(val); }else if(!strcmp(key, "Wi-Fi")){ strncpy(inContext->flashContentInRam.micoSystemConfig.ssid, json_object_get_string(val), maxSsidLen); inContext->flashContentInRam.micoSystemConfig.channel = 0; memset(inContext->flashContentInRam.micoSystemConfig.bssid, 0x0, 6); inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; memcpy(inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.user_key, maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = inContext->flashContentInRam.micoSystemConfig.user_keyLength; }else if(!strcmp(key, "Password")){ inContext->flashContentInRam.micoSystemConfig.security = SECURITY_TYPE_AUTO; strncpy(inContext->flashContentInRam.micoSystemConfig.key, json_object_get_string(val), maxKeyLen); strncpy(inContext->flashContentInRam.micoSystemConfig.user_key, json_object_get_string(val), maxKeyLen); inContext->flashContentInRam.micoSystemConfig.keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); inContext->flashContentInRam.micoSystemConfig.user_keyLength = strlen(inContext->flashContentInRam.micoSystemConfig.key); }else if(!strcmp(key, "DHCP")){ inContext->flashContentInRam.micoSystemConfig.dhcpEnable = json_object_get_boolean(val); }else if(!strcmp(key, "IP address")){ strncpy(inContext->flashContentInRam.micoSystemConfig.localIp, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "Net Mask")){ strncpy(inContext->flashContentInRam.micoSystemConfig.netMask, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "Gateway")){ strncpy(inContext->flashContentInRam.micoSystemConfig.gateWay, json_object_get_string(val), maxIpLen); }else if(!strcmp(key, "DNS Server")){ strncpy(inContext->flashContentInRam.micoSystemConfig.dnsServer, json_object_get_string(val), maxIpLen); }/*else if(!strcmp(key, "Baurdrate")){ inContext->flashContentInRam.appConfig.fogcloudConfig.USART_BaudRate = json_object_get_int(val); } */else if(!strcmp(key, "loginId")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.loginId, json_object_get_string(val), MAX_SIZE_LOGIN_ID); } else if(!strcmp(key, "devpasswd")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.devPasswd, json_object_get_string(val), MAX_SIZE_DEV_PASSWD); } else if(!strcmp(key, "userToken")){ strncpy(inContext->flashContentInRam.appConfig.fogcloudConfig.userToken, json_object_get_string(val), MAX_SIZE_USER_TOKEN); }else{ } } json_object_put(new_obj); mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex); exit: return err; }