Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
8 changes: 4 additions & 4 deletions basic_pkt_fwd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ LGW_INC += $(LGW_PATH)/inc/loragw_hal.h
### Linking options

ifeq ($(CFG_SPI),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(CFG_SPI),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(CFG_SPI),mac)
$(error [error] Option mac not supported for SPI here)
else
# keep compatibility with SX1301 HAL version 1.2.x and bellow
ifeq ($(LGW_PHY),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(LGW_PHY),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(LGW_PHY),mac)
$(error [error] Option mac not supported for SPI here)
else
Expand Down
8 changes: 4 additions & 4 deletions beacon_pkt_fwd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ LGW_INC += $(LGW_PATH)/inc/loragw_gps.h
### Linking options

ifeq ($(CFG_SPI),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(CFG_SPI),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(CFG_SPI),mac)
$(error [error] Option mac not supported for SPI here)
else
# keep compatibility with SX1301 HAL version 1.2.x and bellow
ifeq ($(LGW_PHY),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(LGW_PHY),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(LGW_PHY),mac)
$(error [error] Option mac not supported for SPI here)
else
Expand Down
8 changes: 4 additions & 4 deletions gps_pkt_fwd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ LGW_INC += $(LGW_PATH)/inc/loragw_gps.h
### Linking options

ifeq ($(CFG_SPI),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(CFG_SPI),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(CFG_SPI),mac)
$(error [error] Option mac not supported for SPI here)
else
# keep compatibility with SX1301 HAL version 1.2.x and bellow
ifeq ($(LGW_PHY),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(LGW_PHY),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(LGW_PHY),mac)
$(error [error] Option mac not supported for SPI here)
else
Expand Down
23 changes: 14 additions & 9 deletions poly_pkt_fwd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RELEASE_VERSION := $(shell cat ../VERSION)
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar

#CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
VFLAG := -D VERSION_STRING="\"$(RELEASE_VERSION)\""

Expand All @@ -36,24 +37,25 @@ LGW_INC += $(LGW_PATH)/inc/loragw_gps.h
### Linking options

