FEDER:Lora Network Installation: Difference between revisions

From UNamur InfoSec
Jump to navigation Jump to search
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
We have installed a LoraWAN using raspberry pi 2 and IMST gateway (iC880A-USB). The loriot.io network service has been used in our experimentation. LoPy micro-controllers were used as end-devices in our test.  We were able publishing data to Loriot.io by using LoPy board. Below are the step-by-step LoraWAN installation procedure.
We have installed a LoraWAN using raspberry pi 2 and IMST gateway (iC880A-USB). The loriot.io network service has been used in our experimentation. LoPy micro-controllers were used as end-devices in our test.  We were able publishing data to Loriot.io by using LoPy board. Below are the step-by-step LoraWAN installation procedure.
You can download the installation file here: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf


==[[Setting up the gateway ]]==


I. Setting up the gateway
&nbsp;  &nbsp;  &nbsp;  1.    Make sure that the Raspberry Pi is connected to the internet and that you connected the IMST iC880A over USB. <br>
1.    Make sure that the Raspberry Pi is connected to the internet and that you connected the IMST iC880A over USB.
&nbsp;  &nbsp;  &nbsp;  2. Download of the Open Source Driver <br>
2. Download of the Open Source Driver
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  a. Install git client: <br>
a. Install git client:  
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  sudo apt-get install git <br>
sudo apt-get install git
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  b. Create local folder:
b. Create local folder:
mkdir -p ~/LoRa/lora_gateway
c. Clone the repository:
cd ~/LoRa/lora_gateway
git clone https://github.com/Lora-net/lora_gateway.git
Note: Use lora_gateway 2.0.0, not the latest version. (Run git checkout v2.0.0 in the lora_gateway folder).
cd lora_gateway
git checkout v2.0.0
3. Downloading Additional Drivers
a. Create a folder for the libmpsse files:
mkdir –p ~/LoRa/libmpsse
b. Download the newest version of the libmpsse files:
cd ~/LoRa/libmpsse
wget https://storage.googleapis.com/google-code-archivedownloads/v2/code.google.com/libmpsse/libmpsse-1.3.tar.gz
tar –xzvf libmpsse-1.3.tar.gz
c. Follow the installation instructions from the hosted website:
(https://code.google.com/p/libmpsse/wiki/Installation)
sudo apt-get install libftdi-dev
cd ~/LoRa/libmpsse/libmpsse-1.3/src
./configure --disable-python && make && sudo make install
sudo ldconfig


Note: If the configure step fails, follow the instructions and try to install the missing dependencies.  
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  mkdir -p ~/LoRa/lora_gateway
4. Configuration of the Driver
 
The driver must be configured in order to work with the iC880A. The following chapter describes the necessary configuration options to make.
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  c. Clone the repository:
In the folder “LoRa/github/lora_gateway/libloragw” there is a file called “libraray.cfg”. This file contains the most important options for the HAL-library and must be modified to your needs before compiling the software.
 
a. File: lora_gateway/libloragw/library.cfg This file is used as general configuration file for the whole libloragw system library. In order to fit the needs of the iC880A, some parameters must be set to the following values prior (re-) compiling the library:
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  cd ~/LoRa/lora_gateway
CFG_SPI= ftdi
 
CFG_CHIP= sx1301
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  git clone https://github.com/Lora-net/lora_gateway.git
CFG_RADIO= sx1257
 
CFG_BAND= eu868
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Note: Use lora_gateway 2.0.0, not the latest version. (Run git checkout v2.0.0 in the lora_gateway folder).
The parameter called “CFG_BRD” must be left empty or set to:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  cd lora_gateway
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  git checkout v2.0.0
 
&nbsp;  &nbsp;  &nbsp;  3. Downloading Additional Drivers
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  a. Create a folder for the libmpsse files:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  mkdir –p ~/LoRa/libmpsse
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  b. Download the newest version of the libmpsse files:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  cd ~/LoRa/libmpsse
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  wget https://storage.googleapis.com/google-code-archivedownloads/v2/code.google.com/libmpsse/libmpsse-1.3.tar.gz
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  tar –xzvf libmpsse-1.3.tar.gz
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  c. Follow the installation instructions from the hosted website:(https://code.google.com/p/libmpsse/wiki/Installation)
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  sudo apt-get install libftdi-dev
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  cd ~/LoRa/libmpsse/libmpsse-1.3/src
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ./configure --disable-python && make && sudo make install
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  sudo ldconfig
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Note: If the configure step fails, follow the instructions and try to install the missing dependencies.  
 
&nbsp;  &nbsp;  &nbsp;  4. Configuration of the Driver
 
&nbsp;  &nbsp;  &nbsp;  The driver must be configured in order to work with the iC880A. The following chapter describes the necessary configuration options to make.
 
&nbsp;  &nbsp;  &nbsp;  In the folder “LoRa/github/lora_gateway/libloragw” there is a file called “libraray.cfg”. This file contains the most important options for the HAL-library and must be modified to your needs  
 
&nbsp;  &nbsp;  &nbsp;  before compiling the software.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  a. File: lora_gateway/libloragw/library.cfg  
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; This file is used as general configuration file for the whole libloragw system library. In order to fit the needs of the iC880A, some parameters must be set to the following  
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; values prior (re-) compiling the library:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  CFG_SPI= ftdi
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  CFG_CHIP= sx1301
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  CFG_RADIO= sx1257
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  CFG_BAND= eu868
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  The parameter called “CFG_BRD” must be left empty or set to:
CFG_BRD= ref_1301_868
CFG_BRD= ref_1301_868
Additionally, there are some optional debug settings that can be turned on (1) or off (0):
DEBUG_AUX= 0
DEBUG_SPI= 0
DEBUG_REG= 0
DEBUG_HAL= 1
DEBUG_GPS= 0
These flags are used by the internal modules of the library to enable / disable additional output for debugging purposes.


b. File: lora_gateway/libloragw/src/loragw_spi.ftdi.c
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Additionally, there are some optional debug settings that can be turned on (1) or off (0):
As second step a small modification must be done in one of the low-level connection files. The WiMOD iC880A LoRa Concentrator board uses a FTDI USB to SPI converter chip that is not supported in Semtech’s reference code. The only difference is another USB PID. Therefore, the USB PID settings in the libloragw library have to be adjusted prior compiling the library.
 
Open the file lora_gateway/libloragw/src/loragw_spi.ftdi.c with your favorite editor (e.g. nano)
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  DEBUG_AUX= 0
nano lora_gateway/libloragw/src/loragw_spi.ftdi.c
 
Find the block with the “PRIVATE CONSTANTS” (around line 50 in the file) and change the line
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  DEBUG_SPI= 0
#define PID 0x6010
 
To
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  DEBUG_REG= 0
#define PID 0x6014
 
Afterwards save the file and close the editor.
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  DEBUG_HAL= 1
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  DEBUG_GPS= 0
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  These flags are used by the internal modules of the library to enable / disable additional output for debugging purposes.
 
&nbsp;  &nbsp;  &nbsp;  b. File: lora_gateway/libloragw/src/loragw_spi.ftdi.c
 
&nbsp;  &nbsp;  &nbsp;  As second step a small modification must be done in one of the low-level connection files. The WiMOD iC880A LoRa Concentrator board uses a FTDI USB to SPI converter chip that is not  
 
&nbsp;  &nbsp;  &nbsp;  supported in Semtech’s reference code. The only difference is another USB PID. Therefore, the USB PID settings in the libloragw library have to be adjusted prior compiling the library.
 
&nbsp;  &nbsp;  &nbsp;  Open the file lora_gateway/libloragw/src/loragw_spi.ftdi.c with your favorite editor (e.g. nano)
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nano lora_gateway/libloragw/src/loragw_spi.ftdi.c
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Find the block with the “PRIVATE CONSTANTS” (around line 50 in the file) and change the line
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #define PID 0x6010
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  To
 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #define PID 0x6014
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Afterwards save the file and close the editor.
 
&nbsp;  &nbsp;  &nbsp;  5. Compilation of the Library
 
&nbsp;  &nbsp;  &nbsp;  In order to compile the libloragw library it is assumed that a gcc/g++ compiler and a make utility is already installed and runnable.
 
&nbsp;  &nbsp;  &nbsp;  Enter the lora_gateway folder and execute the make command:
 
&nbsp;  &nbsp;  &nbsp;  cd lora_gateway
 
&nbsp;  &nbsp;  &nbsp;  make
 
&nbsp;  &nbsp;  &nbsp;  This will compile the library and some of the basic test utilities located in the subfolders of lora_gateway.
 
&nbsp;  &nbsp;  &nbsp;  After a successful compilation a library file called “libloragw.a” has been created and is ready for usage now.
 
&nbsp;  &nbsp;  &nbsp;  6. Setting up “udev” Rules
 
&nbsp;  &nbsp;  &nbsp;  The FTDI USB chip needs to be run in the SPI mode. Therefore an “udev” rule must be installed on the Linux host system. This rule will configure the right mode automatically when the iC880A
 
&nbsp;  &nbsp;  &nbsp;  device is connected to the host system. In order to install the udev rule the following steps must be done:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  In the folder lora_gateway/libloragw there is a template file present. Open the file in
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  your favorite editor (e.g. nano).
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  nano lora_gateway/libloragw/99-libftdi.rules
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  locate the line
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010",
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  MODE="0664", GROUP="plugdev"
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  and change the entry
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  ATTRS{idProduct}=="6010”
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  to:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  ATTRS{idProduct}=="6014”
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  Save the file and leave the editor. Next copy the file to the folder /etc/udev/rules.d/
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  sudo cp 99-libftdi.rules /etc/udev/rules.d/
 
&nbsp;  &nbsp;  &nbsp;  7. After following these steps:
 
&nbsp;  &nbsp;  &nbsp;  Restart the Pi.
 
&nbsp;  &nbsp;  &nbsp;  Run:
 
&nbsp;  &nbsp;  &nbsp;  ~/LoRa/lora_gateway/lora_gateway/util_pkt_logger/util_pkt_logger
 
&nbsp;  &nbsp;  &nbsp;  You see ‘INFO: concentrator started, packet can now be received’, which indicates that everything is functioning.
 
==[[Setting up LoRa network on LORIOT ]]==
 
&nbsp;  &nbsp;  &nbsp;  a. Installing the LORIOT software
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; i. Sign up for an account.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ii. You’re redirected to the dashboard page.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; iii. Click the link to register a new gateway.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; iv. You’re taken through a wizard. Choose the gateway you have, and follow the steps.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; v. You’re taken to the gateway page where you’ll find the LORIOT binary for your platform and a link to set up document.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; Tip: Use a tool like scp to copy the binary from your computer to the gateway. For example:
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; scp ~/Downloads/loriot_pi_2_iC880A_USB_1.0.1.tar pi@192.168.2.7:~/
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; vi. Copy the libmpsse.so library from the installation package to the usr/lib directory.
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; vii. Run the loriot_pi_[B/2]_[CONCENTRATOR_TYPE]_[VERSION] binary
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; viii. Upon a successful startup, the process will daemonize to background. The last printed message should be INFO: Concentrator started, daemonizing
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ix. The gateway shows as connected on the LORIOT gateway page. You’re ready to work on the device.
 
==[[Working with device]]==
 
&nbsp;  &nbsp;  &nbsp; a. Create an application in LORIOT
 
&nbsp;  &nbsp;  &nbsp;  b. Generate a device on LORIOT
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; i. Go to your application page
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ii. Click on Devices
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; iii. Click generate new device
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; iv. Click on newly generated device
 
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; v. Copy DevAddr, NwkSKey, AppSKey


5. Compilation of the Library
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; vi. Replace dev_addr, nwk_swkey, app_swkey in below example code and run the program
In order to compile the libloragw library it is assumed that a gcc/g++ compiler and a make utility is already installed and runnable.
Enter the lora_gateway folder and execute the make command:
cd lora_gateway
make
This will compile the library and some of the basic test utilities located in the subfolders of lora_gateway.
After a successful compilation a library file called “libloragw.a” has been created and is ready for usage now.


6. Setting up “udev” Rules
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; vii. You should see message send from device on the device page (check the image in given link: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf).
The FTDI USB chip needs to be run in the SPI mode. Therefore an “udev” rule must be installed on the Linux host system. This rule will configure the right mode automatically when the iC880A device is connected to the host system. In order to install the udev rule the following steps must be done:


In the folder lora_gateway/libloragw there is a template file present. Open the file in
your favorite editor (e.g. nano).
nano lora_gateway/libloragw/99-libftdi.rules


locate the line
&nbsp;  &nbsp;  &nbsp; c. Connect to LORIOT websocket for output data:
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010",
MODE="0664", GROUP="plugdev"


and change the entry
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; i. In LORIOT: go to your dashboard, and click Applications > Sample App > Output.
ATTRS{idProduct}=="6010”
to:
ATTRS{idProduct}=="6014”


Save the file and leave the editor. Next copy the file to the folder /etc/udev/rules.d/
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ii. Change the output type to WebSocket.
sudo cp 99-libftdi.rules /etc/udev/rules.d/
7. After following these steps:
Restart the Pi.
Run:
~/LoRa/lora_gateway/lora_gateway/util_pkt_logger/util_pkt_logger
You see ‘INFO: concentrator started, packet can now be received’, which indicates that everything is functioning.


II. Setting up LoRa network on LORIOT
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; iii. Copy the URL and the token under Current output setup, and paste them in the code sample below: (check the sample code in the given link: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf)


a. Installing the LORIOT software
==[[References]]==
i. Sign up for an account.
ii. You’re redirected to the dashboard page.
iii. Click the link to register a new gateway.
iv. You’re taken through a wizard. Choose the gateway you have, and follow the steps.
v. You’re taken to the gateway page where you’ll find the LORIOT binary for your platform and a link to set up document.
Tip: Use a tool like scp to copy the binary from your computer to the gateway. For example:
scp ~/Downloads/loriot_pi_2_iC880A_USB_1.0.1.tar pi@192.168.2.7:~/
vi. Copy the libmpsse.so library from the installation package to the usr/lib directory.
vii. Run the loriot_pi_[B/2]_[CONCENTRATOR_TYPE]_[VERSION] binary
viii. Upon a successful startup, the process will daemonize to background. The last printed message should be INFO: Concentrator started, daemonizing
ix. The gateway shows as connected on the LORIOT gateway page. You’re ready to work on the device.


III. Working with device
&nbsp;  &nbsp;  &nbsp; Building your own private LoRa network https://docs.mbed.com/docs/lora-with-mbed/en/latest/intro-to-lora/


a. Create an application in LORIOT
&nbsp;  &nbsp;  &nbsp; iC880A Quick Start Guide https://wireless-solutions.de/images/stories/downloads/Radio%20Modules/iC880A/iC880A_QuickStartGuide.pdf
b. Generate a device on LORIOT
i. Go to your application page
ii. Click on Devices
iii. Click generate new device
iv. Click on newly generated device
v. Copy DevAddr, NwkSKey, AppSKey
vi. Replace dev_addr, nwk_swkey, app_swkey in below example code and run the program
vii. You should see message send from device on the device page.


c. Connect to LORIOT websocket for output data:
&nbsp;  &nbsp;  &nbsp; LORIOT gateway installation guide https://eu1.loriot.io/home/documentation.html#docu/gwguide/pi
i. In LORIOT: go to your dashboard, and click Applications > Sample App > Output.
ii. Change the output type to WebSocket.
iii. Copy the URL and the token under Current output setup, and paste them in the code sample below:


IV. References
&nbsp;  &nbsp;  &nbsp; LoRaWAN with ABP join method (LoPy) https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/lora-abp.html
Building your own private LoRa network
https://docs.mbed.com/docs/lora-with-mbed/en/latest/intro-to-lora/
iC880A Quick Start Guide
https://wireless-solutions.de/images/stories/downloads/Radio%20Modules/iC880A/iC880A_QuickStartGuide.pdf
LORIOT gateway installation guide
https://eu1.loriot.io/home/documentation.html#docu/gwguide/pi
LoRaWAN with ABP join method (LoPy)
https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/lora-abp.html

Latest revision as of 15:48, 5 March 2017

We have installed a LoraWAN using raspberry pi 2 and IMST gateway (iC880A-USB). The loriot.io network service has been used in our experimentation. LoPy micro-controllers were used as end-devices in our test. We were able publishing data to Loriot.io by using LoPy board. Below are the step-by-step LoraWAN installation procedure. You can download the installation file here: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf

Setting up the gateway

      1. Make sure that the Raspberry Pi is connected to the internet and that you connected the IMST iC880A over USB.
      2. Download of the Open Source Driver
          a. Install git client:
              sudo apt-get install git
          b. Create local folder:

              mkdir -p ~/LoRa/lora_gateway

          c. Clone the repository:

              cd ~/LoRa/lora_gateway

              git clone https://github.com/Lora-net/lora_gateway.git

              Note: Use lora_gateway 2.0.0, not the latest version. (Run git checkout v2.0.0 in the lora_gateway folder).

              cd lora_gateway

              git checkout v2.0.0

      3. Downloading Additional Drivers

          a. Create a folder for the libmpsse files:

              mkdir –p ~/LoRa/libmpsse

          b. Download the newest version of the libmpsse files:

              cd ~/LoRa/libmpsse

              wget https://storage.googleapis.com/google-code-archivedownloads/v2/code.google.com/libmpsse/libmpsse-1.3.tar.gz

              tar –xzvf libmpsse-1.3.tar.gz

          c. Follow the installation instructions from the hosted website:(https://code.google.com/p/libmpsse/wiki/Installation)

              sudo apt-get install libftdi-dev

              cd ~/LoRa/libmpsse/libmpsse-1.3/src

                ./configure --disable-python && make && sudo make install

              sudo ldconfig

                Note: If the configure step fails, follow the instructions and try to install the missing dependencies.

      4. Configuration of the Driver

      The driver must be configured in order to work with the iC880A. The following chapter describes the necessary configuration options to make.

      In the folder “LoRa/github/lora_gateway/libloragw” there is a file called “libraray.cfg”. This file contains the most important options for the HAL-library and must be modified to your needs

      before compiling the software.

          a. File: lora_gateway/libloragw/library.cfg

          This file is used as general configuration file for the whole libloragw system library. In order to fit the needs of the iC880A, some parameters must be set to the following

          values prior (re-) compiling the library:

            CFG_SPI= ftdi

            CFG_CHIP= sx1301

            CFG_RADIO= sx1257

            CFG_BAND= eu868

            The parameter called “CFG_BRD” must be left empty or set to: CFG_BRD= ref_1301_868

            Additionally, there are some optional debug settings that can be turned on (1) or off (0):

              DEBUG_AUX= 0

              DEBUG_SPI= 0

              DEBUG_REG= 0

              DEBUG_HAL= 1

              DEBUG_GPS= 0

            These flags are used by the internal modules of the library to enable / disable additional output for debugging purposes.

      b. File: lora_gateway/libloragw/src/loragw_spi.ftdi.c

      As second step a small modification must be done in one of the low-level connection files. The WiMOD iC880A LoRa Concentrator board uses a FTDI USB to SPI converter chip that is not

      supported in Semtech’s reference code. The only difference is another USB PID. Therefore, the USB PID settings in the libloragw library have to be adjusted prior compiling the library.

      Open the file lora_gateway/libloragw/src/loragw_spi.ftdi.c with your favorite editor (e.g. nano)

          nano lora_gateway/libloragw/src/loragw_spi.ftdi.c

          Find the block with the “PRIVATE CONSTANTS” (around line 50 in the file) and change the line

          #define PID 0x6010

          To

          #define PID 0x6014

          Afterwards save the file and close the editor.

      5. Compilation of the Library

      In order to compile the libloragw library it is assumed that a gcc/g++ compiler and a make utility is already installed and runnable.

      Enter the lora_gateway folder and execute the make command:

      cd lora_gateway

      make

      This will compile the library and some of the basic test utilities located in the subfolders of lora_gateway.

      After a successful compilation a library file called “libloragw.a” has been created and is ready for usage now.

      6. Setting up “udev” Rules

      The FTDI USB chip needs to be run in the SPI mode. Therefore an “udev” rule must be installed on the Linux host system. This rule will configure the right mode automatically when the iC880A

      device is connected to the host system. In order to install the udev rule the following steps must be done:

          In the folder lora_gateway/libloragw there is a template file present. Open the file in

          your favorite editor (e.g. nano).

          nano lora_gateway/libloragw/99-libftdi.rules

          locate the line

          SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",

          ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010",

          MODE="0664", GROUP="plugdev"

          and change the entry

          ATTRS{idProduct}=="6010”

          to:

          ATTRS{idProduct}=="6014”

          Save the file and leave the editor. Next copy the file to the folder /etc/udev/rules.d/

          sudo cp 99-libftdi.rules /etc/udev/rules.d/

      7. After following these steps:

      Restart the Pi.

      Run:

      ~/LoRa/lora_gateway/lora_gateway/util_pkt_logger/util_pkt_logger

      You see ‘INFO: concentrator started, packet can now be received’, which indicates that everything is functioning.

Setting up LoRa network on LORIOT

      a. Installing the LORIOT software

          i. Sign up for an account.

          ii. You’re redirected to the dashboard page.

          iii. Click the link to register a new gateway.

          iv. You’re taken through a wizard. Choose the gateway you have, and follow the steps.

          v. You’re taken to the gateway page where you’ll find the LORIOT binary for your platform and a link to set up document.

          Tip: Use a tool like scp to copy the binary from your computer to the gateway. For example:

          scp ~/Downloads/loriot_pi_2_iC880A_USB_1.0.1.tar pi@192.168.2.7:~/

          vi. Copy the libmpsse.so library from the installation package to the usr/lib directory.

          vii. Run the loriot_pi_[B/2]_[CONCENTRATOR_TYPE]_[VERSION] binary

          viii. Upon a successful startup, the process will daemonize to background. The last printed message should be INFO: Concentrator started, daemonizing

          ix. The gateway shows as connected on the LORIOT gateway page. You’re ready to work on the device.

Working with device

      a. Create an application in LORIOT

      b. Generate a device on LORIOT

          i. Go to your application page

          ii. Click on Devices

          iii. Click generate new device

          iv. Click on newly generated device

          v. Copy DevAddr, NwkSKey, AppSKey

          vi. Replace dev_addr, nwk_swkey, app_swkey in below example code and run the program

          vii. You should see message send from device on the device page (check the image in given link: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf).


      c. Connect to LORIOT websocket for output data:

          i. In LORIOT: go to your dashboard, and click Applications > Sample App > Output.

          ii. Change the output type to WebSocket.

          iii. Copy the URL and the token under Current output setup, and paste them in the code sample below: (check the sample code in the given link: https://doc.info.fundp.ac.be/mediawiki/index.php/File:Install-Lora-network.pdf)

References

      Building your own private LoRa network https://docs.mbed.com/docs/lora-with-mbed/en/latest/intro-to-lora/

      iC880A Quick Start Guide https://wireless-solutions.de/images/stories/downloads/Radio%20Modules/iC880A/iC880A_QuickStartGuide.pdf

      LORIOT gateway installation guide https://eu1.loriot.io/home/documentation.html#docu/gwguide/pi

      LoRaWAN with ABP join method (LoPy) https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/lora-abp.html