atstat_e changeClientAddr(int32_t cNum, c8_t *ipAddr) { if(AT_FAILED == network_config(cNum,ipAddr)){ return AT_FAILED; } return AT_OK; }
/* --------------------------------------------------------------- */ PROCESS_THREAD(node_process, ev, data) { // All the process start with this PROCESS_BEGIN(); PRINTF("# Starting...\n"); // Configure the network network_config(); if (!conn) { printf("E01\n"); PROCESS_EXIT(); } #if IS_RPL_ROOT create_dag(); #endif // Main, infinite, loop of the process PRINTF("# Ready!\n"); while (1) { // Wait, block the process, until an event happens. // Meanwhile, other process will continue running. PROCESS_WAIT_EVENT(); // Check the type of event that unblock the process if (ev == tcpip_event) tcpip_handler(); else if (ev == serial_line_event_message) input_handler((char*)data); } // All the process ends with this PROCESS_END(); }
template<typename Config> void SystemSetupConsole<Config>::handle(char c) { if ('i' == c) { // see if we have any additional properties. This is true // for Cellular and Mesh devices. hal_system_info_t info = {}; info.size = sizeof(info); HAL_OTA_Add_System_Info(&info, true, nullptr); LOG(TRACE, "device info key/value count: %d", info.key_value_count); if (info.key_value_count) { print("Device ID: "); String id = spark_deviceID(); print(id.c_str()); print("\r\n"); for (int i=0; i<info.key_value_count; i++) { char key[20]; if (!filter_key(info.key_values[i].key, key, sizeof(key))) { print(key); print(": "); print(info.key_values[i].value); print("\r\n"); } } } else { #if PLATFORM_ID<3 print("Your core id is "); #else print("Your device id is "); #endif String id = spark_deviceID(); print(id.c_str()); print("\r\n"); } HAL_OTA_Add_System_Info(&info, false, nullptr); } else if ('m' == c) { print("Your device MAC address is\r\n"); IPConfig config = {}; #if !HAL_PLATFORM_WIFI auto conf = static_cast<const IPConfig*>(network_config(0, 0, 0)); #else auto conf = static_cast<const IPConfig*>(network_config(NETWORK_INTERFACE_WIFI_STA, 0, 0)); #endif if (conf && conf->size) { memcpy(&config, conf, std::min(sizeof(config), (size_t)conf->size)); } const uint8_t* addr = config.nw.uaMacAddr; print(bytes2hex(addr++, 1).c_str()); for (int i = 1; i < 6; i++) { print(":"); print(bytes2hex(addr++, 1).c_str()); } print("\r\n"); } else if ('f' == c) { serial.println("Waiting for the binary file to be sent ... (press 'a' to abort)"); system_firmwareUpdate(&serial); } else if ('x' == c) { exit(); } else if ('s' == c) { auto prefix = "{"; auto suffix = "}\r\n"; WrappedStreamAppender appender(serial, (const uint8_t*)prefix, strlen(prefix), (const uint8_t*)suffix, strlen(suffix)); system_module_info(append_instance, &appender); } else if ('v' == c) { StreamAppender appender(serial); append_system_version_info(&appender); print("\r\n"); } else if ('L' == c) { system_set_flag(SYSTEM_FLAG_STARTUP_LISTEN_MODE, 1, nullptr); System.enterSafeMode(); } else if ('c' == c) { bool claimed = HAL_IsDeviceClaimed(nullptr); print("Device claimed: "); print(claimed ? "yes" : "no"); print("\r\n"); } else if ('C' == c) { char code[64]; print("Enter 63-digit claim code: "); read_line(code, 63); if (strlen(code)==63) { HAL_Set_Claim_Code(code); print("Claim code set to: "); print(code); } else { print("Sorry, claim code is not 63 characters long. Claim code unchanged."); } print("\r\n"); } else if ('d' == c) { system_format_diag_data(nullptr, 0, 0, StreamAppender::append, &serial, nullptr); print("\r\n"); } }
int main(int argc, char ** argv) { int ret; DCC_LOG_INIT(); DCC_LOG_CONNECT(); stdio_init(); printf("\n---\n"); cm3_udelay_calibrate(); thinkos_init(THINKOS_OPT_PRIORITY(0) | THINKOS_OPT_ID(0)); trace_init(); tracef("## YARD-ICE " VERSION_NUM " - " VERSION_DATE " ##"); stm32f_nvram_env_init(); bsp_io_ini(); rtc_init(); supervisor_init(); __os_sleep(10); #if ENABLE_NETWORK DCC_LOG(LOG_TRACE, "network_config()."); network_config(); #endif DCC_LOG(LOG_TRACE, "modules_init()."); modules_init(); tracef("* Starting system module ..."); DCC_LOG(LOG_TRACE, "sys_start()."); sys_start(); tracef("* Initializing YARD-ICE debugger..."); DCC_LOG(LOG_TRACE, "debugger_init()."); debugger_init(); tracef("* Initializing JTAG module ..."); DCC_LOG(LOG_TRACE, "jtag_start()."); if ((ret = jtag_start()) < 0) { tracef("jtag_start() failed! [ret=%d]", ret); debugger_except("JTAG driver fault"); } #if (ENABLE_NAND) tracef("* Initializing NAND module..."); if (mod_nand_start() < 0) { tracef("mod_nand_start() failed!"); return 0; } #endif #if (ENABLE_I2C) tracef("* starting I2C module ... "); i2c_init(); #endif tracef("* configuring initial target ... "); init_target(); #if (ENABLE_VCOM) tracef("* starting VCOM daemon ... "); /* connect the UART to the JTAG auxiliary pins */ jtag3ctrl_aux_uart(true); vcom_start(); #endif #if (ENABLE_COMM) tracef("* starting COMM daemon ... "); comm_tcp_start(&debugger.comm); #endif #if (ENABLE_TFTP) tracef("* starting TFTP server ... "); tftpd_start(); #endif #if (ENABLE_GDB) tracef("* starting GDB daemon ... "); gdb_rspd_start(); #endif #if ENABLE_USB tracef("* starting USB shell ... "); usb_shell(); #endif #if ENABLE_TELNET tracef("* starting TELNET server ... "); telnet_shell(); #endif return console_shell(); }