BTstack for EA LPC4088 QSB example program

Dependencies:   LPC4088-USBHost mbed

Fork of KL46Z-BTstack_example by Norimasa Okamoto

The usage is the same as KL46Z-BTstack_example.
使い方はKL46Z-BTstack_exampleと同じです。
/media/uploads/va009039/lpc4088-btstack-480x360.jpg

KL46Z-USBHostBTstack/USBHostBTstack.h

Committer:
va009039
Date:
2014-01-25
Revision:
3:54f9b5e0d12d
Child:
4:cf1b23f4dcd4

File content as of revision 3:54f9b5e0d12d:

#include "USBHostConf.h"
#include "USBHost.h"
#pragma once

#define TEST_ASSERT(A) while(!(A)){fprintf(stderr,"\n\n%s@%d %s ASSERT!\n\n",__PRETTY_FUNCTION__,__LINE__,#A);exit(1);};

/** 
 * A class to communicate a BTstack
 */
class USBHostBTstack {
public:
    /**
    * Constructor
    *
    */
    USBHostBTstack();

    /**
    * Check if a BTstack device is connected
    *
    * @return true if a BTstack device is connected
    */
    bool connected();

    /**
     * Try to connect to a BTstack device
     *
     * @return true if connection was successful
     */
    bool connect();
    
    int open();
    int send_packet(uint8_t packet_type, uint8_t* packet, int size);
    void register_packet_handler( void (*pMethod)(uint8_t, uint8_t*, uint16_t));
    void poll();

private:
    USBHost * host;
    USBDeviceConnected * dev;
    uint8_t int_report[64];
    uint8_t bulk_report[64];
    USBEndpoint * bulk_out;
    void (*m_pCb)(uint8_t, uint8_t*, uint16_t);
};

void _debug_bytes(const char* pretty, int line, const char* s, uint8_t* buf, int len);