SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By BlueBeardo
#172298
I am using the BC127 breakout board. I have it hooked up to inputs 0 and 1 of an Arduino Uno. I am connecting to the BC127 with an Motorola Moto X with Android version 4.4.2. I am playing music with the Google Play Music App. Everything seems to be working ok.

I am having trouble getting the song metadata. I only get the song info in the Arduino serial monitor when the song finishes and changes to the next song on its own. If I press track forward, back, play, or pause on the board or on my phone, I do not get the track metadata. I do get it if I press back or forward twice quickly. Not sure why.

I tried changing the baud rate as high as it would go to see if i was missing the data. What am I missing? Is there a command that I can get that will update the status of the song?

Here is the code I am using in the Arduino:
Code: Select all
#include <bc127.h>

BC127 BTModu(&Serial);

const unsigned int MAX_INPUT = 100;
boolean test = true;

void setup()
{
  Serial.begin(9600);
  
  // Blast the existing settings of the BC127 module, so I know that the module is
  //  set to factory defaults.
  BTModu.exitDataMode(); // Just in case...do this or other commands won't take.
  BTModu.restore();
  BTModu.writeConfig();
  BTModu.reset();
  BTModu.setBaudRate(BC127::s115200bps);
  Serial.begin(115200);
  Serial.println("Ready");
}

void process_data (const char * data)
{
  if (data [0] != 'E' && data [1] != 'R') //Find a better way to do this
  {
    Serial.println (data);
    if (data [0] == 'O' && data [9] == 'V' && test)
    {
      test = false;
      delay(100);
      BTModu.musicCommands(BC127::PLAY);
      
    }
  } 
}

void processIncomingByte (const byte inByte)
{
  static char input_line [MAX_INPUT];
  static unsigned int input_pos = 0;

  switch (inByte)
  {

    case '\r':   // end of text
      input_line [input_pos] = '\0';  // terminating null byte
      
      // terminator reached! process input_line here ...
      process_data (input_line);
      
      // reset buffer for next time
      input_pos = 0;
      break;

    case '\n':   // discard carriage return
      break;

    default:
      // keep adding if not full ... allow for terminating null byte
      if (input_pos < (MAX_INPUT - 1))
      {
        input_line [input_pos++] = inByte;
      }
      break;

  } 
}

void loop()
{
  if (Serial.available () > 0) processIncomingByte (Serial.read ());
}
By BlueBeardo
#172309
This seems to be a bug with my Moto X and the Google play app. I get correct info with Pandora on my Moto X. The Google Play app also works fine on my Nexus 7.

Still Investigating....