mbed base bard check program for BlueTooth USB dongle module (3 switches, 6 leds, I2C LCD, A/D)
Fork of BTstack by
Diff: BTstack/hci_transport_usb.cpp
- Revision:
- 1:b657594559be
- Parent:
- 0:1ed23ab1345f
- Child:
- 2:871b41f4789e
--- a/BTstack/hci_transport_usb.cpp Tue Jun 26 14:27:45 2012 +0000 +++ b/BTstack/hci_transport_usb.cpp Thu Mar 21 13:53:05 2013 +0000 @@ -58,10 +58,8 @@ #include "hci.h" #include "hci_transport.h" #include "hci_dump.h" -#include "usbbt.h" -// prototypes -static int usb_close(void *transport_config); - +#include "USBHostBTstack.h" + enum { LIB_USB_CLOSED = 0, LIB_USB_OPENED, @@ -73,19 +71,13 @@ // single instance static hci_transport_t * hci_transport_usb = NULL; -static usbbt* bt = NULL; -static int usb_process_ds(struct data_source *ds) { - if (bt) { - bt->poll(); - } - return 0; -} +static USBHostBTstack* bt = NULL; static int usb_open(void *transport_config){ log_info("usb_open\n"); - data_source_t *ds = (data_source_t*)malloc(sizeof(data_source_t)); - ds->process = usb_process_ds; - run_loop_add_data_source(ds); + if (bt) { + return bt->open(); + } return 0; } static int usb_close(void *transport_config){ @@ -104,7 +96,7 @@ static void usb_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size)){ log_info("registering packet handler\n"); if (bt) { - bt->setOnPacket(handler); + bt->register_packet_handler(handler); } } @@ -115,8 +107,7 @@ // get usb singleton hci_transport_t * hci_transport_usb_instance() { if (!bt) { - bt = new usbbt; - bt->setup(); + bt = new USBHostBTstack; } if (!hci_transport_usb) { hci_transport_usb = (hci_transport_t*)malloc( sizeof(hci_transport_t));