示例#1
0
/* Receive and process packets. For now, returning from
 * stream_rx_usb() means that UAP and clocks have been found, and that
 * hopping should be started. A more flexible framework would be
 * nice. */
void rx_live(struct libusb_device_handle* devh, btbb_piconet* pn, int timeout)
{
	int r = btbb_init(max_ac_errors);
	if (r < 0)
		return;

	if (timeout)
		set_timeout(timeout);

	if (follow_pn)
		cmd_set_clock(devh, 0);
	else {
		stream_rx_usb(devh, XFER_LEN, 0, cb_br_rx, pn);
		/* Allow pending transfers to finish */
		sleep(1);
	}
	/* Used when follow_pn is preset OR set by stream_rx_usb above
	 * i.e. This cannot be rolled in to the above if...else
	 */
	if (follow_pn) {
		cmd_stop(devh);
		cmd_set_bdaddr(devh, btbb_piconet_get_bdaddr(follow_pn));
		cmd_start_hopping(devh, btbb_piconet_get_clk_offset(follow_pn));
		stream_rx_usb(devh, XFER_LEN, 0, cb_br_rx, follow_pn);
	}
}
示例#2
0
/* Receive and process packets. For now, returning from
 * stream_rx_usb() means that UAP and clocks have been found, and that
 * hopping should be started. A more flexible framework would be
 * nice. */
void rx_live(ubertooth_t* ut, btbb_piconet* pn, int timeout)
{
	int r = btbb_init(max_ac_errors);
	if (r < 0)
		return;

	if (timeout)
		set_timeout(ut, timeout);

	if (ut->follow_pn)
		cmd_set_clock(ut->devh, 0);
	else {
		stream_rx_usb(ut, cb_br_rx, pn);
		/* Allow pending transfers to finish */
		sleep(1);
	}
	/* Used when follow_pn is preset OR set by stream_rx_usb above
	 * i.e. This cannot be rolled in to the above if...else
	 */
	if (ut->follow_pn) {
		ut->stop_ubertooth = 0;
		ut->usb_really_full = 0;
		// cmd_stop(ut->devh);
		cmd_set_bdaddr(ut->devh, btbb_piconet_get_bdaddr(ut->follow_pn));
		cmd_start_hopping(ut->devh, btbb_piconet_get_clk_offset(ut->follow_pn));
		stream_rx_usb(ut, cb_br_rx, ut->follow_pn);
	}
}