Ejemplo n.º 1
0
int main()
{
	sdp_open();
	sdp_add_keyboard();
	sleep(60);	
	sdp_remove();
	return(1);
}
Ejemplo n.º 2
0
int main(int argc, char *argv[]) {
	int i;

	if (argc == 1) {
		printf("version : %s\n", HIDEMU_VERSION);
		return 0;
	}

	if(hci_get_route(NULL)  < 0) {
		printf("Bluetooth off\n");
		return -1;
	}

	if (DBG_CONSOLE) {

		for (i = 0; i < argc; i++) {
			printf("arg[%d]=%s\n", i, argv[i]);
		}

	}

	if (argc == ADD_HID_ARGS && (strncmp(argv[1], ADD_HID_GENERIC, strlen(argv[1])) == 0)) {
		int handle = add_hid(HID_MODE_GENERIC);
		printf("handle: 0x%X\n", handle);
		if (sdp_record != NULL) {
			sdp_record_free(sdp_record);
		}
	} else if (argc == ADD_HID_ARGS && (strncmp(argv[1], ADD_HID_BDREMOTE, strlen(argv[1])) == 0)) {
		int handle = add_hid(HID_MODE_BDREMOTE);
		printf("handle: 0x%X\n", handle);
		if (sdp_record != NULL) {
			sdp_record_free(sdp_record);
		}
	} else if (argc == ADD_HID_ARGS && (strncmp(argv[1], ADD_HID_PS3KEYPAD, strlen(argv[1])) == 0)) {
		int handle = add_hid(HID_MODE_PS3KEYPAD);
		printf("handle: 0x%X\n", handle);
		if (sdp_record != NULL) {
			sdp_record_free(sdp_record);
		}

	} else if (argc == DEL_HID_ARGS && (strncmp(argv[1], DEL_HID, strlen(argv[1])) == 0) && !strncasecmp(argv[2], "0x", 2)) {
		int handle = strtol(argv[2]+2, NULL, 16);
		printf("Removed handle: 0x%X\n", handle);
		if (!sdp_session) {
			sdp_open(sdp_session);
		}
		sdp_remove(handle);
		sdp_close(sdp_session);

	} else if (argc == READ_CLASS_ARGS && (strncmp(argv[1], READ_CLASS, strlen(argv[1])) == 0)) {
		uint8_t cls[3];
		if (read_device_class(0, cls) == 0) {
			printf("class: 0x%02x%02x%02x\n", cls[2], cls[1], cls[0]);
		}

	} else if (argc == SPOOF_CLASS_ARGS && (strncmp(argv[1], SPOOF_CLASS, strlen(argv[1])) == 0)) {
		if (spoof_device_class(0, argv[2]) == 0) {
			printf("class spoofed.\n");
		}

	} else {
		printf("Invalid arguments\n");
		LOGE("Invalid arguments\n");
	}

	return 0;

}