AndroidAccessory.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 The Android Open Source Project
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 /* __AndroidAccessory_h__ */


rosserial_adk_demo
Author(s): Adam Stambler
autogenerated on Mon Dec 2 2013 12:02:02