1

What I have read from many documents of Android Developer and lectures that I searched on the internet is: Advertising is sending signals to a broadcasting device so that the device could be found and Broadcasting is scanning the advertising devices to connect/send data.

Is what I understood correct?

Then is it true that BluetoothLeAdvertiser should be implemented first before scanning activity?

I am keep researching on the internet to find information in order to create an app that can broadcast a short word to other nearby devices through BLE. However, when I was doing research people do not use class LeAdvertiser that was introduced as an example on Android Developer page. Why is it??

Hally
  • 81
  • 8
  • 2
    A broadcaster sends advertisements. An observer performs scanning, i.e. listen to advertisements. You can of course write your code in which order you want. Do you have any specific question or have any issues implementing the available APIs? – Emil Jun 20 '21 at 19:00
  • I was wondering about the order of whole BLE communication process. So broadcaster sends advertisements and observer performs scanning. But I also read that advertisements can include a short data transmission as well, because I want to short sentence. So would it be possible to make that the main device that sends data do advertisement like peripheral device does and other devices that receives data can work like central device? I read https://developer.android.com/reference/kotlin/android/bluetooth/le/BluetoothLeAdvertiser page, but its difficult to find examples of how to use the classes... – Hally Jun 21 '21 at 05:47

1 Answers1

1

As Emil said, broadcaster/advertiser is the device that sends out BLE adverts. Broadly speaking, there are 4 main (GAP) roles in Bluetooth Low Energy:-

  • Broadcaster - A devices that just advertises data.
  • Peripheral - A device that advertises data but can be connected to by remote devices as well.
  • Observer - A device that just scans for data.
  • Central - A device that can scan for data as well as connect to them.

When BLE was first introduced, beacons/sensors (e.g. Heart Rate, Thermometer) occupied the first two categories and phones/computers occupied the other two. However, BLE has since evolved and a lot of devices now support all four roles and a device can operate in one or more roles at the same time.

And yes, if you want your device to be found by other observers/scanners, then you should first use LeAdvertiser in order to send out BLE adverts. Have a look at the links below that show how this is used:-

Youssif Saeed
  • 11,789
  • 4
  • 44
  • 72
  • Thank you very much for your answer! If I am trying to create an app that sends a sentence to nearby devices and other devices only receive using BLE, the devices should work as Broadcaster and Observer? If they do not require connection (like two-way communication and pairing), they do not have to work as Peripheral and Central? – Hally Jun 21 '21 at 08:01
  • 1
    Yes that's correct - if you want to send the string/sentence without establishing a connection, then one device has to be the broadcaster/advertise and the other device has to be the observer/scanner. However, please keep in mind that because this sentence is being 'broadcasted', all other scanner will be able to read the string message. This is one of the reasons that sending data is recommended to be done in a connection. – Youssif Saeed Jun 21 '21 at 16:52