Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __AndroidAccessory_h__
00018 #define __AndroidAccessory_h__
00019
00020 #include "WProgram.h"
00021 #include <Max3421e.h>
00022 #include <Usb.h>
00023
00024 class AndroidAccessory {
00025 private:
00026 const char *manufacturer;
00027 const char *model;
00028 const char *description;
00029 const char *version;
00030 const char *uri;
00031 const char *serial;
00032
00033 MAX3421E max;
00034 USB usb;
00035 bool connected;
00036 uint8_t in;
00037 uint8_t out;
00038
00039 EP_RECORD epRecord[8];
00040
00041 uint8_t descBuff[256];
00042
00043 bool isAccessoryDevice(USB_DEVICE_DESCRIPTOR *desc)
00044 {
00045 return desc->idVendor == 0x18d1 &&
00046 (desc->idProduct == 0x2D00 || desc->idProduct == 0x2D01);
00047 }
00048
00049 int getProtocol(byte addr);
00050 void sendString(byte addr, int index, const char *str);
00051 bool switchDevice(byte addr);
00052 bool findEndpoints(byte addr, EP_RECORD *inEp, EP_RECORD *outEp);
00053 bool configureAndroid(void);
00054
00055 public:
00056 AndroidAccessory(const char *manufacturer,
00057 const char *model,
00058 const char *description,
00059 const char *version,
00060 const char *uri,
00061 const char *serial);
00062
00063 void powerOn(void);
00064
00065 bool isConnected(void);
00066 int read(void *buff, int len, unsigned int nakLimit = USB_NAK_LIMIT);
00067 int write(void *buff, int len);
00068 };
00069
00070 #endif