Make sure you have installed and configured your Go environment.
This procedure describes how to build the packet forwarder for a machine that can interact with a concentrator using SPI. If you build the packet forwarder on the machine itself, the SPI configuration will be dynamically determined. Otherwise, see the SPI configuration section to see how to specify the SPI configuration.
$ go get -u github.com/TheThingsNetwork/packet_forwarder
$ cd $GOPATH/src/github.com/TheThingsNetwork/packet_forwarder
$ make dev-deps
$ make deps
$ make build
The build will then be available in the release/
folder.
If the gateway you wish to build the packet forwarder for doesn't support compilation, you will need to specify the target platform through environment variables:
GOOS
: OS of the target machine, following one of the values supported by the Go toolchain. Example:GOARCH=linux
.GOARCH
: Architecture of the target machine, following one of the values supported by the Go toolchain. Example:GOARCH=amd64
,GOARCH=arm
.GOARM
: If building the packet forwarder for anarm
architecture, the ARM architecture to support. Example:GOARM=5
,GOARM=7
.CC
: thecc
compiler collection to use. Example:CC=arm-none-linux-gnueabi-gcc
,CC=arm-mlinux-gnuneabi-gcc
.CROSS_COMPILE
: the prefix of the compiler collections to use. Example:CROSS_COMPILE=arm-none-linux-gnueabi-
,CROSS_COMPILE=arm-mlinux-gnuneabi-
.
These environment variables need to be set just after the make dev-deps
step of the build process.
Note: in several cases, toolchain setup scripts will set some of those variables for you, such as with the Multitech toolchain.
If the build machine is different from the target machine, the SPI configuration can't be determined during the build process. You will then have to specify the configuration as a parameter.
-
If the target machine is a
kerlink
,imst_rpi
,linklabs_blowfish_rpi
orlorank
machine, the SPI configuration for those devices is already part of the HAL - you can build for those by specifyingPLATFORM=kerlink
,PLATFORM=lorank
, and such. You can seelora_gateway/libloragw/library.cfg
, once the dependencies have been installed. -
Otherwise, you can specify the parameters of the SPI interface with those parameters:
SPI_SPEED
(default:8000000
)SPIDEV
(default: the first/dev/spidev*
file found on the build machine)SPI_CS_CHANGE
(default:0
)VID
(default:0x0403
)PID
(default:0x6014
)
If the gateway you are running the packet forwarder has a GPS available, you can enable it by passing during the build the GPS_PATH
environment variable. This GPS_PATH
should point to the TTY path of the GPS. For example, on the Kerlink build, GPS_PATH=/dev/nmea
.