Just today I built a lightweight daemon to support the RAK10701 (very slick device, nicely done). Using Paho-MQTT and cJSON, I built a stand-alone service that runs on my ChirpStack server instances using the MQTT interface. I referred to the configuration directions for ChirpStack/Datacake.
I wasn’t quite sure what to make of this snippet of code from the Datacake decoder. It seems to compare the calculated distance (in km) with minDistance/maxDistance, which seem to be in meters. For example, if decoded.minDistance is 1800m and new_distance is 10km, it would seem to update decoded.minDistance to 10000m, so on. decodec.maxDistance appears to stick at whatever the first new_distance value is. Looking at the GitHub repo, this is indeed the bug fixed 3 weeks ago; there’s still old code on the RAK10701 webpage/guide.
// Calculate distance
var new_distance = distance(gw_lat[idx], gw_long[idx], decoded.latitude, decoded.longitude);
if ((new_distance < decoded.minDistance) || (decoded.minDistance == 0)) {
decoded.minDistance = new_distance * 1000;
}
if ((new_distance > decoded.maxDistance) || (decoded.maxDistance == 0)) {
decoded.maxDistance = new_distance * 1000;
}
I ended-up just converting distance to meters before doing min/max handling, and the minMod/maxMod are just those disances in units of 250m. At least that seems to be giving the right results. I sure do like the RAK10701.
Cheers,
Dana
Lamarr, Inc.