Skip to content

Commit

Permalink
Merge pull request #76 from meshtastic/wip
Browse files Browse the repository at this point in the history
Protobufs and add optional DTR and Handshake args to serial connection
  • Loading branch information
thebentern authored May 4, 2024
2 parents 093b3d7 + 496a995 commit 8daca8d
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 167 deletions.
12 changes: 7 additions & 5 deletions Meshtastic/Connections/SerialConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,24 @@ namespace Meshtastic.Connections;
public class SerialConnection : DeviceConnection
{
private readonly SerialPort serialPort;
private const Handshake DEFAULT_HANDSHAKE = Handshake.None;
private const bool DEFAULT_DTR_ENABLE = true;

public SerialConnection(ILogger logger, string port, int baudRate = Resources.DEFAULT_BAUD_RATE) : base(logger)
{
serialPort = new SerialPort(port, baudRate)
{
DtrEnable = true,
Handshake = Handshake.XOnXOff,
WriteBufferSize = 8,
DtrEnable = DEFAULT_DTR_ENABLE,
Handshake = DEFAULT_HANDSHAKE,
WriteBufferSize = 256,
};
}

public SerialConnection(ILogger logger,
string port,
DeviceStateContainer container,
bool dtrEnable = true,
Handshake handshake = Handshake.XOnXOff,
bool dtrEnable = DEFAULT_DTR_ENABLE,
Handshake handshake = DEFAULT_HANDSHAKE,
int baudRate = Resources.DEFAULT_BAUD_RATE) : base(logger)
{
serialPort = new SerialPort(port, baudRate)
Expand Down
2 changes: 1 addition & 1 deletion Meshtastic/Generated/Admin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public uint RemoveFavoriteNode {
public const int RemoveFixedPositionFieldNumber = 42;
/// <summary>
///
/// Clear fixed position coordinates and then set position.fixed_position = false
/// Clear fixed position coordinates and then set position.fixed_position = false
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
Expand Down
2 changes: 1 addition & 1 deletion Meshtastic/Generated/Atak.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public enum MemberRole {
#region Messages
/// <summary>
///
/// Packets for the official ATAK Plugin
/// Packets for the official ATAK Plugin
/// </summary>
public sealed partial class TAKPacket : pb::IMessage<TAKPacket>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
Expand Down
60 changes: 51 additions & 9 deletions Meshtastic/Generated/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ static ChannelReflection() {
"GAIgASgMEgwKBG5hbWUYAyABKAkSCgoCaWQYBCABKAcSFgoOdXBsaW5rX2Vu",
"YWJsZWQYBSABKAgSGAoQZG93bmxpbmtfZW5hYmxlZBgGIAEoCBIzCg9tb2R1",
"bGVfc2V0dGluZ3MYByABKAsyGi5tZXNodGFzdGljLk1vZHVsZVNldHRpbmdz",
"IiwKDk1vZHVsZVNldHRpbmdzEhoKEnBvc2l0aW9uX3ByZWNpc2lvbhgBIAEo",
"DSKhAQoHQ2hhbm5lbBINCgVpbmRleBgBIAEoBRItCghzZXR0aW5ncxgCIAEo",
"CzIbLm1lc2h0YXN0aWMuQ2hhbm5lbFNldHRpbmdzEiYKBHJvbGUYAyABKA4y",
"GC5tZXNodGFzdGljLkNoYW5uZWwuUm9sZSIwCgRSb2xlEgwKCERJU0FCTEVE",
"EAASCwoHUFJJTUFSWRABEg0KCVNFQ09OREFSWRACQmIKE2NvbS5nZWVrc3Zp",
"bGxlLm1lc2hCDUNoYW5uZWxQcm90b3NaImdpdGh1Yi5jb20vbWVzaHRhc3Rp",
"Yy9nby9nZW5lcmF0ZWSqAhRNZXNodGFzdGljLlByb3RvYnVmc7oCAGIGcHJv",
"dG8z"));
"IkUKDk1vZHVsZVNldHRpbmdzEhoKEnBvc2l0aW9uX3ByZWNpc2lvbhgBIAEo",
"DRIXCg9pc19jbGllbnRfbXV0ZWQYAiABKAgioQEKB0NoYW5uZWwSDQoFaW5k",
"ZXgYASABKAUSLQoIc2V0dGluZ3MYAiABKAsyGy5tZXNodGFzdGljLkNoYW5u",
"ZWxTZXR0aW5ncxImCgRyb2xlGAMgASgOMhgubWVzaHRhc3RpYy5DaGFubmVs",
"LlJvbGUiMAoEUm9sZRIMCghESVNBQkxFRBAAEgsKB1BSSU1BUlkQARINCglT",
"RUNPTkRBUlkQAkJiChNjb20uZ2Vla3N2aWxsZS5tZXNoQg1DaGFubmVsUHJv",
"dG9zWiJnaXRodWIuY29tL21lc2h0YXN0aWMvZ28vZ2VuZXJhdGVkqgIUTWVz",
"aHRhc3RpYy5Qcm90b2J1ZnO6AgBiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Meshtastic.Protobufs.ChannelSettings), global::Meshtastic.Protobufs.ChannelSettings.Parser, new[]{ "ChannelNum", "Psk", "Name", "Id", "UplinkEnabled", "DownlinkEnabled", "ModuleSettings" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Meshtastic.Protobufs.ModuleSettings), global::Meshtastic.Protobufs.ModuleSettings.Parser, new[]{ "PositionPrecision" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Meshtastic.Protobufs.ModuleSettings), global::Meshtastic.Protobufs.ModuleSettings.Parser, new[]{ "PositionPrecision", "IsClientMuted" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Meshtastic.Protobufs.Channel), global::Meshtastic.Protobufs.Channel.Parser, new[]{ "Index", "Settings", "Role" }, null, new[]{ typeof(global::Meshtastic.Protobufs.Channel.Types.Role) }, null, null)
}));
}
Expand Down Expand Up @@ -581,6 +581,7 @@ public ModuleSettings() {
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public ModuleSettings(ModuleSettings other) : this() {
positionPrecision_ = other.positionPrecision_;
isClientMuted_ = other.isClientMuted_;
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

Expand All @@ -606,6 +607,23 @@ public uint PositionPrecision {
}
}

/// <summary>Field number for the "is_client_muted" field.</summary>
public const int IsClientMutedFieldNumber = 2;
private bool isClientMuted_;
/// <summary>
///
/// Controls whether or not the phone / clients should mute the current channel
/// Useful for noisy public channels you don't necessarily want to disable
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool IsClientMuted {
get { return isClientMuted_; }
set {
isClientMuted_ = value;
}
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
Expand All @@ -622,6 +640,7 @@ public bool Equals(ModuleSettings other) {
return true;
}
if (PositionPrecision != other.PositionPrecision) return false;
if (IsClientMuted != other.IsClientMuted) return false;
return Equals(_unknownFields, other._unknownFields);
}

Expand All @@ -630,6 +649,7 @@ public bool Equals(ModuleSettings other) {
public override int GetHashCode() {
int hash = 1;
if (PositionPrecision != 0) hash ^= PositionPrecision.GetHashCode();
if (IsClientMuted != false) hash ^= IsClientMuted.GetHashCode();
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
Expand All @@ -652,6 +672,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(8);
output.WriteUInt32(PositionPrecision);
}
if (IsClientMuted != false) {
output.WriteRawTag(16);
output.WriteBool(IsClientMuted);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
Expand All @@ -666,6 +690,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(8);
output.WriteUInt32(PositionPrecision);
}
if (IsClientMuted != false) {
output.WriteRawTag(16);
output.WriteBool(IsClientMuted);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
Expand All @@ -679,6 +707,9 @@ public int CalculateSize() {
if (PositionPrecision != 0) {
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(PositionPrecision);
}
if (IsClientMuted != false) {
size += 1 + 1;
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
Expand All @@ -694,6 +725,9 @@ public void MergeFrom(ModuleSettings other) {
if (other.PositionPrecision != 0) {
PositionPrecision = other.PositionPrecision;
}
if (other.IsClientMuted != false) {
IsClientMuted = other.IsClientMuted;
}
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand All @@ -713,6 +747,10 @@ public void MergeFrom(pb::CodedInputStream input) {
PositionPrecision = input.ReadUInt32();
break;
}
case 16: {
IsClientMuted = input.ReadBool();
break;
}
}
}
#endif
Expand All @@ -732,6 +770,10 @@ public void MergeFrom(pb::CodedInputStream input) {
PositionPrecision = input.ReadUInt32();
break;
}
case 16: {
IsClientMuted = input.ReadBool();
break;
}
}
}
}
Expand Down
Loading

0 comments on commit 8daca8d

Please sign in to comment.