Can MQTT relay be implemented?

The premise gateway bridge is installed on the raspberry pi.

I’m imagining that an MQTT relay is implemented on my notebook, which enables raspberry pi to send MQTT data to the notebook for processing. After that, the notebook sends MQTT data to the network server.

In fact, I am trying to reproduce the OPR Server function in a paper below:

It does play a role in forwarding MQTT data between the gateway and network server.

I believe that the network server they use is chirpstack: it is not only the references of chirpstack in this paper, but also the network architecture that can send mqtt data from gateway instead of UDP data from packet forwarder. At present, I have only seen it in chirpstack.

Here is the more specific working process:

Can we implement an MQTT broker, and receive the data sent by the gateway, store it in the database for processing, and then send the data in the specified format through an MQTT client to the network server? :joy:

It depends. You could have different topics for the gateways and for the network-server. Your service would sit in the middle and does the “mapping” from one set of topics to the other.
For example:
gateway --> raw/gateway/XXXX/YYYY --> OPR --> opr/gateway/XXXX/YYYY --> network-server
The Issue you might encounter thou is “timing”. Just consuming frames wont be such an Issue, but if you have to answer back, you have to be quick or else you will miss the window, this also applies to “plain” downlinks.

There are two problems:
how to receive the MQTT data in the gateway bridge format, and how to send the MQTT data in the format that the network server can receive.

1 Like

@shirou_Emiya I was looking at sending the data to additional broker. I think this is possible as the comments in the config file state that we can add another MQTT server. The problem that I was thinking of was decrypting the messages as we’d need the application/network keys for that, and I don’t think we can get them before the join request in case OTAA is the chosen one.

My question is how to decrypt the packet/payload at the additional broker if you have done something like that @chopmann @shirou_Emiya

I’d be very grateful for any responses.
Thank you!

You will have to “share” the keys. Using ABP is effectively sharing the keys.

@chopmann i see, thank you!

Do you have a reference to how to decrypt the packets/payload if received at another MQTT broker i.e. source code in any programming language or at least decryption method etc.

Probably the App-Server code is the best place to look at.
This might help:

I have no tried it yet.

My recent work is to implement a socket relay, but the MQTT part is not involved.