Hi,
I am creating some Python scripts to configure tenant, user, gateways, devices… So far, so good. Thanks to brocaar for his work.
There is one thing that I did not find in the documentation. To create a device profile, there are some constants e.g., for the region, the MAC version, etc. I did not find how to include them in Python. So, I am using directly the values from https://github.com/chirpstack/chirpstack/blob/master/api/proto/common/common.proto . For example:
req = api.CreateDeviceProfileRequest()
req.device_profile.tenant_id = TENANTID
req.device_profile.name = DEVICEPROFILENAME
req.device_profile.description = DEVICEPROFILEDESCRIPTION
# Values from https://github.com/chirpstack/chirpstack/blob/master/api/proto/common/common.proto
req.device_profile.region = 0 # Region.EU868
req.device_profile.mac_version = 3 # LORAWAN_1_0_3
req.device_profile.reg_params_revision = 0 # A
req.device_profile.adr_algorithm_id = "default" # Default ADR algorithm (LoRa only)
req.device_profile.flush_queue_on_activate = True
(...)
Is there a Python library so I can import and use these constants (e.g. xxx.LORAWAN_1_0_3 instead of its value 3).
Thanks!
BRs,
Jorge
brocaar
November 15, 2023, 2:40pm
2
I believe these are there:
pip install chirpstack_api==4.5.1
python
Python 3.10.13 (main, Aug 24 2023, 12:59:26) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from chirpstack_api import common
>>> help(common)
Help on package chirpstack_api.common in chirpstack_api:
NAME
chirpstack_api.common
PACKAGE CONTENTS
common_pb2
common_pb2_grpc
DATA
A = 0
ABSOLUTE = 1
AS923 = 7
AS923_2 = 12
AS923_3 = 13
AS923_4 = 14
AU915 = 5
Aggregation = <google.protobuf.internal.enum_type_wrapper.EnumTypeWrap...
B = 1
CLASS_A = 0
CLASS_B = 1
CLASS_C = 2
CN470 = 6
CN779 = 3
CONFIG = 2
CONFIRMED_DATA_DOWN = 5
CONFIRMED_DATA_UP = 4
COUNTER = 0
DAY = 1
DESCRIPTOR = <google.protobuf.descriptor.FileDescriptor object>
DeviceClass = <google.protobuf.internal.enum_type_wrapper.EnumTypeWrap...
EU433 = 4
EU868 = 0
FSK = 1
GAUGE = 2
GEO_RESOLVER_GNSS = 5
GEO_RESOLVER_RSSI = 4
GEO_RESOLVER_TDOA = 3
GEO_RESOLVER_WIFI = 6
GPS = 1
HOUR = 0
IN865 = 9
ISM2400 = 11
JOIN_ACCEPT = 1
JOIN_REQUEST = 0
KR920 = 8
LORA = 0
LORAWAN_1_0_0 = 0
LORAWAN_1_0_1 = 1
LORAWAN_1_0_2 = 2
LORAWAN_1_0_3 = 3
LORAWAN_1_0_4 = 4
LORAWAN_1_1_0 = 5
LR_FHSS = 2
LocationSource = <google.protobuf.internal.enum_type_wrapper.EnumTypeW...
MONTH = 2
MType = <google.protobuf.internal.enum_type_wrapper.EnumTypeWrapper ob...
...
Thanks so much. I will test this later and post the results. Thanks again.
BRs,
Jorge
system
Closed
February 13, 2024, 4:31pm
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.