weliem / blessed-android

BLESSED, a Bluetooth Low Energy (BLE) library for Android
MIT License
557 stars 119 forks source link

What is the best method for receiving and responding to infrequent Bluetooth communications? #86

Closed phillipytran closed 3 years ago

phillipytran commented 3 years ago

My app communicates with a microcontroller and I would like the microcontroller to send a Bluetooth message to the app in response to certain events. These events are infrequent and can occur at random intervals (ie no patterns/periodicity). In the example app, I see that you create BroadcastReceivers for each Service in MainActivity and in BluetoothHandler, you broadcast an Intent whenever the Characteristic is updated. Is this the best method for what I am attempting to accomplish?

weliem commented 3 years ago

There are many ways to send data to an activity. I used broadcasts in the example app just because it is simple to do.

This library is about the BLE communication itself and the example app shows a way how to integrate it into an app.

I can't tell you what is best for your usecase. You will need to figure that out yourself....

phillipytran commented 3 years ago

That's fair enough. Thanks for taking the time to get back to me.