int main (int argc, char *argv[]){
	if(isUsbAccessory() < 0){
		if(init() < 0){
			deInit();
			return 0;
		}

		//doTransfer();
		if(setupAccessory(
			"Nexus-Computing GmbH",
			"osciprime",
			"Description",
			"antilope",
			"http://neuxs-computing.ch",
			"2254711SerialNo.") < 0){
			fprintf(stdout, "Error setting up accessory\n");
			deInit();
			return -1;
		};
	}

	if(mainPhase() < 0){
		fprintf(stdout, "Error during main phase\n");
		deInit();
		return -1;
	}	
	deInit();
	fprintf(stdout, "Done, no errors\n");
	return 0;
}
Beispiel #2
0
int main(int argc, char *argv[])
{
	int err;

	libusb_init(NULL);
	libusb_set_debug(NULL, 3);

	/* Try to open directly accessory. If it's not there, try to switch phone to it */
	handle = libusb_open_device_with_vid_pid(NULL, ACCESSORY_VID, ACCESSORY_PID_DBG);
	//if(handle)
		//libusb_reset_device(handle);

	if(handle == NULL){
		printf("Device not in Accessory mode. Trying to switch it to it...\n");
		err = setupAccessory("STMicroelectronics", "adkping", "Just pings data", "2.0",
			"http://www.st.com", "1234567890123456");
		if(err < 0){
			fprintf(stdout, "Sorry, can't set up accessory, giving up\n");
			deInit();
			return -1;
		}
	}

	/* Do some stuff */
	if(mainPhase() < 0){
		fprintf(stdout, "Error during main phase\n");
		deInit();
		return -1;
	}
	
	deInit();
	fprintf(stdout, "Done, no errors\n");

	return 0;
}
int main (int argc, char *argv[]){
	if(init() < 0)
		return;
	//doTransfer();
	if(setupAccessory(
		"Manufacturer",
		"Model",
		"Description",
		"VersionName",
		"http://neuxs-computing.ch",
		"2254711SerialNo.") < 0){
		fprintf(stdout, "Error setting up accessory\n");
		deInit();
		return -1;
	};
	if(mainPhase() < 0){
		fprintf(stdout, "Error during main phase\n");
		deInit();
		return -1;
	}	
	deInit();
	fprintf(stdout, "Done, no errors\n");
	return 0;
}