Skip to content

Commit

Permalink
refactor: add new event ids
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Aug 13, 2024
1 parent d79bb3b commit 04fbd02
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions GalaxyBudsClient/Message/Decoder/GenericEventDecoder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using GalaxyBudsClient.Generated.Model.Attributes;
using GalaxyBudsClient.Model.Constants;
Expand All @@ -10,10 +11,11 @@ public class GenericEventDecoder : BaseMessageDecoder
{
public Devices Device { get; }
public TimeSpan Timestamp { get; }
public byte EventId { get; }
public byte EventRawId { get; }
public EventIds EventId { get; }
public MsgTypes MessageType { get; }
public byte[] EventData { get; }
// EventIds and EventData contents are unknown
// EventIds and EventData contents are mostly unknown

public GenericEventDecoder(SppMessage msg) : base(msg)
{
Expand All @@ -22,7 +24,8 @@ public GenericEventDecoder(SppMessage msg) : base(msg)

Device = reader.ReadChar() == 'L' ? Devices.L : Devices.R;
Timestamp = TimeSpan.FromMilliseconds(reader.ReadUInt32());
EventId = reader.ReadByte();
EventRawId = reader.ReadByte();
EventId = (EventIds)EventRawId;
MessageType = (MsgTypes)reader.ReadByte();

try
Expand All @@ -31,40 +34,40 @@ public GenericEventDecoder(SppMessage msg) : base(msg)
}
catch (Exception)
{
EventData = Array.Empty<byte>();
EventData = [];
}
}
}

/*
TODO Find out what some of the EventIds and EventData contents are
this.debugArraySubMsgId.put(1, "EARBUD_STATUS");
this.debugArraySubMsgId.put(16, "EARBUD_GTIME");
this.debugArraySubMsgId.put(17, "CRADLE_INFO");
this.debugArraySubMsgId.put(18, "BATTERY_INFO");
this.debugArraySubMsgId.put(82, "BRDG_CONGESTED_RELEASE");
this.debugArraySubMsgId.put(145, "FOTA_BINARY_UPDATE");
this.debugArraySubMsgId.put(146, "FOTA_HOME_BINARY_UPDATE");
this.debugArraySubMsgId.put(147, "FOTA_ROLE_CHANGE_FAILED_A");
this.debugArraySubMsgId.put(148, "FOTA_ROLE_CHANGE_FAILED_B");
this.debugArraySubMsgId.put(149, "FOTA_UPDATE_MGR_API_OPEN");
this.debugArraySubMsgId.put(150, "FOTA_UPDATE_MGR_API_ABORT");
this.debugArraySubMsgId.put(151, "FOTA_UPDATE_MGR_API_CLOSE");
this.debugArraySubMsgId.put(152, "FOTA_UPDATE_MGR_INVALID_EVT");
this.debugArraySubMsgId.put(153, "FOTA_EARBUDSTATE_AT_USER_ABORT");
this.debugArraySubMsgId.put(176, "SH_AMBIENT_EVT");
this.debugArraySubMsgId.put(177, "SH_AMBIENT_INVALID_WEAR_STATE");
this.debugArraySubMsgId.put(178, "SH_WEAR_STATE_CHANGED");
this.debugArraySubMsgId.put(179, "SESSION_VOLUME");
this.debugArraySubMsgId.put(47872, "FOTA2_NONE");
this.debugArraySubMsgId.put(47873, "FOTA2_FSM_CHANGED");
this.debugArraySubMsgId.put(47874, "FOTA2_DOWNLOAD_ABORT");
this.debugArraySubMsgId.put(47875, "FOTA2_DOWNLOAD_ABORTED");
this.debugArraySubMsgId.put(47876, "FOTA2_DOWNLOAD_COMMIT");
this.debugArraySubMsgId.put(47877, "FOTA2_DOWNLOAD_COMMITED");
this.debugArraySubMsgId.put(47878, "FOTA2_DOWNLOAD_FINISH");
this.debugArraySubMsgId.put(47879, "FOTA2_DOWNLOAD_TIMEOUT");
this.debugArraySubMsgId.put(47880, "FOTA2_DOWNLOAD_TIMEOUT_CB");
*/
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum EventIds
{
UNKNOWN = 0,
EARBUD_STATUS = 1,
EARBUD_GTIME = 16,
CRADLE_INFO = 17,
BATTERY_INFO = 18,
BRDG_CONGESTED_RELEASE = 82,
FOTA_BINARY_UPDATE = 145,
FOTA_HOME_BINARY_UPDATE = 146,
FOTA_ROLE_CHANGE_FAILED_A = 147,
FOTA_ROLE_CHANGE_FAILED_B = 148,
FOTA_UPDATE_MGR_API_OPEN = 149,
FOTA_UPDATE_MGR_API_ABORT = 150,
FOTA_UPDATE_MGR_API_CLOSE = 151,
FOTA_UPDATE_MGR_INVALID_EVT = 152,
FOTA_EARBUDSTATE_AT_USER_ABORT = 153,
SH_AMBIENT_EVT = 176,
SH_AMBIENT_INVALID_WEAR_STATE = 177,
SH_WEAR_STATE_CHANGED = 178,
SESSION_VOLUME = 179,
FOTA2_NONE = 47872,
FOTA2_FSM_CHANGED = 47873,
FOTA2_DOWNLOAD_ABORT = 47874,
FOTA2_DOWNLOAD_ABORTED = 47875,
FOTA2_DOWNLOAD_COMMIT = 47876,
FOTA2_DOWNLOAD_COMMITED = 47877,
FOTA2_DOWNLOAD_FINISH = 47878,
FOTA2_DOWNLOAD_TIMEOUT = 47879,
FOTA2_DOWNLOAD_TIMEOUT_CB = 47880
}
}

0 comments on commit 04fbd02

Please sign in to comment.