Skip to content

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
* Added missing LICENSE.TXT file
* HAL & Packet Forwarder: added support for sx1250-based reference design for
CN490 region
* Packet Forwarder: disabled beaconing by default
  • Loading branch information
mcoracin committed Nov 22, 2019
1 parent 5942224 commit 81e748c
Show file tree
Hide file tree
Showing 23 changed files with 306 additions and 48 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*/*.a
*/obj/
*.swp
bin/
libloragw/inc/config.h
libloragw/test_loragw_*
packet_forwarder/lora_pkt_fwd
util_chip_id/chip_id
util_net_downlink/net_downlink
80 changes: 80 additions & 0 deletions LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
Copyright (c) 2019, SEMTECH S.A.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Semtech corporation nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL SEMTECH S.A. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--- For the parson library used by the packet forwarder ---

Parson ( http://kgabis.github.com/parson/ )
Copyright (c) 2012 Krzysztof Gabis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
ITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

--- For the tinyMT32 library used by the HAL ---

Copyright (c) 2011 Mutsuo Saito, Makoto Matsumoto, Hiroshima
University and The University of Tokyo. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the Hiroshima University nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.0.4
13 changes: 7 additions & 6 deletions libloragw/inc/loragw_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,13 @@ struct lgw_rssi_tcomp_s {
@brief Configuration structure for a RF chain
*/
struct lgw_conf_rxrf_s {
bool enable; /*!> enable or disable that RF chain */
uint32_t freq_hz; /*!> center frequency of the radio in Hz */
float rssi_offset; /*!> Board-specific RSSI correction factor */
struct lgw_rssi_tcomp_s rssi_tcomp; /*!> Board-specific RSSI temperature compensation coefficients */
lgw_radio_type_t type; /*!> Radio type for that RF chain (SX1255, SX1257....) */
bool tx_enable; /*!> enable or disable TX on that RF chain */
bool enable; /*!> enable or disable that RF chain */
uint32_t freq_hz; /*!> center frequency of the radio in Hz */
float rssi_offset; /*!> Board-specific RSSI correction factor */
struct lgw_rssi_tcomp_s rssi_tcomp; /*!> Board-specific RSSI temperature compensation coefficients */
lgw_radio_type_t type; /*!> Radio type for that RF chain (SX1255, SX1257....) */
bool tx_enable; /*!> enable or disable TX on that RF chain */
bool single_input_mode; /*!> Configure the radio in single or differential input mode (SX1250 only) */
};

/**
Expand Down
2 changes: 1 addition & 1 deletion libloragw/inc/loragw_sx1250.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int sx1250_write_command(uint8_t rf_chain, sx1250_op_code_t op_code, uint8_t *da
int sx1250_read_command(uint8_t rf_chain, sx1250_op_code_t op_code, uint8_t *data, uint16_t size);

int sx1250_calibrate(uint8_t rf_chain, uint32_t freq_hz);
int sx1250_setup(uint8_t rf_chain, uint32_t freq_hz);
int sx1250_setup(uint8_t rf_chain, uint32_t freq_hz, bool single_input_mode);

#endif

Expand Down
13 changes: 12 additions & 1 deletion libloragw/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,18 @@ To debug your application, it might help to compile the loragw_hal function
with the debug messages activated (set DEBUG_HAL=1 in library.cfg).
It then send a lot of details, including detailed error messages to *stderr*.

## 6. License
## 6. Notes

### 6.1. Spreading factor SF5 & SF6

The sx1302 supports SF5 and SF6 spreading factors, and the HAL also. But it is
important to note that the only syncword supported for SF5 and SF6 is 0x12
(also known as "private").

This is true whatever how of the "lorawan_public" field of lgw_conf_board_s is
set.

## 7. License

Copyright (c) 2019, SEMTECH S.A.
All rights reserved.
Expand Down
8 changes: 5 additions & 3 deletions libloragw/src/loragw_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,15 @@ int lgw_rxrf_setconf(uint8_t rf_chain, struct lgw_conf_rxrf_s * conf) {
CONTEXT_RF_CHAIN[rf_chain].rssi_tcomp.coeff_e = conf->rssi_tcomp.coeff_e;
CONTEXT_RF_CHAIN[rf_chain].type = conf->type;
CONTEXT_RF_CHAIN[rf_chain].tx_enable = conf->tx_enable;
CONTEXT_RF_CHAIN[rf_chain].single_input_mode = conf->single_input_mode;

DEBUG_PRINTF("Note: rf_chain %d configuration; en:%d freq:%d rssi_offset:%f radio_type:%d tx_enable:%d\n", rf_chain,
DEBUG_PRINTF("Note: rf_chain %d configuration; en:%d freq:%d rssi_offset:%f radio_type:%d tx_enable:%d single_input_mode:%d\n", rf_chain,
CONTEXT_RF_CHAIN[rf_chain].enable,
CONTEXT_RF_CHAIN[rf_chain].freq_hz,
CONTEXT_RF_CHAIN[rf_chain].rssi_offset,
CONTEXT_RF_CHAIN[rf_chain].type,
CONTEXT_RF_CHAIN[rf_chain].tx_enable);
CONTEXT_RF_CHAIN[rf_chain].tx_enable,
CONTEXT_RF_CHAIN[rf_chain].single_input_mode);

return LGW_HAL_SUCCESS;
}
Expand Down Expand Up @@ -594,7 +596,7 @@ int lgw_start(void) {
sx1302_radio_reset(i, CONTEXT_RF_CHAIN[i].type);
switch (CONTEXT_RF_CHAIN[i].type) {
case LGW_RADIO_TYPE_SX1250:
sx1250_setup(i, CONTEXT_RF_CHAIN[i].freq_hz);
sx1250_setup(i, CONTEXT_RF_CHAIN[i].freq_hz, CONTEXT_RF_CHAIN[i].single_input_mode);
break;
case LGW_RADIO_TYPE_SX1255:
case LGW_RADIO_TYPE_SX1257:
Expand Down
11 changes: 10 additions & 1 deletion libloragw/src/loragw_sx1250.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ int sx1250_calibrate(uint8_t rf_chain, uint32_t freq_hz) {

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */

int sx1250_setup(uint8_t rf_chain, uint32_t freq_hz) {
int sx1250_setup(uint8_t rf_chain, uint32_t freq_hz, bool single_input_mode) {
int32_t freq_reg;
uint8_t buff[16];

Expand Down Expand Up @@ -297,6 +297,15 @@ int sx1250_setup(uint8_t rf_chain, uint32_t freq_hz) {
buff[2] = 0xFF;
sx1250_write_command(rf_chain, SET_RX, buff, 3); /* Rx Continuous */

/* Select single input or differential input mode */
if (single_input_mode == true) {
printf("INFO: Configuring SX1250_%u in single input mode\n", rf_chain);
buff[0] = 0x08;
buff[1] = 0xE2;
buff[2] = 0x0D;
sx1250_write_command(rf_chain, WRITE_REGISTER, buff, 3);
}

buff[0] = 0x05;
buff[1] = 0x87;
buff[2] = 0x0B;
Expand Down
10 changes: 9 additions & 1 deletion libloragw/tst/test_loragw_cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ void usage(void) {
printf(" -k <uint> Concentrator clock source (Radio A or Radio B) [0..1]\n");
printf(" -c <uint> RF chain to be used for TX (Radio A or Radio B) [0..1]\n");
printf(" -r <uint> Radio type (1255, 1257, 1250)\n");
printf(" -j Set radio in single input mode (SX1250 only)\n");
printf(" -f <float> Radio TX frequency in MHz\n");
printf( "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
printf(" --pa <uint> PA gain [0..3]\n");
Expand Down Expand Up @@ -465,6 +466,7 @@ int main(int argc, char **argv)
uint8_t clocksource = 0;
uint8_t rf_chain = 0;
lgw_radio_type_t radio_type = LGW_RADIO_TYPE_NONE;
bool single_input_mode = false;

struct lgw_conf_board_s boardconf;
struct lgw_conf_rxrf_s rfconf;
Expand All @@ -490,7 +492,7 @@ int main(int argc, char **argv)
};

/* parse command line options */
while ((i = getopt_long (argc, argv, "hf:k:r:c:d:", long_options, &option_index)) != -1) {
while ((i = getopt_long (argc, argv, "hjf:k:r:c:d:", long_options, &option_index)) != -1) {
switch (i) {
case 'h':
usage();
Expand Down Expand Up @@ -543,6 +545,10 @@ int main(int argc, char **argv)
}
break;

case 'j':
single_input_mode = true;
break;

case 'f': /* <float> Radio TX frequency in MHz */
i = sscanf(optarg, "%lf", &arg_d);
if (i != 1) {
Expand Down Expand Up @@ -616,6 +622,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = ft;
rfconf.type = radio_type;
rfconf.tx_enable = true;
rfconf.single_input_mode = single_input_mode;
if (lgw_rxrf_setconf(0, &rfconf) != LGW_HAL_SUCCESS) {
printf("ERROR: failed to configure rxrf 0\n");
return EXIT_FAILURE;
Expand All @@ -626,6 +633,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = ft;
rfconf.type = radio_type;
rfconf.tx_enable = true;
rfconf.single_input_mode = single_input_mode;
if (lgw_rxrf_setconf(1, &rfconf) != LGW_HAL_SUCCESS) {
printf("ERROR: failed to configure rxrf 1\n");
return EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion libloragw/tst/test_loragw_capture_ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ int main(int argc, char **argv)
sx1302_radio_reset(i, rf_radio_type[i]);
switch (radio_type) {
case LGW_RADIO_TYPE_SX1250:
sx1250_setup(i, rf_rx_freq[i]);
sx1250_setup(i, rf_rx_freq[i], false);
break;
case LGW_RADIO_TYPE_SX1255:
case LGW_RADIO_TYPE_SX1257:
Expand Down
3 changes: 3 additions & 0 deletions libloragw/tst/test_loragw_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = fa;
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;
Expand All @@ -202,6 +203,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = fb;
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;
Expand Down Expand Up @@ -235,6 +237,7 @@ int main(int argc, char **argv)
lgw_get_trigcnt(&counter);
}
wait_ms(10);
printf("%u\n", counter);
}

/* Stop the gateway */
Expand Down
2 changes: 2 additions & 0 deletions libloragw/tst/test_loragw_gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ int main(int argc, char **argv)
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;
Expand All @@ -297,6 +298,7 @@ int main(int argc, char **argv)
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;
Expand Down
27 changes: 17 additions & 10 deletions libloragw/tst/test_loragw_hal_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ static void sig_handler(int sigio) {

void usage(void) {
//printf("Library version information: %s\n", lgw_version_info());
printf( "Available options:\n");
printf( " -h print this help\n");
printf( " -k <uint> Concentrator clock source (Radio A or Radio B) [0..1]\n");
printf( " -r <uint> Radio type (1255, 1257, 1250)\n");
printf( " -a <float> Radio A RX frequency in MHz\n");
printf( " -b <float> Radio B RX frequency in MHz\n");
printf( " -n <uint> Number of packet received with CRC OK for each HAL start/stop loop\n");
printf( " -z <uint> Size of the RX packet array to be passed to lgw_receive()\n");
printf( " -m <uint> Channel frequency plan mode [0:LoRaWAN-like, 1:Same frequency for all channels (-400000Hz on RF0)]\n");
printf("Available options:\n");
printf(" -h print this help\n");
printf(" -k <uint> Concentrator clock source (Radio A or Radio B) [0..1]\n");
printf(" -r <uint> Radio type (1255, 1257, 1250)\n");
printf(" -a <float> Radio A RX frequency in MHz\n");
printf(" -b <float> Radio B RX frequency in MHz\n");
printf(" -n <uint> Number of packet received with CRC OK for each HAL start/stop loop\n");
printf(" -z <uint> Size of the RX packet array to be passed to lgw_receive()\n");
printf(" -m <uint> Channel frequency plan mode [0:LoRaWAN-like, 1:Same frequency for all channels (-400000Hz on RF0)]\n");
printf(" -j Set radio in single input mode (SX1250 only)\n");
}

/* -------------------------------------------------------------------------- */
Expand All @@ -97,6 +98,7 @@ int main(int argc, char **argv)
uint8_t clocksource = 0;
lgw_radio_type_t radio_type = LGW_RADIO_TYPE_NONE;
uint8_t max_rx_pkt = 16;
bool single_input_mode = false;

struct lgw_conf_board_s boardconf;
struct lgw_conf_rxrf_s rfconf;
Expand Down Expand Up @@ -136,7 +138,7 @@ int main(int argc, char **argv)
const uint8_t channel_rfchain_mode1[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

/* parse command line options */
while ((i = getopt (argc, argv, "ha:b:k:r:n:z:m:")) != -1) {
while ((i = getopt (argc, argv, "hja:b:k:r:n:z:m:")) != -1) {
switch (i) {
case 'h':
usage();
Expand Down Expand Up @@ -170,6 +172,9 @@ int main(int argc, char **argv)
clocksource = (uint8_t)arg_u;
}
break;
case 'j': /* Set radio in single input mode */
single_input_mode = true;
break;
case 'a': /* <float> Radio A RX frequency in MHz */
i = sscanf(optarg, "%lf", &arg_d);
if (i != 1) {
Expand Down Expand Up @@ -250,6 +255,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = fa;
rfconf.type = radio_type;
rfconf.tx_enable = false;
rfconf.single_input_mode = single_input_mode;
if (lgw_rxrf_setconf(0, &rfconf) != LGW_HAL_SUCCESS) {
printf("ERROR: failed to configure rxrf 0\n");
return EXIT_FAILURE;
Expand All @@ -260,6 +266,7 @@ int main(int argc, char **argv)
rfconf.freq_hz = fb;
rfconf.type = radio_type;
rfconf.tx_enable = false;
rfconf.single_input_mode = single_input_mode;
if (lgw_rxrf_setconf(1, &rfconf) != LGW_HAL_SUCCESS) {
printf("ERROR: failed to configure rxrf 1\n");
return EXIT_FAILURE;
Expand Down
Loading

0 comments on commit 81e748c

Please sign in to comment.