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.