0

I'm trying to make an angle detector, when it goes below 60 degree, it will send a notification to the phone. I have the gyroscope settled, but I don't know where to start with the bluetooth. Can anyone help? Note: I'm trying to make it so that whenever the angle goes below 60 degree it will show a banner or some sort of notification

I tried asking friends but they can't help

  • Are you using Bluetooth Classic or Bluetooth Low Energy? Since you said Bluetooth Terminal I would assume Bluetooth Classic. – Michael Kotzjan Jun 12 '23 at 13:44
  • 1
    I am using HC-06 which I think is bluetooth classic since it does not support BLE. – Silverash_0299 Jun 13 '23 at 07:09
  • Thanks for clarifying! What have you tried so far? have you worked through the [Android Developer Guide](https://developer.android.com/guide/topics/connectivity/bluetooth) regarding Bluetooth Classic? – Michael Kotzjan Jun 13 '23 at 07:39
  • I have went through it a few days ago, I tried using the app and sending messages through and I also have asked some of my friends. The problem is bluetooth terminal is only able to send and receive messages when you're in the app, so what if I wanted it to send notifications when you're using some other app? – Silverash_0299 Jun 13 '23 at 08:00
  • You want to use a background service for that. See https://stackoverflow.com/questions/49729452/how-to-keep-bluetooth-connection-background and https://stackoverflow.com/questions/25267753/how-to-keep-bluetooth-connection-in-background – Michael Kotzjan Jun 13 '23 at 11:39
  • I have looked through the links, they seem the same, but that only covers how to stop Bluetooth from disconnecting after closing the app. Although that is one problem down, I still need a way to let it send notification when it receives certain data as mentioned above. – Silverash_0299 Jun 14 '23 at 02:48
  • If you use a background service you can receive bluetooth signals even if the app is closed/in background. Now simply send a notification whenever you receive something via bluetooth: https://developer.android.com/develop/ui/views/notifications/build-notification – Michael Kotzjan Jun 14 '23 at 05:28
  • Well I apologize kind of a noob here but how exactly do I relate this to Bluetooth terminal? Do I need to write another piece of code for the notification then copy paste it somewhere? – Silverash_0299 Jun 14 '23 at 09:45
  • Since you want to write your own app that works like Bluetooth Terminal and allows sending notifications you should start working through the Developer Guide about Bluetooth until you have your own app that receives the messages from your angle detector. The next step for me would be to handle these messages, read the angle and do something depending on the angle. If it is below 60 degree you show a message or a notification. Afterwards you can start working on using services to allow the app to run in the background. – Michael Kotzjan Jun 14 '23 at 10:00
  • That’s a lot of work, but thanks. The guide should have all the things I need (right?). Thanks again for giving me a starting point – Silverash_0299 Jun 14 '23 at 11:33
  • You should find guides for all the parts, the combining is in your hands ;) your welcome! Fell free to open another question if you are stuck at some point. The best case would be if you could provide a minimal reproducable example for your problem :) – Michael Kotzjan Jun 14 '23 at 12:00

0 Answers0