ifeq ($(CFG_SPI),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(CFG_SPI),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(CFG_SPI),mac)
LIBS := -lloragw -lpthread -lmpsse
LIBS := -lloragw -lpthread -lmpsse -lm
else
# keep compatibility with SX1301 HAL version 1.2.x and bellow
ifeq ($(LGW_PHY),native)
LIBS := -lloragw -lrt -lpthread
LIBS := -lloragw -lrt -lpthread -lm
else ifeq ($(LGW_PHY),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
LIBS := -lloragw -lrt -lpthread -lmpsse -lm
else ifeq ($(LGW_PHY),mac)
LIBS := -lloragw -lpthread -lmpsse
LIBS := -lloragw -lpthread -lmpsse -lm
else
$(error [error] Can't find configuration for SPI phy)
endif
endif


### General build targets

all: $(APP_NAME)
Expand All @@ -73,15 +75,18 @@ obj/parson.o: src/parson.c inc/parson.h
obj/monitor.o: src/monitor.c inc/monitor.h
$(CC) -c $(CFLAGS) $< -o $@

obj/gpiolib.o: src/gpiolib.c inc/gpiolib.h
$(CC) -c $(CFLAGS) $< -o $@

obj/ghost.o: src/ghost.c inc/ghost.h $(LGW_INC)
$(CC) -I$(LGW_PATH)/inc -c $(CFLAGS) $< -o $@

### Main program compilation and assembly

obj/$(APP_NAME).o: src/$(APP_NAME).c $(LGW_INC) inc/parson.h inc/base64.h inc/ghost.h inc/monitor.h
obj/$(APP_NAME).o: src/$(APP_NAME).c $(LGW_INC) inc/parson.h inc/base64.h inc/ghost.h inc/monitor.h inc/gpiolib.h
$(CC) -c $(CFLAGS) $(VFLAG) -I$(LGW_PATH)/inc $< -o $@

$(APP_NAME): obj/$(APP_NAME).o $(LGW_PATH)/libloragw.a obj/parson.o obj/base64.o obj/ghost.o obj/monitor.o
$(CC) -L$(LGW_PATH) $< obj/parson.o obj/base64.o obj/ghost.o obj/monitor.o -o $@ $(LIBS)
$(APP_NAME): obj/$(APP_NAME).o $(LGW_PATH)/libloragw.a obj/parson.o obj/base64.o obj/ghost.o obj/monitor.o obj/gpiolib.o
$(CC) -L$(LGW_PATH) $< obj/parson.o obj/base64.o obj/ghost.o obj/monitor.o obj/gpiolib.o -o $@ $(LIBS)

### EOF
21 changes: 21 additions & 0 deletions poly_pkt_fwd/inc/gpiolib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef _GPIOLIB_H_

/* returns -1 or the file descriptor of the gpio value file */
int gpio_export(int gpio);
/* Set direction to 2 = high output, 1 low output, 0 input */
int gpio_direction(int gpio, int dir);
/* Release the GPIO to be claimed by other processes or a kernel driver */
void gpio_unexport(int gpio);
/* Single GPIO read */
int gpio_read(int gpio);
/* Set GPIO to val (1 = high) */
int gpio_write(int gpio, int val);
/* Set which edge(s) causes the value select to return */
int gpio_setedge(int gpio, int rising, int falling);
/* Blocks on select until GPIO toggles on edge */
int gpio_select(int gpio);

/* Return the GPIO file descriptor */
int gpio_getfd(int gpio);

#endif //_GPIOLIB_H_
25 changes: 25 additions & 0 deletions poly_pkt_fwd/local_conf-ic880a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
/* Put there parameters that are different for each gateway (eg. pointing one gateway to a test server while the others stay in production) */
/* Settings defined in global_conf will be overwritten by those in local_conf */
"gateway_conf": {
/* you must pick a unique 64b number for each gateway (represented by an hex string) */
"gateway_ID": "AA555A000004BABA",
/* Email of gateway operator, max 40 chars*/
"contact_email": "operator@gateway.tst",
/* Public description of this device, max 64 chars */
"description": "Update me",

/* For ic880A plate */
/* https://github.com/ch2i/iC880A-Raspberry-PI */
"led_heartbeat": 4, /* GPIO4 Blue */
"led_down": 18, /* GPIO18 White */
"led_error": 23, /* GPIO23 Red */
"led_packet": 24, /* GPIO24 Green */

/* Enter VALID GPS coordinates below before enabling fake GPS */
"fake_gps": false,
"ref_latitude": 10,
"ref_longitude": 20,
"ref_altitude": -1
}
}
23 changes: 23 additions & 0 deletions poly_pkt_fwd/local_conf-linklabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
/* Put there parameters that are different for each gateway (eg. pointing one gateway to a test server while the others stay in production) */
/* Settings defined in global_conf will be overwritten by those in local_conf */
"gateway_conf": {
/* you must pick a unique 64b number for each gateway (represented by an hex string) */
"gateway_ID": "AA555A000004BABA",
/* Email of gateway operator, max 40 chars*/
"contact_email": "operator@gateway.tst",
/* Public description of this device, max 64 chars */
"description": "Update me",

/* For Linklabs boards */
"pin_pps": 4, /* GPIO4 PPS from GPS */
"led_pps": 25, /* GPIO25 PPS RED */
"led_packet": 27, /* GPIO27 RED */

/* Enter VALID GPS coordinates below before enabling fake GPS */
"fake_gps": false,
"ref_latitude": 10,
"ref_longitude": 20,
"ref_altitude": -1
}
}
96 changes: 96 additions & 0 deletions poly_pkt_fwd/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,102 @@ up/down stream, all can be (de)activated by modifying the json.
To learn more about the network protocol between the gateway and the server,
please read the PROTOCOL.TXT document.

Specific Raspberry PI boards version features
=============================================

To be able to drive Raspbery PI concentrator on boards LED, this program
use ~~bcm2835 library, you need to install them before anything.
see http://www.airspayce.com/mikem/bcm2835/~~ gpiolib which control GPIO using
linux filesystem, making this packet forwarder more compatible with different
target.

This version has been written to works with Linklabs board and also with
ic880a concentrator + Raspberry Pi Plate.
https://github.com/ch2i/iC880A-Raspberry-PI

Option for LED are in the configuration file so it should works with
any board just adjusting GPIO settings. Settings are the following,
a name and the GPIO pin number. Names are :

- `led_heartbeat` LED used for hearbeat, will always blink when running
- `led_down` LED used for downstream, will blink on each downstream from server
- `led_error` LED used for hearbeat, will blink when a error occured
- `led_packet` LED will blink on each packet received
- `led_pps` LED used for GPS PPS indicator (mainly linklabs board)
- `pin_pps` Pin where PPS signal is connected to (if any, mainly linklabs board)
- `pin_reset` GPIO pin connected to SX1301 concentrator reset

