![](/media/cache/profiles/ddcbe25988981920c872c1787382f04d.50x50_q85.jpg)
Android Open Accessory Library化してみました。 バルク転送の使い方が分かっていないため、相変わらず動作は不安定。 I do not understand the usage of the bulk transfer. Please teach someone.
AndroidAccessory.h
00001 00002 #ifndef ADK_H_INCLUDED 00003 #define ADK_H_INCLUDED 00004 00005 #include "mbed.h" 00006 #include "USBHost.h" 00007 00008 00009 #define ADKLOG 1 00010 #if ADKLOG 00011 #define LOG(...) printf(__VA_ARGS__) 00012 #define Log(...) printf(__VA_ARGS__) 00013 #define log(...) printf(__VA_ARGS__) 00014 00015 #else 00016 #define LOG(...) do {} while(0) 00017 #define Log(...) do {} while(0) 00018 #define log(...) do {} while(0) 00019 00020 #endif 00021 00022 #define ACCESSORY_STRING_MANUFACTURER 0 00023 #define ACCESSORY_STRING_MODEL 1 00024 #define ACCESSORY_STRING_DESCRIPTION 2 00025 #define ACCESSORY_STRING_VERSION 3 00026 #define ACCESSORY_STRING_URI 4 00027 #define ACCESSORY_STRING_SERIAL 5 00028 00029 #define ACCESSORY_GET_PROTOCOL 51 00030 #define ACCESSORY_SEND_STRING 52 00031 #define ACCESSORY_START 53 00032 00033 00034 bool switchDevice(int device); 00035 00036 class AndroidAccessory { 00037 public: 00038 00039 AndroidAccessory(int rbuffsize,int wbuffsize, 00040 const char* manufacturer, 00041 const char *model, 00042 const char *description, 00043 const char *version, 00044 const char *uri, 00045 const char *serial 00046 ); 00047 virtual void init(int device, int configuration, int interfaceNumber); 00048 00049 virtual void resetDevice()=0; 00050 virtual void setupDevice()=0; 00051 virtual int callbackRead(u8 *buff, int len)=0; 00052 int write(u8 *buff, int len); 00053 int write() { 00054 return write(_writebuff,_writebuffsize); 00055 } 00056 //int read(u8 *buff, int len); 00057 00058 00059 void adkEnd() { 00060 // _initok=false; 00061 resetDevice(); 00062 }; //if connection close 00063 bool switchDevice(int device); 00064 00065 //buffer 00066 u8* _readbuff; 00067 int _readbuffsize; 00068 u8* _writebuff; 00069 int _writebuffsize; 00070 u8* _strbuff;//255bytes; 00071 00072 private: 00073 00074 void sendString(int device, int index, const char *str); 00075 int getProtocol(int device); 00076 00077 const char *manufacturer; 00078 const char *model; 00079 const char *description; 00080 const char *version; 00081 const char *uri; 00082 const char *serial; 00083 00084 //endpoints 00085 int input_ep; 00086 int output_ep; 00087 00088 int _device; 00089 int _configuration; 00090 int _interfaceNumber; 00091 00092 //bool _initok; 00093 00094 }; 00095 00096 extern AndroidAccessory* _adk; 00097 00098 00099 #endif
Generated on Thu Jul 14 2022 06:30:46 by
![doxygen](doxygen.png)