It is possible to find actual ble
txPower
of android device. So that, I can use it below Beacon builder object instead of -59 as txPower.
Beacon beacon = new Beacon.Builder()
.setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
.setId2("1")
.setId3("2")
.setManufacturer(0x0118)
.setTxPower(-59)
.setDataFields(Arrays.asList(new Long[] {0l}))
.build();
The use case what I have is, to read distance between two android ble device.
The txPower field is supposed to be the expected signal strength in dBm at 1 meter. Every Android phone model has a slightly different BLE transmitter output power, typically measuring from -50 dBm to -70 dBm at 1 meter.
Unfortunately there is no good way to get the proper value to use for a specific Android device model unless you measure this yourself. Android has no built-in APIs to get this, and I have never seen any published specs from phone manufacturers.
There has been renewed interest in this subject as teams develop contact tracing apps. I actually went out in a field last weekend to measure the transmitter output power of a number of devices I had handy. The Google Pixel 3a, for example, I measured -60 dBm.
If you want to take your own measurements to help in this effort, I suggest this procedure:
Here's my spreadsheet with the calculations: https://docs.google.com/spreadsheets/d/1-voNJAeHz78AarZmfds8WiplNhUDzeYrsW0YzKfrExU/edit?usp=sharing
I also wrote a blog post that touches on the problem of the lack of a good data set, and tells you more than you ever wanted to know about beacon ranging.