GPS PPS pin on linklabs boards are not connected to LED but on a GPIO, so `led_pps`
and `pin_pps` are used for a "software link", incoming PPS signal going to GPIO input
is redirected to GPIO led output, thus for example, with linklabs, configuration can be


```json
"pin_pps": 4, /* GPIO4 PPS from GPS */
"led_pps": 25, /* GPIO25 PPS RED */
"led_packet": 27, /* GPIO27 RED */
```

for ic880a RPI plate (4 leds), configuration can be
```json
"led_heartbeat": 4, /* GPIO4 Blue */
"led_down": 18, /* GPIO18 White */
"led_error": 23, /* GPIO23 Red */
"led_packet": 24, /* GPIO24 Green */
"pin_reset": 17, /* GPIO17 concentrator reset */

```

And for RAK831 RPI Zero plate configuration can be (no led pins)
```json
"pin_reset": 25, /* GPIO25 concentrator reset */
```


An extented Log ouput on each packet received has also been added to this version, this
can be usefull for monitoring packet recevided by concentrator, regardless if they are or
not send the gateway. It's logged as info with the following informations

INFO: [#DeviceAddr] containing the device Addr (as seen on TTN dashboard) so you can
filter with a grep for example
`tail -f /var/log/lora_pkt_fwd.log | grep "\[\#"`

then it's followed by :

- `jRQ` for join request
- `jAC` for join accept
- `uUP` for unconfirmed up
- `uDN` for unconfirmed down
- `cUP` for confirmed up
- `cDN` for confirmed down
- `RFU` for RFU

Other following data are classic information of frame received. Here below an example of log

```
root@pi01(ro):~# tail -f /var/log/lora_pkt_fwd.log
INFO: [up] PUSH_ACK for server log.gatewaystats.org received in 26 ms
INFO: [down] for server log.gatewaystats.org PULL_ACK received in 25 ms
INFO: [#25FAAE33] RFU CRC:Bad Freq:867.30MHz ch:4 RFch:0 LORA[SF7 125Khz 2/3] RSSI:-107dB SNR:-11.5dB Size:232b
INFO: [down] for server router.eu.thethings.network PULL_ACK received in 40 ms
INFO: [down] for server log.gatewaystats.org PULL_ACK received in 26 ms
INFO: [#1DCDB85F] cUP CRC:OK Freq:867.10MHz ch:3 RFch:0 LORA[SF12 125Khz 4/5] RSSI:-65dB SNR:+9.0dB Size:16b Data:'gF+4zR0ArAEBqkBtIvDn+A=='
INFO: [up] PUSH_ACK for server router.eu.thethings.network received in 40 ms
INFO: [up] PUSH_ACK for server log.gatewaystats.org received in 26 ms
INFO: [down] for server router.eu.thethings.network serv_addr[ic]PULL_RESP received :)
INFO: [down] a packet will be sent on timestamp value 2481851356
INFO: [#87802833] jAC CRC:Bad Freq:867.50MHz ch:5 RFch:0 LORA[SF7 125Khz 4/7] RSSI:-107dB SNR:-11.0dB Size:20b
INFO: [down] for server router.eu.thethings.network PULL_ACK received in 43 ms
INFO: [#DD5343A9] jAC CRC:Bad Freq:868.10MHz ch:0 RFch:1 LORA[SF7 125Khz 4/5] RSSI:-105dB SNR:-7.0dB Size:23b
INFO: [#37F76D0D] jRQ CRC:Bad Freq:867.10MHz ch:3 RFch:0 LORA[SF7 125Khz 4/5] RSSI:-102dB SNR:-7.0dB Size:23b
INFO: [#1D57298D] uUP CRC:OK Freq:867.30MHz ch:4 RFch:0 LORA[SF7 125Khz 4/5] RSSI:-95dB SNR:-3.0dB Size:23b Data:'QI0pVx2ADgABMTFQD+MBsz7x6VL877c='
INFO: [#1D57298D] uUP CRC:OK Freq:867.50MHz ch:5 RFch:0 LORA[SF7 125Khz 4/5] RSSI:-49dB SNR:+7.5dB Size:23b Data:'QI0pVx2ADgABMTFQD+MBsz7x6VL877c='
INFO: [up] PUSH_ACK for server router.eu.thethings.network received in 42 ms
INFO: [up] PUSH_ACK for server log.gatewaystats.org received in 27 ms

```


2. System schematic and definitions
------------------------------------

Expand Down
Loading