Saanch / btstack

Automatically exported from code.google.com/p/btstack
0 stars 0 forks source link

[PATCH] Win32-Cygwin with USB support #211

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Attached are patches adding Win32 USB support to btstack. From usbForWin32.c:
// Compatibility layer to allow apps using the libusb-1.0 to use libusb-win32
// (which uses the libusb-0.1 API).  Only the parts required by btstack are
// implemented.
// We don't use the libusb-1.0 support for Win32 because it currently uses
// the WinUSB driver which can't handle Bluetooth devices.

Attached are three/four patches
1. usb1aa.patch -- Various general fixes and tidying-up to hci_tranport_usb.c 
and daemon.c: Missed libusb_free_config_descriptor, missed "\n"s in logging 
strings, tv uninitialised, setting libusb_state twice, check of length of 
bulk_write.

2. usb1.patch -- Make some changes to hci_tranport_usb.c to support use on 
Win32/Cygwin.  Includes the above changes too.  The Win32 support needs the 
next patch in place to work.

3. usb2_Win32Cygwin.patch -- Secondly my libusb-1.0 to libusb-win32/0.1 compat 
layer.  The two new files contains the license as used by the existing files in 
btstack.  The modified version of libusb.h contains a GPL-style license…

4. cfgin3.patch -- Change configure.in to not require USB_VENDOR_ID and 
USB_PRODUCT_ID as the USB device look-up functions in hci_tranport_usb.c seem 
to work fine -- on my Windows box at least.

To use on Win32:
1. Download the btstack sources.
2. Download the libusb-win (libusb-0.1) binaries.  (I used 
libusb-win32-bin-1.2.5.0.zip).
3. Run its inf-wizard.exe app with administrator privileges, select the 
Bluetooth dongle you wish to use, and install the driver.
4. In btstack as normal run ./bootstrap.sh, ./configure, and make.  For 
./configure use the following command which enables USB support and adds the 
USB compat layer and libusb-win32 usage.  Change the vendor-id and product-id 
values to suit the dongle, and the path to suit the location of the 
libusb-win32 installation.

  ./configure --with-hci-transport=usb --with-vendor-id=0x1234 --with-product-id=0x4567 PLATFORM_SOURCES="usbForWin32.c" LIBUSB_CFLAGS=" " CPPFLAGS="-I/tmp/libusb-win32-bin-1.2.5.0/include" LIBUSB_LIBS="-lusb"

5. Run BTDaemon.exe as usual and one of the example apps and all should be well.

____
Notes on minor items.
• In the "configure" command I originally used LIBUSB_CFLAGS but they didn't 
seem to appear in the Makefile and thus I changed to using CPPFLAGS.  On 
investigation it appears that "configure.in" has both CFLAGS and CPPFLAGS, but 
that CFLAGS is not used in creating the makefiles.  I wasn't sure whether add 
CFLAGS to the makefiles, or to simply remove all usage of CFLAGS in 
configure.in.

Original issue reported on code.google.com by alanj...@yahoo.com on 12 Nov 2011 at 2:36

Attachments:

GoogleCodeExporter commented 9 years ago
Patches usb1aa.patch and cfgin3NotRequireVendorProduct.patch are independent of 
Win32/Cygwin.  Therefore they can/should be applied now and the Win32 bits left 
for later analysis/application.

* usb1aa.patch -- fixes some small bugs in src/hci_transport_usb.c

* cfgin3NotRequireVendorProduct.patch -- Enables the use of the automatic USB 
search for a BT radio, not requiring USB_VENDOR_ID, USB_PRODUCT_ID.

Original comment by alanj...@yahoo.com on 20 Nov 2011 at 12:08

GoogleCodeExporter commented 9 years ago
A new version of the USB Win32 compat layer: Correctly NULL terminate the 
libusb_get_device_list return value -- only really important when no dongles 
are plugged-in.

As before: Patches usb1aa.patch and cfgin3NotRequireVendorProduct.patch are 
independent of Win32/Cygwin.  Therefore they can/should be applied now and the 
Win32 bits left for later analysis/application.

Original comment by alanj...@yahoo.com on 28 Nov 2011 at 8:09

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Alan! Long time ago, you've ported BTstack and submitted the patches above. 
I think I did apply the general ones at that time. I've also figured I get a 
stab at getting BTstack to run on Windows and libusb-1.0 since that's available 
now and uses the stable WinUSB backend. It's compiled using MINGW and MSYS.
The code in example/libusb assumes that libusb has been installed in the 
default /usr/local. I'll probably clean it up a bit and move the Makefile to 
platforms/libusb/example. Let me know if you give it a try. Cheers, Matthias

Original comment by matthias.ringwald@gmail.com on 13 Nov 2014 at 2:10