Open nvchung opened 5 years ago
Hi,
Is this correct?
Do I have to pass the rangingData as int?
import com.moko.support.utils.MokoUtils;
Double distance = MokoUtils.getDistance(rssi, rangingData);
Thank you
Yes, the rangeingData must be a positive integer
Hi, Thank you. For Eddystone UUID the rangingdata will be; int txPower = Integer.parseInt(data.substring(2, 4), 16);
Can you please confirm. Thank you. JR
Sorry for not clear. To save battery I am only using one Slot EddyStone format UUID.
Hence, according following class;
public class BeaconXUID implements Serializable { public String rangingData; public String namespace; public String instanceId; }
and following class
public class BeaconXParser {
public static BeaconXUID getUID(String data) {
BeaconXUID uid = new BeaconXUID();
int txPower = Integer.parseInt(data.substring(2, 4), 16);
uid.rangingData = (byte) txPower + "";
uid.namespace = data.substring(4, 24);
uid.instanceId = data.substring(24, 36);
return uid;
}
The rangingdata = int txPower. Am I right?
Yes, you are right.
Thank you very much for your help.
@johanromuald how do you get distance? have you got a solution?
which parameter should i pass to get distance from BeaconXListAdapter
class
if(txPower >0) { Double Tdistance = (MokoUtils.getDistance(beaconXInfo.rssi, txPower)) / 1000; String Sdistance= String.valueOf( Tdistance); distance = Sdistance.substring(0,4); }
It is not reliable as RSSI varies rapidly. You have to come with some kind filter or running average RSSI to do this.
@johanromuald getting multiple txpower in list so not getting distance
I want to get a distance from device to the beacon, I find getDistance function in com.moko.support.utils.MokoUtils but dont know how to use? Pls help!