Sorry stupid question, above there is some code (writing from mobile).
Reference = ideal code for the situation to copy the idea / function.
Sorry stupid question, above there is some code (writing from mobile).
Reference = ideal code for the situation to copy the idea / function.
For changing the power table in the json, I believe you already have that in the thread.
For changing the algorithm in the code to settle for the closest match, I’d assume someone has done it in some version, they’re all pretty comparable when you start diffing the relevant portions of the actual code.
But that may be a legitimate question - is there a version of the packet forwarder which settles for a close rather than exact match?
There are a number of versions (that I know) that take the next lowest power and they are
Let’s try and explain the problem. I published this previously in the TTN Slack channel but that may have disappeared by now
The gateway code is compiled from two pieces of code,
The two pass messages via a Queue.
The packet forwarder has a test (refer line 2014-2026 of the picoGW code picoGW_packet_forwarder/lora_pkt_fwd/src/lora_pkt_fwd.c at master · Lora-net/picoGW_packet_forwarder · GitHub) where it checks for a match of the requested power from the server and the powers listed in the tx_lut table
The HAL performs the same test but in this case it selects the next lowest power from the tx_lut table
The first thing that struck me, there is duplicated and redundant checking being conducted.
So the simple solution is to remove the test in the Packet Forwarder and allow the HAL to perform the check and select the most appropriate power.
CAUTION: I have checked the PicoGW HAL code and its not the same as the other versions of the HAL. There isn’t a test in the PicoGW HAL code for power so this solution will not work.
What is required is to edit these lines and change them from being an exact match to selecting the next lowest.
This is the code from the sx1301 HAL that could be used as a concept to create the solution
/* interpretation of TX power */ for (pow_index = txgain_lut.size-1; pow_index > 0; pow_index--) { if (txgain_lut.lut[pow_index].rf_power <= pkt_data.rf_power) { break; } }
Edit:
Try this in place of lines 2014 - 2026
if (jit_result == JIT_ERROR_OK) { /* interpretation of TX power */ for (i = txlut.size-1; 0; i--) { if (txlut.lut[i].rf_power <= txpkt.rf_power) { /* Found an exact match or next lowest power, we can continue*/ break; } } }
The patch I published also addressed another issue.
If you look at line 971 of the code you will see a “ToDo” where there is no checking of the configuration parameters.
There is no check for the entries in the tx-lut table are in increasing order of power. This is necessary for the selection process in the HAL code to work. As long as the tx_lut table has not been modified it should work fine.