Fixed version check for AOA 2.0
Fork of AndroidAccessory by
Diff: AndroidAccessory.h
- Revision:
- 0:1151e4446dbc
- Child:
- 1:0d5fc52b4dcd
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/AndroidAccessory.h Mon Aug 01 09:51:55 2011 +0000 @@ -0,0 +1,106 @@ + +#ifndef ADK_H_INCLUDED +#define ADK_H_INCLUDED + +#include "mbed.h" +#include "USBHost.h" + + +//#define ADKLOG 1 +#if ADKLOG +#define LOG(...) printf(__VA_ARGS__) +#define Log(...) printf(__VA_ARGS__) +#define log(...) printf(__VA_ARGS__) + +#else +#define LOG(...) do {} while(0) +#define Log(...) do {} while(0) +#define log(...) do {} while(0) + +#endif + +#define ACCESSORY_STRING_MANUFACTURER 0 +#define ACCESSORY_STRING_MODEL 1 +#define ACCESSORY_STRING_DESCRIPTION 2 +#define ACCESSORY_STRING_VERSION 3 +#define ACCESSORY_STRING_URI 4 +#define ACCESSORY_STRING_SERIAL 5 + +#define ACCESSORY_GET_PROTOCOL 51 +#define ACCESSORY_SEND_STRING 52 +#define ACCESSORY_START 53 + + +bool switchDevice(int device); + +class AndroidAccessory { +public: + + AndroidAccessory(int rbuffsize,int wbuffsize, + const char* manufacturer, + const char *model, + const char *description, + const char *version, + const char *uri, + const char *serial + ); + virtual void init(int device, int configuration, int interfaceNumber); + + virtual void resetDevice()=0; + virtual void setupDevice()=0; + virtual int callbackRead(u8 *buff, int len)=0; + virtual int callbackWrite()=0; + int write(u8 *buff, int len); + int write() { + return write(_writebuff,_writebuffsize); + } + int writeNC(u8 *buff, int len); + int writeNC() { + return writeNC(_writebuff,_writebuffsize); + } + + int read(u8 *buff, int len); + + + void adkEnd() { + // _initok=false; + resetDevice(); + }; //if connection close + bool switchDevice(int device); + + //buffer + u8* _readbuff; + int _readbuffsize; + u8* _writebuff; + int _writebuffsize; + u8* _strbuff;//255bytes; + void sendString(const char *str); + +private: + + void sendString(int device, int index, const char *str); + int getProtocol(int device); + + const char *manufacturer; + const char *model; + const char *description; + const char *version; + const char *uri; + const char *serial; + + //endpoints + int input_ep; + int output_ep; + + int _device; + int _configuration; + int _interfaceNumber; + + //bool _initok; + +}; + +extern AndroidAccessory* _adk; + + +#endif \ No newline at end of file