Howto connect a Balena gateway to V2 and V3

Here is a quick howto that I use to connect a RPI Balena gateway with mp_pkt_fwd to both V2 and V3:
I do assume that the gateway is already registered to V2 and running.

  1. Create a gateway in V3.
    a. Give a name to the gateway (Gateway ID) no Gateway EUI!
    b. Choose the frequency plan “Europe 863-870 MHz (SF9 for RX2 - recommended)” which applies to my situation.
    c. Save it
  2. In V3 gateway select API Settings
    a. Select Add API key,
    b. Provide a name for the key
    c. Select “Grant Individual rights”
    d. select “link as Gateway to a Gateway Server for traffic exchange, i.e. write uplink and read downlink”
    e. click “Generate API Key”
    f. Copy the API key to your clipboard (and save it somewhere safe. You cannot read it anymore afterwards)
    g. click “I have copied the key”
  3. Browse to balena dashboard and login to Belena.
    a. Select the application of your gateway
    b. select the gateway that will be connected to V3
    c. In the “service variables” for your gateway add the following keys:
SERVER_2_ADDRESS    eu1.cloud.thethings.network:1881
SERVER_2_DOWNLINK   true
SERVER_2_GWID       <Gateway ID from step 1.b>
SERVER_2_GWKEY      <API-key from step 2.f>
SERVER_2_TYPE       ttn
SERVER_2_ENABLED    true
Please note that:
 - SERVER_2 is an arbitrary choice.
 - A more advanced configuration is possible for multiple gateways.
  1. Your Balena deployment will restart, with the new variables applied.
    a. The gateway will restart and connect to V3.
    b. The status will change and data will enter at “live data”

Resources:

One note on connecting to multiple servers by a single gateway: Fundamentally it is an unwanted situation to have a single gateway connected to multiple network servers. The reason for this is that only one network server can supervise the duty-cycle of a gateway. Network servers are unaware of the presence of each other and do not share the downlink airtime they used from a gateway.
In practice, I expect it to be very unlikely that a gateway is sending that much downlink data. This is because the traffic load is very low. On the other hand, the migration process that TTN users are being forced into is extremely obscure and measures, as proposed in this howto, are required.

9 Likes

You can omit

For server type ttn. These are only used for type Semtech.

3 Likes

Thanks for the confirmation. I updated the post.

This is great, well done all

Note, worked first time even without a restart on Balena which was odd, anyway - working, live data showing everything in triplicate mind

1 Like

Balena automatically restarts a container when environment variables are added/changed/removed.

3 Likes

Is the variable for the first server GW_ID and for the second GWID?
Is there a difference?

Is this solution still going to work when V2 goes down?

I followed these instructions and I have my gateways working on both V2 and V3…just wondering if I will need to do anything else to keep them working in the future.

As soon as V2 is shutdown the Balena code has to be refactored because it is currently using the V2 account server. W’ll keep an eye on that.

2 Likes

Did you meant “Device variables” or “Custom Configuration variables”? There are no “Service variables” anymore. Asking, because something is wronh in my configuration - receiving error “Unable to fetch configuration from TTN. Are your GW_ID and GW_KEY correct?”

If you are running the recently modified version of mp_pkt_fwd of @kersing on Balena I can say that these instructions are not valid.
Currently, I have the same problem with his version I have asked @kersing in a DM but have not received a response.

@pe1mew great, thank you. I have one old RPi 0 & RAK831, working in Balena in v2. The only way to keep alive this combination is to use the same balena image, but move from v2 to v3. There is no basic station balena image for RPi 0 :frowning:

For the first time in 5 years I took vacation time from the forum because I was away on a short break. There was an issue in the instructions in my github repository which I just fixed. To use the new stuff make sure to clone to an empty folder and fresh Balena application. (Or just update the python script in your existing application)

1 Like

These instructions helped my perfectly well to upgrade my RAK831 gateway from v2 to v3. works perfectly okay ! Now all I need to find out is how to respond to the Balena changes announced. any advice?

And you are referring to what changes??

Went eazy peazy, just had to restart my device to get it updated to new balena connection portal. I had not logged in to my dashboard for about a year, and found the announcement concerning access to balena.vpn shutting down soon, introducing cloudlink.balena-cloud.com

1 Like

n.b. about my RAK831 gw stack upgrade v2 to v3: I noticed the original GW_ID and GW_KEY device variables are still required and cannot be deleted. I had to put them back because my gw stopped functioning when deleting all the old ones and putting only the new ones.
Mentioning this might help any late upgraders (or am I really the last one?:slight_smile: