BLE demo for mbed Ported RunningElectronics's SBDBT firmware for BLE. It can communicate with iOS
Dependencies: FatFileSystem mbed
Fork of BTstack by
usbbt/usbbt.h@6:cf06ba884429, 2013-02-20 (annotated)
- Committer:
- todotani
- Date:
- Wed Feb 20 14:18:38 2013 +0000
- Revision:
- 6:cf06ba884429
- Parent:
- 0:1ed23ab1345f
Change tick timer to 1ms. Change attribute 0xFFF1 as read of DigitalIn p5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
va009039 | 0:1ed23ab1345f | 1 | #ifndef USBBT_H |
va009039 | 0:1ed23ab1345f | 2 | #define USBBT_H |
va009039 | 0:1ed23ab1345f | 3 | #include "UsbHostMgr.h" |
va009039 | 0:1ed23ab1345f | 4 | #include "UsbEndpoint.h" |
va009039 | 0:1ed23ab1345f | 5 | #include "UsbBaseClass.h" |
va009039 | 0:1ed23ab1345f | 6 | |
va009039 | 0:1ed23ab1345f | 7 | #define HCI_COMMAND_DATA_PACKET 0x01 |
va009039 | 0:1ed23ab1345f | 8 | #define HCI_ACL_DATA_PACKET 0x02 |
va009039 | 0:1ed23ab1345f | 9 | #define HCI_SCO_DATA_PACKET 0x03 |
va009039 | 0:1ed23ab1345f | 10 | #define HCI_EVENT_PACKET 0x04 |
va009039 | 0:1ed23ab1345f | 11 | |
va009039 | 0:1ed23ab1345f | 12 | class usbbt : public UsbBaseClass { |
va009039 | 0:1ed23ab1345f | 13 | public: |
va009039 | 0:1ed23ab1345f | 14 | usbbt(int dongle = 0); |
va009039 | 0:1ed23ab1345f | 15 | int setup(int timeout = 9000); |
va009039 | 0:1ed23ab1345f | 16 | int send_packet(uint8_t packet_type, uint8_t* packet, int size); |
va009039 | 0:1ed23ab1345f | 17 | void poll(); |
va009039 | 0:1ed23ab1345f | 18 | ///Setups the result callback |
va009039 | 0:1ed23ab1345f | 19 | /** |
va009039 | 0:1ed23ab1345f | 20 | @param pMethod : callback function |
va009039 | 0:1ed23ab1345f | 21 | */ |
va009039 | 0:1ed23ab1345f | 22 | void setOnPacket( void (*pMethod)(uint8_t, uint8_t*, uint16_t) ); |
va009039 | 0:1ed23ab1345f | 23 | |
va009039 | 0:1ed23ab1345f | 24 | ///Setups the result callback |
va009039 | 0:1ed23ab1345f | 25 | /** |
va009039 | 0:1ed23ab1345f | 26 | @param pItem : instance of class on which to execute the callback method |
va009039 | 0:1ed23ab1345f | 27 | @param pMethod : callback method |
va009039 | 0:1ed23ab1345f | 28 | */ |
va009039 | 0:1ed23ab1345f | 29 | class CDummy; |
va009039 | 0:1ed23ab1345f | 30 | template<class T> |
va009039 | 0:1ed23ab1345f | 31 | void setOnPacket( T* pItem, void (T::*pMethod)(uint8_t, uint8_t*, uint16_t) ) |
va009039 | 0:1ed23ab1345f | 32 | { |
va009039 | 0:1ed23ab1345f | 33 | m_pCb = NULL; |
va009039 | 0:1ed23ab1345f | 34 | m_pCbItem = (CDummy*) pItem; |
va009039 | 0:1ed23ab1345f | 35 | m_pCbMeth = (void (CDummy::*)(uint8_t, uint8_t*, uint16_t)) pMethod; |
va009039 | 0:1ed23ab1345f | 36 | } |
va009039 | 0:1ed23ab1345f | 37 | void clearOnPacket(); |
va009039 | 0:1ed23ab1345f | 38 | private: |
va009039 | 0:1ed23ab1345f | 39 | int ParseConfiguration(); |
va009039 | 0:1ed23ab1345f | 40 | void onPacket(uint8_t packet_type, uint8_t* packet, uint16_t size); |
va009039 | 0:1ed23ab1345f | 41 | int m_dongle; |
va009039 | 0:1ed23ab1345f | 42 | UsbDevice* m_pDev; |
va009039 | 0:1ed23ab1345f | 43 | UsbEndpoint* m_pEpIntIn; |
va009039 | 0:1ed23ab1345f | 44 | UsbEndpoint* m_pEpBulkIn; |
va009039 | 0:1ed23ab1345f | 45 | UsbEndpoint* m_pEpBulkOut; |
va009039 | 0:1ed23ab1345f | 46 | Timer m_timer; |
va009039 | 0:1ed23ab1345f | 47 | int m_int_seq; |
va009039 | 0:1ed23ab1345f | 48 | uint8_t m_int_buf[64]; |
va009039 | 0:1ed23ab1345f | 49 | int m_bulk_seq; |
va009039 | 0:1ed23ab1345f | 50 | uint8_t m_bulk_buf[64]; |
va009039 | 0:1ed23ab1345f | 51 | CDummy* m_pCbItem; |
va009039 | 0:1ed23ab1345f | 52 | void (CDummy::*m_pCbMeth)(uint8_t, uint8_t*, uint16_t); |
va009039 | 0:1ed23ab1345f | 53 | void (*m_pCb)(uint8_t, uint8_t*, uint16_t); |
va009039 | 0:1ed23ab1345f | 54 | }; |
va009039 | 0:1ed23ab1345f | 55 | #endif //USBBT_H |