summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2021-01-25 14:54:20 -0600
committerJason Reiss <jreiss@multitech.com>2021-02-02 06:19:08 -0600
commita79fc6674a93347b8db0696239da4d57bf6b1da9 (patch)
tree86b022566c378e94bc571c9fb338199709c71090
parente124777c147b95fbac9a64a99a14adc3e758f987 (diff)
downloadpacket_forwarder_mtac_full-a79fc6674a93347b8db0696239da4d57bf6b1da9.tar.gz
packet_forwarder_mtac_full-a79fc6674a93347b8db0696239da4d57bf6b1da9.tar.bz2
packet_forwarder_mtac_full-a79fc6674a93347b8db0696239da4d57bf6b1da9.zip
Load temperature adjusted LUT values and tables when temp_lut.json configuraion is detected.
-rw-r--r--lora_pkt_fwd/cfg/temp_lut.json.MTAC-LORA-1.5236
-rw-r--r--lora_pkt_fwd/global_conf.json4
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c398
3 files changed, 529 insertions, 109 deletions
diff --git a/lora_pkt_fwd/cfg/temp_lut.json.MTAC-LORA-1.5 b/lora_pkt_fwd/cfg/temp_lut.json.MTAC-LORA-1.5
new file mode 100644
index 0000000..421acb5
--- /dev/null
+++ b/lora_pkt_fwd/cfg/temp_lut.json.MTAC-LORA-1.5
@@ -0,0 +1,236 @@
+{
+"LUT-40": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [11.8, 7.2, 10.2, 6.7]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [13.5, 12.9, 12.4, 7.8]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [15.4, 14.4, 15.1, 10.7]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [17.2, 16.8, 17.0, 15.5]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [17.4, 17.8, 15.7, 14.0]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [18.5, 18.1, 18.0, 16.5]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [17.4, 16.7, 15.7, 13.0]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [20.6, 20.2, 17.0, 14.5]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [21.6, 21.3, 21.6, 20.1]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [22.5, 22.4, 22.1, 21.3]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [23.0, 22.8, 22.7, 21.8]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [27.4, 27.0, 26.5, 24.0]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [28.3, 27.6, 28.2, 25.6]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [28.5, 28.5, 28.5, 28.4]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.6, 28.6, 28.6, 28.4]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.6, 28.6, 28.6, 28.5]}
+},
+"LUT-30": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [9.2, 8.6, 7.2, 3.3]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [10.8, 10.0, 7.8, 5.6]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [12.5, 10.8, 10.4, 7.9]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [16.1, 15.1, 11.9, 13.7]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [15.6, 16.6, 16.0, 15.2]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [17.1, 17.4, 15.8, 13.4]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [16.7, 16.0, 15.0, 12.1]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [18.1, 17.2, 16.4, 13.8]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [21.0, 21.5, 20.7, 19.8]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [22.3, 22.1, 21.9, 20.7]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [22.8, 22.6, 22.2, 21.7]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [27.1, 26.7, 26.0, 23.0]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [27.8, 27.4, 26.9, 24.8]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [28.5, 28.2, 28.1, 28.2]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.5, 28.5, 28.5, 28.4]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.6, 28.6, 28.6, 28.5]}
+},
+"LUT-20": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [7.2, 6.0, 4.8, 1.8]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [8.8, 8.2, 7.0, 4.2]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [10.5, 9.4, 8.4, 5.7]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [13.8, 13.5, 13.0, 11.7]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [14.9, 14.5, 14.8, 13.3]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [15.9, 16.5, 15.6, 14.6]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [16.3, 15.5, 14.5, 11.6]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [17.8, 16.9, 15.9, 13.3]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [21.1, 20.7, 20.2, 19.6]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [21.6, 21.3, 21.0, 20.1]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [22.5, 22.2, 21.9, 21.8]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [26.9, 26.3, 25.5, 22.3]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [27.6, 27.2, 26.6, 24.2]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [28.4, 28.2, 28.3, 28.2]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.5, 28.5, 28.4, 28.3]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.6, 28.6, 28.5, 28.5]}
+},
+"LUT-10": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [6.3, 5.5, 4.3, 1.1]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [7.9, 7.1, 6.2, 3.2]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [9.2, 8.4, 7.6, 4.9]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [12.4, 12.2, 11.9, 7.8]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [13.2, 12.6, 12.6, 12.0]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [14.8, 14.4, 14.1, 12.5]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [15.9, 15.0, 14.1, 11.1]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [17.2, 16.4, 15.4, 12.8]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [20.8, 20.5, 20.1, 19.1]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [21.2, 20.9, 20.9, 19.8]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [22.2, 21.9, 21.3, 20.7]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [26.6, 25.9, 24.9, 21.8]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [27.4, 26.9, 26.4, 23.6]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [28.2, 28.3, 28.2, 28.2]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.4, 28.4, 28.4, 28.3]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.5, 28.4, 28.4, 28.4]}
+},
+"LUT0": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [5.6, 4.7, 3.5, 0.2]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [7.2, 6.5, 5.5, 2.5]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [8.4, 7.7, 6.9, 4.2]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [11.9, 10.2, 11.1, 9.9]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [12.4, 11.7, 11.8, 10.7]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [13.1, 12.6, 12.4, 11.8]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [15.2, 14.4, 13.3, 10.3]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [16.6, 15.7, 14.8, 12.0]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [19.2, 18.5, 19.5, 18.8]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [20.8, 20.1, 20.4, 19.3]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [22.1, 21.3, 21.0, 20.4]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [26.1, 25.3, 24.2, 20.8]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [27.0, 26.5, 25.7, 22.7]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [28.0, 27.9, 27.6, 26.0]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.2, 28.3, 28.2, 28.0]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.4, 28.4, 28.3, 28.2]}
+},
+"LUT10": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [5.2, 4.1, 3.0, -0.4]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [6.7, 5.9, 4.9, 1.9]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [8.0, 7.2, 6.4, 3.5]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [10.2, 10.8, 8.9, 6.7]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [11.7, 11.1, 10.8, 10.4]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [12.2, 12.1, 12.0, 10.7]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [14.7, 13.8, 12.8, 9.7]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [16.0, 15.2, 14.2, 11.4]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [18.7, 18.0, 17.1, 18.3]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [20.1, 19.8, 18.9, 19.2]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [21.1, 20.7, 20.5, 19.7]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [25.5, 24.6, 23.6, 20.2]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [26.6, 26.1, 25.1, 22.0]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [27.8, 27.6, 27.3, 25.7]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [28.1, 28.1, 28.0, 27.5]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.3, 28.2, 28.2, 28.1]}
+},
+"LUT20": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [4.4, 3.3, 2.1, -1.2]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [6.0, 5.2, 4.1, 0.9]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [7.2, 6.5, 5.6, 2.7]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [9.6, 9.0, 8.2, 6.0]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [10.7, 10.4, 9.8, 8.4]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [11.5, 11.4, 11.4, 10.4]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [13.9, 13.0, 11.9, 8.8]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [15.3, 14.4, 13.4, 10.6]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [18.2, 17.3, 16.4, 13.8]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [19.4, 19.0, 19.0, 16.2]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [20.6, 20.4, 19.9, 19.9]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [24.8, 23.8, 22.7, 19.2]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [26.1, 25.3, 24.3, 21.2]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [27.5, 27.3, 26.9, 24.8]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [27.9, 27.9, 27.8, 27.1]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [28.0, 28.0, 28.0, 27.8]}
+},
+"LUT30": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [3.7, 2.4, 1.1, -2.2]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [5.2, 4.3, 3.2, 0.0]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [6.5, 5.7, 4.8, 1.8]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [8.9, 8.3, 7.5, 5.4]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [10.1, 10.2, 9.3, 7.4]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [11.2, 10.9, 10.5, 9.4]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [13.1, 12.2, 11.0, 7.8]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [14.5, 13.7, 12.6, 9.7]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [17.3, 16.6, 15.7, 13.1]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [18.8, 18.3, 17.9, 16.1]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [20.0, 19.8, 19.3, 19.1]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [24.1, 22.9, 21.8, 18.3]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [25.4, 24.6, 23.5, 20.3]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [27.2, 26.9, 26.3, 23.9]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [27.7, 27.5, 27.2, 26.7]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [27.9, 27.8, 27.8, 27.5]}
+},
+"LUT40": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [3.2, 1.8, 0.5, -2.8]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [4.7, 3.7, 2.6, -0.6]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [6.0, 5.2, 4.2, 1.1]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [8.4, 7.8, 6.9, 4.6]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [9.3, 9.2, 8.6, 6.5]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [10.5, 10.4, 10.0, 9.0]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [12.6, 11.6, 10.5, 7.2]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [13.9, 13.1, 12.1, 9.0]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [16.8, 16.0, 15.1, 12.5]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [18.2, 17.7, 16.5, 15.1]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [19.6, 19.1, 18.8, 17.6]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [23.3, 22.3, 21.0, 17.5]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [24.7, 23.9, 22.7, 19.4]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [27.0, 26.5, 25.8, 23.2]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [27.4, 27.3, 27.1, 25.7]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [27.8, 27.7, 27.6, 27.3]}
+},
+"LUT50": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [2.5, 1.0, -0.3, -3.7]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [4.0, 2.9, 1.8, -1.5]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [5.3, 4.5, 3.5, 0.4]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [7.8, 7.1, 6.3, 3.9]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [9.0, 8.4, 7.6, 6.3]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [10.1, 9.9, 9.3, 8.0]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [11.8, 10.8, 9.7, 6.3]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [13.2, 12.3, 11.3, 8.1]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [16.1, 15.4, 14.4, 11.8]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [17.3, 16.8, 16.5, 13.7]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [19.0, 18.6, 18.4, 16.3]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [22.6, 21.4, 20.0, 16.5]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [24.1, 23.1, 21.9, 18.5]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [26.6, 26.0, 25.1, 22.4]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [27.3, 27.1, 26.6, 24.5]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [27.6, 27.5, 27.4, 26.8]}
+},
+"LUT60": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [2.0, 0.4, -1.0, -4.3]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [3.5, 2.3, 1.2, -2.1]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [4.7, 3.9, 2.8, -0.3]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [7.3, 6.6, 5.7, 3.2]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [8.3, 7.7, 6.9, 4.7]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [9.5, 9.5, 8.7, 6.9]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [11.3, 10.2, 9.0, 5.6]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [12.6, 11.7, 10.7, 7.5]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [15.6, 14.8, 13.7, 11.0]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [16.8, 16.1, 15.2, 12.6]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [18.5, 18.0, 17.2, 15.9]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [21.8, 20.6, 19.3, 15.7]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [23.3, 22.3, 21.2, 17.7]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [26.1, 25.4, 24.5, 21.6]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [26.9, 26.5, 25.8, 24.6]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [27.5, 27.5, 27.2, 26.0]}
+},
+"LUT70": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [1.2, -0.4, -1.9, -5.3]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [2.6, 1.5, 0.2, -3.0]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [3.9, 3.0, 1.9, -1.2]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [6.5, 5.8, 5.0, 2.3]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [7.6, 7.0, 6.2, 3.9]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [9.2, 8.6, 8.1, 6.5]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [10.5, 9.3, 8.0, 4.7]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [11.8, 10.8, 9.8, 6.6]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [14.8, 13.9, 13.0, 10.2]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [16.1, 15.4, 14.4, 11.8]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [18.0, 17.3, 16.7, 14.3]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [20.8, 19.6, 18.4, 14.6]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [22.4, 21.3, 20.1, 16.6]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [25.4, 24.5, 23.5, 20.6]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [26.4, 25.9, 25.0, 22.2]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [27.2, 27.0, 26.7, 25.0]}
+},
+"LUT85": {
+"tx_lut_0":{"rf_power": 0, "pa_gain": 1, "mix_gain": 8, "dig_gain": [0.2, -1.7, -3.3, -6.7]},
+"tx_lut_1":{"rf_power": 1, "pa_gain": 1, "mix_gain": 9, "dig_gain": [1.4, 0.2, -1.2, -4.5]},
+"tx_lut_2":{"rf_power": 2, "pa_gain": 1, "mix_gain": 10, "dig_gain": [2.7, 1.6, 0.6, -2.7]},
+"tx_lut_3":{"rf_power": 3, "pa_gain": 1, "mix_gain": 12, "dig_gain": [5.4, 4.7, 3.8, 1.0]},
+"tx_lut_4":{"rf_power": 4, "pa_gain": 1, "mix_gain": 13, "dig_gain": [6.5, 5.9, 5.1, 2.6]},
+"tx_lut_5":{"rf_power": 5, "pa_gain": 1, "mix_gain": 15, "dig_gain": [8.1, 7.6, 7.0, 4.9]},
+"tx_lut_6":{"rf_power": 6, "pa_gain": 2, "mix_gain": 9, "dig_gain": [9.3, 7.9, 6.6, 3.2]},
+"tx_lut_7":{"rf_power": 7, "pa_gain": 2, "mix_gain": 10, "dig_gain": [10.6, 9.6, 8.4, 5.1]},
+"tx_lut_8":{"rf_power": 8, "pa_gain": 2, "mix_gain": 12, "dig_gain": [13.6, 12.8, 11.7, 8.8]},
+"tx_lut_9":{"rf_power": 9, "pa_gain": 2, "mix_gain": 13, "dig_gain": [15.0, 14.2, 13.3, 10.5]},
+"tx_lut_10":{"rf_power": 10, "pa_gain": 2, "mix_gain": 15, "dig_gain": [17.0, 16.4, 15.6, 13.1]},
+"tx_lut_11":{"rf_power": 11, "pa_gain": 3, "mix_gain": 9, "dig_gain": [19.6, 18.0, 16.6, 13.1]},
+"tx_lut_12":{"rf_power": 12, "pa_gain": 3, "mix_gain": 10, "dig_gain": [20.9, 19.8, 18.5, 15.0]},
+"tx_lut_13":{"rf_power": 13, "pa_gain": 3, "mix_gain": 12, "dig_gain": [24.2, 23.3, 22.3, 19.1]},
+"tx_lut_14":{"rf_power": 14, "pa_gain": 3, "mix_gain": 13, "dig_gain": [25.4, 24.8, 23.7, 20.8]},
+"tx_lut_15":{"rf_power": 15, "pa_gain": 3, "mix_gain": 15, "dig_gain": [26.7, 26.4, 26.1, 23.9]}
+}
+}
diff --git a/lora_pkt_fwd/global_conf.json b/lora_pkt_fwd/global_conf.json
index d73b50c..640fd18 100644
--- a/lora_pkt_fwd/global_conf.json
+++ b/lora_pkt_fwd/global_conf.json
@@ -16,8 +16,8 @@
"antenna_gain": 0, /* antenna gain, in dBi */
"temperature_comp": {
"enabled": false,
- "values": [ [-20,-2], [-10,-1], [0,0], [0,0] ],
- "current_temp_file": "/var/run/lora/current_temp"
+ "current_temp_type": "SENSOR",
+ "current_temp_file": "/sys/class/hwmon/hwmon0/temp1_input"
},
"radio_0": {
"enable": true,
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
index c75624f..c438ca3 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -294,12 +294,12 @@ static struct jit_queue_s jit_queue;
/* Gateway specificities */
static int8_t antenna_gain = 0;
-#define TEMP_ADJ_MAX 4
-#define DEFAULT_TEMP_COMP_FILE "/var/run/lora/current_temp"
-static int16_t temp_comp_table[TEMP_ADJ_MAX][2] = { 0 };
-static char temp_comp_file[64] = {0};
-static int16_t temp_comp_value = 0;
-static int16_t temp_comp_adj = 0;
+#define DEFAULT_TEMP_COMP_TYPE "SENSOR"
+#define DEFAULT_TEMP_COMP_FILE "/sys/class/hwmon/hwmon0/temp1_input"
+static char temp_comp_type[16] = {0};
+static uint8_t temp_comp_file_type = 0;
+static char temp_comp_file[128] = {0};
+static int temp_comp_value = 20;
static bool temp_comp_enabled = false;
/* TX capabilities */
@@ -338,29 +338,181 @@ void thread_spectralscan(void);
/* -------------------------------------------------------------------------- */
/* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */
+#define TEMP_LUT_SIZE_MAX 13
+
+/**
+@struct lgw_tx_alt_gain_s
+@brief Structure containing all gains of Tx chain
+*/
+struct lgw_tx_alt_gain_s {
+ float dig_gain[4];/*!> RF power output measured at each dig setting 0-3 */
+ uint8_t pa_gain; /*!> 2 bits, control of the external PA (SX1301 I/O) */
+ uint8_t dac_gain; /*!> 2 bits, control of the radio DAC */
+ uint8_t mix_gain; /*!> 4 bits, control of the radio mixer */
+ int8_t rf_power; /*!> measured TX power at the board connector, in dBm */
+};
+
+/**
+@struct lgw_tx_alt_gain_lut_s
+@brief Structure defining the Tx gain LUT
+*/
+struct lgw_tx_alt_gain_lut_s {
+ struct lgw_tx_alt_gain_s lut[TX_GAIN_LUT_SIZE_MAX]; /*!> Array of Tx gain struct */
+ int8_t temp;
+ uint8_t size; /*!> Number of LUT indexes */
+};
+
+/**
+@struct lgw_tx_alt_gain_lut_s
+@brief Structure defining the Tx gain LUT
+*/
+struct lgw_tx_temp_lut_s {
+ struct lgw_tx_alt_gain_lut_s lut[TEMP_LUT_SIZE_MAX]; /*!> Array of Tx gain struct */
+ uint8_t size; /*!> Number of LUT indexes */
+};
+
+struct lgw_tx_temp_lut_s tx_temp_lut;
+
+void lookup_power_settings(float tx_pwr, int8_t* rf_power, int8_t* dig_gain) {
+ float min_diff = 99;
+
+ for (int i = 0; i < TEMP_LUT_SIZE_MAX; i++) {
+ if (i == TEMP_LUT_SIZE_MAX-1 || (tx_temp_lut.lut[i].temp <= temp_comp_value && tx_temp_lut.lut[i+1].temp > temp_comp_value)) {
+ for (int j = 0; j < TX_GAIN_LUT_SIZE_MAX; j++) {
+ for (int h = 0; h < 4; h++) {
+ if (tx_pwr >= tx_temp_lut.lut[i].lut[j].dig_gain[h] && (tx_pwr - tx_temp_lut.lut[i].lut[j].dig_gain[h]) < min_diff) {
+ min_diff = (tx_pwr - tx_temp_lut.lut[i].lut[j].dig_gain[h]);
+ *rf_power = j;
+ *dig_gain = h;
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ if (min_diff == 99) {
+ // minimum output if no match was found
+ *rf_power = 0;
+ *dig_gain = 3;
+ }
+}
+
+void load_temp_lookup() {
+
+ int i;
+ char param_name[32]; /* used to generate variable parameter names */
+ const char *str; /* used to store string value from JSON object */
+ const char conf_obj_name[] = "SX1301_conf";
+ JSON_Value *root_val = NULL;
+ JSON_Object *conf_obj = NULL;
+ JSON_Object *conf_lut_obj = NULL;
+ JSON_Value *val = NULL;
+ JSON_Array *conf_array = NULL;
+ char *temp_lut_path= "temp_lut.json"; /* contain temperature lut configuration */
+ if (access(temp_lut_path, R_OK) != 0) { /* if there is a global conf, parse it and then try to parse local conf */
+ return;
+ }
+
+ MSG("INFO: found temp_lut configuration file %s, parsing it\n", temp_lut_path);
+
+ memset(&tx_temp_lut, 0, sizeof tx_temp_lut); /* initialize configuration structure */
+
+ /* try to parse JSON */
+ root_val = json_parse_file_with_comments(temp_lut_path);
+ if (root_val == NULL) {
+ MSG("ERROR: %s is not a valid JSON file\n", temp_lut_path);
+ exit(EXIT_FAILURE);
+ }
+
+ temp_comp_enabled = true;
+
+ int index = 0;
+ for (int temp = -60; temp <= 100; temp++) {
+ snprintf(param_name, sizeof param_name, "LUT%i", temp); /* compose parameter path inside JSON structure */
+ /* point to the gateway configuration object */
+ conf_obj = json_object_get_object(json_value_get_object(root_val), param_name);
+ if (conf_obj == NULL) {
+ continue;
+ }
+
+ tx_temp_lut.lut[index].temp = temp;
+
+ for (i = 0; i < TX_GAIN_LUT_SIZE_MAX; i++) {
+ snprintf(param_name, sizeof param_name, "tx_lut_%i", i); /* compose parameter path inside JSON structure */
+ conf_lut_obj = json_object_get_object(conf_obj, param_name); /* fetch value (if possible) */
+ if (conf_lut_obj == NULL) {
+ MSG("INFO: no configuration for tx gain lut %i\n", i);
+ continue;
+ }
+ tx_temp_lut.lut[index].size++; /* update TX LUT size based on JSON object found in configuration file */
+ /* there is an object to configure that TX gain index, let's parse it */
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.pa_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ tx_temp_lut.lut[index].lut[i].pa_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ tx_temp_lut.lut[index].lut[i].pa_gain = 0;
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.dac_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ tx_temp_lut.lut[index].lut[i].dac_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ tx_temp_lut.lut[index].lut[i].dac_gain = 3; /* This is the only dac_gain supported for now */
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.mix_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ tx_temp_lut.lut[index].lut[i].mix_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ tx_temp_lut.lut[index].lut[i].mix_gain = 0;
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.rf_power", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ tx_temp_lut.lut[index].lut[i].rf_power = (int8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ tx_temp_lut.lut[index].lut[i].rf_power = 0;
+ }
+
+ conf_array = json_object_get_array(conf_lut_obj, "dig_gain");
+ if (conf_array != NULL) {
+ for (int j = 0; j < 4; j++) {
+ /* Get lut channel configuration object from array */
+ tx_temp_lut.lut[index].lut[i].dig_gain[j] = (float)json_array_get_number(conf_array, j);
+ }
+ }
+ }
+
+ index++;
+ }
+}
+
+
static void update_temp_comp_value() {
if (!temp_comp_enabled) {
return;
}
/* try to open file to read */
FILE *filePointer;
+
if (filePointer = fopen(temp_comp_file, "r")) {
- int bufferLength = 4;
+ int bufferLength = 10;
char buffer[bufferLength];
fgets(buffer, bufferLength, filePointer);
- temp_comp_value = atoi(buffer);
- int16_t adj_val = 0;
+ temp_comp_value = atoi(buffer);
- for (int i = 0; i < TEMP_ADJ_MAX; i++) {
- if (temp_comp_table[i][0] <= temp_comp_value) {
- adj_val = temp_comp_table[i][1];
- }
+ if (temp_comp_file_type == 0) {
+ // SENSOR provides a mC reading
+ temp_comp_value = ((temp_comp_value % 1000) >= 500 ? 1 : 0) + (temp_comp_value / 1000);
}
- temp_comp_adj = adj_val;
-
fclose(filePointer);
}
@@ -521,6 +673,8 @@ static int parse_SX1301_configuration(const char * conf_file) {
struct lgw_conf_rxif_s ifconf;
uint32_t sf, bw, fdev;
+ load_temp_lookup();
+
/* try to parse JSON */
root_val = json_parse_file_with_comments(conf_file);
if (root_val == NULL) {
@@ -658,13 +812,12 @@ static int parse_SX1301_configuration(const char * conf_file) {
conf_temp_comp_obj = json_object_get_object(conf_obj, "temperature_comp"); /* fetch value (if possible) */
if (conf_temp_comp_obj == NULL) {
- MSG("INFO: no configuration for Temperature Compensation\n");
+ MSG("INFO: Default Temperature Compensation\n");
+ strncpy(temp_comp_file, DEFAULT_TEMP_COMP_FILE, sizeof(temp_comp_file)-1);
} else {
val = json_object_get_value(conf_temp_comp_obj, "enable"); /* fetch value (if possible) */
if (json_value_get_type(val) == JSONBoolean) {
temp_comp_enabled = (bool)json_value_get_boolean(val);
- } else {
- temp_comp_enabled = false;
}
if (temp_comp_enabled) {
@@ -679,99 +832,100 @@ static int parse_SX1301_configuration(const char * conf_file) {
strncpy(temp_comp_file, DEFAULT_TEMP_COMP_FILE, sizeof(temp_comp_file)-1);
}
- /* load temp adj table */
- int adj_count = 0;
- conf_array = json_object_get_array(conf_temp_comp_obj, "values");
- if (conf_array != NULL) {
- adj_count = json_array_get_count( conf_array );
-
- JSON_Array *temp_values = NULL;
- for (i = 0; i < (int)adj_count; i++) {
- /* Sanity check */
- if (i >= TEMP_ADJ_MAX)
- {
- MSG("ERROR: Temp adj %d not supported, skip it\n", i );
- break;
- }
-
- /* Get LBT channel configuration object from array */
- temp_values = json_array_get_array(conf_array, i);
- size_t cnt = json_array_get_count(temp_values);
-
- if (cnt == 2) {
- temp_comp_table[i][0] = (int16_t)json_array_get_number(temp_values, 0);
- temp_comp_table[i][1] = (int16_t)json_array_get_number(temp_values, 1);
- }
- }
+ /* Current temperature type (optional) */
+ str = json_object_get_string(conf_temp_comp_obj, "current_temp_type");
+ if (str != NULL) {
+ strncpy(temp_comp_type, str, sizeof(temp_comp_type)-1);
+ MSG("INFO: Current temperature file is configured to \"%s\"\n", temp_comp_type);
+ } else {
+ strncpy(temp_comp_type, DEFAULT_TEMP_COMP_TYPE, sizeof(temp_comp_type)-1);
}
- update_temp_comp_value();
+ if (strncmp(temp_comp_type, "FILE", 4) == 0) {
+ temp_comp_file_type = 1;
+ }
} else {
MSG("INFO: Temperature Compensation disabled\n");
}
}
- /* set configuration for tx gains */
- memset(&txlut, 0, sizeof txlut); /* initialize configuration structure */
- for (i = 0; i < TX_GAIN_LUT_SIZE_MAX; i++) {
- snprintf(param_name, sizeof param_name, "tx_lut_%i", i); /* compose parameter path inside JSON structure */
- val = json_object_get_value(conf_obj, param_name); /* fetch value (if possible) */
- if (json_value_get_type(val) != JSONObject) {
- MSG("INFO: no configuration for tx gain lut %i\n", i);
- continue;
- }
- txlut.size++; /* update TX LUT size based on JSON object found in configuration file */
- /* there is an object to configure that TX gain index, let's parse it */
- snprintf(param_name, sizeof param_name, "tx_lut_%i.pa_gain", i);
- val = json_object_dotget_value(conf_obj, param_name);
- if (json_value_get_type(val) == JSONNumber) {
- txlut.lut[i].pa_gain = (uint8_t)json_value_get_number(val);
- } else {
- MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
- txlut.lut[i].pa_gain = 0;
- }
- snprintf(param_name, sizeof param_name, "tx_lut_%i.dac_gain", i);
- val = json_object_dotget_value(conf_obj, param_name);
- if (json_value_get_type(val) == JSONNumber) {
- txlut.lut[i].dac_gain = (uint8_t)json_value_get_number(val);
- } else {
- txlut.lut[i].dac_gain = 3; /* This is the only dac_gain supported for now */
- }
- snprintf(param_name, sizeof param_name, "tx_lut_%i.dig_gain", i);
- val = json_object_dotget_value(conf_obj, param_name);
- if (json_value_get_type(val) == JSONNumber) {
- txlut.lut[i].dig_gain = (uint8_t)json_value_get_number(val);
- } else {
- MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ if (temp_comp_enabled) {
+ update_temp_comp_value();
+
+ MSG("INFO: Loading temperature compensated LUT values\n");
+
+ for (i = 0; i < TX_GAIN_LUT_SIZE_MAX; i++) {
+ txlut.lut[i].rf_power = tx_temp_lut.lut[0].lut[i].rf_power;
+ txlut.lut[i].pa_gain = tx_temp_lut.lut[0].lut[i].pa_gain;
+ txlut.lut[i].mix_gain = tx_temp_lut.lut[0].lut[i].mix_gain;
txlut.lut[i].dig_gain = 0;
+ txlut.lut[i].dac_gain = 3;
+ MSG("LUT %d RF: %d PA: %d MIX: %d DIG: %d DAC: %d\n", i, txlut.lut[i].rf_power, txlut.lut[i].pa_gain, txlut.lut[i].mix_gain, txlut.lut[i].dig_gain, txlut.lut[i].dac_gain);
}
- snprintf(param_name, sizeof param_name, "tx_lut_%i.mix_gain", i);
- val = json_object_dotget_value(conf_obj, param_name);
- if (json_value_get_type(val) == JSONNumber) {
- txlut.lut[i].mix_gain = (uint8_t)json_value_get_number(val);
- } else {
- MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
- txlut.lut[i].mix_gain = 0;
+ } else {
+
+ /* set configuration for tx gains */
+ memset(&txlut, 0, sizeof txlut); /* initialize configuration structure */
+ for (i = 0; i < TX_GAIN_LUT_SIZE_MAX; i++) {
+ snprintf(param_name, sizeof param_name, "tx_lut_%i", i); /* compose parameter path inside JSON structure */
+ val = json_object_get_value(conf_obj, param_name); /* fetch value (if possible) */
+ if (json_value_get_type(val) != JSONObject) {
+ MSG("INFO: no configuration for tx gain lut %i\n", i);
+ continue;
+ }
+ txlut.size++; /* update TX LUT size based on JSON object found in configuration file */
+ /* there is an object to configure that TX gain index, let's parse it */
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.pa_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ txlut.lut[i].pa_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ txlut.lut[i].pa_gain = 0;
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.dac_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ txlut.lut[i].dac_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ txlut.lut[i].dac_gain = 3; /* This is the only dac_gain supported for now */
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.dig_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ txlut.lut[i].dig_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ txlut.lut[i].dig_gain = 0;
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.mix_gain", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ txlut.lut[i].mix_gain = (uint8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ txlut.lut[i].mix_gain = 0;
+ }
+ snprintf(param_name, sizeof param_name, "tx_lut_%i.rf_power", i);
+ val = json_object_dotget_value(conf_obj, param_name);
+ if (json_value_get_type(val) == JSONNumber) {
+ txlut.lut[i].rf_power = (int8_t)json_value_get_number(val);
+ } else {
+ MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
+ txlut.lut[i].rf_power = 0;
+ }
}
- snprintf(param_name, sizeof param_name, "tx_lut_%i.rf_power", i);
- val = json_object_dotget_value(conf_obj, param_name);
- if (json_value_get_type(val) == JSONNumber) {
- txlut.lut[i].rf_power = (int8_t)json_value_get_number(val);
+ /* all parameters parsed, submitting configuration to the HAL */
+ if (txlut.size > 0) {
+ MSG("INFO: Configuring TX LUT with %u indexes\n", txlut.size);
+ if (lgw_txgain_setconf(&txlut) != LGW_HAL_SUCCESS) {
+ MSG("ERROR: Failed to configure concentrator TX Gain LUT\n");
+ return -1;
+ }
} else {
- MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i);
- txlut.lut[i].rf_power = 0;
+ MSG("WARNING: No TX gain LUT defined\n");
}
}
- /* all parameters parsed, submitting configuration to the HAL */
- if (txlut.size > 0) {
- MSG("INFO: Configuring TX LUT with %u indexes\n", txlut.size);
- if (lgw_txgain_setconf(&txlut) != LGW_HAL_SUCCESS) {
- MSG("ERROR: Failed to configure concentrator TX Gain LUT\n");
- return -1;
- }
- } else {
- MSG("WARNING: No TX gain LUT defined\n");
- }
/* set configuration for RF chains */
for (i = 0; i < LGW_RF_CHAIN_NB; ++i) {
@@ -1856,7 +2010,6 @@ int main(int argc, char** argv)
if (temp_comp_enabled) {
update_temp_comp_value();
printf("# Temperature: %i C\n", temp_comp_value);
- printf("# Temp TxPow Adj: %i dB\n", temp_comp_adj);
}
jit_print_queue (&jit_queue, false, DEBUG_LOG);
@@ -2508,14 +2661,25 @@ void thread_down(void) {
beacon_pkt.tx_mode = ON_GPS; /* send on PPS pulse */
beacon_pkt.rf_chain = 0; /* antenna A */
beacon_pkt.rf_power = beacon_power - antenna_gain;
+ beacon_pkt.dig_gain = -1;
if (max_tx_power != -99) {
- if (txpkt.rf_power > max_tx_power - antenna_gain) {
+ if (beacon_power > max_tx_power) {
MSG("INFO: [beacon] tx power reduced tx power: % dBm attn gain: %d dBi\n", max_tx_power, antenna_gain);
- beacon_pkt.rf_power = max_tx_power - antenna_gain;
+ beacon_power = max_tx_power - antenna_gain;
}
}
+ if (temp_comp_enabled) {
+ float pwr = beacon_power;
+ /* look for power index and DIG gain for current temperature */
+ int8_t lut_pwr = 0;
+ int8_t lut_dig = 0;
+ lookup_power_settings(pwr, &lut_pwr, &lut_dig);
+ beacon_pkt.rf_power = lut_pwr;
+ beacon_pkt.dig_gain = lut_dig;
+ }
+
beacon_pkt.modulation = MOD_LORA;
switch (beacon_bw_hz) {
case 125000:
@@ -2720,6 +2884,16 @@ void thread_down(void) {
break;
}
+ if (temp_comp_enabled) {
+ float pwr = beacon_power;
+ /* look for power index and DIG gain for current temperature */
+ int8_t lut_pwr = 0;
+ int8_t lut_dig = 0;
+ lookup_power_settings(pwr, &lut_pwr, &lut_dig);
+ beacon_pkt.rf_power = lut_pwr;
+ beacon_pkt.dig_gain = lut_dig;
+ }
+
jit_result = jit_enqueue(&jit_queue, &current_concentrator_time, &beacon_pkt, JIT_PKT_TYPE_BEACON);
if (jit_result == JIT_ERROR_OK) {
/* update stats */
@@ -2968,23 +3142,33 @@ void thread_down(void) {
continue;
}
txpkt.rf_chain = (uint8_t)json_value_get_number(val);
+ txpkt.dig_gain = -1;
+
+ float pwr = 0;
/* parse TX power (optional field) */
val = json_object_get_value(txpk_obj,"powe");
if (val != NULL) {
- txpkt.rf_power = (int8_t)json_value_get_number(val) - antenna_gain;
-
+ pwr = json_value_get_number(val) - antenna_gain;
if (max_tx_power != -99) {
- if (txpkt.rf_power > max_tx_power - antenna_gain) {
+ if (pwr > max_tx_power - antenna_gain) {
MSG("INFO: [down] tx power reduced tx power: % dBm attn gain: %d dBi\n", max_tx_power, antenna_gain);
- txpkt.rf_power = max_tx_power - antenna_gain;
+ pwr = max_tx_power - antenna_gain;
}
}
}
if (temp_comp_enabled) {
- txpkt.rf_power += (int8_t)temp_comp_adj;
- MSG("INFO: Tx power temp adjusted to %d\n", (int)txpkt.rf_power);
+ /* look for power index and DIG gain for current temperature */
+ int8_t lut_pwr = 0;
+ int8_t lut_dig = 0;
+ lookup_power_settings(pwr, &lut_pwr, &lut_dig);
+ txpkt.rf_power = lut_pwr;
+ txpkt.dig_gain = lut_dig;
+ /* look for power index and DIG gain for current temperature */
+ MSG("INFO: Tx power %f temp adjusted to IDX: %d DIG: %d\n", pwr, (int)txpkt.rf_power, (int)txpkt.dig_gain);
+ } else {
+ txpkt.rf_power = pwr;
}
/* Parse modulation (mandatory) */