Sending MAC Commands via Network Server API

Hello, I’m trying to send some MAC Commands (LinkCheckReq, LinkADRReq, etc) to my device in order to do some testing.

Based on some of the other posts in this forum, I’m using LoraServer’s gRPC API. I’ve generated a Python stub using the protos available here

I’ve also created the following client to send a simple LinkCheckReq to my device:

import grpc

# import the generated classes
import ns_pb2
import ns_pb2_grpc

# open a gRPC channel
channel = grpc.insecure_channel('my_sever_ip_here:8000')

# create a stub (client)
stub = ns_pb2_grpc.NetworkServerServiceStub(channel)

# Send MAC Command to Device Queue

# create a valid request message
request = ns_pb2.CreateMACCommandQueueItemRequest(
    dev_eui=bytes.fromhex('abcdabcdabcdabcd'),
    cid=2)

request.commands[:] = [bytes.fromhex('02')]

# make the call
response = stub.CreateMACCommandQueueItem(request)

I then expect to see a LinkCheckAns in the App Server GUI, but it doesn’t seem like anything happens.

Any idea what I’m doing wrong, or how I can investigate further?

I’m able to send a GetDevice Request with the same setup:

# create a valid request message
request = ns_pb2.GetDeviceRequest(dev_eui=bytes.fromhex('abcdabcdabcdabcd'))

# make the call
response = stub.GetDevice(request)

print(response)

and get a valid-looking response:

device {
  dev_eui: "foo"
  device_profile_id: "bar"
  service_profile_id: "foobar"
  routing_profile_id: "barfoo"
  skip_f_cnt_check: true
}
created_at {
  seconds: 1566078930
  nanos: 865545000
}
updated_at {
  seconds: 1568473358
  nanos: 687129000
}

Any help would be greatly appreciated!

You will not see mac-commands in the device payload queue. This is because mac-commands are not regular application payloads.

Thanks @brocaar!

How can I discover what is in the mac-command queue? How do I know if my command was successfully sent to the device (and if it was ack’d)?

I see some information in the LoraServer logs, but I’m having trouble interpreting.