drop support for C# FNE masters; add support to send group aff, unit reg and unit dereg transfer packets;

pull/1/head
Bryan Biedenkapp 2 years ago
parent ff5d4cf1c8
commit e3220ac473

@ -522,26 +522,6 @@ namespace fnecore
}
} // public class PeerConnectedEvent : EventArgs
/// <summary>
/// Type of FNE instance.
/// </summary>
public enum FneType : byte
{
/// <summary>
/// Master
/// </summary>
MASTER,
/// <summary>
/// Peer
/// </summary>
PEER,
/// <summary>
/// Unknown (should never happen)
/// </summary>
UNKNOWN = 0xFF
} // public enum FneType : byte
/// <summary>
/// This class implements some base functionality for all other FNE network classes.
/// </summary>
@ -553,7 +533,6 @@ namespace fnecore
protected static Random rand = null;
protected bool isStarted = false;
protected FneType fneType;
/*
** Properties
@ -574,11 +553,6 @@ namespace fnecore
/// </summary>
public bool IsStarted => isStarted;
/// <summary>
/// Gets the <see cref="FneType"/> this <see cref="FneBase"/> is.
/// </summary>
public FneType FneType => fneType;
/// <summary>
/// Gets/sets the interval that peers will need to ping the master.
/// </summary>
@ -691,8 +665,6 @@ namespace fnecore
this.systemName = systemName;
this.peerId = peerId;
this.fneType = FneType.UNKNOWN;
// set a default "noop" logger
Logger = (LogLevel level, string message) => { };
}

File diff suppressed because it is too large Load Diff

@ -130,8 +130,6 @@ namespace fnecore
/// <param name="endpoint"></param>
public FnePeer(string systemName, uint peerId, IPEndPoint endpoint) : base(systemName, peerId)
{
fneType = FneType.PEER;
masterEndpoint = endpoint;
client = new UdpReceiver();
@ -143,7 +141,7 @@ namespace fnecore
}
/// <summary>
/// Starts the main execution loop for this <see cref="FneMaster"/>.
/// Starts the main execution loop for this <see cref="FnePeer"/>.
/// </summary>
public override void Start()
{
@ -170,7 +168,7 @@ namespace fnecore
}
/// <summary>
/// Stops the main execution loop for this <see cref="FneMaster"/>.
/// Stops the main execution loop for this <see cref="FnePeer"/>.
/// </summary>
public override void Stop()
{
@ -256,6 +254,50 @@ namespace fnecore
SendMaster(opcode, message, pktSeq());
}
/// <summary>
/// Helper to send group affiliation announcements to the master.
/// </summary>
/// <param name="srcId"></param>
/// <param name="dstId"></param>
public void SendMasterGroupAffiliation(uint srcId, uint dstId)
{
// send message to master
byte[] res = new byte[6];
FneUtils.Write3Bytes(srcId, ref res, 0);
FneUtils.Write3Bytes(dstId, ref res, 3);
SendMaster(CreateOpcode(Constants.NET_FUNC_TRANSFER, Constants.NET_ANNC_SUBFUNC_GRP_AFFIL), res, 0);
}
/// <summary>
/// Helper to send unit registration announcements to the master.
/// </summary>
/// <param name="srcId"></param>
public void SendMasterUnitRegistration(uint srcId)
{
// send message to master
byte[] res = new byte[3];
FneUtils.Write3Bytes(srcId, ref res, 0);
SendMaster(CreateOpcode(Constants.NET_FUNC_TRANSFER, Constants.NET_ANNC_SUBFUNC_UNIT_REG), res, 0);
}
/// <summary>
/// Helper to send unit deregistration announcements to the master.
/// </summary>
/// <param name="srcId"></param>
public void SendMasterUnitDeRegistration(uint srcId)
{
// send message to master
byte[] res = new byte[3];
FneUtils.Write3Bytes(srcId, ref res, 0);
SendMaster(CreateOpcode(Constants.NET_FUNC_TRANSFER, Constants.NET_ANNC_SUBFUNC_UNIT_DEREG), res, 0);
}
/// <summary>
/// Helper to update the RTP packet sequence.
/// </summary>

@ -123,7 +123,7 @@ namespace fnecore
/// </summary>
public abstract class FneSystemBase
{
protected FneBase fne;
protected FnePeer fne;
protected const int DMR_FRAME_LENGTH_BYTES = 33;
protected const int DMR_PACKET_SIZE = 55;
@ -178,19 +178,6 @@ namespace fnecore
}
}
/// <summary>
/// Gets the <see cref="FneType"/> this <see cref="FneBase"/> is.
/// </summary>
public FneType FneType
{
get
{
if (fne != null)
return fne.FneType;
return FneType.UNKNOWN;
}
}
/*
** Methods
*/
@ -198,9 +185,9 @@ namespace fnecore
/// <summary>
/// Initializes a new instance of the <see cref="FneSystemBase"/> class.
/// </summary>
/// <param name="fne">Instance of <see cref="FneMaster"/> or <see cref="FnePeer"/></param>
/// <param name="fne">Instance of <see cref="FnePeer"/></param>
/// <param name="fneLogLevel"></param>
public FneSystemBase(FneBase fne, LogLevel fneLogLevel = LogLevel.INFO)
public FneSystemBase(FnePeer fne, LogLevel fneLogLevel = LogLevel.INFO)
{
this.fne = fne;
@ -490,22 +477,9 @@ namespace fnecore
Buffer.BlockCopy(raw, 0, payload, 24, raw.Length);
payload[23U] = (byte)(P25_MSG_HDR_SIZE + raw.Length);
// what type of FNE are we?
if (FneType == FneType.MASTER)
{
FneMaster master = (FneMaster)fne;
lock (master.Peers)
{
foreach (uint peerId in master.Peers.Keys)
master.SendPeer(peerId, FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, 0, callData.TxStreamID);
}
}
else if (FneType == FneType.PEER)
{
FnePeer peer = (FnePeer)fne;
ushort pktSeq = peer.pktSeq(true);
peer.SendMaster(FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, pktSeq, callData.TxStreamID);
}
FnePeer peer = (FnePeer)fne;
ushort pktSeq = peer.pktSeq(true);
peer.SendMaster(FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, pktSeq, callData.TxStreamID);
}
/// <summary>
@ -523,22 +497,9 @@ namespace fnecore
if (grantDemand)
payload[14U] |= 0x80;
// what type of FNE are we?
if (FneType == FneType.MASTER)
{
FneMaster master = (FneMaster)fne;
lock (master.Peers)
{
foreach (uint peerId in master.Peers.Keys)
master.SendPeer(peerId, FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, 0, callData.TxStreamID);
}
}
else if (FneType == FneType.PEER)
{
FnePeer peer = (FnePeer)fne;
ushort pktSeq = peer.pktSeq(true);
peer.SendMaster(FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, pktSeq, callData.TxStreamID);
}
FnePeer peer = (FnePeer)fne;
ushort pktSeq = peer.pktSeq(true);
peer.SendMaster(FneBase.CreateOpcode(Constants.NET_FUNC_PROTOCOL, Constants.NET_PROTOCOL_SUBFUNC_P25), payload, pktSeq, callData.TxStreamID);
}
} // public abstract class FneSystemBase
} // namespace fnecore

Loading…
Cancel
Save

Powered by TurnKey Linux.