libhci update

Iain Hibbert plunky at rya-online.net
Thu May 14 09:51:48 UTC 2009


On Wed, 22 Apr 2009, Maksim Yevmenkin wrote:
> > I've got no more comments here
>
> thanks for the review. i committed it to -head.

Hi Max, I'm in progress of translating for NetBSD and in bt_devinquiry() I
see

	if (ii == NULL) {
		errno = EINVAL;
		return (-1);
	}

but I think this test might be bogus? manpage implies that the caller
provides a buffer but we allocate one..

	/* Calculate inquire length in 1.28 second units */
	to = (time_t) ((double) length / 1.28);

	if (to <= 0)
		cp->inquiry_length = 4;		/* 5.12 seconds */
	else if (to > 254)
		cp->inquiry_length = 255;	/* 326.40 seconds */
	else
		cp->inquiry_length = to + 1;

2.1 spec says 1.28 -> 61.44 seconds range is acceptable (0x01->0x30)

Then, to avoid the floating point arithmetic, can use (to * 100 / 128) but
would need to be range checked first. I'm inclined to use something like

	if (to == 0)
		to = 4;
	else if (to == 1)
		to = 2;
	else if (to > 61)
		to = 61;

	cp->inquiry_length = (uint8_t)(to * 100 / 128);

also, I'm not sure that the timeout is handled right; the bt_devrecv()
uses the complete timeout each time but the time endpoint might need to be
calculated so that time-to-end can be used?

Also I'm wondering what to do in the case bt_devrecv() does actually time
out - what can it mean and should we [attempt to] cancel the inquiry?

(actually the whole timeout thing is probably irrelevant for a properly
functioning device :)

iain


More information about the freebsd-bluetooth mailing list