Custom response to Device

Hello! I’m using Chirpstack V3 and I planning to migrate to V4 but I had customized the old version to intercep the response message when the device is connecting to server(after reboot or poweron). In the response message I add especific information to device to work correctly. In the custom code I get the ingormation data from database. My question is that:
V4 have an method to make it without changing the main Chirpstack code?

I’m thinking, I will need make an service to send the messages in intervals, but in my custom code I just send this message when the device need.

If you mean that you need to send downlinks in response to uplink messages, that is the role of the application server - which Chirpstack doesn’t really take the role of.
I would write an application that integrates with Chirpstack using one of its integration methods, to process and to respond to messages from the device.

After further investigation, I discovered that I would have to manipulate the DeviceTimeReq response, and to do so I would have to disable ChirpStack’s automatic response to this mac_command. Then I would have to create a service that responds to this command.
Is this possible?
Can I disable only the mac_command for DeviceTimeReq, or do I have to disable it for all mac_commands?

Hi,

I think I have a similar problem as the user above.
So I would try to explain my problem in this topic.

In my current setup, I have connected an ESP32 (LoRaWAN-End-Device) with my ChirpStack-All-In-One-Gateway (short gateway; RapberryPi 3B+ with ChirpStack-Software v4.10.2). The ESP32 communicates in LoRaWAN-Class-A.
On the other side of the gateway, I have connected my application over gRPC to it. For this, I use the python libraries grpc, api from chirpstack_api and common from chirpstack_api.

Currently I am trying to send an application-specific response message from my application to the ESP32 at that moment when the ESP32 has sent an uplink message to the gateway (forwarded to my application).

To do this, I’m streaming the LoRaWAN-Frames with api.StreamDeviceFramesRequest() from the gateway.
When a message is received by the application, it sends directly the response message with api.EnqueueDeviceQueueItemRequest().

Here you can see the function with which I try to send the response message:

 def send_downlink(self, DevEui, msg_byte_1, msg_byte_2):
        channel = grpc.insecure_channel(self.cs_server_ip+":"+self.cs_server_port)
        client = api.DeviceServiceStub(channel)
        auth_token = [("authorization", "Bearer %s" % self.cs_api_token)]

        try:
            hex_byte_message = (
            struct.pack('B', msg_byte_1) +
            struct.pack('B', msg_byte_2))

            req = api.EnqueueDeviceQueueItemRequest()

            req.queue_item.dev_eui = DevEui
            req.queue_item.confirmed = False
            req.queue_item.f_port = 10
            req.queue_item.data = bytes(hex_byte_message)

            resp = client.Enqueue(req, metadata=auth_token)
            return resp.id
            
        except grpc.RpcError as e:
            print(e)
            return False

Finally I can see the response message in the queue of the gateway. But it is not directly sent (forwarded) to the ESP32.
I think that the response message arrives to late in the queue of the gateway to forward it directly.
How ever, this message is only sent to the ESP32 with the next uplink message of the ESP32. (But so, this response message arrives to late at the ESP32).

I hope I could describe my problem in the best possible way.

Has anyone had a similar problem in the past or can help me to find a solution for this problem?

Thanks in advance.