std::string ControlSettings::to_string() { Json::Value root; set_if(root, "beerSet", beerSetting, 0.0); set_if(root, "fridgeSet", fridgeSetting, 0.0); set_if(root, "heatEst", heatEstimator, 0.0); set_if(root, "coolEst", coolEstimator, 0.0); set_if(root, "mode", static_cast<char>(mode), static_cast<char>(Mode::Null)); return Json::FastWriter().write(root); }
std::string Temperatures::to_string() { Json::Value root; set_if(root, "BeerTemp", beerReading, 0.0); set_if(root, "BeerSet", beerSetting, 0.0); set_if_not_empty(root, "BeerAnn", beerAnnotation); set_if(root, "FridgeTemp", fridgeReading, 0.0); set_if(root, "FridgeSet", fridgeSetting, 0.0); set_if_not_empty(root, "FridgeAnn", fridgeAnnotation); set_if(root, "State", static_cast<int>(state), static_cast<int>(Temperatures::State::Null)); return Json::FastWriter().write(root); }
int cmd_ifconfig(int argc, char** argv) { extern void list_if(void); extern void set_if(char* netif_name, char* ip_addr, char* gw_addr, char* nm_addr); if(argc == 1) { list_if(); } else if(argc == 5) { rt_kprintf("config : %s\n", argv[1]); rt_kprintf("IP addr: %s\n", argv[2]); rt_kprintf("Gateway: %s\n", argv[3]); rt_kprintf("netmask: %s\n", argv[4]); set_if(argv[1], argv[2], argv[3], argv[4]); } else { rt_kprintf("bad parameter! e.g: ifconfig e0 192.168.1.30 192.168.1.1 255.255.255.0\n"); } return 0; }
ms_MediaCode ms_find_code_from_name(const char *name, const ms_Flag *user_flag_list) { const char *end; char stripped_name[LONGER_THAN_NAMES]; static const ms_SizeDescription *sorted_list[array_size(list) - 1]; static unsigned int entries = 0; ms_SizeDescription keydata, *key = &keydata; const ms_SizeDescription **found; ms_MediaCode flags = 0; size_t l; /* On the first use of this function, compile a table of pointers into the list which is sorted by the names of the sizes. */ if (entries == 0) { while (entries < array_size(sorted_list)) { sorted_list[entries] = list + entries + 1; /* ignore 'ms_none' */ entries++; } qsort(sorted_list, array_size(sorted_list), sizeof(ms_SizeDescription *), &cmp_by_name); } /* Prevent idiots (like myself) from crashing the routine */ if (name == NULL) return ms_none; /* Identify trailing qualifiers */ end = strchr(name, '.'); /* before first qualifier */ if (end == NULL) end = strchr(name, '\0'); else { const char *s = end, *t; do { ms_MediaCode flag; s++; if ((t = strchr(s, '.')) == NULL) t = strchr(s, '\0'); l = t - s; #define set_if(keyword) \ if (l == STRLEN(MS_##keyword##_STRING) && \ strncmp(s, MS_##keyword##_STRING, l) == 0) flag = MS_##keyword##_FLAG set_if(TRANSVERSE); else set_if(BIG); else set_if(SMALL); else set_if(EXTRA);
void rt_init_thread_entry(void *parameter) { #ifdef RT_USING_COMPONENTS_INIT /* initialization RT-Thread Components */ rt_components_init(); #endif #ifdef RT_USING_LWIP /* initialize eth interface */ rt_hw_wifi_init("spi01", MODE_STATION); // MODE_STATION MODE_SOFTAP rw009_join("you_AP", "you_passwd"); set_if("w0", "192.168.1.30", "192.168.1.1", "255.255.255.0"); //rt_hw_wifi_init("spi01", MODE_SOFTAP); // MODE_STATION MODE_SOFTAP //rw009_softap(WIFI_AP_SSID, WIFI_AP_PASS, WIFI_AP_SEC, WIFI_AP_CHANNEL); //dhcpd_start(); #endif /* RT_USING_LWIP */ }
void rt_init_thread_entry(void* parameter) { rt_i2c_core_init(); rt_hw_i2c_init(); rt_hw_spi_init(); //³õʼ»¯Ä£ÄâI2C //I2C_Soft_Init(); rt_hw_mpu6050_init("i2c1", MPU6050_DEFAULT_ADDRESS); rt_motors_hw_init(); /* LwIP Initialization */ #ifdef RT_USING_LWIP { extern void lwip_sys_init(void); /* register ethernetif device */ eth_system_device_init(); /* initialize wifi interface */ rt_hw_wifi_init("spi10"); /* init lwip system */ lwip_system_init(); rt_kprintf("TCP/IP initialized!\n"); set_if("w0","192.168.3.9","192.168.3.1","255.255.255.0"); rw009_join("rtthread_11n","rtthread_finsh"); } #endif apps_copter_init(); #ifdef RT_USING_FINSH /* init finsh */ finsh_system_init(); finsh_set_device(RT_CONSOLE_DEVICE_NAME); #endif }