Send MAC commands issue

Hello,

I got this error when I am assigning MAC commands to the field commands
“Assignment not allowed to repeated field “commands” in protocol message object”
This is my code.

import grpc
from chirpstack_api.ns import NetworkServerServiceStub
from chirpstack_api.ns.ns_pb2 import CreateMACCommandQueueItemRequest

host = "localhost:8000"


channel = grpc.insecure_channel(host)

ns = NetworkServerServiceStub(channel)

macCmd = CreateMACCommandQueueItemRequest()


devStatusReq = bytes.fromhex("06")

linkAdrReq = bytes.fromhex("0357FF0001")
devEUI = "deadbeefdead0001"

# cList = [devStatusReq, linkAdrReq, devStatusReq]


cList = [linkAdrReq]
macCmd.dev_eui = bytes.fromhex(devEUI)
macCmd.cid = 3
macCmd.commands = cList
print(macCmd.dev_eui)
ns.CreateMACCommandQueueItem(macCmd)

@brocaar help

This is not a ChirpStack error I believe, but an error in your Python code. Could it be caused by?

macCmd.commands = cList

Hello @Mohamed_Hamnache, how did you solve the problem?

This causes

Assignment not allowed to repeated field “commands” in protocol message object

Per stackoverflow you have to extend or append to the already existing list (initially empty), so that would be

macCmd.commands.extend(cList)

This throws no error in my script.