From b4f7f377a71198a78f1859d84b2c30f388969502 Mon Sep 17 00:00:00 2001 From: firealarmss Date: Sat, 8 Mar 2025 20:35:38 -0600 Subject: [PATCH] Add a helper function to send a NET_ANNC_SUBFUNC_AFFILS to the master --- FnePeer.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/FnePeer.cs b/FnePeer.cs index bff5c91..af1d508 100644 --- a/FnePeer.cs +++ b/FnePeer.cs @@ -24,6 +24,9 @@ using System.Text.Json; using fnecore.DMR; using fnecore.P25; using fnecore.NXDN; +using System.Collections.Generic; +using System.Net.NetworkInformation; +using System.Linq; namespace fnecore { @@ -273,7 +276,29 @@ namespace fnecore FneUtils.Write3Bytes(dstId, ref res, 3); SendMaster(CreateOpcode(Constants.NET_FUNC_ANNOUNCE, Constants.NET_ANNC_SUBFUNC_GRP_AFFIL), res, 0, 0, true); + } + + /// + /// Helper to send group affiliation dictionary to the master + /// + /// + public void SendMasterAffiliationUpdate(List> affs) + { + int bufferSize = 4 + (affs.Count * 8); + byte[] buffer = new byte[bufferSize]; + + FneUtils.WriteBytes((uint)affs.Count, ref buffer, 0); + + int offset = 4; + foreach (var entry in affs) + { + FneUtils.Write3Bytes(entry.Item1, ref buffer, offset); + FneUtils.Write3Bytes(entry.Item2, ref buffer, offset + 4); + + offset += 8; + } + SendMaster(CreateOpcode(Constants.NET_FUNC_ANNOUNCE, Constants.NET_ANNC_SUBFUNC_AFFILS), buffer, 0, 0, true); } ///