#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#define ARRAY_SIZE 25
AndroidAccessory acc("Google, Inc.",
"Prueba",
"Prueba",
"1.0",
"http://www.android.com",
"0000000012345678");
char hello[ARRAY_SIZE] = {'H','o','l','a',' ',
'M','u','n','d','o',' ', 'd', 'e', 's', 'd', 'e ',' ',
'A', 'r', 'd', 'u', 'i', 'n', 'o', '!'};
byte rcvmsg[255];
byte sntmsg[ARRAY_SIZE];
void setup()
{
Serial.begin(115200);
acc.powerOn();
}
void loop() {
if (acc.isConnected()) {
//read the sent text message into the byte array
int len = acc.read(rcvmsg, sizeof(rcvmsg), 1);
if (len > 0)
{
for(int x = 0; x < 4; x++)
{
Serial.print((char)rcvmsg[x]);
delay(250);
}
Serial.println();
delay(250);
}
for(int x = 0; x < ARRAY_SIZE; x++)
{
sntmsg[x] = hello[x];
}
acc.write(sntmsg, ARRAY_SIZE);
delay(250);
}//Fin del if que verifica si el accesorio esta conectado
}