Bellafaire / Android-Companion-App-For-BLE-Devices

Provides an open source app which can send phone notifications and control phone functions over BLE
MIT License
43 stars 8 forks source link

notification request always fails on new update #9

Open themelispan opened 2 years ago

themelispan commented 2 years ago

I saw that the esp32 wouldn't receive notifications and modified the code a bit: (Just added a couple of Serial.print commands)

void loop()
{
  // available commands
  //   /notifications - gets current android notifications as a string format "appName,Title;ExtraText,ExtraInfoText,ExtraSubText,ExtraTitle;Description;"
  //   /calendar - returns a string of calender events for the next 24 hours in format "title;description;startDate;startTime;endTime;eventLocation;"
  //   /time - returns a string representing the time
  //   /isPlaying - returns "true" or "false" indicating whether spotify is playing on the android device
  //   /currentSong - returns the current song name and artist playing on spotify as one string
  //   /play - hits the media play button on the android device
  //   /pause - hits the media pause button on the android device
  //   /nextSong - hits the media next song button on the android device
  //   /lastSong - hits the media previous song button on the android device

  String data = "";

  /* A bluetooth command can be processed with the below code.
     commands can either be blocking or non-blocking (Preventing execution until data is fully recieved)
     A string pointer is passed in to the sendBLE function, if an operation is not in progress then the function will return TRUE
     and data will be placed in the data string.
     sendBLE will return false if a command is currently in progress.  */
  boolean requestSuccess = sendBLE(
                             "/notifications", //command
                             &data,            //pointer to string
                             true              //whether the request is blocking or not.
                           );
  /* Certain commands that do not request data, such as the media control commands,
     can use the below function
      boolean sendBLE(String command)
      which will return true if the command was successful and false if not.
  */

  if (requestSuccess)
  {
    Serial.println(data);
    ttgo->tft->println(data);
  } else {
    Serial.println("request failed");
  }
  delay(5000);
}

I always get the "request failed" message. But the notification posted/removed part works well. By watching debug messages I concluded that it never actually receives any string. From what I saw, the sendBLE function of the current and the previous version are identical so it's a problem in the app, I've done all the settings that I did on the previous app. Plus, inside the app it says:

Device Has Notification Update Service: false

That is likely related but I don't know how the app works

Bellafaire commented 2 years ago

"Device Has Notification Update Service: false" shouldn't be related, that's meant to indicate whether a characteristic is available for the update service. I believe I just forgot to add the check to update that.

I'm unable to replicate the issue you're experiencing. Try force stopping the app and reconnecting to a fresh instance.

themelispan commented 2 years ago

Force-stopping the app didnt do anything. Rebooting both devices didnt do anything either. I don't know what is wrong

themelispan commented 2 years ago

I even tried commands such as media control that do not request any data and they do not work

Bellafaire commented 2 years ago

Is the connection status updating on the app side?