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
12 changes: 12 additions & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Host
CHIRPSTACK_HOSTNAME=

#Postgres
POSTGRES_DSN=
POSTGRESQL_CA_CERT=/certs/rds-combined-ca-bundle.pem

#IOT Core
AWS_IOT_ENDPOINT=

#Redis
REDIS_SERVER=
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# hidden files, exluding gitattributes
.*
!.gitattributes
!.env_example

# data folder
/data
/lorawan-devices

# Ignore environment files
.env
.env.*

/configuration/chirpstack/mqtt_*
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,25 @@ You should be able to access the UI by opening http://localhost:8090 in your bro

**Note:** It is recommended to use the [gRPC](https://www.chirpstack.io/docs/chirpstack/api/grpc.html)
interface over the [REST](https://www.chirpstack.io/docs/chirpstack/api/rest.html) interface.

## Setup Instructions

### 1. Download RDS CA Certificate Bundle
Amazon RDS requires SSL/TLS for secure connections. Download the combined CA bundle:

```bash
curl https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem -o rds-combined-ca-bundle.pem
```

### 2. Enable Required PostgreSQL Extension
Execute the command below in the database.
```bash
CREATE EXTENSION IF NOT EXISTS pg_trgm;
```

### 3. Run ChirpStack with Docker Compose
```bash
docker-compose up -d
docker-compose up -d --force-recreate --no-deps
docker-compose down
```
31 changes: 26 additions & 5 deletions configuration/chirpstack/chirpstack.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
# * disable - Do not use TLS
# * prefer - Attempt to connect with TLS but allow sessions without
# * require - Require the use of TLS
dsn="postgres://chirpstack:chirpstack@$POSTGRESQL_HOST/chirpstack?sslmode=disable"
dsn = "$POSTGRESQL__DSN"

# NEW in v4.7+: path to the CA used to validate the server cert
ca_cert = "$POSTGRESQL__CA__CERT"

automigrate = true

# Max open connections.
#
Expand All @@ -39,9 +44,10 @@
# Server address or addresses.
#
# Set multiple addresses when connecting to a cluster.
servers=[
"redis://$REDIS_HOST/",
]
servers=["$REDIS__SERVER"]

pool_size=20
database=0

# TLS enabled.
tls_enabled=false
Expand Down Expand Up @@ -81,6 +87,13 @@
"us915_1",
]

[network]
# Maximum items in the downlink queue per device.
max_device_queue_size=16

# Optional expiration (if supported by your version).
device_queue_expiration="168h" # 7 days


# API interface configuration.
[api]
Expand All @@ -101,5 +114,13 @@
enabled=["mqtt"]

[integration.mqtt]
server="tcp://$MQTT_BROKER_HOST:1883/"
server="$AWS__IOT__ENDPOINT"
json=true

client_id="as-$CHIRPSTACK__ENVIRONMENT-$CHIRPSTACK__HOSTNAME-app"
event_topic="$CHIRPSTACK__ENVIRONMENT/application/{{application_id}}/device/{{dev_eui}}/event/{{event}}"
command_topic="$CHIRPSTACK__ENVIRONMENT/application/{{application_id}}/device/{{dev_eui}}/command/{{command}}"

tls_cert="/etc/chirpstack/mqtt_cert.crt"
tls_key="/etc/chirpstack/mqtt_key.key"
ca_cert="/etc/chirpstack/mqtt_ca.pem"
6 changes: 5 additions & 1 deletion configuration/chirpstack/region_eu868.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@
# Set the client id to be used by this client when connecting to the MQTT
# broker. A client id must be no longer than 23 characters. If left blank,
# a random id will be generated by ChirpStack.
client_id=""
client_id="ns-$CHIRPSTACK__ENVIRONMENT-$CHIRPSTACK__HOSTNAME-eu868"

# Must match your GB templates (no $share here)
event_topic="$CHIRPSTACK__ENVIRONMENT/eu868/gateway/+/event/+"
command_topic="$CHIRPSTACK__ENVIRONMENT/eu868/gateway/{{ gateway_id }}/command/{{ command }}"

# Keep alive interval.
#
Expand Down
6 changes: 5 additions & 1 deletion configuration/chirpstack/region_us915_1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@
# Set the client id to be used by this client when connecting to the MQTT
# broker. A client id must be no longer than 23 characters. If left blank,
# a random id will be generated by ChirpStack.
client_id=""
client_id="ns-$CHIRPSTACK__ENVIRONMENT-$CHIRPSTACK__HOSTNAME-us9151"

# Must match your GB templates (no $share here)
event_topic="$CHIRPSTACK__ENVIRONMENT/us915_1/gateway/+/event/+"
command_topic="$CHIRPSTACK__ENVIRONMENT/us915_1/gateway/{{ gateway_id }}/command/{{ command }}"

# Keep alive interval.
#
Expand Down
50 changes: 19 additions & 31 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
services:
chirpstack:
image: chirpstack/chirpstack:4
hostname: ${CHIRPSTACK_HOSTNAME}
command: -c /etc/chirpstack
restart: unless-stopped
env_file:
- .env
volumes:
- ./configuration/chirpstack:/etc/chirpstack
- ./rds-combined-ca-bundle.pem:/certs/rds-combined-ca-bundle.pem:ro
depends_on:
- postgres
- mosquitto
- redis
environment:
- MQTT_BROKER_HOST=mosquitto
- REDIS_HOST=redis
- POSTGRESQL_HOST=postgres
- AWS__IOT__ENDPOINT=${AWS_IOT_ENDPOINT}
- CHIRPSTACK__HOSTNAME=${CHIRPSTACK_HOSTNAME}
- CHIRPSTACK__ENVIRONMENT=${CHIRPSTACK_ENVIRONMENT}
- POSTGRESQL__DSN=${POSTGRES_DSN}
- POSTGRESQL__CA__CERT=${POSTGRESQL_CA_CERT}
- REDIS__SERVER=${REDIS_SERVER}
ports:
- "8080:8080"

Expand All @@ -24,12 +30,16 @@ services:
volumes:
- ./configuration/chirpstack-gateway-bridge:/etc/chirpstack-gateway-bridge
environment:
- INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/event/{{ .EventType }}
- INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/state/{{ .StateType }}
- INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=eu868/gateway/{{ .GatewayID }}/command/#
- CHIRPSTACK__HOSTNAME=${CHIRPSTACK_HOSTNAME}
- CHIRPSTACK__ENVIRONMENT=${CHIRPSTACK_ENVIRONMENT} # or dev/prod; MUST exist for GB
- INTEGRATION__MQTT__SERVER=tcp://mosquitto:1883 # <- broker for GB
- INTEGRATION__MQTT__CLIENT_ID=gb-${CHIRPSTACK_ENVIRONMENT}-${CHIRPSTACK_HOSTNAME}
- INTEGRATION__MQTT__EVENT_TOPIC_TEMPLATE=${CHIRPSTACK_ENVIRONMENT}/us915_1/gateway/{{ .GatewayID }}/event/{{ .EventType }}
- INTEGRATION__MQTT__STATE_TOPIC_TEMPLATE=${CHIRPSTACK_ENVIRONMENT}/us915_1/gateway/{{ .GatewayID }}/state/{{ .StateType }}
- INTEGRATION__MQTT__COMMAND_TOPIC_TEMPLATE=$$share/${CHIRPSTACK_ENVIRONMENT}-gbgrp/${CHIRPSTACK_ENVIRONMENT}/us915_1/gateway/{{ .GatewayID }}/command/#
depends_on:
- mosquitto

chirpstack-gateway-bridge-basicstation:
image: chirpstack/chirpstack-gateway-bridge:4
restart: unless-stopped
Expand All @@ -50,32 +60,10 @@ services:
depends_on:
- chirpstack

postgres:
image: postgres:14-alpine
restart: unless-stopped
volumes:
- ./configuration/postgresql/initdb:/docker-entrypoint-initdb.d
- postgresqldata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=chirpstack
- POSTGRES_PASSWORD=chirpstack
- POSTGRES_DB=chirpstack

redis:
image: redis:7-alpine
restart: unless-stopped
command: redis-server --save 300 1 --save 60 100 --appendonly no
volumes:
- redisdata:/data

mosquitto:
image: eclipse-mosquitto:2
restart: unless-stopped
ports:
- "1883:1883"
volumes:
volumes:
- ./configuration/mosquitto/config/:/mosquitto/config/

volumes:
postgresqldata:
redisdata:
Loading