示例#1
0
int main (void)
{
    /*
     * Call idigi_init() with a NULL callback, we are only verifying that we 
     * can compile and link the IIK.
     */
    (void)idigi_init((idigi_callback_t)0);
    return 0;
}
/* important interface functions */
void ArduinoiDigiInterfaceClass::setup(uint8_t *mac, IPAddress ip, uint32_t vendorId)
{
  setMac(mac);
  setIp(ip);
  setVendorId(vendorId);
  
  idigi_handle = idigi_init((idigi_callback_t) &ArduinoiDigiInterfaceClass::appCallback);
  AR_DEBUG_PRINTF("idigi_init complete.\r\n");  
}
示例#3
0
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;

}
示例#4
0
int main (void)
{
    int status=EXIT_FAILURE;
    idigi_handle_t idigi_handle;

    APP_DEBUG("main: Starting iDigi\n");
    idigi_handle = idigi_init((idigi_callback_t) app_idigi_callback);
    if (idigi_handle == NULL)
    {
        APP_DEBUG("main: idigi_init() failed\n");
        goto done;
    }

    /* Sample program control loop */
    for(;;)
    {
        idigi_status_t status;
        /*
         * Example of using idigi_step(), we run a portion of the IIK then run
         * a portion of the users application.
         */
        status = idigi_step(idigi_handle);
        if (status != idigi_success && status != idigi_receive_error &&
            status != idigi_send_error && status != idigi_connect_error)
        {
            /* We exclude idigi_receive_error, idigi_send_error, &
             * idigi_connect_error. We want to reconnect iDigi
             * even if idigi_step returns error in receive, send, or connect.
             */
            APP_DEBUG("main: idigi_step() failed\n");
            break;
        }
        if (application_step(idigi_handle) != 0)
        {
            APP_DEBUG("main: application_step() failed\n");
            goto done;
        }
        usleep(1000);
    }

done:
    return status;
}
示例#5
0
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();
   }
}
示例#6
0
int main (void)
{
    pthread_t idigi_thread;
    pthread_t application_thread;

    idigi_handle_t idigi_handle;

    APP_DEBUG("Start iDigi\n");
    idigi_handle = idigi_init((idigi_callback_t) app_idigi_callback);
    if (idigi_handle != NULL)
    {
        int ccode;
        ccode = pthread_create(&idigi_thread, NULL, idigi_run_thread, idigi_handle);
        if (ccode != 0)
        {
            APP_DEBUG("thread_create() error on idigi_process_thread %d\n", ccode);
            goto done;
        }

        ccode = pthread_create(&application_thread, NULL, application_run_thread, idigi_handle);
        if (ccode != 0)
        {
            APP_DEBUG("thread_create() error on idigi_process_thread %d\n", ccode);
            goto done;
        }

        pthread_join(idigi_thread, NULL);
        pthread_join(application_thread, NULL);
        APP_DEBUG("iDigi terminated\n");
    }
    else
    {
        APP_DEBUG("unable to initialize iDigi\n");
    }
done:
    return 0;
}
示例#7
0
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;

}