Date: Mon, 6 Apr 2009 12:58:43 -0800 From: Maksim Yevmenkin <emax@freebsd.org> To: Bruce Simpson <bms@incunabulum.net> Cc: "freebsd-bluetooth@freebsd.org" <freebsd-bluetooth@freebsd.org>, "alexei@raylab.com" <alexei@raylab.com> Subject: Re: libhci update Message-ID: <bb4a86c70904061358l3983ed51m11265859a833f202@mail.gmail.com> In-Reply-To: <49D92E26.2030508@incunabulum.net> References: <49D92E26.2030508@incunabulum.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--00163630f4a9f0c9e20466e929c3 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Bruce, > So I decided to just go ahead and reimplement Markus Brueffer's libhci. > I've attached a tarball of the Hg repository. thanks! > It would be great to have feedback from you about this. right, a few things. - dev_id is kinda gross, imo. Iain and i discussed this and agreed that devname is the way to go. mapping between dev_id and devname can be (has to be) done and i have no objection to this, however, all the native api probably should use devname and not dev_id; - all the hci_xxx functions (with possible exception of inquiry) should probably be left out of the library. there is really not enough consumers for them; - i not sure i like, hci_xxx names; Iain and i have been discussing this before and agreed that, bt_XXX and bt_devXXXX are better names; i'm attaching the diffs that was sitting in my queue (still need to update man pages). please take a look at it and let me know what you think. > The API is now compatible with the current BlueZ SVN code. One of the > trade-offs involved was choosing an identifier which would fit in an 'int' > type, as BlueZ identifies its devices using uint16_t. > > As a compromise, I wrote code which emulates BlueZ device enumeration > using the Netgraph node ID (32 bits wide). Unfortunately this introduces > a dependency on -lnetgraph, unless the Bluetooth stack is itself taught to > produce such an identifier (and supply it via an ioctl()). i actually went this route before :) but i opted for much simpler scheme: #define hci_devid2type(id) (((id) >> 12) & 0x0f) #define hci_devid2unit(id) ((id) & 0x0fff) #define hci_mkdevid(type, unit) ((((type) & 0x0f) << 12) | (unit & 0x0fff)) struct hci_type2prefix { int type; char const *prefix; }; static struct hci_type2prefix const type2prefix[] = { { .type = HCI_VIRTUAL, .prefix = NULL, }, { .type = HCI_USB, .prefix = "ubt", }, { .type = HCI_PCCARD, .prefix = "btccc", }, { .type = HCI_UART, .prefix = "h4", }, { .type = HCI_RS232, .prefix = NULL, }, { .type = HCI_PCI, .prefix = NULL, }, { .type = HCI_SDIO, .prefix = NULL, }, { .type = -1, .prefix = NULL, }, /* should be last */ }; static int hci_name2devid(char const *name) { struct hci_type2prefix const *t; int plen, unit; char *ep; for (t = &type2prefix[0]; t->type != -1; t ++) { if (t->prefix == NULL) continue; plen = strlen(t->prefix); if (strncmp(name, t->prefix, plen) != 0) continue; unit = strtoul(name + plen, &ep, 10); if (*ep != '\0' && strcmp(ep, "hci") != 0 && strcmp(ep, "l2cap") != 0) { errno = ENODEV; return (-1); } return (hci_mkdevid(t->type, unit)); } errno = ENODEV; return (-1); } static char * hci_devid2name(int dev_id, char *name, int namelen) { struct hci_type2prefix const *t; int type, unit; if (dev_id >= 0) { type = hci_devid2type(dev_id); unit = hci_devid2unit(dev_id); for (t = &type2prefix[0]; t->type != -1; t ++) { if (t->type == type && t->prefix != NULL) { snprintf(name, namelen, "%s%uhci", t->prefix, unit); return (name); } } } errno = EINVAL; return (NULL); } this code is left out for now. not sure if i like it :) > I noticed during the port that periodic inquiry doesn't actually buy us > anything > at all. With a CSR BlueCore4-ROM dongle, the microcontroller will not > raise any other events *at all* at the HCI layer during inquiry. > > Mind you, I haven't tried any of the Bluetooth HCI 2.0/EDR commands, > many of these are not yet implemented in the FreeBSD stack, am I right? well, most of 2.0 commands do not need any implementation. just need to add defines and typedefs. some events might need handling, i.e. inquiry with rssi. but generally it should just work. > I also had a crack at porting NetBSD's 'btconfig'. I haven't included it in > this drop, however, it does depend on the libhci functions I have written. how about just fixing hcicontrol(8) do to that you want? is this too much work? > I see that NetBSD's libsdp does support 128 bit UUIDs. Whilst this is > highly desirable, it is also a prerequisite for any of the high level > language > wrappers (e.g. PyBlueZ, BlueCove) which make use of SDP. ok, i will take a look at the diffs to see what is different. > Anyway, let me know what you think. I am eager to get the SDP issues > knocked on the head ASAP. right, that would likely be complete replacement of libsdp and sdpd. thanks, max --00163630f4a9f0c9e20466e929c3 Content-Type: text/plain; charset=US-ASCII; name="bluetooth.hci.diff.txt" Content-Disposition: attachment; filename="bluetooth.hci.diff.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_ft7myoeu1 SW5kZXg6IGhjaS5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGhjaS5jCShyZXZpc2lvbiAxOTA1OTQpCisrKyBo Y2kuYwkod29ya2luZyBjb3B5KQpAQCAtMzAsMTUgKzMwLDQyMSBAQAogICogJEZyZWVCU0QkCiAg Ki8KIAorI2luY2x1ZGUgPGFzc2VydC5oPgogI2luY2x1ZGUgPGJsdWV0b290aC5oPgogI2luY2x1 ZGUgPHN0ZGlvLmg+CiAjaW5jbHVkZSA8c3RkbGliLmg+CiAjaW5jbHVkZSA8c3RyaW5nLmg+CiAj aW5jbHVkZSA8dW5pc3RkLmg+CiAKK3N0YXRpYyBpbnQgICAgYnRfZGV2YW55X2NiKGludCBzLCBz dHJ1Y3QgYnRfZGV2aW5mbyBjb25zdCAqZGksIHZvaWQgKnhkZXZuYW1lKTsKIHN0YXRpYyBjaGFy ICogYnRfZGV2Mm5vZGUgKGNoYXIgY29uc3QgKmRldm5hbWUsIGNoYXIgKm5vZGVuYW1lLCBpbnQg bm5sZW4pOwogCiBpbnQKK2J0X2Rldm9wZW4oY2hhciBjb25zdCAqZGV2bmFtZSkKK3sKKwlzdHJ1 Y3Qgc29ja2FkZHJfaGNpCWhhOworCWJkYWRkcl90CQliYTsKKwlpbnQJCQlzOworCisJaWYgKGRl dm5hbWUgPT0gTlVMTCkgeworCQllcnJubyA9IEVJTlZBTDsKKwkJcmV0dXJuICgtMSk7CisJfQor CisJbWVtc2V0KCZoYSwgMCwgc2l6ZW9mKGhhKSk7CisJaGEuaGNpX2xlbiA9IHNpemVvZihoYSk7 CisJaGEuaGNpX2ZhbWlseSA9IEFGX0JMVUVUT09USDsKKworCWlmIChidF9hdG9uKGRldm5hbWUs ICZiYSkpIHsKKwkJaWYgKCFidF9kZXZuYW1lKGhhLmhjaV9ub2RlLCAmYmEpKQorCQkJcmV0dXJu ICgtMSk7CisJfSBlbHNlIGlmIChidF9kZXYybm9kZShkZXZuYW1lLCBoYS5oY2lfbm9kZSwKKwkJ CQkJc2l6ZW9mKGhhLmhjaV9ub2RlKSkgPT0gTlVMTCkgeworCQllcnJubyA9IEVOWElPOworCQly ZXR1cm4gKC0xKTsKKwl9CisKKwlzID0gc29ja2V0KFBGX0JMVUVUT09USCwgU09DS19SQVcsIEJM VUVUT09USF9QUk9UT19IQ0kpOworCWlmIChzIDwgMCkKKwkJcmV0dXJuICgtMSk7CisKKwlpZiAo YmluZChzLCAoc3RydWN0IHNvY2thZGRyICopICZoYSwgc2l6ZW9mKGhhKSkgPCAwIHx8CisJICAg IGNvbm5lY3QocywgKHN0cnVjdCBzb2NrYWRkciAqKSAmaGEsIHNpemVvZihoYSkpIDwgMCkgewor CQljbG9zZShzKTsKKwkJcmV0dXJuICgtMSk7CisJfQorCisJcmV0dXJuIChzKTsKK30KKworaW50 CitidF9kZXZjbG9zZShpbnQgcykKK3sKKwlyZXR1cm4gKGNsb3NlKHMpKTsKK30KKworaW50Citi dF9kZXZzZW5kKGludCBzLCB1aW50MTZfdCBvZ2YsIHVpbnQxNl90IG9jZiwgaW50IHBsZW4sIHZv aWQgKnBhcmFtKQoreworCW5nX2hjaV9jbWRfcGt0X3QJaDsKKwlzdHJ1Y3QgaW92ZWMJCWl2WzJd OworCWludAkJCWl2bjsKKworCWlmIChwbGVuIDwgMCB8fCAocGxlbiA+IDAgJiYgcGFyYW0gPT0g TlVMTCkpIHsgCisJCWVycm5vID0gRUlOVkFMOworCQlyZXR1cm4gKC0xKTsKKwl9CisKKwlpdlsw XS5pb3ZfYmFzZSA9ICZoOworCWl2WzBdLmlvdl9sZW4gPSBzaXplb2YoaCk7CisJaXZuID0gMTsK KworCWgudHlwZSA9IE5HX0hDSV9DTURfUEtUOworCWgub3Bjb2RlID0gaHRvbGUxNihOR19IQ0lf T1BDT0RFKG9nZiwgb2NmKSk7CisJaWYgKHBsZW4gPiAwKSB7CisJCWgubGVuZ3RoID0gcGxlbjsK KworCQlpdlsxXS5pb3ZfYmFzZSA9IHBhcmFtOworCQlpdlsxXS5pb3ZfbGVuID0gcGxlbjsKKwkJ aXZuID0gMjsKKwl9IGVsc2UKKwkJaC5sZW5ndGggPSAwOworCisJd2hpbGUgKHdyaXRldihzLCBp diwgaXZuKSA8IDApIHsKKwkJaWYgKGVycm5vID09IEVBR0FJTiB8fCBlcnJubyA9PSBFSU5UUikK KwkJCWNvbnRpbnVlOworCisJCXJldHVybiAoLTEpOworCX0KKworCXJldHVybiAoMCk7Cit9CisK K2ludAorYnRfZGV2cmVjdihpbnQgcywgdWludDhfdCAqYnVmLCBpbnQgc2l6ZSwgdGltZV90IHRv KQoreworCWZkX3NldAkJcmZkOworCXN0cnVjdCB0aW1ldmFsCXR2OworCWludAkJbjsKKworCWlm IChidWYgPT0gTlVMTCB8fCBzaXplIDw9IDAgfHwgdG8gPCAwKSB7CisJCWVycm5vID0gRUlOVkFM OworCQlyZXR1cm4gKC0xKTsKKwl9CisKKwlGRF9aRVJPKCZyZmQpOworCUZEX1NFVChzLCAmcmZk KTsKKworCXR2LnR2X3NlYyA9IHRvOworCXR2LnR2X3VzZWMgPSAwOworCisJd2hpbGUgKChuID0g c2VsZWN0KHMgKyAxLCAmcmZkLCBOVUxMLCBOVUxMLCAmdHYpKSA8IDApIHsKKwkJaWYgKGVycm5v ID09IEVBR0FJTiB8fCBlcnJubyA9PSBFSU5UUikKKwkJCWNvbnRpbnVlOworCisJCXJldHVybiAo LTEpOworCX0KKworCWlmIChuID09IDApIHsKKwkJZXJybm8gPSBFVElNRURPVVQ7CisJCXJldHVy biAoLTEpOworCX0KKworCWFzc2VydChGRF9JU1NFVChzLCAmcmZkKSk7CisKKwl3aGlsZS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Ci0JaWYgKGJpbmQocywg KHN0cnVjdCBzb2NrYWRkciAqKSAmaGEsIHNpemVvZihoYSkpIDwgMCB8fAotCSAgICBjb25uZWN0 KHMsIChzdHJ1Y3Qgc29ja2FkZHIgKikgJmhhLCBzaXplb2YoaGEpKSA8IDApCisJaGFsZW4gPSBz aXplb2YoaGEpOworCWlmIChnZXRzb2NrbmFtZShzLCAoc3RydWN0IHNvY2thZGRyICopICZoYSwg JmhhbGVuKSA8IDApCiAJCWdvdG8gYmFkOwogCXN0cmxjcHkoZGktPmRldm5hbWUsIGhhLmhjaV9u b2RlLCBzaXplb2YoZGktPmRldm5hbWUpKTsKIApAQCAtMTM4LDcgKzUzMiw3IEBACiAKIAlydmFs ID0gMDsKIGJhZDoKLQljbG9zZShzKTsKKwlidF9kZXZjbG9zZShzKTsKIAogCXJldHVybiAocnZh bCk7CiB9CkBAIC0yMDUsNiArNTk5LDEzIEBACiAJcmV0dXJuIChjb3VudCk7CiB9CiAKK3N0YXRp YyBpbnQKK2J0X2RldmFueV9jYihpbnQgcywgc3RydWN0IGJ0X2RldmluZm8gY29uc3QgKmRpLCB2 b2lkICp4ZGV2bmFtZSkKK3sKKwlzdHJsY3B5KChjaGFyICopIHhkZXZuYW1lLCBkaS0+ZGV2bmFt ZSwgSENJX0RFVk5BTUVfU0laRSk7CisJcmV0dXJuICgxKTsKK30KKwogc3RhdGljIGNoYXIgKgog YnRfZGV2Mm5vZGUoY2hhciBjb25zdCAqZGV2bmFtZSwgY2hhciAqbm9kZW5hbWUsIGludCBubmxl bikKIHsKSW5kZXg6IGJsdWV0b290aC5oCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGJsdWV0b290aC5oCShyZXZp c2lvbiAxOTA1OTQpCisrKyBibHVldG9vdGguaAkod29ya2luZyBjb3B5KQpAQCAtMzksNiArMzks NyBAQAogI2luY2x1ZGUgPHN5cy9lbmRpYW4uaD4K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mZnNldDsKK307CisKIHR5cGVk ZWYgaW50CShidF9kZXZlbnVtX2NiX3QpKGludCwgc3RydWN0IGJ0X2RldmluZm8gY29uc3QgKiwg dm9pZCAqKTsKIAoraW50CQlidF9kZXZvcGVuIChjaGFyIGNvbnN0ICpkZXZuYW1lKTsKK2ludAkJ YnRfZGV2Y2xvc2UoaW50IHMpOworaW50CQlidF9kZXZzZW5kIChpbnQgcywgdWludDE2X3Qgb2dm LCB1aW50MTZfdCBvY2YsIGludCBwbGVuLCB2b2lkICpwYXJhbSk7CitpbnQJCWJ0X2RldnJlY3Yg KGludCBzLCB1aW50OF90ICpidWYsIGludCBzaXplLCB0aW1lX3QgdG8pOworaW50CQlidF9kZXZy ZXEgIChpbnQgcywgc3RydWN0IGJ0X2RldnJlcSAqciwgdGltZV90IHRvKTsKK2ludAkJYnRfZGV2 ZmlsdGVyKGludCBzLCBzdHJ1Y3QgYnRfZGV2ZmlsdGVyIGNvbnN0ICpuZXcsCisJCQkgICAgIHN0 cnVjdCBidF9kZXZmaWx0ZXIgKm9sZCk7CitpbnQJCWJ0X2RldmlucXVpcnkoY2hhciBjb25zdCAq ZGV2bmFtZSwgaW50IGxlbmd0aCwgaW50IG51bV9yc3AsCisJCQkgICAgICB1aW50OF90IGNvbnN0 ICpsYXAsIHN0cnVjdCBidF9kZXZpbnF1aXJ5ICoqaWkpOwogaW50CQlidF9kZXZpbmZvIChzdHJ1 Y3QgYnRfZGV2aW5mbyAqZGkpOwogaW50CQlidF9kZXZlbnVtIChidF9kZXZlbnVtX2NiX3QgKmNi LCB2b2lkICphcmcpOwogCisKIC8qCiAgKiBiZGFkZHIgdXRpbGl0eSBmdW5jdGlvbnMgKGZyb20g TmV0QlNEKQogICovCg== --00163630f4a9f0c9e20466e929c3--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bb4a86c70904061358l3983ed51m11265859a833f202>