I have a following task. I should communicate between Chirpstack network server and Python. I have found that Python has a Paho library which can help me out here, but I am still not quite sure about the configuration I need here. My plan is to implement some kind of algorithm in Python for calculating references and then send those references (among some other things) as downlink messages to my end devices.
What is confusing me is the question do I also need to install Node red in order to integrate chirpstack with python or will the two without node red suffice? Any guidelines on this problem will be greatly appreciated.
I am using X-Logic XWG1 LoraWAN Gateway and STM32 Nucleo WL55JC1 as an end node. So far, I have successfully registered both of them on the network server and tested communication with sending some uplinks and downlinks.
You can use a MQTT client in Python to subscribe to events and enqueue downlinks. Or you could create a HTTP endpoint in Python and use the gRPC API for enqueuing downlinks.
thank You for replying in such a short notice. What do You think is the better way to approach this problem? What do You recommend? Also, do You know where can I find some examples of this or?
The best approach would be the one that fits your architecture best Using the gRPC for downlink enqueue has the benefit that you get an immediate response back (e.g. OK response or error). With MQTT enqueue, there is no response.
With regards to handling HTTP events in Python, see:
after I have tried to enqueue downlink according to the links You have provided me, I ran into some kind of issues and was not able to find anything on the internet regarding that.
Traceback (most recent call last):
File “c:\Users\RENS\Desktop\Python\script.py”, line 35, in
resp = client.Enqueue(req, metadata=auth_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\RENS\AppData\Local\Programs\Python\Python312\Lib\site-packages\grpc_channel.py”, line 1181, in call
return _end_unary_response_blocking(state, call, False, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\RENS\AppData\Local\Programs\Python\Python312\Lib\site-packages\grpc_channel.py”, line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = “”
debug_error_string = “UNKNOWN:Error received from peer {created_time:“2024-05-13T11:23:53.0060217+00:00”, grpc_status:16, grpc_message:”“}”
It looks like your API calls aren’t properly authenticating with the Chirpstack server. Are you sure your API token is correct? If thats not the problem can you share the code you used?
I have tried to generate new API key from my chirpstack server several times, but every time I get the same error. Do You think that the error might be coming from wrong Dev_EUI? Right now, I do not have any devices connected because I am waiting for the new equipment.
another question. I want to access API token from outer application (Python) and I am using this code, but unfortunately I keep getting the same error.
yes, that makes sense, but what I am trying to achieve with this code I pasted yesterday, is to create a python script for obtaining API token automatically, but unfortunately do not have any luck with that.