First, congratulations for ChirpStack, which is a great tool.
For testing purposes, I need to send MAC commands to my device.
I did not find a service dedicated to sending MAC commands, so I tried with the “/api/devices{device_queue_item.dev_eui}/queue” service, but when I put an fPort value of 0 (indicating a MAC commands payload), the call is rejected.
{
“error”: “f_port must be > 0”,
“code”: 3,
“message”: “f_port must be > 0”,
“details”: []
}
Am I missing something, or is there another service for this purpose ?
Thank you very much for your support.
Michel Kuenemann
You can’t send downlink payloads from the application server either, but you can still queue them up there via API.
To answer the OP’s original question, since what you’re looking to do isn’t common enough to be exposed via the application server API, you may need to use the network server gRPC API:
I have installed the Chripstack gRPC api sucessfully and I am able to log to my Server thanks to the code example provided in the README.md file.
I am using Node.js
I have tested the createMACCommandQueueItem() service like this:
var grpc = require('grpc');
var networkServerService = require('@chirpstack/chirpstack-api/ns/ns_grpc_pb');
var networkServerServiceMessages = require('@chirpstack/chirpstack-api/ns/ns_pb');
const CSSIP = '192.168.1.4:8080';
const networkServerServiceClient = new networkServerService.NetworkServerServiceClient(
CSSIP,
grpc.credentials.createInsecure()
);
function main()
{
var dev = Buffer.from('8C192D70000700FF', 'hex');
var list = Buffer.from('06', 'hex');
var jCmd = {
devEui: dev,
cid: 6,
commandsList: list
};
var macCmd = new networkServerServiceMessages.CreateMACCommandQueueItemRequest( jCmd);
//console.log(macCmd);
networkServerServiceClient.createMACCommandQueueItem( macCmd, (response) => {
console.log(response);
});
}
}
main();
At run time I get the following error:
Error: 12 UNIMPLEMENTED: unknown service ns.NetworkServerService
Hi Michel,
I am also trying to learn how to send MAC commands for manual ADR,
Would you be able to post your complete working script please?
Best Wishes
Patrick
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.