No, RUI3 will not automatically adjust the data rate.
If you are using a custom firmware, you can implement it with an extra function:
uint16_t in865_eu433_ru864_eu868_ps[16] = {51, 51, 51, 115, 242, 242, 242, 242, 0, 0, 0, 0, 0, 0, 0, 0};
uint16_t au915_ps[16] = {51, 51, 51, 115, 242, 242, 242, 0, 53, 129, 242, 242, 242, 242, 0, 0};
uint16_t cn470_kr920_ps[16] = {51, 51, 51, 115, 242, 242, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
uint16_t us915_ps[16] = {11, 53, 125, 242, 242, 0, 0, 0, 53, 129, 242, 242, 242, 242, 0, 0};
uint16_t as923_ps[16] = {0, 0, 19, 61, 133, 250, 250, 250, 0, 0, 0, 0, 0, 0, 0, 0};
uint16_t *region_map[12] = {in865_eu433_ru864_eu868_ps, cn470_kr920_ps, in865_eu433_ru864_eu868_ps, in865_eu433_ru864_eu868_ps, in865_eu433_ru864_eu868_ps,
us915_ps, au915_ps, cn470_kr920_ps, as923_ps, as923_ps, as923_ps, as923_ps};
/**
* @brief Get the minimum datarate based on region and required payload size
*
* @param region LoRaWAN region
* 0 = EU433, 1 = CN470, 2 = RU864, 3 = IN865, 4 = EU868, 5 = US915,
* 6 = AU915, 7 = KR920, 8 = AS923-1 , 9 = AS923-2 , 10 = AS923-3 , 11 = AS923-4)
* @param payload_size required payload size
* @return uint8_t datarate 0 to 15 or 16 if no matching DR could be found
*/
uint8_t get_min_dr(uint16_t region, uint16_t payload_size)
{
// Get the datarate - payload size map
uint16_t *region_ps = region_map[region];
// Go through all payload sizes
for (uint8_t idx = 0; idx < 16; idx++)
{
// Check if dr payload size is larger than requested payload size
if (payload_size < region_ps[idx])
{
// Found a datarate that can carry the payload size
return idx;
}
}
// No matching datarate for the payload size found
return 16;
}
and use it like this:
// Check DR
uint8_t new_dr = get_min_dr(api.lorawan.band.get(), g_solution_data.getSize());
if (new_dr != 16)
{
if (new_dr != api.lorawan.dr.get())
{
// Set the new data rate
api.lorawan.dr.set(new_dr);
Serial.printf("Datarate changed to %d\n", api.lorawan.dr.get());
}
}
else
{
Serial.println("No matching datarate found");
}
// Send the packet
if (api.lorawan.send(g_solution_data.getSize(), g_solution_data.getBuffer()))
{
Serial.printf("Packet enqueued, size %d\n", g_solution_data.getSize());
}
else
{
Serial.println("Send failed");
}