void main() { int rc; char c; char mac[6]; if (idigi_init()) exit(1); printf("Hit <space> to print network interface status and MAC address\n"); printf(" ? to print XBee node table\n"); printf(" a to print memory usage\n"); printf("\nNote: MAC address is useful for manually adding device to iDigi.\n\n"); _restart: do { rc = idigi_tick(); if (kbhit()) { c = getchar(); if (c == ' ') { ip_print_ifs(); printf("MAC address: %02X%02X%02X:%02X%02X%02X\n", SysIDBlock.macAddr[0], SysIDBlock.macAddr[1], SysIDBlock.macAddr[2], SysIDBlock.macAddr[3], SysIDBlock.macAddr[4], SysIDBlock.macAddr[5] ); } else if (c == '?') sxa_node_table_dump(); else if (c == 'a') _sys_malloc_stats(); } } while (!rc); printf("Final rc = %d\n", rc); if (rc == -NETERR_ABORT) { // RCI reboot request was received. Normally we would use this // to shut down cleanly and reboot the board. printf("Rebooting via exit(0)!\n"); exit(0); } goto _restart; }
SSPEC_RESOURCETABLE_END void main() { /* * sock_init initializes the TCP/IP stack. * http_init initializes the web server. */ #ifdef USE_IDIGI // Start iDigi services if (idigi_init()) exit(1); #else // Start network and wait for interface to come up (or error exit). sock_init_or_exit(1); #endif http_init(); /* * tcp_reserveport causes the web server to ignore requests when there * isn't an available socket (HTTP_MAXSERVERS are all serving index_html * or rabbit1.gif). This saves some memory, but can cause the client * delays when retrieving pages. */ tcp_reserveport(80); /* * http_handler needs to be called to handle the active http servers. */ while (1) { #ifdef USE_IDIGI idigi_tick(); #endif http_handler(); } }
void main() { int rc; // idigi_init() does everything required to start the network and the // iDigi connection. if (idigi_init()) exit(1); _restart: do { // Insert any work your application needs to do at this point. // Drive iDigi and the network, until it indicates a special condition. rc = idigi_tick(); } while (!rc); printf("Final rc = %d\n", rc); if (rc == -NETERR_ABORT) { // RCI reboot request was received. Normally we would use this // to shut down cleanly and reboot the board. printf("Rebooting via exit(0)!\n"); exit(0); } if (rc == -NETERR_NONE) { // Device network has been reconfigured by iDigi web interface etc. // The network is still up, so applications may use this opportunity // to shut down any in-progress connections cleanly. The next call // to idigi_tick() will close down the network, reconfigure it, // then bring it back up. printf("Network reconfiguration in progress...\n"); } goto _restart; }