packet_forwarder Use with Raspberry Pi

本文档详细介绍了如何使用Raspberry Pi 2和Semtech LoRa网关参考设计搭建LoRa网关,包括硬件连接、软件安装配置及运行基本的Packet Forwarder程序等步骤。

Michael Coracin edited this page on 12 Jul · 17 revisions

The Semtech LoRa GW reference design has been tested with a Raspberry Pi 2:https://www.raspberrypi.org/products/raspberry-pi-2-model-b

Use an external 5.0V (>1A) to supply GW reference design power supply, do not use the 5.0V supply from Raspberry Pi board.

For basic testing, the utilities provided on the lora_gateway repository (https://github.com/Lora-net/lora_gateway) will do the job (pkt_logger, util_tx_test, etc....):

  1. lora_gateway: SX1301 driver library source code (https://github.com/Lora-net/lora_gateway)

    This source code has been adapted to use the Raspberry Pi hardware SPI. Please refer to the readme.md file which is in the lora_gateway directory to get details about how to use it.

  2. packet_forwarder: Gateway application source code (https://github.com/Lora-net/packet_forwarder)

    A LoRa packet forwarder is a program that forwards RF packets received by the SX1301 concentrator to a server through an IP/UDP link (uplinks), and emits RF packets that are sent by the server (downlinks). Please refer to the readme.md file which is in the packet_forwarder directory to get details about how to use it.

Note: lora_gateway and packet_forwarder are compatible with the two Semtech GW LoRa reference design versions (i.e. with and without FPGA). There is an automatic check which allows distinguishing the 2 different designs.

Please also note that the default configuration file “global_conf.json”, is given as an example (based on Semtech IoT starter kit reference design i.e. without FPGA) and may need to be adapted according to your design. The configuration file to be used for “GW LoRa EU v1.5 reference design” is located in [PATH]/packet_forwarder/lora_pkt_fwd/cfg/global_conf.json.PCB_E336.EU868.*  

SPI connection

Raspberry Pi connector <-> J100_PC_HOST GW ref design v1.5 connector

  • MOSI (Pin19) <-> MOSI_PC_HOST (Pin 2)
  • MISO (Pin 21) <-> MISO_PC_HOST (Pin 3)
  • SCLK (Pin 23) <-> SCK_PC_HOST (Pin 4)
  • CE0 (Pin 24) <-> CSN_PC_HOST (Pin 1)
  • GND (Pin 25) <-> GND (Pin 5)

Software installation

Download a Raspbian image to be installed on Raspberry Pi's SD card, for example the "Raspbian Jessie Lite" that can be found here: https://www.raspberrypi.org/downloads/raspbian/

Refer to following guide to setup your SD card with the downloaded image:https://www.raspberrypi.org/documentation/installation/installing-images/

Connect to the Raspberry Pi host

Once the SD card is flashed, insert it in the Raspberry Pi and choose a way to login Raspberry Pi:

  • HDMI monitor and USB keyboard directly plugged on the RPi
  • UART terminal (using a USB to TTL serial cable)
  • SSH client through LAN connection

Enable SPI driver on Raspberry Pi

The SPI peripheral is not turned on by default. To enable it, do the following.

  • Run sudo raspi-config.
  • Use the down arrow to select 9 Advanced Options
  • Arrow down to A6 SPI.
  • Select yes when it asks you to enable SPI
  • Also select yes when it asks about automatically loading the kernel module.
  • Use the right arrow to select the button.
  • Select yes when it asks to reboot.

The system will reboot. When it comes back up, log in and enter the following command ls /dev/*spi*

The Pi should respond with /dev/spidev0.0 /dev/spidev0.1

Get the latest software for Semtech (SX1301 driver/HAL and Packet Forwarder)

The Raspberry Pi needs to have a working internet access, either through its ethernet port, or through a WiFi dongle.

Compile SX1301 driver/HAL and Packet Forwarder

cd ~/lora_gateway

make all

cd ~/packet_forwarder

make all

Run the "basic" Packet Forwarder

Before launching the packet forwarder, there are few parameters to be set in the associated configuration files, global_conf.json and local_conf.json.

Update the "gateway_ID":

The gateway ID is a unique identifier to identify a gateway on a server. It can be for example a EUI-64 converted from the 48-bits MAC address. Edit the local_conf.json file and change the default "gateway_ID field" by the EUI-64 you want to assign to your gateway.

Use the proper flavour of global_conf.json:

Several versions of global_conf.json are provided to match with either the GW ref design 1.0 or 1.5, and to describe the desired packet forwarder flavour (basic, gps, beacon). So depending on the board you are using, replace the global_conf.json file with:

  • lora_pkt_fwd/cfg/global_conf.json.PCB_E336.EU868.basic for a basic packet forwarder on GW v1.5
  • lora_pkt_fwd/cfg/global_conf.json.PCB_E286.EU868.beacon for gps+beacon packet forwarder on GW v1.0
Update the server address to your network server

Set the server_address field of the global_conf.json file to the IP address or hostname of your LoRa Network Server.

Run the packet forwarder

cd ~/packet_forwarder/lora_pkt_fwd

./lora_pkt_fwd

CPSS_DXCH_PACKET_ANALYZER_FIELD_LOCAL_DEV_SRC_IS_TRUNK_E, /** local dev src port */ CPSS_DXCH_PACKET_ANALYZER_FIELD_LOCAL_DEV_SRC_PORT_E, /** local dev src trunk id */ CPSS_DXCH_PACKET_ANALYZER_FIELD_LOCAL_DEV_SRC_TRUNK_ID_E, /** local dev src eport */ CPSS_DXCH_PACKET_ANALYZER_FIELD_LOCAL_DEV_SRC_EPORT_E, /** local dev trg phy port */ CPSS_DXCH_PACKET_ANALYZER_FIELD_LOCAL_DEV_TRG_PHY_PORT_E, /** Orig Is Trunk */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_IS_TRUNK_E, /** Orig Src_Dev */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_SRC_DEV_E, /** Orig Src Phy Is Trunk */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_SRC_PHY_IS_TRUNK_E, /** Orig Src Phy Port or Trunk ID */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_SRC_PHY_PORT_OR_TRUNK_ID_E, /** Orig Src Trunk ID */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_SRC_TRUNK_ID_E, /** trg eport */ CPSS_DXCH_PACKET_ANALYZER_FIELD_TRG_EPORT_E, /** trg phy port */ CPSS_DXCH_PACKET_ANALYZER_FIELD_TRG_PHY_PORT_E, /**@brief L2 */ /** mac sa */ CPSS_DXCH_PACKET_ANALYZER_FIELD_MAC_SA_E, /** mac da */ CPSS_DXCH_PACKET_ANALYZER_FIELD_MAC_DA_E, /** orig vid */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ORIG_VID_E, /** evidx */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EVIDX_E, /** evlan */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EVLAN_E, /** ether type */ CPSS_DXCH_PACKET_ANALYZER_FIELD_ETHER_TYPE_E, /**@brief L3 */ /** ipv4_sip */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPV4_SIP_E, /** ipv4 dip */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPV4_DIP_E, /** ipv6 sip */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPV6_SIP_E, /** ipv6 dip */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPV6_DIP_E, /** ipx protocol */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPX_PROTOCOL_E, /** dscp */ CPSS_DXCH_PACKET_ANALYZER_FIELD_DSCP_E, /**@brief MetaData */ /** Byte Count */ CPSS_DXCH_PACKET_ANALYZER_FIELD_BYTE_COUNT_E, /** is ip */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IS_IP_E, /** is ipv4 */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IS_IPV4_E, /** is ipv6 */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IS_IPV6_E, /** ip legal */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IP_LEGAL_E, /** ipm */ CPSS_DXCH_PACKET_ANALYZER_FIELD_IPM_E, /** l4 valid */ CPSS_DXCH_PACKET_ANALYZER_FIELD_L4_VALID_E, /** mac to me */ CPSS_DXCH_PACKET_ANALYZER_FIELD_MAC_TO_ME_E, /** packet cmd */ CPSS_DXCH_PACKET_ANALYZER_FIELD_PACKET_CMD_E, /** Queue Port */ CPSS_DXCH_PACKET_ANALYZER_FIELD_QUEUE_PORT_E, /** Queue Priority */ CPSS_DXCH_PACKET_ANALYZER_FIELD_QUEUE_PRIORITY_E, /** use vidx */ CPSS_DXCH_PACKET_ANALYZER_FIELD_USE_VIDX_E, /** egress filter drop */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_FILTER_DROP_E, /** egress filter en */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_FILTER_EN_E, /** egress filter registered */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_FILTER_REGISTERED_E, /** cpu code */ CPSS_DXCH_PACKET_ANALYZER_FIELD_CPU_CODE_E, /** marvell tagged */ CPSS_DXCH_PACKET_ANALYZER_FIELD_MARVELL_TAGGED_E, /** marvell tagged extended */ CPSS_DXCH_PACKET_ANALYZER_FIELD_MARVELL_TAGGED_EXTENDED_E, /** bypass bridge */ CPSS_DXCH_PACKET_ANALYZER_FIELD_BYPASS_BRIDGE_E, /** bypass ingress pipe */ CPSS_DXCH_PACKET_ANALYZER_FIELD_BYPASS_INGRESS_PIPE_E, /** tunnel start */ CPSS_DXCH_PACKET_ANALYZER_FIELD_TUNNEL_START_E, /** tunnel terminated */ CPSS_DXCH_PACKET_ANALYZER_FIELD_TUNNEL_TERMINATED_E, /** egress packet cmd */ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_PACKET_CMD_E, /** packet_trace **/ CPSS_DXCH_PACKET_ANALYZER_FIELD_PACKET_TRACE_E, /** outgoing_mtag_cmd **/ CPSS_DXCH_PACKET_ANALYZER_FIELD_OUTGOING_MTAG_CMD_E, /** queue_offset **/ CPSS_DXCH_PACKET_ANALYZER_FIELD_QUEUE_OFFSET_E, /** egress_mac_da **/ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_MAC_DA_E, /** egress_mac_sa **/ CPSS_DXCH_PACKET_ANALYZER_FIELD_EGRESS_MAC_SA_E,帮我把上面这个枚举转化为字符串数组,枚举号对应数组下标
最新发布
10-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值