I’m attempting to test a multicast scenario, but I’m having issues.
#1. Is there any relation to setting up a multicast-group in Applications web ui, and using grpc through node for example?
#2. I can’t seem to find a very comprehensive api guide for node js, am I missing something here? I’ve done the example to queue to a single device, but I can’t get over top dead center on anything else.
#3. The examples/class_c/main.go example in the fuota server would appear to create the session from scratch, vs a pre existing session, perhaps related to question #1.
My background is a reasonable amount of modern web coding and embedded development, so not really new to coding.
const grpc = require("@grpc/grpc-js");
const mc_grpc = require("@chirpstack/chirpstack-api/api/multicast_group_grpc_pb");
const multicast_group_pb = require("@chirpstack/chirpstack-api/api/multicast_group_pb");
const api_multicast_group_pb = require("@chirpstack/chirpstack-api/api/multicast_group_pb");
// This must point to the ChirpStack API interface.
const server = "noreply.somewhere.com";
// The DevEUI for which we want to enqueue the downlink.
const multicast_group_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx84f5";
// The API token (can be obtained through the ChirpStack web-interface).
const apiToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxNiJ9.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxeSJ9.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxqY6E";
// Create the client for the DeviceService.
const mcService = new mc_grpc.MulticastGroupServiceClient(
server,
grpc.credentials.createSsl(),
);
// Create the Metadata object.
const metadata = new grpc.Metadata();
metadata.set("authorization", "Bearer " + apiToken);
let req = new multicast_group_pb.EnqueueMulticastGroupQueueItemRequest();
let item = new multicast_group_pb.MulticastGroupQueueItem();
item.setMulticastGroupId(multicast_group_id);
item.setFPort(50);
item.setData(new Uint8Array([0xFE, 0xED, 0xBE, 0xEF]));
let device = new api_multicast_group_pb.AddDeviceToMulticastGroupRequest();
/* NOTE: Do this once for each device
device.setDevEui('xxxxxxxxxxxxx0e5');
device.setMulticastGroupId(multicast_group_id);
mcService.addDevice(device, metadata, (err, resp) => {
if (err !== null) {
console.log(err);
return;
}
console.log("Added device " + resp);
console.log("Time: " + new Date().getTime());
});*/
req.setQueueItem(item);
mcService.enqueue(req, metadata, (err, resp) => {
if (err !== null) {
console.log(err);
return;
}
console.log("MC Downlink has been enqueued with id: " + resp);
console.log("Time: " + new Date().getTime());
});