From 6fcf87dccc70f6a483c2039ecd5429c1d964a724 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Tue, 31 Jul 2018 15:06:42 -0500 Subject: Added global conf settings for attenuation and pkf fpga setup to use attenuation --- lora_pkt_fwd/global_conf.json | 466 +++++++++++++++++++++------------------- lora_pkt_fwd/src/lora_pkt_fwd.c | 8 + 2 files changed, 248 insertions(+), 226 deletions(-) diff --git a/lora_pkt_fwd/global_conf.json b/lora_pkt_fwd/global_conf.json index 2d0948c..3a9b2a2 100644 --- a/lora_pkt_fwd/global_conf.json +++ b/lora_pkt_fwd/global_conf.json @@ -1,228 +1,242 @@ { - "SX1301_conf": { - "lorawan_public": true, - "clksrc": 1, /* radio_1 provides clock to concentrator */ - "lbt_cfg": { - "enable": false, - "rssi_target": -80, /* dBm */ - "chan_cfg":[ /* 8 channels maximum */ - { "freq_hz": 867100000, "scan_time_us": 128 }, - { "freq_hz": 867300000, "scan_time_us": 5000 }, - { "freq_hz": 867500000, "scan_time_us": 128 }, - { "freq_hz": 869525000, "scan_time_us": 128 } - ], - "sx127x_rssi_offset": -4 /* dB */ - }, - "antenna_gain": 0, /* antenna gain, in dBi */ - "radio_0": { - "enable": true, - "type": "SX1257", - "freq": 867500000, - "rssi_offset": -166.0, - "tx_enable": true, - "tx_notch_freq": 129000, /* [126..250] KHz */ - "tx_freq_min": 863000000, - "tx_freq_max": 870000000 - }, - "radio_1": { - "enable": true, - "type": "SX1257", - "freq": 868500000, - "rssi_offset": -166.0, - "tx_enable": false - }, - "chan_multiSF_0": { - /* Lora MAC channel, 125kHz, all SF, 868.1 MHz */ - "enable": true, - "radio": 1, - "if": -400000 - }, - "chan_multiSF_1": { - /* Lora MAC channel, 125kHz, all SF, 868.3 MHz */ - "enable": true, - "radio": 1, - "if": -200000 - }, - "chan_multiSF_2": { - /* Lora MAC channel, 125kHz, all SF, 868.5 MHz */ - "enable": true, - "radio": 1, - "if": 0 - }, - "chan_multiSF_3": { - /* Lora MAC channel, 125kHz, all SF, 867.1 MHz */ - "enable": true, - "radio": 0, - "if": -400000 - }, - "chan_multiSF_4": { - /* Lora MAC channel, 125kHz, all SF, 867.3 MHz */ - "enable": true, - "radio": 0, - "if": -200000 - }, - "chan_multiSF_5": { - /* Lora MAC channel, 125kHz, all SF, 867.5 MHz */ - "enable": true, - "radio": 0, - "if": 0 - }, - "chan_multiSF_6": { - /* Lora MAC channel, 125kHz, all SF, 867.7 MHz */ - "enable": true, - "radio": 0, - "if": 200000 - }, - "chan_multiSF_7": { - /* Lora MAC channel, 125kHz, all SF, 867.9 MHz */ - "enable": true, - "radio": 0, - "if": 400000 - }, - "chan_Lora_std": { - /* Lora MAC channel, 250kHz, SF7, 868.3 MHz */ - "enable": true, - "radio": 1, - "if": -200000, - "bandwidth": 250000, - "spread_factor": 7 - }, - "chan_FSK": { - /* FSK 50kbps channel, 868.8 MHz */ - "enable": true, - "radio": 1, - "if": 300000, - "bandwidth": 125000, - "datarate": 50000 - }, - "tx_lut_0": { - /* TX gain table, index 0 */ - "pa_gain": 0, - "mix_gain": 8, - "rf_power": -6, - "dig_gain": 0 - }, - "tx_lut_1": { - /* TX gain table, index 1 */ - "pa_gain": 0, - "mix_gain": 10, - "rf_power": -3, - "dig_gain": 0 - }, - "tx_lut_2": { - /* TX gain table, index 2 */ - "pa_gain": 0, - "mix_gain": 12, - "rf_power": 0, - "dig_gain": 0 - }, - "tx_lut_3": { - /* TX gain table, index 3 */ - "pa_gain": 1, - "mix_gain": 8, - "rf_power": 3, - "dig_gain": 0 - }, - "tx_lut_4": { - /* TX gain table, index 4 */ - "pa_gain": 1, - "mix_gain": 10, - "rf_power": 6, - "dig_gain": 0 - }, - "tx_lut_5": { - /* TX gain table, index 5 */ - "pa_gain": 1, - "mix_gain": 12, - "rf_power": 10, - "dig_gain": 0 - }, - "tx_lut_6": { - /* TX gain table, index 6 */ - "pa_gain": 1, - "mix_gain": 13, - "rf_power": 11, - "dig_gain": 0 - }, - "tx_lut_7": { - /* TX gain table, index 7 */ - "pa_gain": 2, - "mix_gain": 9, - "rf_power": 12, - "dig_gain": 0 - }, - "tx_lut_8": { - /* TX gain table, index 8 */ - "pa_gain": 1, - "mix_gain": 15, - "rf_power": 13, - "dig_gain": 0 - }, - "tx_lut_9": { - /* TX gain table, index 9 */ - "pa_gain": 2, - "mix_gain": 10, - "rf_power": 14, - "dig_gain": 0 - }, - "tx_lut_10": { - /* TX gain table, index 10 */ - "pa_gain": 2, - "mix_gain": 11, - "rf_power": 16, - "dig_gain": 0 - }, - "tx_lut_11": { - /* TX gain table, index 11 */ - "pa_gain": 3, - "mix_gain": 9, - "rf_power": 20, - "dig_gain": 0 - }, - "tx_lut_12": { - /* TX gain table, index 12 */ - "pa_gain": 3, - "mix_gain": 10, - "rf_power": 23, - "dig_gain": 0 - }, - "tx_lut_13": { - /* TX gain table, index 13 */ - "pa_gain": 3, - "mix_gain": 11, - "rf_power": 25, - "dig_gain": 0 - }, - "tx_lut_14": { - /* TX gain table, index 14 */ - "pa_gain": 3, - "mix_gain": 12, - "rf_power": 26, - "dig_gain": 0 - }, - "tx_lut_15": { - /* TX gain table, index 15 */ - "pa_gain": 3, - "mix_gain": 14, - "rf_power": 27, - "dig_gain": 0 - } - }, - - "gateway_conf": { - "gateway_ID": "AA555A0000000000", - /* change with default server address/ports, or overwrite in local_conf.json */ - "server_address": "localhost", - "serv_port_up": 1680, - "serv_port_down": 1680, - /* adjust the following parameters for your network */ - "keepalive_interval": 10, - "stat_interval": 30, - "push_timeout_ms": 100, - /* forward only valid packets */ - "forward_crc_valid": true, - "forward_crc_error": false, - "forward_crc_disabled": false - } + "SX1301_conf" : + { + "antenna_gain" : 0, + "chan_FSK" : + { + "bandwidth" : 125000, + "datarate" : 50000, + "enable" : false, + "if" : 300000, + "radio" : 0 + }, + "chan_Lora_std" : + { + "bandwidth" : 500000, + "enable" : true, + "if" : 300000, + "radio" : 0, + "spread_factor" : 8 + }, + "chan_multiSF_" : + { + "radio" : null + }, + "chan_multiSF_0" : + { + "enable" : true, + "if" : -400000, + "radio" : 0 + }, + "chan_multiSF_1" : + { + "enable" : true, + "if" : -200000, + "radio" : 0 + }, + "chan_multiSF_2" : + { + "enable" : true, + "if" : 0, + "radio" : 0 + }, + "chan_multiSF_3" : + { + "enable" : true, + "if" : 200000, + "radio" : 0 + }, + "chan_multiSF_4" : + { + "enable" : true, + "if" : -400000, + "radio" : 1 + }, + "chan_multiSF_5" : + { + "enable" : true, + "if" : -200000, + "radio" : 1 + }, + "chan_multiSF_6" : + { + "enable" : true, + "if" : 0, + "radio" : 1 + }, + "chan_multiSF_7" : + { + "enable" : true, + "if" : 200000, + "radio" : 1 + }, + "clksrc" : 0, + "lbt_cfg" : + { + "enable" : false, + "rssi_target" : 160 + }, + "lorawan_public" : true, + "radio_0" : + { + "enable" : true, + "freq" : 902700000, + "rssi_offset" : -162, + "tx_enable" : true, + "tx_freq_max" : 928000000, + "tx_freq_min" : 902000000, + "type" : "SX1257" + }, + "radio_1" : + { + "enable" : true, + "freq" : 903500000, + "rssi_offset" : -162, + "tx_enable" : false, + "type" : "SX1257" + }, + "tx_lut_0" : + { + "dig_gain" : 0, + "mix_gain" : 11, + "pa_gain" : 0, + "rf_power" : -6, + "attenuation": 0.0 + }, + "tx_lut_1" : + { + "dig_gain" : 0, + "mix_gain" : 13, + "pa_gain" : 0, + "rf_power" : -3, + "attenuation": 1.0 + }, + "tx_lut_10" : + { + "dig_gain" : 0, + "mix_gain" : 15, + "pa_gain" : 2, + "rf_power" : 16, + "attenuation": 10.0 + }, + "tx_lut_11" : + { + "dig_gain" : 0, + "mix_gain" : 10, + "pa_gain" : 3, + "rf_power" : 20, + "attenuation": 11.0 + }, + "tx_lut_12" : + { + "dig_gain" : 0, + "mix_gain" : 12, + "pa_gain" : 3, + "rf_power" : 23, + "attenuation": 12.0 + }, + "tx_lut_13" : + { + "dig_gain" : 0, + "mix_gain" : 13, + "pa_gain" : 3, + "rf_power" : 25, + "attenuation": 13.0 + }, + "tx_lut_14" : + { + "dig_gain" : 0, + "mix_gain" : 15, + "pa_gain" : 3, + "rf_power" : 26, + "attenuation": 14.0 + }, + "tx_lut_15" : + { + "dig_gain" : 0, + "mix_gain" : 15, + "pa_gain" : 3, + "rf_power" : 27, + "attenuation": 15.0 + }, + "tx_lut_2" : + { + "dig_gain" : 0, + "mix_gain" : 9, + "pa_gain" : 1, + "rf_power" : 0, + "attenuation": 2.0 + }, + "tx_lut_3" : + { + "dig_gain" : 0, + "mix_gain" : 10, + "pa_gain" : 1, + "rf_power" : 3, + "attenuation": 3.0 + }, + "tx_lut_4" : + { + "dig_gain" : 0, + "mix_gain" : 12, + "pa_gain" : 1, + "rf_power" : 6, + "attenuation": 4.0 + }, + "tx_lut_5" : + { + "dig_gain" : 0, + "mix_gain" : 10, + "pa_gain" : 2, + "rf_power" : 10, + "attenuation": 5.0 + }, + "tx_lut_6" : + { + "dig_gain" : 0, + "mix_gain" : 11, + "pa_gain" : 2, + "rf_power" : 11, + "attenuation": 6.0 + }, + "tx_lut_7" : + { + "dig_gain" : 0, + "mix_gain" : 11, + "pa_gain" : 2, + "rf_power" : 12, + "attenuation": 7.0 + }, + "tx_lut_8" : + { + "dig_gain" : 2, + "mix_gain" : 12, + "pa_gain" : 2, + "rf_power" : 13, + "attenuation": 8.0 + }, + "tx_lut_9" : + { + "dig_gain" : 0, + "mix_gain" : 13, + "pa_gain" : 2, + "rf_power" : 14, + "attenuation": 9.0 + } + }, + "gateway_conf" : + { + "autoquit_threshold" : 60, + "forward_crc_disabled" : false, + "forward_crc_error" : true, + "forward_crc_valid" : true, + "gateway_ID" : "00800000000000a1", + "keepalive_interval" : 10, + "push_timeout_ms" : 120, + "serv_port_down" : 1782, + "serv_port_up" : 1780, + "server_address" : "127.0.0.1", + "stat_interval" : 20, + "synch_word" : 52 + } } - diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index ca19e28..eaaa017 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -462,6 +462,14 @@ static int parse_SX1301_configuration(const char * conf_file) { 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.attenuation", i); + val = json_object_dotget_value(conf_obj, param_name); + if (json_value_get_type(val) == JSONNumber) { + txlut.lut[i].attenuation = (float)json_value_get_number(val); + } else { + MSG("WARNING: Data type for %s[%d] seems wrong, please check\n", param_name, i); + txlut.lut[i].attenuation = -1.0; + } } /* all parameters parsed, submitting configuration to the HAL */ if (txlut.size > 0) { -- cgit v1.2.3