diff --git a/README.md b/README.md old mode 100644 new mode 100755 index da83c1a..dca9786 --- a/README.md +++ b/README.md @@ -2,21 +2,30 @@ ## Introduction -The aim of this project is to help users set up a LoRa network easily. The User Guide can be get from our Web. +The aim of this project is to help users to use the RAK Raspberry Pi Developer Gateway more easily. The User Guide can be get from our Web(https://docs.rakwireless.com/Introduction/). ## Supported platforms This project currently provides support for the below platforms. * RAK831 -* RAK833(USB/SPI) * RAK2245 -* RAK2247(USB/SPI) -* RAK7243/RAK7244 +* RAK7243/RAK7244 no LTE +* RAK7243/RAK7244 with LTE +* RAK833(USB) +* RAK2247(USB) +* RAK833(SPI) +* RAK2247(SPI) * RAK2246 -* RAK2287 +* RAK7248 no LTE (RAK2287 + raspberry pi) +* RAK7248 with LTE (RAK2287 + LTE + raspberry pi) * RAK2285 ## Changelog +2020-11-25 V4.2.6 + +* 1.Added support for RAK7248C. +* 2.Added support for class B in global_conf.json, but it is disabled by default. When needed, you can enable it in `/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json`. + 2020-09-01 V4.2.5 * 1.Add AS920_923. @@ -94,31 +103,21 @@ step3 : Clone the installer and start the installation (More installation option step4 : Next you will see some messages as follow. Please select the corresponding hardware model. Please select your gateway model: - * 1.RAK831 - * 2.RAK2245 - * 3.RAK7243/RAK7244 no LTE - * 4.RAK7243/RAK7244 with LTE - * 5.RAK833(USB) - * 6.RAK2247(USB) - * 7.RAK833(SPI) - * 8.RAK2247(SPI) - * 9.RAK2246 - * 10.RAK2287(SPI) - * 11.RAK2285 - Please enter 1-11 to select the model: - -step5 : Wait a moment and the installation is complete.If your gateway uses a wired connection, please reconfigure the LAN's IP address using "sudo gateway-config" after the installation is complete. + * 1.RAK831 + * 2.RAK2245 + * 3.RAK7243/RAK7244 no LTE + * 4.RAK7243/RAK7244 with LTE + * 5.RAK833(USB) + * 6.RAK2247(USB) + * 7.RAK833(SPI) + * 8.RAK2247(SPI) + * 9.RAK2246 + * 10.RAK7248 no LTE (RAK2287 + raspberry pi) + * 11.RAK7248 with LTE (RAK2287 + LTE + raspberry pi) + * 12.RAK2285 + Please enter 1-12 to select the model: + +step5 : Wait a moment and the installation is complete. step6 : For more other features, please use "sudo gateway-config". - - - -## Note: The following content is contributed by @x893: - -For DietPi OS need add -apt install build-essential net-tools -y -in rak/install.sh (for example before apt install git ppp dialog jq minicom monit -y) -and need check hciuart enabled because -systemctl disable hciuart -not installed and script fail. diff --git a/choose_model.sh b/choose_model.sh index 02c0738..5d816b3 100755 --- a/choose_model.sh +++ b/choose_model.sh @@ -39,18 +39,19 @@ do_check_variable_type_echo(){ function echo_model_info() { echo_yellow "Please select your gateway model:" - echo_yellow "*\t1.RAK831" - echo_yellow "*\t2.RAK2245" - echo_yellow "*\t3.RAK7243/RAK7244 no LTE" - echo_yellow "*\t4.RAK7243/RAK7244 with LTE" - echo_yellow "*\t5.RAK833(USB)" - echo_yellow "*\t6.RAK2247(USB)" - echo_yellow "*\t7.RAK833(SPI)" - echo_yellow "*\t8.RAK2247(SPI)" - echo_yellow "*\t9.RAK2246" - echo_yellow "*\t10.RAK2287(SPI)" - echo_yellow "*\t11.RAK2285" - echo_yellow "Please enter 1-11 to select the model:\c" + echo_yellow "*\t 1.RAK831" + echo_yellow "*\t 2.RAK2245" + echo_yellow "*\t 3.RAK7243/RAK7244 no LTE" + echo_yellow "*\t 4.RAK7243/RAK7244 with LTE" + echo_yellow "*\t 5.RAK833(USB)" + echo_yellow "*\t 6.RAK2247(USB)" + echo_yellow "*\t 7.RAK833(SPI)" + echo_yellow "*\t 8.RAK2247(SPI)" + echo_yellow "*\t 9.RAK2246" + echo_yellow "*\t10.RAK7248 no LTE (RAK2287 + raspberry pi)" + echo_yellow "*\t11.RAK7248 with LTE (RAK2287 + LTE + raspberry pi)" + echo_yellow "*\t12.RAK2285" + echo_yellow "Please enter 1-12 to select the model:\c" } function do_set_model_to_json() @@ -78,7 +79,7 @@ function do_set_model_to_json() GW_MODEL=RAK7243 fi INSTALL_LTE=1 - do_set_spi_to_json 0 + do_set_spi_to_json 1 elif [ $1 -eq 5 ]; then GW_MODEL=RAK833 do_set_spi_to_json 0 @@ -95,9 +96,13 @@ function do_set_model_to_json() GW_MODEL=RAK2246 do_set_spi_to_json 1 elif [ $1 -eq 10 ]; then - GW_MODEL=RAK2287 + GW_MODEL=RAK7248 do_set_spi_to_json 1 elif [ $1 -eq 11 ]; then + GW_MODEL=RAK7248 + do_set_spi_to_json 1 + INSTALL_LTE=1 + elif [ $1 -eq 12 ]; then GW_MODEL=RAK2285 do_set_spi_to_json 1 else @@ -128,7 +133,7 @@ function do_set_model() do read RAK_MODEL if [ -z "$RAK_MODEL" ]; then - echo_yellow "Please enter 1-11 to select the model:\c" + echo_yellow "Please enter 1-12 to select the model:\c" continue fi @@ -136,7 +141,7 @@ function do_set_model() RET=$? if [ $RET -eq 0 ]; then - if [ $RAK_MODEL -lt 1 ] || [ $RAK_MODEL -gt 11 ]; then + if [ $RAK_MODEL -lt 1 ] || [ $RAK_MODEL -gt 12 ]; then echo_yellow "Please enter 1-10 to select the model:\c" continue else @@ -144,7 +149,7 @@ function do_set_model() return 0 fi else - echo_yellow "Please enter 1-11 to select the model:\c" + echo_yellow "Please enter 1-12 to select the model:\c" continue fi diff --git a/lora/install_normal.sh b/lora/install_normal.sh index 36eecee..49e6ba2 100755 --- a/lora/install_normal.sh +++ b/lora/install_normal.sh @@ -20,56 +20,61 @@ INSTALL_LTE=`do_get_gw_install_lte` mkdir /opt/ttn-gateway -p -if [ "$INSTALL_LTE" = "1" ]; then - pushd rak7243 - ./install.sh - LORA_DIR_TMP=rak7243 - popd + +if [ "${RAK_GW_MODEL}" = "RAK2247" ] || [ "${RAK_GW_MODEL}" = "RAK833" ]; then + if [ "${LORA_SPI}" = "1" ]; then + pushd rak2247_spi + ./install.sh + LORA_DIR_TMP=rak2247_spi + else + pushd rak2247_usb + ./install.sh + LORA_DIR_TMP=rak2247_usb + fi + popd +elif [ "${RAK_GW_MODEL}" = "RAK2287" ] ; then + pushd rak2287_spi + if [ "${INSTALL_LTE}" = "1" ]; then + cp global_conf_i2c global_conf -rf + else + cp global_conf_uart global_conf -rf + fi + ./install.sh + LORA_DIR_TMP=rak2287_spi + popd +elif [ "${RAK_GW_MODEL}" = "RAK7243" ] || [ "${RAK_GW_MODEL}" = "RAK7244" ]; then + pushd rak7243 + if [ "${INSTALL_LTE}" = "1" ]; then + cp global_conf_i2c global_conf -rf + else + cp global_conf_uart global_conf -rf + fi + ./install.sh + LORA_DIR_TMP=rak7243 + popd +elif [ "${RAK_GW_MODEL}" = "RAK2285" ]; then + + pushd rak2285 + LORA_DIR_TMP=rak2285 + ./install.sh + + popd else - if [ "${RAK_GW_MODEL}" = "RAK2247" ] || [ "${RAK_GW_MODEL}" = "RAK833" ]; then - if [ "${LORA_SPI}" = "1" ]; then - pushd rak2247_spi - ./install.sh - LORA_DIR_TMP=rak2247_spi - else - pushd rak2247_usb - ./install.sh - LORA_DIR_TMP=rak2247_usb - fi - popd - elif [ "${RAK_GW_MODEL}" = "RAK2287" ]; then - if [ "${LORA_SPI}" = "1" ]; then - pushd rak2287_spi - ./install.sh - LORA_DIR_TMP=rak2287_spi - else - pushd rak2287_usb - ./install.sh - LORA_DIR_TMP=rak2287_usb - fi - popd - elif [ "${RAK_GW_MODEL}" = "RAK2285" ]; then - - pushd rak2285 - LORA_DIR_TMP=rak2285 - ./install.sh - - popd - else - if [ "${RAK_GW_MODEL}" = "RAK2246" ]; then - pushd rak2246 - ./install.sh - LORA_DIR_TMP=rak2246 - else - pushd rak2245 - ./install.sh - LORA_DIR_TMP=rak2245 - fi - popd - fi + if [ "${RAK_GW_MODEL}" = "RAK2246" ]; then + pushd rak2246 + ./install.sh + LORA_DIR_TMP=rak2246 + else + pushd rak7243 + cp global_conf_uart global_conf -rf + ./install.sh + LORA_DIR_TMP=rak7243 + fi + popd fi -if [ -d $SCRIPT_DIR/../lora_gateway ]; then + +if [ -d $LORA_DIR_TMP/lora_gateway ]; then cp $LORA_DIR_TMP/lora_gateway /opt/ttn-gateway/ -rf fi cp $LORA_DIR_TMP/packet_forwarder /opt/ttn-gateway/ -rf @@ -89,4 +94,5 @@ if [ $rpi_model -eq 3 ] || [ $rpi_model -eq 4 ]; then fi systemctl enable ttn-gateway.service +systemctl restart ttn-gateway.service diff --git a/lora/rak2245/global_conf/global_conf.as_920_923.json b/lora/rak2245/global_conf/global_conf.as_920_923.json old mode 100644 new mode 100755 index ac588df..e89b4b0 --- a/lora/rak2245/global_conf/global_conf.as_920_923.json +++ b/lora/rak2245/global_conf/global_conf.as_920_923.json @@ -13,13 +13,14 @@ "fake_gps":false, "autoquit_threshold":30, "gps_tty_path":"/dev/ttyAMA0", - "beacon_freq_hz":923400000, - "beacon_freq_nb":1, - "beacon_freq_step":600000, - "beacon_datarate":9, - "beacon_bw_hz":125000, - "beacon_power":20, - "beacon_period":0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, "SX1301_conf": { diff --git a/lora/rak2245/global_conf/global_conf.as_923_925.json b/lora/rak2245/global_conf/global_conf.as_923_925.json old mode 100644 new mode 100755 index c81782e..cedd1f2 --- a/lora/rak2245/global_conf/global_conf.as_923_925.json +++ b/lora/rak2245/global_conf/global_conf.as_923_925.json @@ -218,7 +218,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.au_915_928.json b/lora/rak2245/global_conf/global_conf.au_915_928.json old mode 100644 new mode 100755 index d2c6b27..b8458ae --- a/lora/rak2245/global_conf/global_conf.au_915_928.json +++ b/lora/rak2245/global_conf/global_conf.au_915_928.json @@ -214,7 +214,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.cn_470_510.json b/lora/rak2245/global_conf/global_conf.cn_470_510.json old mode 100644 new mode 100755 index 8027017..5c125b5 --- a/lora/rak2245/global_conf/global_conf.cn_470_510.json +++ b/lora/rak2245/global_conf/global_conf.cn_470_510.json @@ -210,7 +210,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 508300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 200000, + "beacon_datarate": 10, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.eu_433.json b/lora/rak2245/global_conf/global_conf.eu_433.json old mode 100644 new mode 100755 index 895934d..240e7c1 --- a/lora/rak2245/global_conf/global_conf.eu_433.json +++ b/lora/rak2245/global_conf/global_conf.eu_433.json @@ -217,7 +217,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 434665000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.eu_863_870.json b/lora/rak2245/global_conf/global_conf.eu_863_870.json old mode 100644 new mode 100755 index 5861a17..9666023 --- a/lora/rak2245/global_conf/global_conf.eu_863_870.json +++ b/lora/rak2245/global_conf/global_conf.eu_863_870.json @@ -194,6 +194,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.in_865_867.json b/lora/rak2245/global_conf/global_conf.in_865_867.json old mode 100644 new mode 100755 index 57d133d..0149ab6 --- a/lora/rak2245/global_conf/global_conf.in_865_867.json +++ b/lora/rak2245/global_conf/global_conf.in_865_867.json @@ -189,7 +189,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.kr_920_923.json b/lora/rak2245/global_conf/global_conf.kr_920_923.json old mode 100644 new mode 100755 index d503fbb..c0ab8cf --- a/lora/rak2245/global_conf/global_conf.kr_920_923.json +++ b/lora/rak2245/global_conf/global_conf.kr_920_923.json @@ -208,7 +208,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.ru_864_870.json b/lora/rak2245/global_conf/global_conf.ru_864_870.json old mode 100644 new mode 100755 index 76ae3de..e9b90a5 --- a/lora/rak2245/global_conf/global_conf.ru_864_870.json +++ b/lora/rak2245/global_conf/global_conf.ru_864_870.json @@ -196,7 +196,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2245/global_conf/global_conf.us_902_928.json b/lora/rak2245/global_conf/global_conf.us_902_928.json old mode 100644 new mode 100755 index d54cb52..c8e0993 --- a/lora/rak2245/global_conf/global_conf.us_902_928.json +++ b/lora/rak2245/global_conf/global_conf.us_902_928.json @@ -206,6 +206,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak2245/install.sh b/lora/rak2245/install.sh index 960e017..bb896d6 100755 --- a/lora/rak2245/install.sh +++ b/lora/rak2245/install.sh @@ -32,6 +32,7 @@ pushd lora_gateway cp $SCRIPT_DIR/library.cfg ./libloragw/library.cfg cp $SCRIPT_DIR/loragw_spi.native.c ./libloragw/src/loragw_spi.native.c +cp $SCRIPT_DIR/../print_lora_log.sh util_pkt_logger/ make popd @@ -49,7 +50,7 @@ pushd packet_forwarder cp $SCRIPT_DIR/lora_pkt_fwd.c ./lora_pkt_fwd/src/lora_pkt_fwd.c make - +rm lora_pkt_fwd/obj/* -f popd cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf diff --git a/lora/rak2246/global_conf/global_conf.as_920_923.json b/lora/rak2246/global_conf/global_conf.as_920_923.json old mode 100644 new mode 100755 index 89b6702..0bc8c58 --- a/lora/rak2246/global_conf/global_conf.as_920_923.json +++ b/lora/rak2246/global_conf/global_conf.as_920_923.json @@ -13,13 +13,14 @@ "fake_gps":false, "autoquit_threshold":30, "gps_tty_path":"/dev/ttyAMA0", - "beacon_freq_hz":923400000, - "beacon_freq_nb":1, - "beacon_freq_step":600000, - "beacon_datarate":9, - "beacon_bw_hz":125000, - "beacon_power":20, - "beacon_period":0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, "SX1301_conf": { diff --git a/lora/rak2246/global_conf/global_conf.as_923_925.json b/lora/rak2246/global_conf/global_conf.as_923_925.json old mode 100644 new mode 100755 index 65d32ff..3a4a26f --- a/lora/rak2246/global_conf/global_conf.as_923_925.json +++ b/lora/rak2246/global_conf/global_conf.as_923_925.json @@ -160,7 +160,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.au_915_928.json b/lora/rak2246/global_conf/global_conf.au_915_928.json old mode 100644 new mode 100755 index 9ea4b3c..d1cc0f5 --- a/lora/rak2246/global_conf/global_conf.au_915_928.json +++ b/lora/rak2246/global_conf/global_conf.au_915_928.json @@ -156,7 +156,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.cn_470_510.json b/lora/rak2246/global_conf/global_conf.cn_470_510.json old mode 100644 new mode 100755 index df2705a..b2aa005 --- a/lora/rak2246/global_conf/global_conf.cn_470_510.json +++ b/lora/rak2246/global_conf/global_conf.cn_470_510.json @@ -210,7 +210,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 508300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 200000, + "beacon_datarate": 10, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.eu_433.json b/lora/rak2246/global_conf/global_conf.eu_433.json old mode 100644 new mode 100755 index 243a2af..fde712b --- a/lora/rak2246/global_conf/global_conf.eu_433.json +++ b/lora/rak2246/global_conf/global_conf.eu_433.json @@ -217,7 +217,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 434665000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.eu_863_870.json b/lora/rak2246/global_conf/global_conf.eu_863_870.json old mode 100644 new mode 100755 index 8cdd3d0..560d394 --- a/lora/rak2246/global_conf/global_conf.eu_863_870.json +++ b/lora/rak2246/global_conf/global_conf.eu_863_870.json @@ -148,6 +148,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.in_865_867.json b/lora/rak2246/global_conf/global_conf.in_865_867.json old mode 100644 new mode 100755 index 992748b..3381cd4 --- a/lora/rak2246/global_conf/global_conf.in_865_867.json +++ b/lora/rak2246/global_conf/global_conf.in_865_867.json @@ -143,7 +143,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.kr_920_923.json b/lora/rak2246/global_conf/global_conf.kr_920_923.json old mode 100644 new mode 100755 index ab9edb6..b80ccfa --- a/lora/rak2246/global_conf/global_conf.kr_920_923.json +++ b/lora/rak2246/global_conf/global_conf.kr_920_923.json @@ -150,7 +150,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.ru_864_870.json b/lora/rak2246/global_conf/global_conf.ru_864_870.json old mode 100644 new mode 100755 index 91d4f36..10f8ca5 --- a/lora/rak2246/global_conf/global_conf.ru_864_870.json +++ b/lora/rak2246/global_conf/global_conf.ru_864_870.json @@ -150,7 +150,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak2246/global_conf/global_conf.us_902_928.json b/lora/rak2246/global_conf/global_conf.us_902_928.json old mode 100644 new mode 100755 index 5819356..0a02495 --- a/lora/rak2246/global_conf/global_conf.us_902_928.json +++ b/lora/rak2246/global_conf/global_conf.us_902_928.json @@ -148,6 +148,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak2246/install.sh b/lora/rak2246/install.sh index 960e017..bb896d6 100755 --- a/lora/rak2246/install.sh +++ b/lora/rak2246/install.sh @@ -32,6 +32,7 @@ pushd lora_gateway cp $SCRIPT_DIR/library.cfg ./libloragw/library.cfg cp $SCRIPT_DIR/loragw_spi.native.c ./libloragw/src/loragw_spi.native.c +cp $SCRIPT_DIR/../print_lora_log.sh util_pkt_logger/ make popd @@ -49,7 +50,7 @@ pushd packet_forwarder cp $SCRIPT_DIR/lora_pkt_fwd.c ./lora_pkt_fwd/src/lora_pkt_fwd.c make - +rm lora_pkt_fwd/obj/* -f popd cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf diff --git a/lora/rak2247_spi/global_conf/global_conf.as_920_923.json b/lora/rak2247_spi/global_conf/global_conf.as_920_923.json old mode 100644 new mode 100755 index c415ddf..0c70c3a --- a/lora/rak2247_spi/global_conf/global_conf.as_920_923.json +++ b/lora/rak2247_spi/global_conf/global_conf.as_920_923.json @@ -11,14 +11,8 @@ "stat_interval":30, "push_timeout_ms":100, "fake_gps":false, - "autoquit_threshold":30, - "beacon_freq_hz":923400000, - "beacon_freq_nb":1, - "beacon_freq_step":600000, - "beacon_datarate":9, - "beacon_bw_hz":125000, - "beacon_power":20, - "beacon_period":0 + "autoquit_threshold":30 + }, "SX1301_conf": { diff --git a/lora/rak2247_spi/install.sh b/lora/rak2247_spi/install.sh index a8538cb..219b97f 100755 --- a/lora/rak2247_spi/install.sh +++ b/lora/rak2247_spi/install.sh @@ -49,7 +49,11 @@ pushd packet_forwarder cp $SCRIPT_DIR/lora_pkt_fwd.c ./lora_pkt_fwd/src/lora_pkt_fwd.c make +rm lora_pkt_fwd/obj/* -f +popd +pushd lora_gateway +make clean popd cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf diff --git a/lora/rak2247_usb/install.sh b/lora/rak2247_usb/install.sh index 8839154..aff60c8 100755 --- a/lora/rak2247_usb/install.sh +++ b/lora/rak2247_usb/install.sh @@ -74,7 +74,11 @@ cp $SCRIPT_DIR/Makefile-pk ./lora_pkt_fwd/Makefile cp $SCRIPT_DIR/lora_pkt_fwd.c ./lora_pkt_fwd/src/lora_pkt_fwd.c make +rm lora_pkt_fwd/obj/* -f +popd +pushd lora_gateway +make clean popd cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf diff --git a/lora/rak2285/global_conf/global_conf.as_920_923.json b/lora/rak2285/global_conf/global_conf.as_920_923.json old mode 100644 new mode 100755 index eaaaee3..4b90f05 --- a/lora/rak2285/global_conf/global_conf.as_920_923.json +++ b/lora/rak2285/global_conf/global_conf.as_920_923.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, "beacon_datarate": 9, "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.as_923_925.json b/lora/rak2285/global_conf/global_conf.as_923_925.json old mode 100644 new mode 100755 index bdd3870..2d8821b --- a/lora/rak2285/global_conf/global_conf.as_923_925.json +++ b/lora/rak2285/global_conf/global_conf.as_923_925.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, "beacon_datarate": 9, "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.au_915_928.json b/lora/rak2285/global_conf/global_conf.au_915_928.json old mode 100644 new mode 100755 index 668c7f0..61b16ad --- a/lora/rak2285/global_conf/global_conf.au_915_928.json +++ b/lora/rak2285/global_conf/global_conf.au_915_928.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.eu_863_870.json b/lora/rak2285/global_conf/global_conf.eu_863_870.json old mode 100644 new mode 100755 index e640215..8dc6e31 --- a/lora/rak2285/global_conf/global_conf.eu_863_870.json +++ b/lora/rak2285/global_conf/global_conf.eu_863_870.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.in_865_867.json b/lora/rak2285/global_conf/global_conf.in_865_867.json old mode 100644 new mode 100755 index bef55bf..c591b3b --- a/lora/rak2285/global_conf/global_conf.in_865_867.json +++ b/lora/rak2285/global_conf/global_conf.in_865_867.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.kr_920_923.json b/lora/rak2285/global_conf/global_conf.kr_920_923.json old mode 100644 new mode 100755 index 654c5f9..6d54ea7 --- a/lora/rak2285/global_conf/global_conf.kr_920_923.json +++ b/lora/rak2285/global_conf/global_conf.kr_920_923.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.ru_864_870.json b/lora/rak2285/global_conf/global_conf.ru_864_870.json old mode 100644 new mode 100755 index b82bacf..acc2c82 --- a/lora/rak2285/global_conf/global_conf.ru_864_870.json +++ b/lora/rak2285/global_conf/global_conf.ru_864_870.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/global_conf/global_conf.us_902_928.json b/lora/rak2285/global_conf/global_conf.us_902_928.json old mode 100644 new mode 100755 index 509d482..9a5d472 --- a/lora/rak2285/global_conf/global_conf.us_902_928.json +++ b/lora/rak2285/global_conf/global_conf.us_902_928.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2285/install.sh b/lora/rak2285/install.sh index e6a92b8..b03666e 100755 --- a/lora/rak2285/install.sh +++ b/lora/rak2285/install.sh @@ -37,12 +37,14 @@ cp ../loragw_hal.c libloragw/src/loragw_hal.c -f cp ../Makefile libloragw/Makefile -f cp ../lora_pkt_fwd.c packet_forwarder/src/lora_pkt_fwd.c make - +rm packet_forwarder/lora_pkt_fwd/obj/* -f popd + if [ -d $INSTALL_DIR/packet_forwarder ]; then rm -rf $INSTALL_DIR/packet_forwarder/ fi cp $INSTALL_DIR/sx1302_hal-1.0.5/packet_forwarder $INSTALL_DIR/ -rf +cp $INSTALL_DIR/sx1302_hal-1.0.5/libloragw $INSTALL_DIR/lora_gateway -rf mv $INSTALL_DIR/packet_forwarder/lora_pkt_fwd $INSTALL_DIR/packet_forwarder/lora_pkt_fwd_bak mkdir -p $INSTALL_DIR/packet_forwarder/lora_pkt_fwd mv $INSTALL_DIR/packet_forwarder/lora_pkt_fwd_bak $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/lora_pkt_fwd diff --git a/lora/rak2287_spi/Makefile b/lora/rak2287_spi/Makefile old mode 100644 new mode 100755 index 439b23a..78481b3 --- a/lora/rak2287_spi/Makefile +++ b/lora/rak2287_spi/Makefile @@ -22,7 +22,7 @@ LIBS := -lloragw -ltinymt32 -lrt -lm ### general build targets -all: libloragw.a test_loragw_spi test_loragw_i2c test_loragw_reg test_loragw_hal_tx test_loragw_hal_rx test_loragw_cal test_loragw_capture_ram test_loragw_spi_sx1250 test_loragw_counter test_loragw_gps +all: libloragw.a test_loragw_spi test_loragw_i2c test_loragw_reg test_loragw_hal_tx test_loragw_hal_rx test_loragw_cal test_loragw_capture_ram test_loragw_spi_sx1250 test_loragw_counter test_loragw_gps test_loragw_gps_i2c clean: rm -f libloragw.a @@ -120,4 +120,7 @@ test_loragw_counter: tst/test_loragw_counter.c libloragw.a test_loragw_gps: tst/test_loragw_gps.c libloragw.a $(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS) +test_loragw_gps_i2c: tst/test_loragw_gps_i2c.c libloragw.a + $(CC) $(CFLAGS) -L. -L../libtools $< -o $@ $(LIBS) + ### EOF diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.as_920_923.json b/lora/rak2287_spi/global_conf_i2c/global_conf.as_920_923.json new file mode 100755 index 0000000..16ed944 --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.as_920_923.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 923000000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 923200000, + "tx_freq_max": 925000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 1}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 2}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 3}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 4}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 5}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 15}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 19} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 922000000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": 200000}, /* Freq : 922.6 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": 400000}, /* Freq : 922.8 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 1, "if": 200000}, /* Freq : 923.0 MHz*/ + "chan_multiSF_3": {"enable": true, "radio": 1, "if": 400000}, /* Freq : 923.2 MHz*/ + "chan_multiSF_4": {"enable": true, "radio": 0, "if": -400000}, /* Freq : 924.0 MHz*/ + "chan_multiSF_5": {"enable": true, "radio": 0, "if": -200000}, /* Freq : 924.2 MHz*/ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": 0}, /* Freq : 924.4 MHz*/ + "chan_multiSF_7": {"enable": true, "radio": 0, "if": 0}, /* Freq : 924.5 MHz*/ + "chan_Lora_std": {"enable": true, "radio": 1, "if": 100000, "bandwidth": 250000, "spread_factor": 7, /* Freq : 904.6 MHz*/ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": true, "radio": 1, "if": -200000, "bandwidth": 125000, "datarate": 50000} /* Freq : 924.8 MHz*/ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.as_923_925.json b/lora/rak2287_spi/global_conf_i2c/global_conf.as_923_925.json new file mode 100755 index 0000000..0fec6ad --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.as_923_925.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 923600000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 923200000, + "tx_freq_max": 925000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 15}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 21}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 924600000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000}, /* Freq : 923.2 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000}, /* Freq : 923.4 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 0, "if": 0}, /* Freq : 923.6 MHz*/ + "chan_multiSF_3": {"enable": true, "radio": 0, "if": 200000}, /* Freq : 923.8 MHz*/ + "chan_multiSF_4": {"enable": true, "radio": 0, "if": 400000}, /* Freq : 924.0 MHz*/ + "chan_multiSF_5": {"enable": true, "radio": 1, "if": -400000}, /* Freq : 924.2 MHz*/ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": -200000}, /* Freq : 924.4 MHz*/ + "chan_multiSF_7": {"enable": true, "radio": 1, "if": 0}, /* Freq : 924.5 MHz*/ + "chan_Lora_std": {"enable": true, "radio": 1, "if": -100000, "bandwidth": 250000, "spread_factor": 7, /* Freq : 904.6 MHz*/ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": true, "radio": 1, "if": 200000, "bandwidth": 125000, "datarate": 50000} /* Freq : 924.8 MHz*/ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.as2.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.au_915_928.json b/lora/rak2287_spi/global_conf_i2c/global_conf.au_915_928.json new file mode 100755 index 0000000..247eb9a --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.au_915_928.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 917200000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 915000000, + "tx_freq_max": 928000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 15}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 21}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 917900000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000}, /* Freq : 916.8 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000}, /* Freq : 917.0 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 0, "if": 0}, /* Freq : 917.2 MHz*/ + "chan_multiSF_3": {"enable": true, "radio": 0, "if": 200000}, /* Freq : 917.4 MHz*/ + "chan_multiSF_4": {"enable": true, "radio": 1, "if": -300000}, /* Freq : 917.6 MHz*/ + "chan_multiSF_5": {"enable": true, "radio": 1, "if": -100000}, /* Freq : 917.8 MHz*/ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": 100000}, /* Freq : 918.0 MHz*/ + "chan_multiSF_7": {"enable": true, "radio": 1, "if": 300000}, /* Freq : 918.2 MHz*/ + "chan_Lora_std": {"enable": true, "radio": 0, "if": 300000, "bandwidth": 500000, "spread_factor": 8, /* Freq : 917.5 MHz*/ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": false, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} /* Disabled */ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "thethings.meshed.com.au", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.eu_863_870.json b/lora/rak2287_spi/global_conf_i2c/global_conf.eu_863_870.json new file mode 100755 index 0000000..b0464e7 --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.eu_863_870.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 867500000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 863000000, + "tx_freq_max": 870000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 4}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 5}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 868500000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 1, "if": -400000}, + "chan_multiSF_1": {"enable": true, "radio": 1, "if": -200000}, + "chan_multiSF_2": {"enable": true, "radio": 1, "if": 0}, + "chan_multiSF_3": {"enable": true, "radio": 0, "if": -400000}, + "chan_multiSF_4": {"enable": true, "radio": 0, "if": -200000}, + "chan_multiSF_5": {"enable": true, "radio": 0, "if": 0}, + "chan_multiSF_6": {"enable": true, "radio": 0, "if": 200000}, + "chan_multiSF_7": {"enable": true, "radio": 0, "if": 400000}, + "chan_Lora_std": {"enable": true, "radio": 1, "if": -200000, "bandwidth": 250000, "spread_factor": 7, + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": true, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.eu.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.in_865_867.json b/lora/rak2287_spi/global_conf_i2c/global_conf.in_865_867.json new file mode 100755 index 0000000..464a0c0 --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.in_865_867.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 865200000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 865000000, + "tx_freq_max": 867000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 4}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 5}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 866385000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -137500}, /* Freq : 865.0625 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": 202500}, /* Freq : 865.4025 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 1, "if": -400000}, /* Freq : 865.9850 MHz*/ + "chan_multiSF_3": {"enable": false, "radio": 0, "if": 200000}, /* Disabled */ + "chan_multiSF_4": {"enable": false, "radio": 1, "if": -300000}, /* Disabled */ + "chan_multiSF_5": {"enable": false, "radio": 1, "if": -100000}, /* Disabled */ + "chan_multiSF_6": {"enable": false, "radio": 1, "if": 100000}, /* Disabled */ + "chan_multiSF_7": {"enable": false, "radio": 1, "if": 300000}, /* Disabled */ + "chan_Lora_std": {"enable": false, "radio": 0, "if": 300000, "bandwidth": 500000, "spread_factor": 8, /* Freq : 917.5 MHz*/ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": false, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} /* Freq : 868.8 MHz*/ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.kr_920_923.json b/lora/rak2287_spi/global_conf_i2c/global_conf.kr_920_923.json new file mode 100755 index 0000000..bd74a47 --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.kr_920_923.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 922400000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 920900000, + "tx_freq_max": 923300000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 15}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 21}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 923000000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -300000}, /* Freq : 922.1 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": -100000}, /* Freq : 922.3 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 0, "if": 100000}, /* Freq : 922.5 MHz*/ + "chan_multiSF_3": {"enable": true, "radio": 0, "if": 300000}, /* Freq : 922.7 MHz*/ + "chan_multiSF_4": {"enable": true, "radio": 1, "if": -100000}, /* Freq : 922.9 MHz*/ + "chan_multiSF_5": {"enable": true, "radio": 1, "if": 100000}, /* Freq : 923.1 MHz*/ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": 300000}, /* Freq : 923.3 MHz*/ + "chan_multiSF_7": {"enable": false, "radio": 1, "if": 300000}, /* Disabled */ + "chan_Lora_std": {"enable": false, "radio": 0, "if": 300000, "bandwidth": 500000, "spread_factor": 8, /* Disabled */ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": false, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} /* Disabled */ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.ru_864_870.json b/lora/rak2287_spi/global_conf_i2c/global_conf.ru_864_870.json new file mode 100755 index 0000000..78299d2 --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.ru_864_870.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 864500000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 863000000, + "tx_freq_max": 870000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 4}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 5}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 869000000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000}, /* Freq : 864.1 MHz */ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000}, /* Freq : 864.3 MHz */ + "chan_multiSF_2": {"enable": true, "radio": 0, "if": 0}, /* Freq : 864.5 MHz */ + "chan_multiSF_3": {"enable": true, "radio": 0, "if": 200000}, /* Freq : 864.7 MHz */ + "chan_multiSF_4": {"enable": true, "radio": 0, "if": 400000}, /* Freq : 864.9 MHz */ + "chan_multiSF_5": {"enable": true, "radio": 1, "if": -100000}, /* Freq : 868.9 MHz */ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": 100000}, /* Freq : 869.1 MHz */ + "chan_multiSF_7": {"enable": false, "radio": 1, "if": 300000}, /* Disabled */ + "chan_Lora_std": {"enable": false, "radio": 0, "if": 300000, "bandwidth": 500000, "spread_factor": 8, /* Disabled */ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": false, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} /* Disabled */ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf_i2c/global_conf.us_902_928.json b/lora/rak2287_spi/global_conf_i2c/global_conf.us_902_928.json new file mode 100755 index 0000000..7435fda --- /dev/null +++ b/lora/rak2287_spi/global_conf_i2c/global_conf.us_902_928.json @@ -0,0 +1,99 @@ +{ + "SX130x_conf": { + "spidev_path": "/dev/spidev0.0", + "lorawan_public": true, + "clksrc": 0, + "antenna_gain": 0, /* antenna gain, in dBi */ + "full_duplex": false, + "precision_timestamp": { + "enable": false, + "max_ts_metrics": 255, + "nb_symbols": 1 + }, + "radio_0": { + "enable": true, + "type": "SX1250", + "freq": 904300000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": true, + "tx_freq_min": 923000000, + "tx_freq_max": 928000000, + "tx_gain_lut":[ + {"rf_power": 12, "pa_gain": 1, "pwr_idx": 6}, + {"rf_power": 13, "pa_gain": 1, "pwr_idx": 7}, + {"rf_power": 14, "pa_gain": 1, "pwr_idx": 8}, + {"rf_power": 15, "pa_gain": 1, "pwr_idx": 9}, + {"rf_power": 16, "pa_gain": 1, "pwr_idx": 10}, + {"rf_power": 17, "pa_gain": 1, "pwr_idx": 11}, + {"rf_power": 18, "pa_gain": 1, "pwr_idx": 12}, + {"rf_power": 19, "pa_gain": 1, "pwr_idx": 13}, + {"rf_power": 20, "pa_gain": 1, "pwr_idx": 14}, + {"rf_power": 21, "pa_gain": 1, "pwr_idx": 15}, + {"rf_power": 22, "pa_gain": 1, "pwr_idx": 16}, + {"rf_power": 23, "pa_gain": 1, "pwr_idx": 17}, + {"rf_power": 24, "pa_gain": 1, "pwr_idx": 18}, + {"rf_power": 25, "pa_gain": 1, "pwr_idx": 19}, + {"rf_power": 26, "pa_gain": 1, "pwr_idx": 21}, + {"rf_power": 27, "pa_gain": 1, "pwr_idx": 22} + ] + }, + "radio_1": { + "enable": true, + "type": "SX1250", + "freq": 905000000, + "rssi_offset": -215.4, + "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0}, + "tx_enable": false + }, + "chan_multiSF_0": {"enable": true, "radio": 0, "if": -400000}, /* Freq : 903.9 MHz*/ + "chan_multiSF_1": {"enable": true, "radio": 0, "if": -200000}, /* Freq : 904.1 MHz*/ + "chan_multiSF_2": {"enable": true, "radio": 0, "if": 0}, /* Freq : 904.3 MHz*/ + "chan_multiSF_3": {"enable": true, "radio": 0, "if": 200000}, /* Freq : 904.5 MHz*/ + "chan_multiSF_4": {"enable": true, "radio": 1, "if": -300000}, /* Freq : 904.7 MHz*/ + "chan_multiSF_5": {"enable": true, "radio": 1, "if": -100000}, /* Freq : 904.9 MHz*/ + "chan_multiSF_6": {"enable": true, "radio": 1, "if": 100000}, /* Freq : 905.1 MHz*/ + "chan_multiSF_7": {"enable": true, "radio": 1, "if": 300000}, /* Freq : 905.3 MHz*/ + "chan_Lora_std": {"enable": true, "radio": 0, "if": 300000, "bandwidth": 500000, "spread_factor": 8, /* Freq : 904.6 MHz*/ + "implicit_hdr": false, "implicit_payload_length": 17, "implicit_crc_en": false, "implicit_coderate": 1}, + "chan_FSK": {"enable": false, "radio": 1, "if": 300000, "bandwidth": 125000, "datarate": 50000} /* Freq : 868.8 MHz*/ + }, + + "gateway_conf": { + "gateway_ID": "AA555A0000000000", + /* change with default server address/ports */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* GPS configuration */ + "gps_tty_path": "/dev/i2c-1", + /* GPS reference coordinates */ + "ref_latitude": 0.0, + "ref_longitude": 0.0, + "ref_altitude": 0, + /* Beaconing parameters */ + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 + }, + + "debug_conf": { + "ref_payload":[ + {"id": "0xCAFE1234"}, + {"id": "0xCAFE2345"} + ], + "log_file": "loragw_hal.log" + } +} diff --git a/lora/rak2287_spi/global_conf/global_conf.as_920_923.json b/lora/rak2287_spi/global_conf_uart/global_conf.as_920_923.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak2287_spi/global_conf/global_conf.as_920_923.json rename to lora/rak2287_spi/global_conf_uart/global_conf.as_920_923.json index eaaaee3..4b90f05 --- a/lora/rak2287_spi/global_conf/global_conf.as_920_923.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.as_920_923.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, "beacon_datarate": 9, "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.as_923_925.json b/lora/rak2287_spi/global_conf_uart/global_conf.as_923_925.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak2287_spi/global_conf/global_conf.as_923_925.json rename to lora/rak2287_spi/global_conf_uart/global_conf.as_923_925.json index 0364291..4cfa336 --- a/lora/rak2287_spi/global_conf/global_conf.as_923_925.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.as_923_925.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, "beacon_datarate": 9, "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.au_915_928.json b/lora/rak2287_spi/global_conf_uart/global_conf.au_915_928.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.au_915_928.json rename to lora/rak2287_spi/global_conf_uart/global_conf.au_915_928.json index 1e3c026..ec9e248 --- a/lora/rak2287_spi/global_conf/global_conf.au_915_928.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.au_915_928.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.eu_863_870.json b/lora/rak2287_spi/global_conf_uart/global_conf.eu_863_870.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.eu_863_870.json rename to lora/rak2287_spi/global_conf_uart/global_conf.eu_863_870.json index 1a1d3fe..aab53ec --- a/lora/rak2287_spi/global_conf/global_conf.eu_863_870.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.eu_863_870.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.in_865_867.json b/lora/rak2287_spi/global_conf_uart/global_conf.in_865_867.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.in_865_867.json rename to lora/rak2287_spi/global_conf_uart/global_conf.in_865_867.json index a6a7f96..304d1ad --- a/lora/rak2287_spi/global_conf/global_conf.in_865_867.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.in_865_867.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.kr_920_923.json b/lora/rak2287_spi/global_conf_uart/global_conf.kr_920_923.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.kr_920_923.json rename to lora/rak2287_spi/global_conf_uart/global_conf.kr_920_923.json index 826a24b..0c4d329 --- a/lora/rak2287_spi/global_conf/global_conf.kr_920_923.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.kr_920_923.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.ru_864_870.json b/lora/rak2287_spi/global_conf_uart/global_conf.ru_864_870.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.ru_864_870.json rename to lora/rak2287_spi/global_conf_uart/global_conf.ru_864_870.json index 348a3f4..51f7426 --- a/lora/rak2287_spi/global_conf/global_conf.ru_864_870.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.ru_864_870.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/global_conf/global_conf.us_902_928.json b/lora/rak2287_spi/global_conf_uart/global_conf.us_902_928.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak2287_spi/global_conf/global_conf.us_902_928.json rename to lora/rak2287_spi/global_conf_uart/global_conf.us_902_928.json index 23cd35b..9ec9bde --- a/lora/rak2287_spi/global_conf/global_conf.us_902_928.json +++ b/lora/rak2287_spi/global_conf_uart/global_conf.us_902_928.json @@ -80,12 +80,13 @@ "ref_longitude": 0.0, "ref_altitude": 0, /* Beaconing parameters */ - "beacon_period": 0, /* disable class B beacon */ - "beacon_freq_hz": 869525000, - "beacon_datarate": 9, - "beacon_bw_hz": 125000, - "beacon_power": 14, - "beacon_infodesc": 0 + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 }, "debug_conf": { diff --git a/lora/rak2287_spi/install.sh b/lora/rak2287_spi/install.sh index 4b40f9f..d63eb89 100755 --- a/lora/rak2287_spi/install.sh +++ b/lora/rak2287_spi/install.sh @@ -31,23 +31,35 @@ make clean rm libloragw/inc/loragw_stts751.h -f rm libloragw/src/loragw_stts751.c -f cp ../loragw_hal.c libloragw/src/loragw_hal.c -f +cp ../test_loragw_gps_uart.c libloragw/tst/test_loragw_gps.c -f +cp ../test_loragw_gps_i2c.c libloragw/tst/test_loragw_gps_i2c.c -f #mkdir -p packet_forwarder/lora_pkt_fwd/ #cp ../reset_lgw.sh packet_forwarder/lora_pkt_fwd/reset_lgw.sh -f cp ../Makefile libloragw/Makefile -f cp ../lora_pkt_fwd.c packet_forwarder/src/lora_pkt_fwd.c make - +rm packet_forwarder/lora_pkt_fwd/obj/* -f popd + if [ -d $INSTALL_DIR/packet_forwarder ]; then rm -rf $INSTALL_DIR/packet_forwarder/ fi cp $INSTALL_DIR/sx1302_hal-1.0.5/packet_forwarder $INSTALL_DIR/ -rf +cp $INSTALL_DIR/sx1302_hal-1.0.5/libloragw $INSTALL_DIR/lora_gateway -rf +if [ -f $SCRIPT_DIR/../../lte/lte_test ]; then + cp $SCRIPT_DIR/../../lte/lte_test $INSTALL_DIR/lora_gateway/ + cp $SCRIPT_DIR/reset_lgw.sh $INSTALL_DIR/lora_gateway/ +fi mv $INSTALL_DIR/packet_forwarder/lora_pkt_fwd $INSTALL_DIR/packet_forwarder/lora_pkt_fwd_bak mkdir -p $INSTALL_DIR/packet_forwarder/lora_pkt_fwd mv $INSTALL_DIR/packet_forwarder/lora_pkt_fwd_bak $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/lora_pkt_fwd -cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf -cp global_conf/global_conf.eu_863_870.json $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json + +if [ -d global_conf ]; then + cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf + cp global_conf/global_conf.eu_863_870.json $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json + sed -i "s/^.*server_address.*$/\t\"server_address\": \"127.0.0.1\",/" $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json +fi + cp reset_lgw.sh $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/reset_lgw.sh -sed -i "s/^.*server_address.*$/\t\"server_address\": \"127.0.0.1\",/" $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json rm -f $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/local_conf.json diff --git a/lora/rak2287_spi/loragw_gps.c b/lora/rak2287_spi/loragw_gps.c new file mode 100755 index 0000000..210b599 --- /dev/null +++ b/lora/rak2287_spi/loragw_gps.c @@ -0,0 +1,898 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (C)2019 Semtech + +Description: + Library of functions to manage a GNSS module (typically GPS) for accurate + timestamping of packets and synchronisation of gateways. + A limited set of module brands/models are supported. + +License: Revised BSD License, see LICENSE.TXT file include in the project +*/ + + +/* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +#define _GNU_SOURCE /* needed for qsort_r to be defined */ +#include /* C99 types */ +#include /* bool type */ +#include /* printf fprintf */ +#include /* memcpy */ +#include + +#include /* struct timespec */ +#include /* open */ +#include /* tcflush */ +#include /* modf */ + +#include + +#include "loragw_gps.h" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE MACROS ------------------------------------------------------- */ + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#if DEBUG_GPS == 1 + #define DEBUG_MSG(args...) fprintf(stderr, args) + #define DEBUG_PRINTF(fmt, args...) fprintf(stderr,"%s:%d: "fmt, __FUNCTION__, __LINE__, args) + #define DEBUG_ARRAY(a,b,c) for(a=0;a= buff_size) { + DEBUG_MSG("Maximum length reached for nmea_checksum\n"); + return -1; + } + } + + /* Convert checksum value to 2 hexadecimal characters */ + checksum[0] = nibble_to_hexchar(check_num / 16); /* upper nibble */ + checksum[1] = nibble_to_hexchar(check_num % 16); /* lower nibble */ + + return i + 1; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +static char nibble_to_hexchar(uint8_t a) { + if (a < 10) { + return '0' + a; + } else if (a < 16) { + return 'A' + (a-10); + } else { + return '?'; + } +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* +Calculate the checksum of a NMEA frame and compare it to the checksum that is +present at the end of it. +Return true if it matches +*/ +static bool validate_nmea_checksum(const char *serial_buff, int buff_size) { + int checksum_index; + char checksum[2]; /* 2 characters to calculate NMEA checksum */ + + checksum_index = nmea_checksum(serial_buff, buff_size, checksum); + + /* could we calculate a verification checksum ? */ + if (checksum_index < 0) { + DEBUG_MSG("ERROR: IMPOSSIBLE TO PARSE NMEA SENTENCE\n"); + return false; + } + + /* check if there are enough char in the serial buffer to read checksum */ + if (checksum_index >= (buff_size - 2)) { + DEBUG_MSG("ERROR: IMPOSSIBLE TO READ NMEA SENTENCE CHECKSUM\n"); + return false; + } + + /* check the checksum per se */ + if ((serial_buff[checksum_index] == checksum[0]) && (serial_buff[checksum_index+1] == checksum[1])) { + return true; + } else { + DEBUG_MSG("ERROR: NMEA CHECKSUM %c%c DOESN'T MATCH VERIFICATION CHECKSUM %c%c\n", serial_buff[checksum_index], serial_buff[checksum_index+1], checksum[0], checksum[1]); + return false; + } +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* +Return true if the "label" string (can contain wildcard characters) matches +the begining of the "s" string +*/ +static bool match_label(const char *s, char *label, int size, char wildcard) { + int i; + + for (i=0; i < size; i++) { + if (label[i] == wildcard) continue; + if (label[i] != s[i]) return false; + } + return true; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +/* +Chop a string into smaller strings +Replace every separator in the input character buffer by a null character so +that all s[index] are valid strings. +Populate an array of integer 'idx_ary' representing indexes of token in the +string. +buff_size and max_idx are there to prevent segfaults. +Return the number of token found (number of idx_ary filled). +*/ +int str_chop(char *s, int buff_size, char separator, int *idx_ary, int max_idx) { + int i = 0; /* index in the string */ + int j = 0; /* index in the result array */ + + if ((s == NULL) || (buff_size < 0) || (separator == 0) || (idx_ary == NULL) || (max_idx < 0)) { + /* unsafe to do anything */ + return -1; + } + if ((buff_size == 0) || (max_idx == 0)) { + /* nothing to do */ + return 0; + } + s[buff_size - 1] = 0; /* add string terminator at the end of the buffer, just to be sure */ + idx_ary[j] = 0; + j += 1; + /* loop until string terminator is reached */ + while (s[i] != 0) { + if (s[i] == separator) { + s[i] = 0; /* replace separator by string terminator */ + if (j >= max_idx) { /* no more room in the index array */ + return j; + } + idx_ary[j] = i+1; /* next token start after replaced separator */ + ++j; + } + ++i; + } + return j; +} + + +static int lgw_gps_enable_i2c(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { + int i; + struct termios ttyopt; /* serial port options */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + uint8_t ubx_cmd_timegps[UBX_MSG_NAVTIMEGPS_LEN] = { + 0xB5, 0x62, /* UBX Sync Chars */ + 0x06, 0x01, /* CFG-MSG Class/ID */ + 0x08, 0x00, /* Payload length */ + 0x01, 0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /* Enable NAV-TIMEGPS output on serial */ + 0x31, 0x91 }; /* Checksum */ + ssize_t num_written; + + /* check input parameters */ + CHECK_NULL(tty_path); + CHECK_NULL(fd_ptr); + + /* open TTY device */ + gps_tty_dev = open(tty_path, O_RDWR | O_NOCTTY); + if (gps_tty_dev <= 0) { + DEBUG_MSG("ERROR: TTY PORT FAIL TO OPEN, CHECK PATH AND ACCESS RIGHTS\n"); + return LGW_GPS_ERROR; + } + *fd_ptr = gps_tty_dev; + if(ioctl(gps_tty_dev, I2C_SLAVE, 0x42) < 0) + { + DEBUG_MSG("ERROR: I2C FAIL TO SET ADDR\n"); + return LGW_GPS_ERROR; + } + + /* manage the different GPS modules families */ + + num_written = write (gps_tty_dev, ubx_cmd_timegps, UBX_MSG_NAVTIMEGPS_LEN); + if (num_written != UBX_MSG_NAVTIMEGPS_LEN) { + DEBUG_MSG("ERROR: Failed to write on serial port (written=%d)\n", (int) num_written); + } + + /* get timezone info */ + tzset(); + + /* initialize global variables */ + gps_time_ok = false; + gps_pos_ok = false; + gps_mod = 'N'; + + return LGW_GPS_SUCCESS; +} + +static int lgw_gps_enable_uart(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { + int i; + struct termios ttyopt; /* serial port options */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + uint8_t ubx_cmd_timegps[UBX_MSG_NAVTIMEGPS_LEN] = { + 0xB5, 0x62, /* UBX Sync Chars */ + 0x06, 0x01, /* CFG-MSG Class/ID */ + 0x08, 0x00, /* Payload length */ + 0x01, 0x20, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, /* Enable NAV-TIMEGPS output on serial */ + 0x32, 0x94 }; /* Checksum */ + ssize_t num_written; + + /* check input parameters */ + CHECK_NULL(tty_path); + CHECK_NULL(fd_ptr); + + /* open TTY device */ + gps_tty_dev = open(tty_path, O_RDWR | O_NOCTTY); + if (gps_tty_dev <= 0) { + DEBUG_MSG("ERROR: TTY PORT FAIL TO OPEN, CHECK PATH AND ACCESS RIGHTS\n"); + return LGW_GPS_ERROR; + } + *fd_ptr = gps_tty_dev; + + /* manage the different GPS modules families */ + if (gps_family == NULL) { + DEBUG_MSG("WARNING: this version of GPS module may not be supported\n"); + } else if (strncmp(gps_family, "ubx7", 4) != 0) { + /* The current implementation relies on proprietary messages from U-Blox */ + /* GPS modules (UBX, NAV-TIMEGPS...) and has only be tested with a u-blox 7. */ + /* Those messages allow to get NATIVE GPS time (no leap seconds) required */ + /* for class-B handling and GPS synchronization */ + /* see lgw_parse_ubx() function for details */ + DEBUG_MSG("WARNING: this version of GPS module may not be supported\n"); + } + + /* manage the target bitrate */ + if (target_brate != 0) { + DEBUG_MSG("WARNING: target_brate parameter ignored for now\n"); // TODO + } + + /* get actual serial port configuration */ + i = tcgetattr(gps_tty_dev, &ttyopt); + if (i != 0) { + DEBUG_MSG("ERROR: IMPOSSIBLE TO GET TTY PORT CONFIGURATION\n"); + return LGW_GPS_ERROR; + } + + /* Save current serial port configuration for restoring later */ + memcpy(&ttyopt_restore, &ttyopt, sizeof ttyopt); + + /* update baudrates */ + cfsetispeed(&ttyopt, DEFAULT_BAUDRATE); + cfsetospeed(&ttyopt, DEFAULT_BAUDRATE); + + /* update terminal parameters */ + /* The following configuration should allow to: + - Get ASCII NMEA messages + - Get UBX binary messages + - Send UBX binary commands + Note: as binary data have to be read/written, we need to disable + various character processing to avoid loosing data */ + /* Control Modes */ + ttyopt.c_cflag |= CLOCAL; /* local connection, no modem control */ + ttyopt.c_cflag |= CREAD; /* enable receiving characters */ + ttyopt.c_cflag |= CS8; /* 8 bit frames */ + ttyopt.c_cflag &= ~PARENB; /* no parity */ + ttyopt.c_cflag &= ~CSTOPB; /* one stop bit */ + /* Input Modes */ + ttyopt.c_iflag |= IGNPAR; /* ignore bytes with parity errors */ + ttyopt.c_iflag &= ~ICRNL; /* do not map CR to NL on input*/ + ttyopt.c_iflag &= ~IGNCR; /* do not ignore carriage return on input */ + ttyopt.c_iflag &= ~IXON; /* disable Start/Stop output control */ + ttyopt.c_iflag &= ~IXOFF; /* do not send Start/Stop characters */ + /* Output Modes */ + ttyopt.c_oflag = 0; /* disable everything on output as we only write binary */ + /* Local Modes */ + ttyopt.c_lflag &= ~ICANON; /* disable canonical input - cannot use with binary input */ + ttyopt.c_lflag &= ~ISIG; /* disable check for INTR, QUIT, SUSP special characters */ + ttyopt.c_lflag &= ~IEXTEN; /* disable any special control character */ + ttyopt.c_lflag &= ~ECHO; /* do not echo back every character typed */ + ttyopt.c_lflag &= ~ECHOE; /* does not erase the last character in current line */ + ttyopt.c_lflag &= ~ECHOK; /* do not echo NL after KILL character */ + + /* settings for non-canonical mode + read will block for until the lesser of VMIN or requested chars have been received */ + ttyopt.c_cc[VMIN] = LGW_GPS_MIN_MSG_SIZE; + ttyopt.c_cc[VTIME] = 0; + + /* set new serial ports parameters */ + i = tcsetattr(gps_tty_dev, TCSANOW, &ttyopt); + if (i != 0){ + DEBUG_MSG("ERROR: IMPOSSIBLE TO UPDATE TTY PORT CONFIGURATION\n"); + return LGW_GPS_ERROR; + } + tcflush(gps_tty_dev, TCIOFLUSH); + + /* Send UBX CFG NAV-TIMEGPS message to tell GPS module to output native GPS time */ + /* This is a binary message, serial port has to be properly configured to handle this */ + num_written = write (gps_tty_dev, ubx_cmd_timegps, UBX_MSG_NAVTIMEGPS_LEN); + if (num_written != UBX_MSG_NAVTIMEGPS_LEN) { + DEBUG_MSG("ERROR: Failed to write on serial port (written=%d)\n", (int) num_written); + } + + /* get timezone info */ + tzset(); + + /* initialize global variables */ + gps_time_ok = false; + gps_pos_ok = false; + gps_mod = 'N'; + + return LGW_GPS_SUCCESS; +} + +/* -------------------------------------------------------------------------- */ +/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */ + +int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { + if (strcmp("/dev/i2c-1", tty_path) == 0) + { + printf("This is i2c for GPS.\n"); + return lgw_gps_enable_i2c(tty_path, gps_family, target_brate, fd_ptr); + } + else + { + printf("This is uart for GPS.\n"); + return lgw_gps_enable_uart(tty_path, gps_family, target_brate, fd_ptr); + } +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_gps_disable(int fd) { + int i; + + /* restore serial ports parameters */ + i = tcsetattr(fd, TCSANOW, &ttyopt_restore); + if (i != 0){ + DEBUG_MSG("ERROR: IMPOSSIBLE TO RESTORE TTY PORT CONFIGURATION - %s\n", strerror(errno)); + return LGW_GPS_ERROR; + } + tcflush(fd, TCIOFLUSH); + + i = close(fd); + if (i != 0) { + DEBUG_PRINTF("ERROR: TTY PORT FAIL TO CLOSE - %s\n", strerror(errno)); + return LGW_GPS_ERROR; + } + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +enum gps_msg lgw_parse_ubx(const char *serial_buff, size_t buff_size, size_t *msg_size) { + bool valid = 0; /* iTOW, fTOW and week validity */ + unsigned int payload_length; + uint8_t ck_a, ck_b; + uint8_t ck_a_rcv, ck_b_rcv; + unsigned int i; + + *msg_size = 0; /* ensure msg_size alway receives a value */ + + /* check input parameters */ + if (serial_buff == NULL) { + return IGNORED; + } + if (buff_size < 8) { + DEBUG_MSG("ERROR: TOO SHORT TO BE A VALID UBX MESSAGE\n"); + return IGNORED; + } + + /* display received serial data and checksum */ + DEBUG_MSG("Note: parsing UBX frame> "); + for (i=0; i (int)(sizeof(parser_buf) - 1)) { + DEBUG_MSG("Note: input string to big for parsing\n"); + return INVALID; + } + + /* look for some NMEA sentences in particular */ + if (buff_size < 8) { + DEBUG_MSG("ERROR: TOO SHORT TO BE A VALID NMEA SENTENCE\n"); + return UNKNOWN; + } else if (!validate_nmea_checksum(serial_buff, buff_size)) { + DEBUG_MSG("Warning: invalid NMEA sentence (bad checksum)\n"); + return INVALID; + } else if (match_label(serial_buff, "$G?RMC", 6, '?')) { + /* + NMEA sentence format: $xxRMC,time,status,lat,NS,long,EW,spd,cog,date,mv,mvEW,posMode*cs + Valid fix: $GPRMC,083559.34,A,4717.11437,N,00833.91522,E,0.004,77.52,091202,,,A*00 + No fix: $GPRMC,,V,,,,,,,,,,N*00 + */ + memcpy(parser_buf, serial_buff, buff_size); + parser_buf[buff_size] = '\0'; + nb_fields = str_chop(parser_buf, buff_size, ',', str_index, ARRAY_SIZE(str_index)); + if (nb_fields != 13) { + DEBUG_MSG("Warning: invalid RMC sentence (number of fields)\n"); + return IGNORED; + } + /* parse GPS status */ + gps_mod = *(parser_buf + str_index[12]); /* get first character, no need to bother with sscanf */ + if ((gps_mod != 'N') && (gps_mod != 'A') && (gps_mod != 'D')) { + gps_mod = 'N'; + } + /* parse complete time */ + i = sscanf(parser_buf + str_index[1], "%2hd%2hd%2hd%4f", &gps_hou, &gps_min, &gps_sec, &gps_fra); + j = sscanf(parser_buf + str_index[9], "%2hd%2hd%2hd", &gps_day, &gps_mon, &gps_yea); + if ((i == 4) && (j == 3)) { + if ((gps_mod == 'A') || (gps_mod == 'D')) { + gps_time_ok = true; + DEBUG_MSG("Note: Valid RMC sentence, GPS locked, date: 20%02d-%02d-%02dT%02d:%02d:%06.3fZ\n", gps_yea, gps_mon, gps_day, gps_hou, gps_min, gps_fra + (float)gps_sec); + } else { + gps_time_ok = false; + DEBUG_MSG("Note: Valid RMC sentence, no satellite fix, estimated date: 20%02d-%02d-%02dT%02d:%02d:%06.3fZ\n", gps_yea, gps_mon, gps_day, gps_hou, gps_min, gps_fra + (float)gps_sec); + } + } else { + /* could not get a valid hour AND date */ + gps_time_ok = false; + DEBUG_MSG("Note: Valid RMC sentence, mode %c, no date\n", gps_mod); + } + return NMEA_RMC; + } else if (match_label(serial_buff, "$G?GGA", 6, '?')) { + /* + NMEA sentence format: $xxGGA,time,lat,NS,long,EW,quality,numSV,HDOP,alt,M,sep,M,diffAge,diffStation*cs + Valid fix: $GPGGA,092725.00,4717.11399,N,00833.91590,E,1,08,1.01,499.6,M,48.0,M,,*5B + */ + memcpy(parser_buf, serial_buff, buff_size); + parser_buf[buff_size] = '\0'; + nb_fields = str_chop(parser_buf, buff_size, ',', str_index, ARRAY_SIZE(str_index)); + if (nb_fields != 15) { + DEBUG_MSG("Warning: invalid GGA sentence (number of fields)\n"); + return IGNORED; + } + /* parse number of satellites used for fix */ + sscanf(parser_buf + str_index[7], "%hd", &gps_sat); + /* parse 3D coordinates */ + i = sscanf(parser_buf + str_index[2], "%2hd%10lf", &gps_dla, &gps_mla); + gps_ola = *(parser_buf + str_index[3]); + j = sscanf(parser_buf + str_index[4], "%3hd%10lf", &gps_dlo, &gps_mlo); + gps_olo = *(parser_buf + str_index[5]); + k = sscanf(parser_buf + str_index[9], "%hd", &gps_alt); + if ((i == 2) && (j == 2) && (k == 1) && ((gps_ola=='N')||(gps_ola=='S')) && ((gps_olo=='E')||(gps_olo=='W'))) { + gps_pos_ok = true; + DEBUG_MSG("Note: Valid GGA sentence, %d sat, lat %02ddeg %06.3fmin %c, lon %03ddeg%06.3fmin %c, alt %d\n", gps_sat, gps_dla, gps_mla, gps_ola, gps_dlo, gps_mlo, gps_olo, gps_alt); + } else { + /* could not get a valid latitude, longitude AND altitude */ + gps_pos_ok = false; + DEBUG_MSG("Note: Valid GGA sentence, %d sat, no coordinates\n", gps_sat); + } + return NMEA_GGA; + } else { + DEBUG_MSG("Note: ignored NMEA sentence\n"); /* quite verbose */ + return IGNORED; + } +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_gps_get(struct timespec *utc, struct timespec *gps_time, struct coord_s *loc, struct coord_s *err) { + struct tm x; + time_t y; + double intpart, fractpart; + + if (utc != NULL) { + if (!gps_time_ok) { + DEBUG_MSG("ERROR: NO VALID TIME TO RETURN\n"); + return LGW_GPS_ERROR; + } + memset(&x, 0, sizeof(x)); + if (gps_yea < 100) { /* 2-digits year, 20xx */ + x.tm_year = gps_yea + 100; /* 100 years offset to 1900 */ + } else { /* 4-digits year, Gregorian calendar */ + x.tm_year = gps_yea - 1900; + } + x.tm_mon = gps_mon - 1; /* tm_mon is [0,11], gps_mon is [1,12] */ + x.tm_mday = gps_day; + x.tm_hour = gps_hou; + x.tm_min = gps_min; + x.tm_sec = gps_sec; + y = mktime(&x) - timezone; /* need to substract timezone bc mktime assumes time vector is local time */ + if (y == (time_t)(-1)) { + DEBUG_MSG("ERROR: FAILED TO CONVERT BROKEN-DOWN TIME\n"); + return LGW_GPS_ERROR; + } + utc->tv_sec = y; + utc->tv_nsec = (int32_t)(gps_fra * 1e9); + } + if (gps_time != NULL) { + if (!gps_time_ok) { + DEBUG_MSG("ERROR: NO VALID TIME TO RETURN\n"); + return LGW_GPS_ERROR; + } + fractpart = modf(((double)gps_iTOW / 1E3) + ((double)gps_fTOW / 1E9), &intpart); + /* Number of seconds since beginning on current GPS week */ + gps_time->tv_sec = (time_t)intpart; + /* Number of seconds since GPS epoch 06.Jan.1980 */ + gps_time->tv_sec += (time_t)gps_week * 604800; /* day*hours*minutes*secondes: 7*24*60*60; */ + /* Fractional part in nanoseconds */ + gps_time->tv_nsec = (long)(fractpart * 1E9); + } + if (loc != NULL) { + if (!gps_pos_ok) { + DEBUG_MSG("ERROR: NO VALID POSITION TO RETURN\n"); + return LGW_GPS_ERROR; + } + loc->lat = ((double)gps_dla + (gps_mla/60.0)) * ((gps_ola == 'N')?1.0:-1.0); + loc->lon = ((double)gps_dlo + (gps_mlo/60.0)) * ((gps_olo == 'E')?1.0:-1.0); + loc->alt = gps_alt; + } + if (err != NULL) { + DEBUG_MSG("Warning: localization error processing not implemented yet\n"); + err->lat = 0.0; + err->lon = 0.0; + err->alt = 0; + } + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_gps_sync(struct tref *ref, uint32_t count_us, struct timespec utc, struct timespec gps_time) { + double cnt_diff; /* internal concentrator time difference (in seconds) */ + double utc_diff; /* UTC time difference (in seconds) */ + double slope; /* time slope between new reference and old reference (for sanity check) */ + + bool aber_n0; /* is the update value for synchronization aberrant or not ? */ + static bool aber_min1 = false; /* keep track of whether value at sync N-1 was aberrant or not */ + static bool aber_min2 = false; /* keep track of whether value at sync N-2 was aberrant or not */ + + CHECK_NULL(ref); + + /* calculate the slope */ + + cnt_diff = (double)(count_us - ref->count_us) / (double)(TS_CPS); /* uncorrected by xtal_err */ + utc_diff = (double)(utc.tv_sec - (ref->utc).tv_sec) + (1E-9 * (double)(utc.tv_nsec - (ref->utc).tv_nsec)); + + /* detect aberrant points by measuring if slope limits are exceeded */ + if (utc_diff != 0) { // prevent divide by zero + slope = cnt_diff/utc_diff; + if ((slope > PLUS_10PPM) || (slope < MINUS_10PPM)) { + DEBUG_MSG("Warning: correction range exceeded\n"); + aber_n0 = true; + } else { + aber_n0 = false; + } + } else { + DEBUG_MSG("Warning: aberrant UTC value for synchronization\n"); + aber_n0 = true; + } + + /* watch if the 3 latest sync point were aberrant or not */ + if (aber_n0 == false) { + /* value no aberrant -> sync with smoothed slope */ + ref->systime = time(NULL); + ref->count_us = count_us; + ref->utc.tv_sec = utc.tv_sec; + ref->utc.tv_nsec = utc.tv_nsec; + ref->gps.tv_sec = gps_time.tv_sec; + ref->gps.tv_nsec = gps_time.tv_nsec; + ref->xtal_err = slope; + aber_min2 = aber_min1; + aber_min1 = aber_n0; + return LGW_GPS_SUCCESS; + } else if (aber_n0 && aber_min1 && aber_min2) { + /* 3 successive aberrant values -> sync reset (keep xtal_err) */ + ref->systime = time(NULL); + ref->count_us = count_us; + ref->utc.tv_sec = utc.tv_sec; + ref->utc.tv_nsec = utc.tv_nsec; + ref->gps.tv_sec = gps_time.tv_sec; + ref->gps.tv_nsec = gps_time.tv_nsec; + /* reset xtal_err only if the present value is out of range */ + if ((ref->xtal_err > PLUS_10PPM) || (ref->xtal_err < MINUS_10PPM)) { + ref->xtal_err = 1.0; + } + DEBUG_MSG("Warning: 3 successive aberrant sync attempts, sync reset\n"); + aber_min2 = aber_min1; + aber_min1 = aber_n0; + return LGW_GPS_SUCCESS; + } else { + /* only 1 or 2 successive aberrant values -> ignore and return an error */ + aber_min2 = aber_min1; + aber_min1 = aber_n0; + return LGW_GPS_ERROR; + } + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_cnt2utc(struct tref ref, uint32_t count_us, struct timespec *utc) { + double delta_sec; + double intpart, fractpart; + long tmp; + + CHECK_NULL(utc); + if ((ref.systime == 0) || (ref.xtal_err > PLUS_10PPM) || (ref.xtal_err < MINUS_10PPM)) { + DEBUG_MSG("ERROR: INVALID REFERENCE FOR CNT -> UTC CONVERSION\n"); + return LGW_GPS_ERROR; + } + + /* calculate delta in seconds between reference count_us and target count_us */ + delta_sec = (double)(count_us - ref.count_us) / (TS_CPS * ref.xtal_err); + + /* now add that delta to reference UTC time */ + fractpart = modf (delta_sec , &intpart); + tmp = ref.utc.tv_nsec + (long)(fractpart * 1E9); + if (tmp < (long)1E9) { /* the nanosecond part doesn't overflow */ + utc->tv_sec = ref.utc.tv_sec + (time_t)intpart; + utc->tv_nsec = tmp; + } else { /* must carry one second */ + utc->tv_sec = ref.utc.tv_sec + (time_t)intpart + 1; + utc->tv_nsec = tmp - (long)1E9; + } + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_utc2cnt(struct tref ref, struct timespec utc, uint32_t *count_us) { + double delta_sec; + + CHECK_NULL(count_us); + if ((ref.systime == 0) || (ref.xtal_err > PLUS_10PPM) || (ref.xtal_err < MINUS_10PPM)) { + DEBUG_MSG("ERROR: INVALID REFERENCE FOR UTC -> CNT CONVERSION\n"); + return LGW_GPS_ERROR; + } + + /* calculate delta in seconds between reference utc and target utc */ + delta_sec = (double)(utc.tv_sec - ref.utc.tv_sec); + delta_sec += 1E-9 * (double)(utc.tv_nsec - ref.utc.tv_nsec); + + /* now convert that to internal counter tics and add that to reference counter value */ + *count_us = ref.count_us + (uint32_t)(delta_sec * TS_CPS * ref.xtal_err); + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_cnt2gps(struct tref ref, uint32_t count_us, struct timespec *gps_time) { + double delta_sec; + double intpart, fractpart; + long tmp; + + CHECK_NULL(gps_time); + if ((ref.systime == 0) || (ref.xtal_err > PLUS_10PPM) || (ref.xtal_err < MINUS_10PPM)) { + DEBUG_MSG("ERROR: INVALID REFERENCE FOR CNT -> GPS CONVERSION\n"); + return LGW_GPS_ERROR; + } + + /* calculate delta in milliseconds between reference count_us and target count_us */ + delta_sec = (double)(count_us - ref.count_us) / (TS_CPS * ref.xtal_err); + + /* now add that delta to reference GPS time */ + fractpart = modf (delta_sec , &intpart); + tmp = ref.gps.tv_nsec + (long)(fractpart * 1E9); + if (tmp < (long)1E9) { /* the nanosecond part doesn't overflow */ + gps_time->tv_sec = ref.gps.tv_sec + (time_t)intpart; + gps_time->tv_nsec = tmp; + } else { /* must carry one second */ + gps_time->tv_sec = ref.gps.tv_sec + (time_t)intpart + 1; + gps_time->tv_nsec = tmp - (long)1E9; + } + + return LGW_GPS_SUCCESS; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + +int lgw_gps2cnt(struct tref ref, struct timespec gps_time, uint32_t *count_us) { + double delta_sec; + + CHECK_NULL(count_us); + if ((ref.systime == 0) || (ref.xtal_err > PLUS_10PPM) || (ref.xtal_err < MINUS_10PPM)) { + DEBUG_MSG("ERROR: INVALID REFERENCE FOR GPS -> CNT CONVERSION\n"); + return LGW_GPS_ERROR; + } + + /* calculate delta in seconds between reference gps time and target gps time */ + delta_sec = (double)(gps_time.tv_sec - ref.gps.tv_sec); + delta_sec += 1E-9 * (double)(gps_time.tv_nsec - ref.gps.tv_nsec); + + /* now convert that to internal counter tics and add that to reference counter value */ + *count_us = ref.count_us + (uint32_t)(delta_sec * TS_CPS * ref.xtal_err); + + return LGW_GPS_SUCCESS; +} + +/* --- EOF ------------------------------------------------------------------ */ diff --git a/lora/rak2287_spi/reset_lgw.sh b/lora/rak2287_spi/reset_lgw.sh index 2e14c4c..565afcd 100755 --- a/lora/rak2287_spi/reset_lgw.sh +++ b/lora/rak2287_spi/reset_lgw.sh @@ -12,7 +12,6 @@ # SX1302_RESET_PIN=17 -SX1302_POWER_EN_PIN=18 WAIT_GPIO() { sleep 0.1 @@ -21,19 +20,13 @@ WAIT_GPIO() { init() { # setup GPIOs echo "$SX1302_RESET_PIN" > /sys/class/gpio/export; WAIT_GPIO - echo "$SX1302_POWER_EN_PIN" > /sys/class/gpio/export; WAIT_GPIO # set GPIOs as output echo "out" > /sys/class/gpio/gpio$SX1302_RESET_PIN/direction; WAIT_GPIO - echo "out" > /sys/class/gpio/gpio$SX1302_POWER_EN_PIN/direction; WAIT_GPIO } reset() { echo "CoreCell reset through GPIO$SX1302_RESET_PIN..." - echo "CoreCell power enable through GPIO$SX1302_POWER_EN_PIN..." - - # write output for SX1302 CoreCell power_enable and reset - echo "1" > /sys/class/gpio/gpio$SX1302_POWER_EN_PIN/value; WAIT_GPIO echo "1" > /sys/class/gpio/gpio$SX1302_RESET_PIN/value; WAIT_GPIO echo "0" > /sys/class/gpio/gpio$SX1302_RESET_PIN/value; WAIT_GPIO @@ -45,10 +38,6 @@ term() { then echo "$SX1302_RESET_PIN" > /sys/class/gpio/unexport; WAIT_GPIO fi - if [ -d /sys/class/gpio/gpio$SX1302_POWER_EN_PIN ] - then - echo "$SX1302_POWER_EN_PIN" > /sys/class/gpio/unexport; WAIT_GPIO - fi } case "$1" in diff --git a/lora/rak2287_spi/test_loragw_gps_i2c.c b/lora/rak2287_spi/test_loragw_gps_i2c.c new file mode 100755 index 0000000..6c08c06 --- /dev/null +++ b/lora/rak2287_spi/test_loragw_gps_i2c.c @@ -0,0 +1,418 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (C)2019 Semtech + +Description: + Minimum test program for the loragw_gps module + +License: Revised BSD License, see LICENSE.TXT file include in the project +*/ + + +/* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +/* fix an issue between POSIX and C99 */ +#if __STDC_VERSION__ >= 199901L + #define _XOPEN_SOURCE 600 +#else + #define _XOPEN_SOURCE 500 +#endif + +#include /* C99 types */ +#include /* bool type */ +#include /* printf */ +#include /* memset */ +#include /* sigaction */ +#include /* exit */ +#include /* read */ + +#include "loragw_hal.h" +#include "loragw_gps.h" +#include "loragw_aux.h" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE MACROS ------------------------------------------------------- */ + +#define MATCH(a,b) ( ((int32_t)(a-b)<=1) && ((int32_t)(a-b)>=-1) ) /* tolerate 1µs */ + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE CONSTANTS ---------------------------------------------------- */ + +#define LINUXDEV_PATH_DEFAULT "/dev/spidev0.0" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE VARIABLES ---------------------------------------------------- */ + +static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */ +static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */ + +struct tref ppm_ref; + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DECLARATION ---------------------------------------- */ + +static void sig_handler(int sigio); +static void gps_process_sync(void); +static void gps_process_coords(void); + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */ + +void usage(void) { + //printf("Library version information: %s\n", lgw_version_info()); + printf( "Available options:\n"); + printf( " -h print this help\n"); + printf( " -k Concentrator clock source (Radio A or Radio B) [0..1]\n"); + printf( " -r Radio type (1255, 1257, 1250)\n"); +} + +static void sig_handler(int sigio) { + if (sigio == SIGQUIT) { + quit_sig = 1;; + } else if ((sigio == SIGINT) || (sigio == SIGTERM)) { + exit_sig = 1; + } +} + +static void gps_process_sync(void) { + /* variables for PPM pulse GPS synchronization */ + uint32_t ppm_tstamp; + struct timespec ppm_gps; + struct timespec ppm_utc; + + /* variables for timestamp <-> GPS time conversions */ + uint32_t x, z; + struct timespec y; + + /* get GPS time for synchronization */ + int i = lgw_gps_get(&ppm_utc, &ppm_gps, NULL, NULL); + if (i != LGW_GPS_SUCCESS) { + printf(" No valid reference GPS time available, synchronization impossible.\n"); + return; + } + + /* get timestamp for synchronization */ + i = lgw_get_trigcnt(&ppm_tstamp); + if (i != LGW_HAL_SUCCESS) { + printf(" Failed to read timestamp, synchronization impossible.\n"); + return; + } + + /* try to update synchronize time reference with the new GPS & timestamp */ + i = lgw_gps_sync(&ppm_ref, ppm_tstamp, ppm_utc, ppm_gps); + if (i != LGW_GPS_SUCCESS) { + printf(" Synchronization error.\n"); + return; + } + + /* display result */ + printf(" * Synchronization successful *\n"); + printf(" UTC reference time: %lld.%09ld\n", (long long)ppm_ref.utc.tv_sec, ppm_ref.utc.tv_nsec); + printf(" GPS reference time: %lld.%09ld\n", (long long)ppm_ref.gps.tv_sec, ppm_ref.gps.tv_nsec); + printf(" Internal counter reference value: %u\n", ppm_ref.count_us); + printf(" Clock error: %.9f\n", ppm_ref.xtal_err); + + x = ppm_tstamp + 500000; + + /* CNT -> GPS -> CNT */ + printf("\n"); + printf(" * Test of timestamp counter <-> GPS value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2gps(ppm_ref, x, &y); + printf(" Conversion to GPS: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_gps2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + /* Display test result */ + if (MATCH(x,z)) { + printf(" ** PASS **: (SX1302 -> GPS -> SX1302) conversion MATCH\n"); + } else { + printf(" ** FAILED **: (SX1302 -> GPS -> SX1302) conversion MISMATCH\n"); + } + + /* CNT -> UTC -> CNT */ + printf("\n"); + printf(" * Test of timestamp counter <-> UTC value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2utc(ppm_ref, x, &y); + printf(" Conversion to UTC: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_utc2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + /* Display test result */ + if (MATCH(x,z)) { + printf(" ** PASS **: (SX1302 -> UTC -> SX1302) conversion MATCH\n"); + } else { + printf(" ** FAILED **: (SX1302 -> UTC -> SX1302) conversion MISMATCH\n"); + } +} + +static void gps_process_coords(void) { + /* position variable */ + struct coord_s coord; + struct coord_s gpserr; + int i = lgw_gps_get(NULL, NULL, &coord, &gpserr); + + /* update gateway coordinates */ + if (i == LGW_GPS_SUCCESS) { + printf("\n"); + printf("# GPS coordinates: latitude %.5f, longitude %.5f, altitude %i m\n", coord.lat, coord.lon, coord.alt); + printf("# GPS err: latitude %.5f, longitude %.5f, altitude %i m\n", gpserr.lat, gpserr.lon, gpserr.alt); + } +} + +/* -------------------------------------------------------------------------- */ +/* --- MAIN FUNCTION -------------------------------------------------------- */ + +int main(int argc, char **argv) +{ + /* SPI interfaces */ + const char spidev_path_default[] = LINUXDEV_PATH_DEFAULT; + const char * spidev_path = spidev_path_default; + + struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */ + + int i; + unsigned int arg_u; + + /* concentrator variables */ + uint8_t clocksource = 0; + lgw_radio_type_t radio_type = LGW_RADIO_TYPE_NONE; + struct lgw_conf_board_s boardconf; + struct lgw_conf_rxrf_s rfconf; + + /* serial variables */ + char serial_buff[128]; /* buffer to receive GPS data */ + size_t wr_idx = 0; /* pointer to end of chars in buffer */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + + /* NMEA/UBX variables */ + enum gps_msg latest_msg; /* keep track of latest NMEA/UBX message parsed */ + + /* parse command line options */ + while ((i = getopt (argc, argv, "hk:r:")) != -1) { + switch (i) { + case 'h': + usage(); + return -1; + break; + case 'r': /* Radio type */ + i = sscanf(optarg, "%u", &arg_u); + if ((i != 1) || ((arg_u != 1255) && (arg_u != 1257) && (arg_u != 1250))) { + printf("ERROR: argument parsing of -r argument. Use -h to print help\n"); + return EXIT_FAILURE; + } else { + switch (arg_u) { + case 1255: + radio_type = LGW_RADIO_TYPE_SX1255; + break; + case 1257: + radio_type = LGW_RADIO_TYPE_SX1257; + break; + default: /* 1250 */ + radio_type = LGW_RADIO_TYPE_SX1250; + break; + } + } + break; + case 'k': /* Clock Source */ + i = sscanf(optarg, "%u", &arg_u); + if ((i != 1) || (arg_u > 1)) { + printf("ERROR: argument parsing of -k argument. Use -h to print help\n"); + return EXIT_FAILURE; + } else { + clocksource = (uint8_t)arg_u; + } + break; + default: + printf("ERROR: argument parsing\n"); + usage(); + exit(EXIT_FAILURE); + } + } + + /* Check arguments */ + if (radio_type == LGW_RADIO_TYPE_NONE) { + printf("ERROR: radio type must be specified\n"); + usage(); + exit(EXIT_FAILURE); + } + + /* configure signal handling */ + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigact.sa_handler = sig_handler; + sigaction(SIGQUIT, &sigact, NULL); + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); + + /* Intro message and library information */ + printf("Beginning of test for loragw_gps.c\n"); + printf("*** Library version information ***\n%s\n***\n", lgw_version_info()); + + /* Board reset */ + if (system("./reset_lgw.sh start") != 0) { + printf("ERROR: failed to reset SX1302, check your reset_lgw.sh script\n"); + exit(EXIT_FAILURE); + } + + /* Open and configure GPS */ + i = lgw_gps_enable("/dev/i2c-1", "ubx7", 0, &gps_tty_dev); + if (i != LGW_GPS_SUCCESS) { + printf("ERROR: Failed to enable GPS\n"); + exit(EXIT_FAILURE); + } + + /* start concentrator (default conf for IoT SK) */ + /* board config */ + memset(&boardconf, 0, sizeof(boardconf)); + boardconf.lorawan_public = true; + boardconf.clksrc = clocksource; + boardconf.full_duplex = false; + strncpy(boardconf.spidev_path, spidev_path, sizeof boardconf.spidev_path); + boardconf.spidev_path[sizeof boardconf.spidev_path - 1] = '\0'; /* ensure string termination */ + if (lgw_board_setconf(&boardconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure board\n"); + return EXIT_FAILURE; + } + + /* set configuration for RF chains */ + memset( &rfconf, 0, sizeof rfconf); + rfconf.enable = true; + rfconf.freq_hz = 868000000; + rfconf.rssi_offset = 0.0; + rfconf.type = radio_type; + rfconf.tx_enable = false; + rfconf.single_input_mode = false; + if (lgw_rxrf_setconf(0, &rfconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure rxrf 0\n"); + return EXIT_FAILURE; + } + + memset( &rfconf, 0, sizeof rfconf); + rfconf.enable = true; + rfconf.freq_hz = 868000000; + rfconf.rssi_offset = 0.0; + rfconf.type = radio_type; + rfconf.tx_enable = false; + rfconf.single_input_mode = false; + if (lgw_rxrf_setconf(1, &rfconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure rxrf 1\n"); + return EXIT_FAILURE; + } + + /* start */ + if (lgw_start() != LGW_HAL_SUCCESS) { + printf("ERROR: IMPOSSIBLE TO START THE GATEWAY\n"); + exit(EXIT_FAILURE); + } + + /* initialize some variables before loop */ + memset(serial_buff, 0, sizeof serial_buff); + memset(&ppm_ref, 0, sizeof ppm_ref); + + /* loop until user action */ + while ((quit_sig != 1) && (exit_sig != 1)) { + size_t rd_idx = 0; + size_t frame_end_idx = 0; + + /* blocking non-canonical read on serial port */ + ssize_t nb_char = read(gps_tty_dev, serial_buff + wr_idx, LGW_GPS_MIN_MSG_SIZE); + if (nb_char <= 0) { + printf("WARNING: [gps] read() returned value %zd\n", nb_char); + continue; + } + wr_idx += (size_t)nb_char; + + /******************************************* + * Scan buffer for UBX/NMEA sync chars and * + * attempt to decode frame if one is found * + *******************************************/ + while (rd_idx < wr_idx) { + size_t frame_size = 0; + + /* Scan buffer for UBX sync char */ + if (serial_buff[rd_idx] == (char)LGW_GPS_UBX_SYNC_CHAR) { + + /*********************** + * Found UBX sync char * + ***********************/ + latest_msg = lgw_parse_ubx(&serial_buff[rd_idx], (wr_idx - rd_idx), &frame_size); + + if (frame_size > 0) { + if (latest_msg == INCOMPLETE) { + /* UBX header found but frame appears to be missing bytes */ + frame_size = 0; + } else if (latest_msg == INVALID) { + /* message header received but message appears to be corrupted */ + printf("WARNING: [gps] could not get a valid message from GPS (no time)\n"); + frame_size = 0; + } else if (latest_msg == UBX_NAV_TIMEGPS) { + printf("\n~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~\n"); + gps_process_sync(); + } + } + } else if(serial_buff[rd_idx] == (char)LGW_GPS_NMEA_SYNC_CHAR) { + /************************ + * Found NMEA sync char * + ************************/ + /* scan for NMEA end marker (LF = 0x0a) */ + char* nmea_end_ptr = memchr(&serial_buff[rd_idx],(int)0x0a, (wr_idx - rd_idx)); + + if (nmea_end_ptr) { + /* found end marker */ + frame_size = nmea_end_ptr - &serial_buff[rd_idx] + 1; + latest_msg = lgw_parse_nmea(&serial_buff[rd_idx], frame_size); + + if(latest_msg == INVALID || latest_msg == UNKNOWN) { + /* checksum failed */ + frame_size = 0; + } else if (latest_msg == NMEA_RMC) { /* Get location from RMC frames */ + gps_process_coords(); + } + } + } + + if (frame_size > 0) { + /* At this point message is a checksum verified frame + we're processed or ignored. Remove frame from buffer */ + rd_idx += frame_size; + frame_end_idx = rd_idx; + } else { + rd_idx++; + } + } /* ...for(rd_idx = 0... */ + + if (frame_end_idx) { + /* Frames have been processed. Remove bytes to end of last processed frame */ + memcpy(serial_buff,&serial_buff[frame_end_idx],wr_idx - frame_end_idx); + wr_idx -= frame_end_idx; + } /* ...for(rd_idx = 0... */ + + /* Prevent buffer overflow */ + if ((sizeof(serial_buff) - wr_idx) < LGW_GPS_MIN_MSG_SIZE) { + memcpy(serial_buff,&serial_buff[LGW_GPS_MIN_MSG_SIZE],wr_idx - LGW_GPS_MIN_MSG_SIZE); + wr_idx -= LGW_GPS_MIN_MSG_SIZE; + } + } + + /* clean up before leaving */ + if (exit_sig == 1) { + lgw_gps_disable(gps_tty_dev); + lgw_stop(); + } + + /* Board reset */ + if (system("./reset_lgw.sh stop") != 0) { + printf("ERROR: failed to reset SX1302, check your reset_lgw.sh script\n"); + exit(EXIT_FAILURE); + } + + printf("\nEnd of test for loragw_gps.c\n"); + exit(EXIT_SUCCESS); +} + +/* --- EOF ------------------------------------------------------------------ */ diff --git a/lora/rak2287_spi/test_loragw_gps_uart.c b/lora/rak2287_spi/test_loragw_gps_uart.c new file mode 100755 index 0000000..df9627b --- /dev/null +++ b/lora/rak2287_spi/test_loragw_gps_uart.c @@ -0,0 +1,418 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (C)2019 Semtech + +Description: + Minimum test program for the loragw_gps module + +License: Revised BSD License, see LICENSE.TXT file include in the project +*/ + + +/* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +/* fix an issue between POSIX and C99 */ +#if __STDC_VERSION__ >= 199901L + #define _XOPEN_SOURCE 600 +#else + #define _XOPEN_SOURCE 500 +#endif + +#include /* C99 types */ +#include /* bool type */ +#include /* printf */ +#include /* memset */ +#include /* sigaction */ +#include /* exit */ +#include /* read */ + +#include "loragw_hal.h" +#include "loragw_gps.h" +#include "loragw_aux.h" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE MACROS ------------------------------------------------------- */ + +#define MATCH(a,b) ( ((int32_t)(a-b)<=1) && ((int32_t)(a-b)>=-1) ) /* tolerate 1µs */ + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE CONSTANTS ---------------------------------------------------- */ + +#define LINUXDEV_PATH_DEFAULT "/dev/spidev0.0" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE VARIABLES ---------------------------------------------------- */ + +static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */ +static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */ + +struct tref ppm_ref; + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DECLARATION ---------------------------------------- */ + +static void sig_handler(int sigio); +static void gps_process_sync(void); +static void gps_process_coords(void); + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */ + +void usage(void) { + //printf("Library version information: %s\n", lgw_version_info()); + printf( "Available options:\n"); + printf( " -h print this help\n"); + printf( " -k Concentrator clock source (Radio A or Radio B) [0..1]\n"); + printf( " -r Radio type (1255, 1257, 1250)\n"); +} + +static void sig_handler(int sigio) { + if (sigio == SIGQUIT) { + quit_sig = 1;; + } else if ((sigio == SIGINT) || (sigio == SIGTERM)) { + exit_sig = 1; + } +} + +static void gps_process_sync(void) { + /* variables for PPM pulse GPS synchronization */ + uint32_t ppm_tstamp; + struct timespec ppm_gps; + struct timespec ppm_utc; + + /* variables for timestamp <-> GPS time conversions */ + uint32_t x, z; + struct timespec y; + + /* get GPS time for synchronization */ + int i = lgw_gps_get(&ppm_utc, &ppm_gps, NULL, NULL); + if (i != LGW_GPS_SUCCESS) { + printf(" No valid reference GPS time available, synchronization impossible.\n"); + return; + } + + /* get timestamp for synchronization */ + i = lgw_get_trigcnt(&ppm_tstamp); + if (i != LGW_HAL_SUCCESS) { + printf(" Failed to read timestamp, synchronization impossible.\n"); + return; + } + + /* try to update synchronize time reference with the new GPS & timestamp */ + i = lgw_gps_sync(&ppm_ref, ppm_tstamp, ppm_utc, ppm_gps); + if (i != LGW_GPS_SUCCESS) { + printf(" Synchronization error.\n"); + return; + } + + /* display result */ + printf(" * Synchronization successful *\n"); + printf(" UTC reference time: %lld.%09ld\n", (long long)ppm_ref.utc.tv_sec, ppm_ref.utc.tv_nsec); + printf(" GPS reference time: %lld.%09ld\n", (long long)ppm_ref.gps.tv_sec, ppm_ref.gps.tv_nsec); + printf(" Internal counter reference value: %u\n", ppm_ref.count_us); + printf(" Clock error: %.9f\n", ppm_ref.xtal_err); + + x = ppm_tstamp + 500000; + + /* CNT -> GPS -> CNT */ + printf("\n"); + printf(" * Test of timestamp counter <-> GPS value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2gps(ppm_ref, x, &y); + printf(" Conversion to GPS: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_gps2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + /* Display test result */ + if (MATCH(x,z)) { + printf(" ** PASS **: (SX1302 -> GPS -> SX1302) conversion MATCH\n"); + } else { + printf(" ** FAILED **: (SX1302 -> GPS -> SX1302) conversion MISMATCH\n"); + } + + /* CNT -> UTC -> CNT */ + printf("\n"); + printf(" * Test of timestamp counter <-> UTC value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2utc(ppm_ref, x, &y); + printf(" Conversion to UTC: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_utc2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + /* Display test result */ + if (MATCH(x,z)) { + printf(" ** PASS **: (SX1302 -> UTC -> SX1302) conversion MATCH\n"); + } else { + printf(" ** FAILED **: (SX1302 -> UTC -> SX1302) conversion MISMATCH\n"); + } +} + +static void gps_process_coords(void) { + /* position variable */ + struct coord_s coord; + struct coord_s gpserr; + int i = lgw_gps_get(NULL, NULL, &coord, &gpserr); + + /* update gateway coordinates */ + if (i == LGW_GPS_SUCCESS) { + printf("\n"); + printf("# GPS coordinates: latitude %.5f, longitude %.5f, altitude %i m\n", coord.lat, coord.lon, coord.alt); + printf("# GPS err: latitude %.5f, longitude %.5f, altitude %i m\n", gpserr.lat, gpserr.lon, gpserr.alt); + } +} + +/* -------------------------------------------------------------------------- */ +/* --- MAIN FUNCTION -------------------------------------------------------- */ + +int main(int argc, char **argv) +{ + /* SPI interfaces */ + const char spidev_path_default[] = LINUXDEV_PATH_DEFAULT; + const char * spidev_path = spidev_path_default; + + struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */ + + int i; + unsigned int arg_u; + + /* concentrator variables */ + uint8_t clocksource = 0; + lgw_radio_type_t radio_type = LGW_RADIO_TYPE_NONE; + struct lgw_conf_board_s boardconf; + struct lgw_conf_rxrf_s rfconf; + + /* serial variables */ + char serial_buff[128]; /* buffer to receive GPS data */ + size_t wr_idx = 0; /* pointer to end of chars in buffer */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + + /* NMEA/UBX variables */ + enum gps_msg latest_msg; /* keep track of latest NMEA/UBX message parsed */ + + /* parse command line options */ + while ((i = getopt (argc, argv, "hk:r:")) != -1) { + switch (i) { + case 'h': + usage(); + return -1; + break; + case 'r': /* Radio type */ + i = sscanf(optarg, "%u", &arg_u); + if ((i != 1) || ((arg_u != 1255) && (arg_u != 1257) && (arg_u != 1250))) { + printf("ERROR: argument parsing of -r argument. Use -h to print help\n"); + return EXIT_FAILURE; + } else { + switch (arg_u) { + case 1255: + radio_type = LGW_RADIO_TYPE_SX1255; + break; + case 1257: + radio_type = LGW_RADIO_TYPE_SX1257; + break; + default: /* 1250 */ + radio_type = LGW_RADIO_TYPE_SX1250; + break; + } + } + break; + case 'k': /* Clock Source */ + i = sscanf(optarg, "%u", &arg_u); + if ((i != 1) || (arg_u > 1)) { + printf("ERROR: argument parsing of -k argument. Use -h to print help\n"); + return EXIT_FAILURE; + } else { + clocksource = (uint8_t)arg_u; + } + break; + default: + printf("ERROR: argument parsing\n"); + usage(); + exit(EXIT_FAILURE); + } + } + + /* Check arguments */ + if (radio_type == LGW_RADIO_TYPE_NONE) { + printf("ERROR: radio type must be specified\n"); + usage(); + exit(EXIT_FAILURE); + } + + /* configure signal handling */ + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigact.sa_handler = sig_handler; + sigaction(SIGQUIT, &sigact, NULL); + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); + + /* Intro message and library information */ + printf("Beginning of test for loragw_gps.c\n"); + printf("*** Library version information ***\n%s\n***\n", lgw_version_info()); + + /* Board reset */ + if (system("./reset_lgw.sh start") != 0) { + printf("ERROR: failed to reset SX1302, check your reset_lgw.sh script\n"); + exit(EXIT_FAILURE); + } + + /* Open and configure GPS */ + i = lgw_gps_enable("/dev/ttyAMA0", "ubx7", 0, &gps_tty_dev); + if (i != LGW_GPS_SUCCESS) { + printf("ERROR: Failed to enable GPS\n"); + exit(EXIT_FAILURE); + } + + /* start concentrator (default conf for IoT SK) */ + /* board config */ + memset(&boardconf, 0, sizeof(boardconf)); + boardconf.lorawan_public = true; + boardconf.clksrc = clocksource; + boardconf.full_duplex = false; + strncpy(boardconf.spidev_path, spidev_path, sizeof boardconf.spidev_path); + boardconf.spidev_path[sizeof boardconf.spidev_path - 1] = '\0'; /* ensure string termination */ + if (lgw_board_setconf(&boardconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure board\n"); + return EXIT_FAILURE; + } + + /* set configuration for RF chains */ + memset( &rfconf, 0, sizeof rfconf); + rfconf.enable = true; + rfconf.freq_hz = 868000000; + rfconf.rssi_offset = 0.0; + rfconf.type = radio_type; + rfconf.tx_enable = false; + rfconf.single_input_mode = false; + if (lgw_rxrf_setconf(0, &rfconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure rxrf 0\n"); + return EXIT_FAILURE; + } + + memset( &rfconf, 0, sizeof rfconf); + rfconf.enable = true; + rfconf.freq_hz = 868000000; + rfconf.rssi_offset = 0.0; + rfconf.type = radio_type; + rfconf.tx_enable = false; + rfconf.single_input_mode = false; + if (lgw_rxrf_setconf(1, &rfconf) != LGW_HAL_SUCCESS) { + printf("ERROR: failed to configure rxrf 1\n"); + return EXIT_FAILURE; + } + + /* start */ + if (lgw_start() != LGW_HAL_SUCCESS) { + printf("ERROR: IMPOSSIBLE TO START THE GATEWAY\n"); + exit(EXIT_FAILURE); + } + + /* initialize some variables before loop */ + memset(serial_buff, 0, sizeof serial_buff); + memset(&ppm_ref, 0, sizeof ppm_ref); + + /* loop until user action */ + while ((quit_sig != 1) && (exit_sig != 1)) { + size_t rd_idx = 0; + size_t frame_end_idx = 0; + + /* blocking non-canonical read on serial port */ + ssize_t nb_char = read(gps_tty_dev, serial_buff + wr_idx, LGW_GPS_MIN_MSG_SIZE); + if (nb_char <= 0) { + printf("WARNING: [gps] read() returned value %zd\n", nb_char); + continue; + } + wr_idx += (size_t)nb_char; + + /******************************************* + * Scan buffer for UBX/NMEA sync chars and * + * attempt to decode frame if one is found * + *******************************************/ + while (rd_idx < wr_idx) { + size_t frame_size = 0; + + /* Scan buffer for UBX sync char */ + if (serial_buff[rd_idx] == (char)LGW_GPS_UBX_SYNC_CHAR) { + + /*********************** + * Found UBX sync char * + ***********************/ + latest_msg = lgw_parse_ubx(&serial_buff[rd_idx], (wr_idx - rd_idx), &frame_size); + + if (frame_size > 0) { + if (latest_msg == INCOMPLETE) { + /* UBX header found but frame appears to be missing bytes */ + frame_size = 0; + } else if (latest_msg == INVALID) { + /* message header received but message appears to be corrupted */ + printf("WARNING: [gps] could not get a valid message from GPS (no time)\n"); + frame_size = 0; + } else if (latest_msg == UBX_NAV_TIMEGPS) { + printf("\n~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~\n"); + gps_process_sync(); + } + } + } else if(serial_buff[rd_idx] == (char)LGW_GPS_NMEA_SYNC_CHAR) { + /************************ + * Found NMEA sync char * + ************************/ + /* scan for NMEA end marker (LF = 0x0a) */ + char* nmea_end_ptr = memchr(&serial_buff[rd_idx],(int)0x0a, (wr_idx - rd_idx)); + + if (nmea_end_ptr) { + /* found end marker */ + frame_size = nmea_end_ptr - &serial_buff[rd_idx] + 1; + latest_msg = lgw_parse_nmea(&serial_buff[rd_idx], frame_size); + + if(latest_msg == INVALID || latest_msg == UNKNOWN) { + /* checksum failed */ + frame_size = 0; + } else if (latest_msg == NMEA_RMC) { /* Get location from RMC frames */ + gps_process_coords(); + } + } + } + + if (frame_size > 0) { + /* At this point message is a checksum verified frame + we're processed or ignored. Remove frame from buffer */ + rd_idx += frame_size; + frame_end_idx = rd_idx; + } else { + rd_idx++; + } + } /* ...for(rd_idx = 0... */ + + if (frame_end_idx) { + /* Frames have been processed. Remove bytes to end of last processed frame */ + memcpy(serial_buff,&serial_buff[frame_end_idx],wr_idx - frame_end_idx); + wr_idx -= frame_end_idx; + } /* ...for(rd_idx = 0... */ + + /* Prevent buffer overflow */ + if ((sizeof(serial_buff) - wr_idx) < LGW_GPS_MIN_MSG_SIZE) { + memcpy(serial_buff,&serial_buff[LGW_GPS_MIN_MSG_SIZE],wr_idx - LGW_GPS_MIN_MSG_SIZE); + wr_idx -= LGW_GPS_MIN_MSG_SIZE; + } + } + + /* clean up before leaving */ + if (exit_sig == 1) { + lgw_gps_disable(gps_tty_dev); + lgw_stop(); + } + + /* Board reset */ + if (system("./reset_lgw.sh stop") != 0) { + printf("ERROR: failed to reset SX1302, check your reset_lgw.sh script\n"); + exit(EXIT_FAILURE); + } + + printf("\nEnd of test for loragw_gps.c\n"); + exit(EXIT_SUCCESS); +} + +/* --- EOF ------------------------------------------------------------------ */ diff --git a/lora/rak7243/Makefile b/lora/rak7243/Makefile new file mode 100755 index 0000000..618dfab --- /dev/null +++ b/lora/rak7243/Makefile @@ -0,0 +1,94 @@ +### get external defined data + +LIBLORAGW_VERSION := `cat ../VERSION` +include library.cfg + +### constant symbols + +ARCH ?= +CROSS_COMPILE ?= +CC := $(CROSS_COMPILE)gcc +AR := $(CROSS_COMPILE)ar + +CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I. + +OBJDIR = obj +INCLUDES = $(wildcard inc/*.h) + +### linking options + +LIBS := -lloragw -lrt -lm + +### general build targets + +all: libloragw.a test_loragw_spi test_loragw_reg test_loragw_hal test_loragw_gps test_loragw_gps_i2c test_loragw_cal + +clean: + rm -f libloragw.a + rm -f test_loragw_* + rm -f $(OBJDIR)/*.o + rm -f inc/config.h + +### transpose library.cfg into a C header file : config.h + +inc/config.h: ../VERSION library.cfg + @echo "*** Checking libloragw library configuration ***" + @rm -f $@ + #File initialization + @echo "#ifndef _LORAGW_CONFIGURATION_H" >> $@ + @echo "#define _LORAGW_CONFIGURATION_H" >> $@ + # Release version + @echo "Release version : $(LIBLORAGW_VERSION)" + @echo " #define LIBLORAGW_VERSION "\"$(LIBLORAGW_VERSION)\""" >> $@ + # Debug options + @echo " #define DEBUG_AUX $(DEBUG_AUX)" >> $@ + @echo " #define DEBUG_SPI $(DEBUG_SPI)" >> $@ + @echo " #define DEBUG_REG $(DEBUG_REG)" >> $@ + @echo " #define DEBUG_HAL $(DEBUG_HAL)" >> $@ + @echo " #define DEBUG_GPS $(DEBUG_GPS)" >> $@ + @echo " #define DEBUG_GPIO $(DEBUG_GPIO)" >> $@ + @echo " #define DEBUG_LBT $(DEBUG_LBT)" >> $@ + # end of file + @echo "#endif" >> $@ + @echo "*** Configuration seems ok ***" + +### library module target + +$(OBJDIR): + mkdir -p $(OBJDIR) + +$(OBJDIR)/%.o: src/%.c $(INCLUDES) inc/config.h | $(OBJDIR) + $(CC) -c $(CFLAGS) $< -o $@ + +$(OBJDIR)/loragw_spi.o: src/loragw_spi.native.c $(INCLUDES) inc/config.h | $(OBJDIR) + $(CC) -c $(CFLAGS) $< -o $@ + +$(OBJDIR)/loragw_hal.o: src/loragw_hal.c $(INCLUDES) src/arb_fw.var src/agc_fw.var src/cal_fw.var inc/config.h | $(OBJDIR) + $(CC) -c $(CFLAGS) $< -o $@ + +### static library + +libloragw.a: $(OBJDIR)/loragw_hal.o $(OBJDIR)/loragw_gps.o $(OBJDIR)/loragw_reg.o $(OBJDIR)/loragw_spi.o $(OBJDIR)/loragw_aux.o $(OBJDIR)/loragw_radio.o $(OBJDIR)/loragw_fpga.o $(OBJDIR)/loragw_lbt.o + $(AR) rcs $@ $^ + +### test programs + +test_loragw_spi: tst/test_loragw_spi.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +test_loragw_reg: tst/test_loragw_reg.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +test_loragw_hal: tst/test_loragw_hal.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +test_loragw_gps: tst/test_loragw_gps.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +test_loragw_gps_i2c: tst/test_loragw_gps_i2c.c libloragw.a + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +test_loragw_cal: tst/test_loragw_cal.c libloragw.a src/cal_fw.var + $(CC) $(CFLAGS) -L. $< -o $@ $(LIBS) + +### EOF diff --git a/lora/rak7243/global_conf/global_conf.as_920_923.json b/lora/rak7243/global_conf_i2c/global_conf.as_920_923.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak7243/global_conf/global_conf.as_920_923.json rename to lora/rak7243/global_conf_i2c/global_conf.as_920_923.json index 1777139..0e7adde --- a/lora/rak7243/global_conf/global_conf.as_920_923.json +++ b/lora/rak7243/global_conf_i2c/global_conf.as_920_923.json @@ -12,14 +12,15 @@ "push_timeout_ms":100, "fake_gps":false, "autoquit_threshold":30, - "gps_tty_path":"/dev/i2c-1", - "beacon_freq_hz":923400000, - "beacon_freq_nb":1, - "beacon_freq_step":600000, - "beacon_datarate":9, - "beacon_bw_hz":125000, - "beacon_power":20, - "beacon_period":0 + "gps_tty_path":"/dev/i2c", + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + }, "SX1301_conf": { diff --git a/lora/rak7243/global_conf/global_conf.as_923_925.json b/lora/rak7243/global_conf_i2c/global_conf.as_923_925.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak7243/global_conf/global_conf.as_923_925.json rename to lora/rak7243/global_conf_i2c/global_conf.as_923_925.json index 3c93b87..1d3fea8 --- a/lora/rak7243/global_conf/global_conf.as_923_925.json +++ b/lora/rak7243/global_conf_i2c/global_conf.as_923_925.json @@ -218,7 +218,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.au_915_928.json b/lora/rak7243/global_conf_i2c/global_conf.au_915_928.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak7243/global_conf/global_conf.au_915_928.json rename to lora/rak7243/global_conf_i2c/global_conf.au_915_928.json index 4d68252..ae3027d --- a/lora/rak7243/global_conf/global_conf.au_915_928.json +++ b/lora/rak7243/global_conf_i2c/global_conf.au_915_928.json @@ -214,7 +214,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.cn_470_510.json b/lora/rak7243/global_conf_i2c/global_conf.cn_470_510.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak7243/global_conf/global_conf.cn_470_510.json rename to lora/rak7243/global_conf_i2c/global_conf.cn_470_510.json index 046745c..4962ae1 --- a/lora/rak7243/global_conf/global_conf.cn_470_510.json +++ b/lora/rak7243/global_conf_i2c/global_conf.cn_470_510.json @@ -210,7 +210,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 508300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 200000, + "beacon_datarate": 10, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.eu_433.json b/lora/rak7243/global_conf_i2c/global_conf.eu_433.json old mode 100644 new mode 100755 similarity index 96% rename from lora/rak7243/global_conf/global_conf.eu_433.json rename to lora/rak7243/global_conf_i2c/global_conf.eu_433.json index 6cfc744..8e7069f --- a/lora/rak7243/global_conf/global_conf.eu_433.json +++ b/lora/rak7243/global_conf_i2c/global_conf.eu_433.json @@ -217,7 +217,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 434665000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.eu_863_870.json b/lora/rak7243/global_conf_i2c/global_conf.eu_863_870.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak7243/global_conf/global_conf.eu_863_870.json rename to lora/rak7243/global_conf_i2c/global_conf.eu_863_870.json index c0884bf..7b94e94 --- a/lora/rak7243/global_conf/global_conf.eu_863_870.json +++ b/lora/rak7243/global_conf_i2c/global_conf.eu_863_870.json @@ -194,6 +194,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.in_865_867.json b/lora/rak7243/global_conf_i2c/global_conf.in_865_867.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak7243/global_conf/global_conf.in_865_867.json rename to lora/rak7243/global_conf_i2c/global_conf.in_865_867.json index 1b5f334..75bf406 --- a/lora/rak7243/global_conf/global_conf.in_865_867.json +++ b/lora/rak7243/global_conf_i2c/global_conf.in_865_867.json @@ -189,7 +189,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.kr_920_923.json b/lora/rak7243/global_conf_i2c/global_conf.kr_920_923.json old mode 100644 new mode 100755 similarity index 94% rename from lora/rak7243/global_conf/global_conf.kr_920_923.json rename to lora/rak7243/global_conf_i2c/global_conf.kr_920_923.json index 73c4c3b..a9394dc --- a/lora/rak7243/global_conf/global_conf.kr_920_923.json +++ b/lora/rak7243/global_conf_i2c/global_conf.kr_920_923.json @@ -208,7 +208,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.ru_864_870.json b/lora/rak7243/global_conf_i2c/global_conf.ru_864_870.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak7243/global_conf/global_conf.ru_864_870.json rename to lora/rak7243/global_conf_i2c/global_conf.ru_864_870.json index e2d78ec..b97c072 --- a/lora/rak7243/global_conf/global_conf.ru_864_870.json +++ b/lora/rak7243/global_conf_i2c/global_conf.ru_864_870.json @@ -196,7 +196,14 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf/global_conf.us_902_928.json b/lora/rak7243/global_conf_i2c/global_conf.us_902_928.json old mode 100644 new mode 100755 similarity index 95% rename from lora/rak7243/global_conf/global_conf.us_902_928.json rename to lora/rak7243/global_conf_i2c/global_conf.us_902_928.json index 085d76a..fb02e67 --- a/lora/rak7243/global_conf/global_conf.us_902_928.json +++ b/lora/rak7243/global_conf_i2c/global_conf.us_902_928.json @@ -206,6 +206,13 @@ "ref_latitude": 10, "ref_longitude": 20, "ref_altitude": -1, - "autoquit_threshold": 20 + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 } } diff --git a/lora/rak7243/global_conf_uart/global_conf.as_920_923.json b/lora/rak7243/global_conf_uart/global_conf.as_920_923.json new file mode 100755 index 0000000..e89b4b0 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.as_920_923.json @@ -0,0 +1,197 @@ +{ + "gateway_conf":{ + "gateway_ID":"0000000000000000", + "server_address":"router.as2.thethings.network", + "serv_port_up":1700, + "serv_port_down":1700, + "forward_crc_disabled":false, + "forward_crc_error":false, + "forward_crc_valid":true, + "keepalive_interval":10, + "stat_interval":30, + "push_timeout_ms":100, + "fake_gps":false, + "autoquit_threshold":30, + "gps_tty_path":"/dev/ttyAMA0", + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + + }, + "SX1301_conf": + { + "lorawan_public":true, + "clksrc":1, + "antenna_gain":0, + "radio_0":{ + "enable":true, + "type":"SX1257", + "freq":923000000, + "rssi_offset":-166, + "tx_enable":true, + "tx_freq_min":921800000, + "tx_freq_max":923600000 + }, + "radio_1":{ + "enable":true, + "type":"SX1257", + "freq":922000000, + "rssi_offset":-166, + "tx_enable":false + }, + "chan_multiSF_0":{ + "enable":true, + "radio":0, + "if":200000 + }, + "chan_multiSF_1":{ + "enable":true, + "radio":0, + "if":400000 + }, + "chan_multiSF_2":{ + "enable":true, + "radio":1, + "if":200000 + }, + "chan_multiSF_3":{ + "enable":true, + "radio":1, + "if":400000 + }, + "chan_multiSF_4":{ + "enable":true, + "radio":0, + "if":-400000 + }, + "chan_multiSF_5":{ + "enable":true, + "radio":0, + "if":-200000 + }, + "chan_multiSF_6":{ + "enable":true, + "radio":1, + "if":0 + }, + "chan_multiSF_7":{ + "enable":true, + "radio":0, + "if":0 + }, + "chan_Lora_std":{ + "enable":true, + "radio":1, + "if":100000, + "bandwidth":250000, + "spread_factor":7 + }, + "chan_FSK":{ + "enable":true, + "radio":1, + "if":-200000, + "bandwidth":125000, + "datarate":50000 + }, + "tx_lut_0":{ + "pa_gain":0, + "mix_gain":9, + "rf_power":-6, + "dig_gain":0 + }, + "tx_lut_1":{ + "pa_gain":0, + "mix_gain":11, + "rf_power":-3, + "dig_gain":0 + }, + "tx_lut_2":{ + "pa_gain":0, + "mix_gain":15, + "rf_power":0, + "dig_gain":0 + }, + "tx_lut_3":{ + "pa_gain":1, + "mix_gain":8, + "rf_power":3, + "dig_gain":0 + }, + "tx_lut_4":{ + "pa_gain":1, + "mix_gain":10, + "rf_power":6, + "dig_gain":0 + }, + "tx_lut_5":{ + "pa_gain":1, + "mix_gain":13, + "rf_power":10, + "dig_gain": 1 + }, + "tx_lut_6":{ + "pa_gain":1, + "mix_gain":14, + "rf_power":11, + "dig_gain":0 + }, + "tx_lut_7":{ + "pa_gain":2, + "mix_gain":10, + "rf_power":12, + "dig_gain":0 + }, + "tx_lut_8":{ + "pa_gain":2, + "mix_gain":10, + "rf_power":13, + "dig_gain":0 + }, + "tx_lut_9":{ + "pa_gain":2, + "mix_gain":11, + "rf_power":14, + "dig_gain": 1 + }, + "tx_lut_10":{ + "pa_gain":2, + "mix_gain": 12, + "rf_power":16, + "dig_gain":0 + }, + "tx_lut_11":{ + "pa_gain":3, + "mix_gain":9, + "rf_power":20, + "dig_gain": 1 + }, + "tx_lut_12":{ + "pa_gain":3, + "mix_gain":11, + "rf_power":23, + "dig_gain": 1 + }, + "tx_lut_13":{ + "pa_gain":3, + "mix_gain":12, + "rf_power":25, + "dig_gain": 1 + }, + "tx_lut_14":{ + "pa_gain":3, + "mix_gain":13, + "rf_power":26, + "dig_gain": 1 + }, + "tx_lut_15":{ + "pa_gain":3, + "mix_gain":13, + "rf_power":27, + "dig_gain":0 + } + } +} diff --git a/lora/rak7243/global_conf_uart/global_conf.as_923_925.json b/lora/rak7243/global_conf_uart/global_conf.as_923_925.json new file mode 100755 index 0000000..cedd1f2 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.as_923_925.json @@ -0,0 +1,231 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 923600000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 923200000, + "tx_freq_max": 925000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 924600000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 923.2 MHz", + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 923.4 MHz", + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 923.6 MHz", + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_3": { + "desc": "Lora MAC, 125kHz, all SF, 923.8 MHz", + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_4": { + "desc": "Lora MAC, 125kHz, all SF, 924.0 MHz", + "enable": true, + "radio": 0, + "if": 400000 + }, + "chan_multiSF_5": { + "desc": "Lora MAC, 125kHz, all SF, 924.2 MHz", + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_6": { + "desc": "Lora MAC, 125kHz, all SF, 924.4 MHz", + "enable": true, + "radio": 1, + "if": -200000 + }, + "chan_multiSF_7": { + "desc": "Lora MAC, 125kHz, all SF, 924.6 MHz", + "enable": true, + "radio": 1, + "if": 0 + }, + "chan_Lora_std": { + "desc": "Lora MAC, 250kHz, SF7, 924.5 MHz", + "enable": true, + "radio": 1, + "if": -100000, + "bandwidth": 250000, + "spread_factor": 7 + }, + "chan_FSK": { + "desc": "FSK 50kbps, 924.8 MHz", + "enable": true, + "radio": 1, + "if": 200000, + "bandwidth": 125000, + "datarate": 50000 + }, + "tx_lut_0": { + "desc": "TX gain table, index 0", + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "desc": "TX gain table, index 1", + "pa_gain": 0, + "mix_gain": 11, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "desc": "TX gain table, index 2", + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "desc": "TX gain table, index 3", + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 0 + }, + "tx_lut_4": { + "desc": "TX gain table, index 4", + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "desc": "TX gain table, index 5", + "pa_gain": 1, + "mix_gain": 13, + "rf_power": 10, + "dig_gain": 1 + }, + "tx_lut_6": { + "desc": "TX gain table, index 6", + "pa_gain": 1, + "mix_gain": 14, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "desc": "TX gain table, index 7", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "desc": "TX gain table, index 8", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "desc": "TX gain table, index 9", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 1 + }, + "tx_lut_10": { + "desc": "TX gain table, index 10", + "pa_gain": 2, + "mix_gain": 12, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "desc": "TX gain table, index 11", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 1 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 25, + "dig_gain": 1 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 1 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.as2.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923400000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } + +} diff --git a/lora/rak7243/global_conf_uart/global_conf.au_915_928.json b/lora/rak7243/global_conf_uart/global_conf.au_915_928.json new file mode 100755 index 0000000..b8458ae --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.au_915_928.json @@ -0,0 +1,228 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 917200000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 915000000, + "tx_freq_max": 928000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 917900000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 916.8 MHz", + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 917.0 MHz", + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 917.2 MHz", + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_3": { + "desc": "Lora MAC, 125kHz, all SF, 917.4 MHz", + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_4": { + "desc": "Lora MAC, 125kHz, all SF, 917.6 MHz", + "enable": true, + "radio": 1, + "if": -300000 + }, + "chan_multiSF_5": { + "desc": "Lora MAC, 125kHz, all SF, 917.8 MHz", + "enable": true, + "radio": 1, + "if": -100000 + }, + "chan_multiSF_6": { + "desc": "Lora MAC, 125kHz, all SF, 918.0 MHz", + "enable": true, + "radio": 1, + "if": 100000 + }, + "chan_multiSF_7": { + "desc": "Lora MAC, 125kHz, all SF, 918.2 MHz", + "enable": true, + "radio": 1, + "if": 300000 + }, + "chan_Lora_std": { + "desc": "Lora MAC, 500kHz, SF8, 917.5 MHz", + "enable": true, + "radio": 0, + "if": 300000, + "bandwidth": 500000, + "spread_factor": 8 + }, + "chan_FSK": { + "desc": "disabled", + "enable": false + }, + "tx_lut_0": { + "desc": "TX gain table, index 0", + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "desc": "TX gain table, index 1", + "pa_gain": 0, + "mix_gain": 11, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "desc": "TX gain table, index 2", + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "desc": "TX gain table, index 3", + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 0 + }, + "tx_lut_4": { + "desc": "TX gain table, index 4", + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "desc": "TX gain table, index 5", + "pa_gain": 1, + "mix_gain": 13, + "rf_power": 10, + "dig_gain": 1 + }, + "tx_lut_6": { + "desc": "TX gain table, index 6", + "pa_gain": 1, + "mix_gain": 14, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "desc": "TX gain table, index 7", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "desc": "TX gain table, index 8", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "desc": "TX gain table, index 9", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 1 + }, + "tx_lut_10": { + "desc": "TX gain table, index 10", + "pa_gain": 2, + "mix_gain": 12, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "desc": "TX gain table, index 11", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 1 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 25, + "dig_gain": 1 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 1 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.au.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 + } + +} + diff --git a/lora/rak7243/global_conf_uart/global_conf.cn_470_510.json b/lora/rak7243/global_conf_uart/global_conf.cn_470_510.json new file mode 100755 index 0000000..5c125b5 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.cn_470_510.json @@ -0,0 +1,223 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1255", + "freq": 486600000, + "rssi_offset": -176.0, + "tx_enable": true, + "tx_freq_min": 470000000, + "tx_freq_max": 510000000 + }, + "radio_1": { + "enable": true, + "type": "SX1255", + "freq": 487400000, + "rssi_offset": -176.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 487.1 MHz", + "enable": true, + "radio": 1, + "if": -300000 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 487.3 MHz", + "enable": true, + "radio": 1, + "if": -100000 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 487.5 MHz", + "enable": true, + "radio": 1, + "if": 100000 + }, + "chan_multiSF_3": { + "desc": "Lora MAC, 125kHz, all SF, 487.7 MHz", + "enable": true, + "radio": 1, + "if": 300000 + }, + "chan_multiSF_4": { + "desc": "Lora MAC, 125kHz, all SF, 486.3 MHz", + "enable": true, + "radio": 0, + "if": -300000 + }, + "chan_multiSF_5": { + "desc": "Lora MAC, 125kHz, all SF, 486.5 MHz", + "enable": true, + "radio": 0, + "if": -100000 + }, + "chan_multiSF_6": { + "desc": "Lora MAC, 125kHz, all SF, 486.7 MHz", + "enable": true, + "radio": 0, + "if": 100000 + }, + "chan_multiSF_7": { + "desc": "Lora MAC, 125kHz, all SF, 486.9 MHz", + "enable": true, + "radio": 0, + "if": 300000 + }, + "chan_Lora_std": { + "desc": "disabled", + "enable": false + }, + "chan_FSK": { + "desc": "disabled", + "enable": false + }, + "tx_lut_0": { + "desc": "TX gain table, index 0", + "pa_gain": 0, + "mix_gain": 8, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "desc": "TX gain table, index 1", + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "desc": "TX gain table, index 2", + "pa_gain": 0, + "mix_gain": 13, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "desc": "TX gain table, index 3", + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 1 + }, + "tx_lut_4": { + "desc": "TX gain table, index 4", + "pa_gain": 1, + "mix_gain": 9, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "desc": "TX gain table, index 5", + "pa_gain": 2, + "mix_gain": 8, + "rf_power": 10, + "dig_gain": 1 + }, + "tx_lut_6": { + "desc": "TX gain table, index 6", + "pa_gain": 2, + "mix_gain": 8, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "desc": "TX gain table, index 7", + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 12, + "dig_gain": 1 + }, + "tx_lut_8": { + "desc": "TX gain table, index 8", + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "desc": "TX gain table, index 9", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 2 + }, + "tx_lut_10": { + "desc": "TX gain table, index 10", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "desc": "TX gain table, index 11", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 23, + "dig_gain": 0 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 15, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 15, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 15, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.cn.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 508300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 200000, + "beacon_datarate": 10, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } +} + diff --git a/lora/rak7243/global_conf_uart/global_conf.eu_433.json b/lora/rak7243/global_conf_uart/global_conf.eu_433.json new file mode 100755 index 0000000..240e7c1 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.eu_433.json @@ -0,0 +1,230 @@ +{ + + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, /* radio_1 provides clock to concentrator */ + "antenna_gain": 0, /* antenna gain, in dBi */ + "radio_0": { + "enable": true, + "type": "SX1255", + "freq": 434375000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 433050000, + "tx_freq_max": 434900000 + }, + "radio_1": { + "enable": true, + "type": "SX1255", + "freq": 433575000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + /* Lora MAC channel, 125kHz, all SF, 433.175 MHz */ + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_1": { + /* Lora MAC channel, 125kHz, all SF, 433.375 MHz */ + "enable": true, + "radio": 1, + "if": -200000 + }, + "chan_multiSF_2": { + /* Lora MAC channel, 125kHz, all SF, 433.575 MHz */ + "enable": true, + "radio": 1, + "if": 0 + }, + "chan_multiSF_3": { + /* Lora MAC channel, 125kHz, all SF, 433.775 MHz */ + "enable": true, + "radio": 1, + "if": 200000 + }, + "chan_multiSF_4": { + /* Lora MAC channel, 125kHz, all SF, 433.975 MHz */ + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_5": { + /* Lora MAC channel, 125kHz, all SF, 434.175 MHz */ + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_6": { + /* Lora MAC channel, 125kHz, all SF, 434.375 MHz */ + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_7": { + /* Lora MAC channel, 125kHz, all SF, 434.575 MHz */ + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_Lora_std": { + /* Lora MAC channel, 250kHz, SF7, 434.175 MHz */ + "enable": true, + "radio": 1, + "if": -200000, + "bandwidth": 250000, + "spread_factor": 7 + }, + "chan_FSK": { + /* FSK 50kbps channel, 434.675 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": 1 + }, + "tx_lut_4": { + /* TX gain table, index 4 */ + "pa_gain": 1, + "mix_gain": 9, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + /* TX gain table, index 5 */ + "pa_gain": 2, + "mix_gain": 8, + "rf_power": 10, + "dig_gain": 2 + }, + "tx_lut_6": { + /* TX gain table, index 6 */ + "pa_gain": 2, + "mix_gain": 8, + "rf_power": 11, + "dig_gain": 1 + }, + "tx_lut_7": { + /* TX gain table, index 7 */ + "pa_gain": 2, + "mix_gain": 8, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + /* TX gain table, index 8 */ + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 13, + "dig_gain": 1 + }, + "tx_lut_9": { + /* TX gain table, index 9 */ + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 14, + "dig_gain": 0 + }, + "tx_lut_10": { + /* TX gain table, index 10 */ + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + /* TX gain table, index 11 */ + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 23, + "dig_gain": 0 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 10, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 10, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 10, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.eu.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 434665000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } +} + diff --git a/lora/rak7243/global_conf_uart/global_conf.eu_863_870.json b/lora/rak7243/global_conf_uart/global_conf.eu_863_870.json new file mode 100755 index 0000000..9666023 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.eu_863_870.json @@ -0,0 +1,206 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "antenna_gain": 0, + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 867500000, + "rssi_offset": -166.0, + "tx_enable": true, + "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": { + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_1": { + "enable": true, + "radio": 1, + "if": -200000 + }, + "chan_multiSF_2": { + "enable": true, + "radio": 1, + "if": 0 + }, + "chan_multiSF_3": { + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_4": { + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_5": { + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_6": { + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_7": { + "enable": true, + "radio": 0, + "if": 400000 + }, + "chan_Lora_std": { + "enable": true, + "radio": 1, + "if": -200000, + "bandwidth": 250000, + "spread_factor": 7 + }, + "chan_FSK": { + "enable": true, + "radio": 1, + "if": 300000, + "bandwidth": 125000, + "datarate": 50000 + }, + "tx_lut_0": { + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "pa_gain": 0, + "mix_gain": 12, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 1 + }, + "tx_lut_4": { + "pa_gain": 1, + "mix_gain": 9, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "pa_gain": 1, + "mix_gain": 11, + "rf_power": 10, + "dig_gain": 0 + }, + "tx_lut_6": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 11, + "dig_gain": 1 + }, + "tx_lut_7": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 13, + "dig_gain": 1 + }, + "tx_lut_9": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 0 + }, + "tx_lut_10": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 16, + "dig_gain": 1 + }, + "tx_lut_11": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.eu.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869525000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } +} diff --git a/lora/rak7243/global_conf_uart/global_conf.in_865_867.json b/lora/rak7243/global_conf_uart/global_conf.in_865_867.json new file mode 100755 index 0000000..0149ab6 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.in_865_867.json @@ -0,0 +1,203 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 865200000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 865000000, + "tx_freq_max": 867000000, + "tx_notch_freq": 129000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 866385000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 865.0625 MHz", + "enable": true, + "radio": 0, + "if": -137500 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 865.4025 MHz", + "enable": true, + "radio": 0, + "if": 202500 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 865.9850 MHz", + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_3": { + "desc": "disabled", + "enable": false + }, + "chan_multiSF_4": { + "desc": "disabled", + "enable": false + }, + "chan_multiSF_5": { + "desc": "disabled", + "enable": false + }, + "chan_multiSF_6": { + "desc": "disabled", + "enable": false + }, + "chan_multiSF_7": { + "desc": "disabled", + "enable": false + }, + "chan_Lora_std": { + "desc": "disabled", + "enable": false + }, + "chan_FSK": { + "desc": "disabled", + "enable": false + }, + "tx_lut_0": { + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "pa_gain": 0, + "mix_gain": 12, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 1 + }, + "tx_lut_4": { + "pa_gain": 1, + "mix_gain": 9, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "pa_gain": 1, + "mix_gain": 11, + "rf_power": 10, + "dig_gain": 0 + }, + "tx_lut_6": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 11, + "dig_gain": 1 + }, + "tx_lut_7": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 13, + "dig_gain": 1 + }, + "tx_lut_9": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 0 + }, + "tx_lut_10": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 16, + "dig_gain": 1 + }, + "tx_lut_11": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.as.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 866500000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 8, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } + +} + diff --git a/lora/rak7243/global_conf_uart/global_conf.kr_920_923.json b/lora/rak7243/global_conf_uart/global_conf.kr_920_923.json new file mode 100755 index 0000000..c0ab8cf --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.kr_920_923.json @@ -0,0 +1,223 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 922400000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 920900000, + "tx_freq_max": 923300000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 923000000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 922.1 MHz", + "enable": true, + "radio": 0, + "if": -300000 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 922.3 MHz", + "enable": true, + "radio": 0, + "if": -100000 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 922.5 MHz", + "enable": true, + "radio": 0, + "if": 100000 + }, + "chan_multiSF_3": { + "desc": "Lora MAC, 125kHz, all SF, 922.7 MHz", + "enable": true, + "radio": 0, + "if": 300000 + }, + "chan_multiSF_4": { + "desc": "Lora MAC, 125kHz, all SF, 922.9 MHz", + "enable": true, + "radio": 1, + "if": -100000 + }, + "chan_multiSF_5": { + "desc": "Lora MAC, 125kHz, all SF, 923.1 MHz", + "enable": true, + "radio": 1, + "if": 100000 + }, + "chan_multiSF_6": { + "desc": "Lora MAC, 125kHz, all SF, 923.3 MHz", + "enable": true, + "radio": 1, + "if": 300000 + }, + "chan_multiSF_7": { + "desc": "disabled", + "enable": false + }, + "chan_Lora_std": { + "desc": "disabled", + "enable": false + }, + "chan_FSK": { + "desc": "disabled", + "enable": false + }, + "tx_lut_0": { + "desc": "TX gain table, index 0", + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "desc": "TX gain table, index 1", + "pa_gain": 0, + "mix_gain": 11, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "desc": "TX gain table, index 2", + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "desc": "TX gain table, index 3", + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 0 + }, + "tx_lut_4": { + "desc": "TX gain table, index 4", + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "desc": "TX gain table, index 5", + "pa_gain": 1, + "mix_gain": 13, + "rf_power": 10, + "dig_gain": 1 + }, + "tx_lut_6": { + "desc": "TX gain table, index 6", + "pa_gain": 1, + "mix_gain": 14, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "desc": "TX gain table, index 7", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "desc": "TX gain table, index 8", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "desc": "TX gain table, index 9", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 1 + }, + "tx_lut_10": { + "desc": "TX gain table, index 10", + "pa_gain": 2, + "mix_gain": 12, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "desc": "TX gain table, index 11", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 1 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 25, + "dig_gain": 1 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 1 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.kr.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } + +} + + diff --git a/lora/rak7243/global_conf_uart/global_conf.ru_864_870.json b/lora/rak7243/global_conf_uart/global_conf.ru_864_870.json new file mode 100755 index 0000000..e9b90a5 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.ru_864_870.json @@ -0,0 +1,210 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "clksrc_desc": "radio_1 provides clock to concentrator for most devices except MultiTech. For MultiTech set to 0.", + "antenna_gain": 0, + "antenna_gain_desc": "antenna gain, in dBi", + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 864500000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 863000000, + "tx_freq_max": 870000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 869000000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "desc": "Lora MAC, 125kHz, all SF, 864.1 MHz", + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_1": { + "desc": "Lora MAC, 125kHz, all SF, 864.3 MHz", + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_2": { + "desc": "Lora MAC, 125kHz, all SF, 864.5 MHz", + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_3": { + "desc": "Lora MAC, 125kHz, all SF, 864.7 MHz", + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_4": { + "desc": "Lora MAC, 125kHz, all SF, 864.9 MHz", + "enable": true, + "radio": 0, + "if": 400000 + }, + "chan_multiSF_5": { + "desc": "Lora MAC, 125kHz, all SF, 868.9 MHz", + "enable": true, + "radio": 1, + "if": -100000 + }, + "chan_multiSF_6": { + "desc": "Lora MAC, 125kHz, all SF, 869.1 MHz", + "enable": true, + "radio": 1, + "if": 100000 + }, + "chan_multiSF_7": { + "desc": "disabled", + "enable": false + }, + "chan_Lora_std": { + "desc": "disabled", + "enable": false + }, + "chan_FSK": { + "desc": "disabled", + "enable": false + }, + "tx_lut_0": { + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "pa_gain": 0, + "mix_gain": 12, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 1 + }, + "tx_lut_4": { + "pa_gain": 1, + "mix_gain": 9, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "pa_gain": 1, + "mix_gain": 11, + "rf_power": 10, + "dig_gain": 0 + }, + "tx_lut_6": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 11, + "dig_gain": 1 + }, + "tx_lut_7": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 13, + "dig_gain": 1 + }, + "tx_lut_9": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 0 + }, + "tx_lut_10": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 16, + "dig_gain": 1 + }, + "tx_lut_11": { + "pa_gain": 3, + "mix_gain": 8, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.ru.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 869100000, + "beacon_freq_nb": 1, + "beacon_freq_step": 0, + "beacon_datarate": 9, + "beacon_bw_hz": 125000, + "beacon_power": 27 + } + +} + diff --git a/lora/rak7243/global_conf_uart/global_conf.us_902_928.json b/lora/rak7243/global_conf_uart/global_conf.us_902_928.json new file mode 100755 index 0000000..c8e0993 --- /dev/null +++ b/lora/rak7243/global_conf_uart/global_conf.us_902_928.json @@ -0,0 +1,218 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "antenna_gain": 0, + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 904300000, + "rssi_offset": -166.0, + "tx_enable": true, + "tx_freq_min": 902000000, + "tx_freq_max": 928000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 905000000, + "rssi_offset": -166.0, + "tx_enable": false + }, + "chan_multiSF_0": { + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_1": { + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_2": { + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_3": { + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_4": { + "enable": true, + "radio": 1, + "if": -300000 + }, + "chan_multiSF_5": { + "enable": true, + "radio": 1, + "if": -100000 + }, + "chan_multiSF_6": { + "enable": true, + "radio": 1, + "if": 100000 + }, + "chan_multiSF_7": { + "enable": true, + "radio": 1, + "if": 300000 + }, + "chan_Lora_std": { + "enable": true, + "radio": 0, + "if": 300000, + "bandwidth": 500000, + "spread_factor": 8 + }, + "chan_FSK": { + "enable": false, + "radio": 0, + "if": 300000, + "bandwidth": 250000, + "datarate": 100000 + }, + "tx_lut_0": { + "desc": "TX gain table, index 0", + "pa_gain": 0, + "mix_gain": 9, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "desc": "TX gain table, index 1", + "pa_gain": 0, + "mix_gain": 11, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "desc": "TX gain table, index 2", + "pa_gain": 0, + "mix_gain": 15, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "desc": "TX gain table, index 3", + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 0 + }, + "tx_lut_4": { + "desc": "TX gain table, index 4", + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "desc": "TX gain table, index 5", + "pa_gain": 1, + "mix_gain": 13, + "rf_power": 10, + "dig_gain": 1 + }, + "tx_lut_6": { + "desc": "TX gain table, index 6", + "pa_gain": 1, + "mix_gain": 14, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "desc": "TX gain table, index 7", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "desc": "TX gain table, index 8", + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "desc": "TX gain table, index 9", + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 14, + "dig_gain": 1 + }, + "tx_lut_10": { + "desc": "TX gain table, index 10", + "pa_gain": 2, + "mix_gain": 12, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "desc": "TX gain table, index 11", + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 1 + }, + "tx_lut_12": { + "desc": "TX gain table, index 12", + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 23, + "dig_gain": 1 + }, + "tx_lut_13": { + "desc": "TX gain table, index 13", + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 25, + "dig_gain": 1 + }, + "tx_lut_14": { + "desc": "TX gain table, index 14", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 26, + "dig_gain": 1 + }, + "tx_lut_15": { + "desc": "TX gain table, index 15", + "pa_gain": 3, + "mix_gain": 13, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "0000000000000000", + /* change with default server address/ports, or overwrite in local_conf.json */ + "server_address": "router.us.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + /* 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, + /* gps enable */ + "gps_tty_path": "/dev/ttyAMA0", + "fake_gps": false, + "ref_latitude": 10, + "ref_longitude": 20, + "ref_altitude": -1, + "autoquit_threshold": 20, + "beacon_period": 0, /* disable class B beacon */ + "beacon_freq_hz": 923300000, + "beacon_freq_nb": 8, + "beacon_freq_step": 600000, + "beacon_datarate": 12, + "beacon_bw_hz": 500000, + "beacon_power": 27 + } +} diff --git a/lora/rak7243/install.sh b/lora/rak7243/install.sh index 413209c..b222c80 100755 --- a/lora/rak7243/install.sh +++ b/lora/rak7243/install.sh @@ -33,7 +33,13 @@ pushd lora_gateway cp $SCRIPT_DIR/library.cfg ./libloragw/library.cfg cp $SCRIPT_DIR/loragw_gps.c ./libloragw/src/loragw_gps.c cp $SCRIPT_DIR/loragw_spi.native.c ./libloragw/src/loragw_spi.native.c -cp $SCRIPT_DIR/test_loragw_gps.c ./libloragw/tst/test_loragw_gps.c +cp $SCRIPT_DIR/test_loragw_gps_uart.c ./libloragw/tst/test_loragw_gps.c +cp $SCRIPT_DIR/test_loragw_gps_i2c.c ./libloragw/tst/test_loragw_gps_i2c.c +cp $SCRIPT_DIR/Makefile ./libloragw/Makefile +cp $SCRIPT_DIR/../print_lora_log.sh util_pkt_logger/ +if [ -f $SCRIPT_DIR/../../lte/lte_test ]; then + cp $SCRIPT_DIR/../../lte/lte_test . +fi make popd @@ -50,12 +56,17 @@ pushd packet_forwarder cp $SCRIPT_DIR/lora_pkt_fwd.c ./lora_pkt_fwd/src/lora_pkt_fwd.c make - +rm lora_pkt_fwd/obj/* -f popd -cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf -cp global_conf/global_conf.eu_863_870.json $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json +if [ -d global_conf ]; then + cp global_conf $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/ -rf + cp global_conf/global_conf.eu_863_870.json $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json + sed -i "s/^.*server_address.*$/\t\"server_address\": \"127.0.0.1\",/" $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json +else + echo "" +fi rm -f $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/local_conf.json -sed -i "s/^.*server_address.*$/\t\"server_address\": \"127.0.0.1\",/" $INSTALL_DIR/packet_forwarder/lora_pkt_fwd/global_conf.json + #cp ppp.sh /usr/local/rak/bin/ diff --git a/lora/rak7243/loragw_gps.c b/lora/rak7243/loragw_gps.c old mode 100644 new mode 100755 index b6f2bb1..6f6cb61 --- a/lora/rak7243/loragw_gps.c +++ b/lora/rak7243/loragw_gps.c @@ -249,10 +249,7 @@ int str_chop(char *s, int buff_size, char separator, int *idx_ary, int max_idx) return j; } -/* -------------------------------------------------------------------------- */ -/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */ - -int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { +static int lgw_gps_enable_i2c(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { int i; struct termios ttyopt; /* serial port options */ int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ @@ -281,8 +278,46 @@ int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int * return LGW_GPS_ERROR; } + num_written = write (gps_tty_dev, ubx_cmd_timegps, UBX_MSG_NAVTIMEGPS_LEN); + if (num_written != UBX_MSG_NAVTIMEGPS_LEN) { + DEBUG_MSG("ERROR: Failed to write on serial port (written=%d)\n", (int) num_written); + } + /* get timezone info */ + tzset(); + + /* initialize global variables */ + gps_time_ok = false; + gps_pos_ok = false; + gps_mod = 'N'; + + return LGW_GPS_SUCCESS; +} + +static int lgw_gps_enable_uart(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { + int i; + struct termios ttyopt; /* serial port options */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + uint8_t ubx_cmd_timegps[UBX_MSG_NAVTIMEGPS_LEN] = { + 0xB5, 0x62, /* UBX Sync Chars */ + 0x06, 0x01, /* CFG-MSG Class/ID */ + 0x08, 0x00, /* Payload length */ + 0x01, 0x20, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, /* Enable NAV-TIMEGPS output on serial */ + 0x32, 0x94 }; /* Checksum */ + ssize_t num_written; + + /* check input parameters */ + CHECK_NULL(tty_path); + CHECK_NULL(fd_ptr); + + /* open TTY device */ + gps_tty_dev = open(tty_path, O_RDWR | O_NOCTTY); + if (gps_tty_dev <= 0) { + DEBUG_MSG("ERROR: TTY PORT FAIL TO OPEN, CHECK PATH AND ACCESS RIGHTS\n"); + return LGW_GPS_ERROR; + } + *fd_ptr = gps_tty_dev; + /* manage the different GPS modules families */ -#if 0 if (gps_family == NULL) { DEBUG_MSG("WARNING: this version of GPS module may not be supported\n"); } else if (strncmp(gps_family, "ubx7", 4) != 0) { @@ -357,11 +392,11 @@ int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int * /* Send UBX CFG NAV-TIMEGPS message to tell GPS module to output native GPS time */ /* This is a binary message, serial port has to be properly configured to handle this */ -#endif num_written = write (gps_tty_dev, ubx_cmd_timegps, UBX_MSG_NAVTIMEGPS_LEN); if (num_written != UBX_MSG_NAVTIMEGPS_LEN) { DEBUG_MSG("ERROR: Failed to write on serial port (written=%d)\n", (int) num_written); } + /* get timezone info */ tzset(); @@ -373,6 +408,22 @@ int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int * return LGW_GPS_SUCCESS; } +/* -------------------------------------------------------------------------- */ +/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */ + +int lgw_gps_enable(char *tty_path, char *gps_family, speed_t target_brate, int *fd_ptr) { + if (strcmp("/dev/i2c-1", tty_path) == 0) + { + printf("This is i2c for GPS.\n"); + return lgw_gps_enable_i2c(tty_path, gps_family, target_brate, fd_ptr); + } + else + { + printf("This is uart for GPS.\n"); + return lgw_gps_enable_uart(tty_path, gps_family, target_brate, fd_ptr); + } +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ int lgw_gps_disable(int fd) { diff --git a/lora/rak7243/test_loragw_gps.c b/lora/rak7243/test_loragw_gps_i2c.c similarity index 100% rename from lora/rak7243/test_loragw_gps.c rename to lora/rak7243/test_loragw_gps_i2c.c diff --git a/lora/rak7243/test_loragw_gps_uart.c b/lora/rak7243/test_loragw_gps_uart.c new file mode 100755 index 0000000..a4164a3 --- /dev/null +++ b/lora/rak7243/test_loragw_gps_uart.c @@ -0,0 +1,288 @@ +/* + / _____) _ | | +( (____ _____ ____ _| |_ _____ ____| |__ + \____ \| ___ | (_ _) ___ |/ ___) _ \ + _____) ) ____| | | || |_| ____( (___| | | | +(______/|_____)_|_|_| \__)_____)\____)_| |_| + (C)2013 Semtech-Cycleo + +Description: + Minimum test program for the loragw_gps 'library' + +License: Revised BSD License, see LICENSE.TXT file include in the project +Maintainer: Michael Coracin +*/ + + +/* -------------------------------------------------------------------------- */ +/* --- DEPENDANCIES --------------------------------------------------------- */ + +/* fix an issue between POSIX and C99 */ +#if __STDC_VERSION__ >= 199901L + #define _XOPEN_SOURCE 600 +#else + #define _XOPEN_SOURCE 500 +#endif + +#include /* C99 types */ +#include /* bool type */ +#include /* printf */ +#include /* memset */ +#include /* sigaction */ +#include /* exit */ +#include /* read */ + +#include "loragw_hal.h" +#include "loragw_gps.h" +#include "loragw_aux.h" + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE VARIABLES ---------------------------------------------------- */ + +static int exit_sig = 0; /* 1 -> application terminates cleanly (shut down hardware, close open files, etc) */ +static int quit_sig = 0; /* 1 -> application terminates without shutting down the hardware */ + +struct tref ppm_ref; + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DECLARATION ---------------------------------------- */ + +static void sig_handler(int sigio); +static void gps_process_sync(void); +static void gps_process_coords(void); + +/* -------------------------------------------------------------------------- */ +/* --- PRIVATE FUNCTIONS DEFINITION ----------------------------------------- */ + +static void sig_handler(int sigio) { + if (sigio == SIGQUIT) { + quit_sig = 1;; + } else if ((sigio == SIGINT) || (sigio == SIGTERM)) { + exit_sig = 1; + } +} + +static void gps_process_sync(void) { + /* variables for PPM pulse GPS synchronization */ + uint32_t ppm_tstamp; + struct timespec ppm_gps; + struct timespec ppm_utc; + + /* variables for timestamp <-> GPS time conversions */ + uint32_t x, z; + struct timespec y; + + /* get GPS time for synchronization */ + int i = lgw_gps_get(&ppm_utc, &ppm_gps, NULL, NULL); + if (i != LGW_GPS_SUCCESS) { + printf(" No valid reference GPS time available, synchronization impossible.\n"); + return; + } + + /* get timestamp for synchronization */ + i = lgw_get_trigcnt(&ppm_tstamp); + if (i != LGW_HAL_SUCCESS) { + printf(" Failed to read timestamp, synchronization impossible.\n"); + return; + } + + /* try to update synchronize time reference with the new GPS & timestamp */ + i = lgw_gps_sync(&ppm_ref, ppm_tstamp, ppm_utc, ppm_gps); + if (i != LGW_GPS_SUCCESS) { + printf(" Synchronization error.\n"); + return; + } + + /* display result */ + printf(" * Synchronization successful *\n"); + printf(" UTC reference time: %lld.%09ld\n", (long long)ppm_ref.utc.tv_sec, ppm_ref.utc.tv_nsec); + printf(" GPS reference time: %lld.%09ld\n", (long long)ppm_ref.gps.tv_sec, ppm_ref.gps.tv_nsec); + printf(" Internal counter reference value: %u\n", ppm_ref.count_us); + printf(" Clock error: %.9f\n", ppm_ref.xtal_err); + + x = ppm_tstamp + 500000; + printf(" * Test of timestamp counter <-> GPS value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2gps(ppm_ref, x, &y); + printf(" Conversion to GPS: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_gps2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + printf(" * Test of timestamp counter <-> UTC value conversion *\n"); + printf(" Test value: %u\n", x); + lgw_cnt2utc(ppm_ref, x, &y); + printf(" Conversion to UTC: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + lgw_utc2cnt(ppm_ref, y, &z); + printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); +} + +static void gps_process_coords(void) { + /* position variable */ + struct coord_s coord; + struct coord_s gpserr; + int i = lgw_gps_get(NULL, NULL, &coord, &gpserr); + + /* update gateway coordinates */ + if (i == LGW_GPS_SUCCESS) { + printf("# GPS coordinates: latitude %.5f, longitude %.5f, altitude %i m\n", coord.lat, coord.lon, coord.alt); + printf("# GPS err: latitude %.5f, longitude %.5f, altitude %i m\n", gpserr.lat, gpserr.lon, gpserr.alt); + } +} + +/* -------------------------------------------------------------------------- */ +/* --- MAIN FUNCTION -------------------------------------------------------- */ + +int main() +{ + struct sigaction sigact; /* SIGQUIT&SIGINT&SIGTERM signal handling */ + + int i; + + /* concentrator variables */ + struct lgw_conf_board_s boardconf; + struct lgw_conf_rxrf_s rfconf; + + /* serial variables */ + char serial_buff[128]; /* buffer to receive GPS data */ + size_t wr_idx = 0; /* pointer to end of chars in buffer */ + int gps_tty_dev; /* file descriptor to the serial port of the GNSS module */ + + /* NMEA/UBX variables */ + enum gps_msg latest_msg; /* keep track of latest NMEA/UBX message parsed */ + + /* configure signal handling */ + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigact.sa_handler = sig_handler; + sigaction(SIGQUIT, &sigact, NULL); + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); + + /* Intro message and library information */ + printf("Beginning of test for loragw_gps.c\n"); + printf("*** Library version information ***\n%s\n***\n", lgw_version_info()); + + /* Open and configure GPS */ + i = lgw_gps_enable("/dev/ttyAMA0", "ubx7", 0, &gps_tty_dev); + if (i != LGW_GPS_SUCCESS) { + printf("ERROR: IMPOSSIBLE TO ENABLE GPS\n"); + exit(EXIT_FAILURE); + } + + /* start concentrator (default conf for IoT SK) */ + /* board config */ + memset(&boardconf, 0, sizeof(boardconf)); + boardconf.lorawan_public = true; + boardconf.clksrc = 1; + lgw_board_setconf(boardconf); + + /* RF config */ + memset(&rfconf, 0, sizeof(rfconf)); + rfconf.enable = true; + rfconf.freq_hz = 868000000; + rfconf.rssi_offset = 0.0; + rfconf.type = LGW_RADIO_TYPE_SX1257; + rfconf.tx_enable = true; + lgw_rxrf_setconf(0, rfconf); + + lgw_start(); + + /* initialize some variables before loop */ + memset(serial_buff, 0, sizeof serial_buff); + memset(&ppm_ref, 0, sizeof ppm_ref); + + /* loop until user action */ + while ((quit_sig != 1) && (exit_sig != 1)) { + size_t rd_idx = 0; + size_t frame_end_idx = 0; + + /* blocking non-canonical read on serial port */ + ssize_t nb_char = read(gps_tty_dev, serial_buff + wr_idx, LGW_GPS_MIN_MSG_SIZE); + if (nb_char <= 0) { + printf("WARNING: [gps] read() returned value %d\n", nb_char); + continue; + } + wr_idx += (size_t)nb_char; + + /******************************************* + * Scan buffer for UBX/NMEA sync chars and * + * attempt to decode frame if one is found * + *******************************************/ + while (rd_idx < wr_idx) { + size_t frame_size = 0; + + /* Scan buffer for UBX sync char */ + if (serial_buff[rd_idx] == LGW_GPS_UBX_SYNC_CHAR) { + + /*********************** + * Found UBX sync char * + ***********************/ + latest_msg = lgw_parse_ubx(&serial_buff[rd_idx], (wr_idx - rd_idx), &frame_size); + + if (frame_size > 0) { + if (latest_msg == INCOMPLETE) { + /* UBX header found but frame appears to be missing bytes */ + frame_size = 0; + } else if (latest_msg == INVALID) { + /* message header received but message appears to be corrupted */ + printf("WARNING: [gps] could not get a valid message from GPS (no time)\n"); + frame_size = 0; + } else if (latest_msg == UBX_NAV_TIMEGPS) { + printf("\n~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~\n"); + gps_process_sync(); + } + } + } else if(serial_buff[rd_idx] == LGW_GPS_NMEA_SYNC_CHAR) { + /************************ + * Found NMEA sync char * + ************************/ + /* scan for NMEA end marker (LF = 0x0a) */ + char* nmea_end_ptr = memchr(&serial_buff[rd_idx],(int)0x0a, (wr_idx - rd_idx)); + + if (nmea_end_ptr) { + /* found end marker */ + frame_size = nmea_end_ptr - &serial_buff[rd_idx] + 1; + latest_msg = lgw_parse_nmea(&serial_buff[rd_idx], frame_size); + + if(latest_msg == INVALID || latest_msg == UNKNOWN) { + /* checksum failed */ + frame_size = 0; + } else if (latest_msg == NMEA_RMC) { /* Get location from RMC frames */ + gps_process_coords(); + } + } + } + + if (frame_size > 0) { + /* At this point message is a checksum verified frame + we're processed or ignored. Remove frame from buffer */ + rd_idx += frame_size; + frame_end_idx = rd_idx; + } else { + rd_idx++; + } + } /* ...for(rd_idx = 0... */ + + if (frame_end_idx) { + /* Frames have been processed. Remove bytes to end of last processed frame */ + memcpy(serial_buff,&serial_buff[frame_end_idx],wr_idx - frame_end_idx); + wr_idx -= frame_end_idx; + } /* ...for(rd_idx = 0... */ + + /* Prevent buffer overflow */ + if ((sizeof(serial_buff) - wr_idx) < LGW_GPS_MIN_MSG_SIZE) { + memcpy(serial_buff,&serial_buff[LGW_GPS_MIN_MSG_SIZE],wr_idx - LGW_GPS_MIN_MSG_SIZE); + wr_idx -= LGW_GPS_MIN_MSG_SIZE; + } + } + + /* clean up before leaving */ + if (exit_sig == 1) { + lgw_gps_disable(gps_tty_dev); + lgw_stop(); + } + + printf("\nEnd of test for loragw_gps.c\n"); + exit(EXIT_SUCCESS); +} + +/* --- EOF ------------------------------------------------------------------ */ diff --git a/lte/install.sh b/lte/install.sh index 0c8ecf2..5f12bee 100755 --- a/lte/install.sh +++ b/lte/install.sh @@ -19,6 +19,8 @@ if [ "${INSTALL_LTE}" = "1" ] || [ "$1" = "create_img" ]; then cp rak-pppd.service /lib/systemd/system cp pppd.sh /usr/local/rak/bin/ cp ppp.sh /usr/local/rak/bin/ + + gcc lte_test.c -o lte_test echo_success "Install LTE module success!\n" sleep 2 diff --git a/lte/lte_test.c b/lte/lte_test.c new file mode 100755 index 0000000..82da003 --- /dev/null +++ b/lte/lte_test.c @@ -0,0 +1,176 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define FALSE 0 +#define TRUE 1 +/***@brief +*@param fd +*@param speed +*@return void*/ + +int speed_arr[] = { B115200, B38400, B19200, B9600, B4800, B2400, B1200, B300, + B115200, B38400, B19200, B9600, B4800, B2400, B1200, B300, }; +int name_arr[] = {115200, 38400, 19200, 9600, 4800, 2400, 1200, 300, + 115200, 38400, 19200, 9600, 4800, 2400, 1200, 300, }; +void set_speed(int fd, int speed) +{ + int i; + int status; + struct termios Opt; + tcgetattr(fd, &Opt); + for ( i= 0; i < sizeof(speed_arr) / sizeof(int); i++) + { + if (speed == name_arr[i]) + { + tcflush(fd, TCIOFLUSH); + cfsetispeed(&Opt, speed_arr[i]); + cfsetospeed(&Opt, speed_arr[i]); + status = tcsetattr(fd, TCSANOW, &Opt); + if (status != 0) + perror("tcsetattr fd1"); + return; + } + tcflush(fd,TCIOFLUSH); + } +} + +int set_Parity(int fd,int databits,int stopbits,int parity) +{ + struct termios options; + if ( tcgetattr( fd,&options) != 0) + { + perror("SetupSerial 1"); + return(FALSE); + } + options.c_cflag &= ~CSIZE; + switch (databits) + { + case 7: + options.c_cflag |= CS7; + break; + case 8: + options.c_cflag |= CS8; + break; + default: + fprintf(stderr,"Unsupported data size\n"); + return (FALSE); + } + switch (parity) + { + case 'n': + case 'N': + options.c_cflag &= ~PARENB; /* Clear parity enable */ + options.c_iflag &= ~INPCK; /* Enable parity checking */ + break; + case 'o': + case 'O': + options.c_cflag |= (PARODD | PARENB); + options.c_iflag |= INPCK; /* Disnable parity checking */ + break; + case 'e': + case 'E': + options.c_cflag |= PARENB; /* Enable parity */ + options.c_cflag &= ~PARODD; + options.c_iflag |= INPCK; /* Disnable parity checking */ + break; + case 'S': + case 's': /*as no parity*/ + options.c_cflag &= ~PARENB; + options.c_cflag &= ~CSTOPB; + break; + default: + fprintf(stderr,"Unsupported parity\n"); + return (FALSE); + } + + switch (stopbits) + { + case 1: + options.c_cflag &= ~CSTOPB; + break; + case 2: + options.c_cflag |= CSTOPB; + break; + default: + fprintf(stderr,"Unsupported stop bits\n"); + return (FALSE); + } + /* Set input parity option */ + if (parity != 'n') + options.c_iflag |= INPCK; + options.c_cc[VTIME] = 150; // 15 seconds + options.c_cc[VMIN] = 0; + + tcflush(fd,TCIFLUSH); /* Update the options and do it NOW */ + if (tcsetattr(fd,TCSANOW,&options) != 0) + { + perror("SetupSerial 3"); + return (FALSE); + } + return (TRUE); + } +/** +*@breif 打开串口 +*/ +int OpenDev(char *Dev) +{ +int fd = open( Dev, O_RDWR | O_NONBLOCK); //| O_NOCTTY | O_NDELAY + if (-1 == fd) + { + perror("Can't Open Serial Port"); + return -1; + } + else + return fd; + +} +/** +*@breif main() +*/ +int main(int argc, char **argv) +{ + int fd; + int tag = 0; + int nread; + char buff[512]; + char *dev ="/dev/ttyAMA0"; + + + fd = OpenDev(dev); + if (fd>0) + set_speed(fd,115200); + else + { + printf("Can't Open Serial Port!\n"); + exit(0); + } + if (set_Parity(fd,8,1,'N')== FALSE) + { + printf("Set Parity Error\n"); + exit(1); + } +// while(1) + { + memset(buff, 0, 512); + strcat(buff, "ATI\r"); + nread = write(fd, buff, 4); + usleep(1000*200); + memset(buff, 0, 512); + while((nread = read(fd,buff,2))>0) + { + printf("%s",buff); + memset(buff, 0, 512); + tag = 1; + } + } + close(fd); +} diff --git a/rak/gateway-config b/rak/gateway-config index b960f45..b4619c5 100755 --- a/rak/gateway-config +++ b/rak/gateway-config @@ -217,15 +217,15 @@ do_setup_LoRaServer_channel_plan() { else FUN=$(dialog --title "Server Channel-plan configuration" --default-item $default_item --menu "Server Channel-plan:" 18 60 12 \ 1 "AS_923(920_923)" \ - 1 "AS_923(923_925)" \ - 2 "AU_915_928" \ - 3 "CN_470_510" \ - 4 "EU_433" \ - 5 "EU_863_870" \ - 6 "IN_865_867" \ - 7 "KR_920_923" \ - 8 "RU_864_870" \ - 9 "US_902_928" \ + 2 "AS_923(923_925)" \ + 3 "AU_915_928" \ + 4 "CN_470_510" \ + 5 "EU_433" \ + 6 "EU_863_870" \ + 7 "IN_865_867" \ + 8 "KR_920_923" \ + 9 "RU_864_870" \ + 10 "US_902_928" \ 3>&1 1>&2 2>&3) RET=$? if [ $RET -eq 0 ]; then diff --git a/rak/gateway-version b/rak/gateway-version index 0f95ce5..790807f 100755 --- a/rak/gateway-version +++ b/rak/gateway-version @@ -17,7 +17,7 @@ if [ "${RAK_MODEL}" = "RAK2247" ] || [ "${RAK_MODEL}" = "RAK833" ]; then else GW_MODEL_STR="${RAK_MODEL} for USB" fi -elif [ "${RAK_MODEL}" = "RAK7243" ] || [ "${RAK_MODEL}" = "RAK7244" ]; then +elif [ "${RAK_MODEL}" = "RAK7243" ] || [ "${RAK_MODEL}" = "RAK7244" ] || [ "${RAK_MODEL}" = "RAK7248" ]; then if [ "$INSTALL_LTE" = "1" ]; then GW_MODEL_STR="${RAK_MODEL} with LTE" else diff --git a/rak/install.sh b/rak/install.sh index c06f9bc..d609170 100755 --- a/rak/install.sh +++ b/rak/install.sh @@ -19,6 +19,7 @@ apt install git ppp dialog jq minicom monit i2c-tools -y cp gateway-config /usr/bin/ cp gateway-version /usr/bin/ +cp rak_test /usr/bin/ cp rak /usr/local/ -rf if [ "$1" = "create_img" ]; then diff --git a/rak/rak/first_boot/copy_pkt_fwd b/rak/rak/first_boot/copy_pkt_fwd index 410d804..6fb9415 100755 --- a/rak/rak/first_boot/copy_pkt_fwd +++ b/rak/rak/first_boot/copy_pkt_fwd @@ -11,24 +11,43 @@ INSTALL_CHIRPSTACK=`do_get_gw_install_chirpstack` if [ ! -d "/opt/ttn-gateway/packet_forwarder" ]; then if [ "$INSTALL_LTE" = "1" ]; then - cp /usr/local/rak/lora/rak7243/* /opt/ttn-gateway/ -rf + if [ "$GW_MODEL" = "RAK7243" ] || [ "$GW_MODEL" = "RAK7244" ]; then + cp /usr/local/rak/lora/rak7243/* /opt/ttn-gateway/ -rf + if [ "$INSTALL_LTE" = "1" ]; then + cp /usr/local/rak/lora/rak7243/global_conf_i2c /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf + else + cp /usr/local/rak/lora/rak7243/global_conf_uart /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf + fi + + elif [ "$GW_MODEL" = "RAK7248" ]; then + if [ "$LORA_SPI" = "1" ]; then + cp /usr/local/rak/lora/rak2287_spi/* /opt/ttn-gateway/ -rf + if [ "$INSTALL_LTE" = "1" ]; then + cp /usr/local/rak/lora/rak2287_spi/global_conf_i2c /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf + else + cp /usr/local/rak/lora/rak2287_spi/global_conf_uart /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf + fi + else + cp /usr/local/rak/lora/rak2287_usb/* /opt/ttn-gateway/ -rf + fi + else + echo "some error." + fi else - if [ "$GW_MODEL" = "RAK2247" ]; then + if [ "$GW_MODEL" = "RAK2247" ]; then if [ "$LORA_SPI" = "1" ]; then cp /usr/local/rak/lora/rak2247_spi/* /opt/ttn-gateway/ -rf else cp /usr/local/rak/lora/rak2247_usb/* /opt/ttn-gateway/ -rf fi - elif [ "$GW_MODEL" = "RAK2287" ]; then - if [ "$LORA_SPI" = "1" ]; then - cp /usr/local/rak/lora/rak2287_spi/* /opt/ttn-gateway/ -rf - else - cp /usr/local/rak/lora/rak2287_usb/* /opt/ttn-gateway/ -rf - fi elif [ "$GW_MODEL" = "RAK2246" ]; then cp /usr/local/rak/lora/rak2246/* /opt/ttn-gateway/ -rf + elif [ "$GW_MODEL" = "RAK7248" ]; then + cp /usr/local/rak/lora/rak2287_spi/* /opt/ttn-gateway/ -rf + cp /usr/local/rak/lora/rak2287_spi/global_conf_uart /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf else - cp /usr/local/rak/lora/rak2245/* /opt/ttn-gateway/ -rf + cp /usr/local/rak/lora/rak7243/* /opt/ttn-gateway/ -rf + cp /usr/local/rak/lora/rak7243/global_conf_uart /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf -rf fi fi @@ -41,4 +60,6 @@ if [ ! -d "/opt/ttn-gateway/packet_forwarder" ]; then fi sed -i "s/^.*server_address.*$/\t\"server_address\": \"127.0.0.1\",/" \ /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json + + chmod 755 /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/global_conf.json fi diff --git a/rak/rak/rak_gw_model.json b/rak/rak/rak_gw_model.json old mode 100644 new mode 100755 index adbe12f..3fbc1a5 --- a/rak/rak/rak_gw_model.json +++ b/rak/rak/rak_gw_model.json @@ -1,5 +1,5 @@ { "gw_model": "RAK7243", - "gw_version": "4.2.5R", + "gw_version": "4.2.6R", "spi": 0 } diff --git a/rak/rak_test b/rak/rak_test new file mode 100755 index 0000000..71b7d8c --- /dev/null +++ b/rak/rak_test @@ -0,0 +1,6 @@ +#!/bin/bash +if [ $UID != 0 ]; then + echo "Operation not permitted. Forgot sudo?" + exit 1 +fi +systemctl stop ttn-gateway