android - Arduino - Converting byte array to string/char array -


i'm working on communication between devices using hid on usb cable. sending string utf-8 encoded android device, , receive , read on arduino leonardo.

my problem unable received message other type. need human readable string comparison i'm sending variety of commands arduino. ide either has type mismatch problem regardless of how try convert received message. i've tried many different things post 1 example. i'm sure there missing that's keeping me getting this!

  int n;   n = rawhid.recv(buffer, 0); // 0 timeout = not wait    if (msuntilnextsend > 2000) {       msuntilnextsend = msuntilnextsend - 2000;  //      string mystr = ""; //      byte charbuff[10]; //       //      (int = 0; < 64; i++) //      { //           mystr.concat((char) buffer[i]); //      } //       //      mystr.tochararray(charbuff, 10);    char readin[64] = { ' ' };   readin = (char *)buffer;   string mystring = string((char *)buffer);     if (strcmp(readin, "test") == 0)   {       string resp = "response";       resp.getbytes(buffer, 64);       n = rawhid.send(buffer, 100);   } 

i've included comments bits of different approach mentioned, have been unsuccessful in attempts. insight appreciated!


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -